diff --git a/addons/account_report_company/__init__.py b/addons/account_report_company/__init__.py index 623cb467c25..42ec779494e 100644 --- a/addons/account_report_company/__init__.py +++ b/addons/account_report_company/__init__.py @@ -19,7 +19,7 @@ # ############################################################################## -import account_invoice +import account_report_company import report # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_report_company/account_invoice.py b/addons/account_report_company/account_report_company.py similarity index 63% rename from addons/account_report_company/account_invoice.py rename to addons/account_report_company/account_report_company.py index fe4a7b2c256..d643acd0c95 100644 --- a/addons/account_report_company/account_invoice.py +++ b/addons/account_report_company/account_report_company.py @@ -21,6 +21,23 @@ from openerp.osv import osv, fields +class res_partner(osv.Model): + _inherit = 'res.partner' + + # indirection 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) + + _commercial_partner_id_store_triggers = { + 'res.partner': (lambda self,cr,uid,ids,context=None: self.search(cr, uid, [('id','child_of',ids)]), + ['parent_id', 'is_company'], 10) + } + + _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) + } + class account_invoice(osv.Model): _inherit = 'account.invoice'