[REVERT] account_report_company: undo override of res.partner.commercial_partner_id field to store it, as the ORM does not support it and it's not strictly necessary

It works when installing the module but would break
everytime another module that inherits from res.partner
is installed/update from command-line (e.g. -i/-u crm),
as account_report_company is low in the dependency graph
so the field is dropped when the ORM notices that
the current field definition is not stored.
This can be solved in trunk by making the field stored
directly in 'base'.

bzr revid: odo@openerp.com-20130420015003-8y48xrb14cjif60w
This commit is contained in:
Olivier Dony 2013-04-20 03:50:03 +02:00
parent 64f29cfa10
commit b91cd6127a
1 changed files with 3 additions and 8 deletions

View File

@ -28,22 +28,17 @@ class res_partner(osv.Model):
def _display_name_compute(self, cr, uid, ids, name, args, context=None):
return dict(self.name_get(cr, uid, ids, context=context))
_commercial_partner_id_store_triggers = {
_display_name_store_triggers = {
'res.partner': (lambda self,cr,uid,ids,context=None: self.search(cr, uid, [('id','child_of',ids)]),
['parent_id', 'is_company'], 10)
}
# indirections to avoid passing a copy of the overridable method when declaring the function field
_commercial_partner_id = lambda self, *args, **kwargs: self._commercial_partner_compute(*args, **kwargs)
# indirection to avoid passing a copy of the overridable method when declaring the function field
_display_name = lambda self, *args, **kwargs: self._display_name_compute(*args, **kwargs)
_columns = {
# make the original field stored, in case it's needed for reporting purposes
'commercial_partner_id': fields.function(_commercial_partner_id, type='many2one', relation='res.partner', string='Commercial Entity',
store=_commercial_partner_id_store_triggers),
# extra field to allow ORDER BY to match visible names
'display_name': fields.function(_display_name, type='char', string='Name', store=_commercial_partner_id_store_triggers),
'display_name': fields.function(_display_name, type='char', string='Name', store=_display_name_store_triggers),
}
class account_invoice(osv.Model):