~openerp-connector-core-editors/openerp-connector/7.0-generic-binder

« back to all changes in this revision

Viewing changes to connector/connector.py

  • Committer: Guewen Baconnier
  • Date: 2013-09-02 07:47:06 UTC
  • Revision ID: guewen.baconnier@camptocamp.com-20130902074706-9dkdwvszztfnh8w7
[FIX] in some cases the modules installed with 'install_in_connector' were not loaded, the __module__ needs to be defined before the call to __init__

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
    # Build a new AbstractModel with the name of the module and the suffix
62
62
    name = "%s.installed" % openerp_module_name
63
63
    class_name = name.replace('.', '_')
64
 
    model = orm.MetaModel(class_name, (orm.AbstractModel,), {'_name': name})
 
64
    # we need to call __new__ and __init__ in 2 phases because
 
65
    # __init__ needs to have the right __module__ and _module attributes
 
66
    model = orm.MetaModel.__new__(orm.MetaModel, class_name,
 
67
                                  (orm.AbstractModel,), {'_name': name})
65
68
    # Update the module of the model, it should be the caller's one
66
 
    model.__module__ = module
 
69
    model._module = openerp_module_name
 
70
    model.__module__ = module.__name__
 
71
    orm.MetaModel.__init__(model, class_name,
 
72
                           (orm.AbstractModel,), {'_name': name})
67
73
 
68
74
 
69
75
# install the connector itself