~openerp-dev/openobject-server/trunk-missing-default-values-pza

« back to all changes in this revision

Viewing changes to openerp/tools/yaml_import.py

  • Committer: Pooja Zankhariya (OpenERP)
  • Date: 2014-01-10 12:56:08 UTC
  • Revision ID: pza@tinyerp.com-20140110125608-936x7pcmwkjmvmj9
[IMP]Misc

Show diffs side-by-side

added added

removed removed

Lines of Context:
132
132
        return self.pool[model_name]
133
133
 
134
134
    def validate_xml_id(self, xml_id):
135
 
        print "\nvalidate_xml_id-xml_id: ",xml_id
136
135
        id = xml_id
137
136
        if '.' in xml_id:
138
137
            module, id = xml_id.split('.', 1)
284
283
        record, fields = node.items()[0]
285
284
        model = self.get_model(record.model)
286
285
 
287
 
        view_id = record.view##4
288
 
 
 
286
        view_id = record.view
289
287
        if view_id and (view_id is not True) and isinstance(view_id, basestring):
290
288
            module = self.module
291
 
            #sale_form_sample
292
 
            #"sale.sale_form_sample"
293
289
            if '.' in view_id:
294
290
                module, view_id = view_id.split('.',1)
295
291
            view_id = self.pool['ir.model.data'].get_object_reference(self.cr, SUPERUSER_ID, module, view_id)[1]
320
316
            context = record.context
321
317
            view_info = False
322
318
            if view_id:
323
 
                varg = view_id##3
 
319
                varg = view_id
324
320
                if view_id is True: varg = False
325
321
                view_info = model.fields_view_get(self.cr, SUPERUSER_ID, varg, 'form', context)
326
322
 
327
 
            record_dict = self._create_record(model, fields, view_info, default=default)##2
 
323
            record_dict = self._create_record(model, fields, view_info, default=default)
328
324
            _logger.debug("RECORD_DICT %s" % record_dict)
329
325
            id = self.pool['ir.model.data']._update(self.cr, SUPERUSER_ID, record.model, \
330
326
                    self.module, record_dict, record.id, noupdate=self.isnoupdate(record), mode=self.mode, context=context)
427
423
                    elif field_name not in defaults:
428
424
                        continue
429
425
 
430
 
                    #print "\n\nel.attrib: ",el.attrib
431
426
                    if not el.attrib.get('on_change', False):
432
427
                        continue
433
428
                    match = re.match("([a-z_1-9A-Z]+)\((.*)\)", el.attrib['on_change'])
449
444
                            ctx[a] = process_val(a, defaults.get(a, False))
450
445
 
451
446
                    # Evaluation args
452
 
                    #print "\nmatch-1-2: ",match,match.group(1),match.group(2)#<_sre.SRE_Match object at 0x9f4e968> product_id_change product_id
453
 
                    args = map(lambda x: eval(x, ctx), match.group(2).split(','))#[36]
454
 
                    result = getattr(model, match.group(1))(self.cr, SUPERUSER_ID, [], *args)#{'value': {'bom_id': False, 'routing_id': False, 'product_uom': 2}}
 
447
                    args = map(lambda x: eval(x, ctx), match.group(2).split(','))
 
448
                    result = getattr(model, match.group(1))(self.cr, SUPERUSER_ID, [], *args)
455
449
                    for key, val in (result or {}).get('value', {}).items():
456
450
                        assert key in fg, "The returning field '%s' from your on_change call '%s' does not exist either on the object '%s', either in the view '%s' used for the creation" % (key, match.group(1), model._name, view_info['name'])
457
451
                        if key not in fields:
867
861
        yaml_tag.add_constructors()
868
862
 
869
863
        is_preceded_by_comment = False
870
 
        #print "\nyaml_string: ",yaml_string
871
864
        for node in yaml.load(yaml_string):
872
 
            #print "\nnode:",node
873
865
            is_preceded_by_comment = self._log_node(node, is_preceded_by_comment)
874
866
            try:
875
867
                self._process_node(node)
956
948
    threading.Thread(target=f).start()
957
949
 
958
950
 
959
 
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
 
951
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
 
 
b'\\ No newline at end of file'