在 2010-01-14四的 23:41 +0100,[email protected]写道:
> Hi,
> 
> This is my first attempt to develop a module (using dia). When I am trying to 
> install the module I am getting folowing error:
> 
> Environment Information : 
> System : Linux-2.6.31-17-generic-i686-with-Ubuntu-9.10-karmic
> OS Name : posix
> Distributor ID:       Ubuntu
> Description:  Ubuntu 9.10
> Release:      9.10
> Codename:     karmic
> Operating System Release : 2.6.31-17-generic
> Operating System Version : #54-Ubuntu SMP Thu Dec 10 16:20:31 UTC 2009
> Operating System Architecture : 32bit
> Operating System Locale : en_US.UTF8
> Python Version : 2.6.4
> OpenERP-Client Version : 5.0.3
> Last revision No. & ID :Bazaar Package not Found !Traceback (most recent call 
> last):
>   File "/usr/lib/openerp-server/netsvc.py", line 244, in dispatch
>     result = LocalService(service_name)(method, *params)
>   File "/usr/lib/openerp-server/netsvc.py", line 73, in __call__
>     return getattr(self, method)(*params)
>   File "/usr/lib/openerp-server/service/web_services.py", line 639, in execute
>     return self._execute(db, uid, wiz_id, datas, action, context)
>   File "/usr/lib/openerp-server/service/web_services.py", line 619, in 
> _execute
>     return wiz.execute(db, uid, self.wiz_datas[wiz_id], action, context)
>   File "/usr/lib/openerp-server/wizard/__init__.py", line 177, in execute
>     res = self.execute_cr(cr, uid, data, state, context)
>   File "/usr/lib/openerp-server/wizard/__init__.py", line 73, in execute_cr
>     action_res = action(self, cr, uid, data, context)
>   File 
> "/usr/lib/openerp-server/addons/base/module/wizard/wizard_module_upgrade.py", 
> line 92, in _upgrade_module
>     db, pool = pooler.restart_pool(cr.dbname, update_module=True)
>   File "/usr/lib/openerp-server/pooler.py", line 62, in restart_pool
>     return get_db_and_pool(db_name, force_demo, status, 
> update_module=update_module)
>   File "/usr/lib/openerp-server/pooler.py", line 40, in get_db_and_pool
>     addons.load_modules(db, force_demo, status, update_module)
>   File "/usr/lib/openerp-server/addons/__init__.py", line 728, in load_modules
>     r = load_module_graph(cr, graph, status, report=report)
>   File "/usr/lib/openerp-server/addons/__init__.py", line 581, in 
> load_module_graph
>     init_module_objects(cr, package.name, modules)
>   File "/usr/lib/openerp-server/addons/__init__.py", line 366, in 
> init_module_objects
>     result = obj._auto_init(cr, {'module': module_name})
>   File "/usr/lib/openerp-server/osv/orm.py", line 1704, in _auto_init
>     cr.execute('CREATE TABLE "%s" ("%s" INTEGER NOT NULL REFERENCES "%s" ON 
> DELETE CASCADE, "%s" INTEGER NOT NULL REFERENCES "%s" ON DELETE CASCADE) WITH 
> OIDS' % (f._rel, f._id1, self._table, f._id2, ref))
>   File "/usr/lib/openerp-server/sql_db.py", line 76, in wrapper
>     return f(self, *args, **kwargs)
>   File "/usr/lib/openerp-server/sql_db.py", line 120, in execute
>     res = self._obj.execute(query, params)
> ProgrammingError: relation "umbrella_service" does not exist
> 
> 
> 
> This is how the py file looks like:
> from osv import osv, fields
> 
> class umbrella_member(osv.osv):
>       """(NULL)"""
>       _name = 'umbrella.member'
>       _columns = {
>               'name': fields.char('Member Name', size=64, required=True),
>               'partner_id': fields.many2one('res.partner', 'Associated 
> Partner'),
>               'subscriptions': 
> fields.many2many('umbrella.service','service_member_subscription_rel','service_id','member_id','Subscriptions'),
>               'usage_ids': fields.one2many('umbrella.usage', 'usage_id', 
> 'Usages'),
>       }
> umbrella_member()
> 
> class umbrella_service(osv.osv):
>       """(NULL)"""
>       _name = 'umbrella.service'
>       _columns = {
>               'name': fields.char('Service Name', size=64, required=True),
>               'product_id': fields.many2one('product_product', 'Associated 
> Product'),
>               'note': fields.text('Note'),
>               'usage_ids': fields.one2many('umbrella.usage', 'usage_id', 
> 'Usages'),
>       }
> umbrella_service()
> 
> class umbrella_usage(osv.osv):
>       _name = 'umbrella.usage'
>       _columns = {
>               'name': fields.char('Description', size=64),
>               'member_id': 
> fields.many2one('umbrella.member','Member',required=True),
>               'service_id': 
> fields.many2one('umbrella.service','Service',required=True),
>               'date': fields.datetime('Date'),
>               'qty': fields.float('Quantity'),
>               'cost': fields.float('Cost'),
>               'override_cost': fields.selection([('yes','Yes'),('no','No')], 
> 'Override Cost'),
>       }
> umbrella_usage()
> 
> It is bit confusing or in fact I haven't gotten the hang of it yet; 
> relationship definition. Basically i tried to copy the uml_test and see how 
> it works. I can define a simple class with few attributes and export it out 
> of dia and install it in OpenERP and it works perfectly alright. However, i 
> think I am struggling with the relationships are bit. 
> 
> Any help?
> 
> Thanks
> Khalid Masood Dhariwal
> 
> 
> 
> 
> -------------------- m2f --------------------
> 
> --
> http://www.openobject.com/forum/viewtopic.php?p=49538#49538
> 
> -------------------- m2f --------------------
> 
> 
> _______________________________________________
> Tinyerp-users mailing list
> http://tiny.be/mailman2/listinfo/tinyerp-users

Python code are interpreted from top to bottom. The subscriptions and
usage_id in the umbrella_member class are refer to attributes of other
classes. When the umbrella_member class is instantiated, the other
classes which refer to, however, are not yet instantiated, and thus
cause the error.

Simply put, you should put umbrella_member class behind the class of
umbrella_usage and umbrella_service.

However, there is still a problem, the umbrella_service and
umbrella_usage are referring to each other. Whichever is put in front of
the the other referring class will cause the above problem described.

The workaround is 'not referring to each other', if you really need
that, put one of the two classes' relation field in a inherited class.

Tony Gu

_______________________________________________
Tinyerp-users mailing list
http://tiny.be/mailman2/listinfo/tinyerp-users

Reply via email to