예제 #1
0
    def store_registry_json(self):

        for schema in self:
            models = []
            for sm in schema.model_ids:
                models.append(sm.model_id.model)
            #print models
            uid = 1
            registry_dict = odoo2proto.odoo2pbmsg_dict10(self.env, models)
            registry_json = json.dumps(registry_dict)

            fp = StringIO.StringIO()
            pprint.pprint(registry_dict, stream=fp)

            registry_dict_pprint = fp.getvalue()
            schema.registry_json = registry_json
            schema.registry_dict = registry_dict_pprint

            schema_dict = {
                'registry': registry_dict,
                'schema_name': str(schema.name),
                'app_name': str(schema.settings_id.name)
            }

            fp = StringIO.StringIO()
            pprint.pprint(schema_dict, stream=fp)
            schema_dict_pprint = fp.getvalue()

            schema_json = json.dumps(schema_dict)
            schema.schema_dict = schema_dict_pprint
            schema.schema_json = schema_json
예제 #2
0
 def _process_models(self, heater_codes, used_in_row, attribute_data, application_fields, fields_index, used_in_row_index, mif_id):
     new_heater_codes = copy.deepcopy(heater_codes)  # deep copy
     models = []
     for heater_code in new_heater_codes:
         code = new_heater_codes[heater_code]
         for idx, c in enumerate(code['code']):
             if not isinstance(c, list):
                 code['code'][idx] = [''.join(c1 for c1 in c)]
             elif isinstance(c, list) and all(str(x) and str(x) in used_in_row for x in c):
                 code['code'][idx] = ['@@' + str(r) + '@@' for r in used_in_row if r]
             elif isinstance(c, list):
                 for i, fields in enumerate(application_fields):
                     if fields == c:
                         code['code'][idx] = ['{' + str(x) + '(' + str(fields_index[i]) + ')' + '}' for x in c]
                         break
         codes = code['code'][:]
         combinations = []
         if ['*'] in codes:
             code['code'] = [item for item in code['code'] if item != ['*']]
             combinations += self._prepare_additional_model_combination(codes)
         combinations += self._get_possible_combination(code['code'])
         for idx, comb in enumerate(combinations):
             models.append({
                 'name': code['name'],
                 'description': code['description'],
                 #'index_categories': code['index_categories'],
                 'mfg_id': code['mfg_id'],
                 'code': ''.join(str(i) for i in comb)})
     return self._create_models(models, attribute_data, used_in_row_index, mif_id)
예제 #3
0
    def store_registry_json(self):

        for schema in self:
            models = []
            for sm in schema.model_ids:
                models.append( sm.model_id.model )
            print models
            uid = 1
            registry_dict = odoo2proto.odoo2pbmsg_dict10(self.env, models)
            registry_json = json.dumps( registry_dict )

            fp=StringIO.StringIO()
            pprint.pprint(registry_dict, stream=fp)
            
            registry_dict_pprint=fp.getvalue()            
            schema.registry_json = registry_json
            schema.registry_dict = registry_dict_pprint
예제 #4
0
    def _get_models(self, domain):
        """
        Return the names of the models to which the attachments are attached.

        :param domain: the domain of the read_group on documents.
        :return: a list of model data, the latter being a dict with the keys
            'id' (technical name),
            'name' (display name) and
            '__count' (how many attachments with that domain).
        """
        not_a_file = []
        not_attached = []
        models = []
        groups = self.read_group(domain, ['res_model'], ['res_model'],
                                 lazy=True)
        for group in groups:
            res_model = group['res_model']
            if not res_model:
                not_a_file.append({
                    'id': res_model,
                    'display_name': _('Not a file'),
                    '__count': group['res_model_count'],
                })
            elif res_model == 'documents.document':
                not_attached.append({
                    'id': res_model,
                    'display_name': _('Not attached'),
                    '__count': group['res_model_count'],
                })
            else:
                models.append({
                    'id':
                    res_model,
                    'display_name':
                    self.env['ir.model']._get(res_model).display_name,
                    '__count':
                    group['res_model_count'],
                })
        return sorted(
            models,
            key=lambda m: m['display_name']) + not_attached + not_a_file
예제 #5
0
 def get_objects(self, data):
     models = []
     dict = {}
     for assignment_obj in self.env['op.assignment'].browse(
             data['assignment_ids']):
         for obj in assignment_obj.assignment_sub_line:
             models.append(obj)
     models = sorted(models, key=lambda r: r.student_id.name)
     for obj in models:
         marks1 = {}
         if obj.student_id.name not in dict and obj.assignment_id.assignment_type_id.code[:
                                                                                          2] == 'S1':
             marks1[obj.assignment_id.assignment_type_id.code] = obj.marks
             dict[obj.student_id.name] = marks1
             # marks1.clear()
         if obj.student_id.name in dict and obj.assignment_id.assignment_type_id.code[:
                                                                                      2] == 'S1':
             marks1[obj.assignment_id.assignment_type_id.code] = obj.marks
             dict[obj.student_id.name].update(marks1)
             # marks1.clear()
     return dict
예제 #6
0
 def get_container_models_to_recompute_patched(s):
     models = get_container_models_to_recompute_patched.origin(s)
     models.append(self._name)
     return models
예제 #7
0
 def _reference_models(self):
     types = self.env['wbs.cost.type'].search([])
     models = []
     for type in types:
         models.append((type.model_id.model, type.model_id.name))
     return models