From 641f19aedf1a5594063a7777a75312e4737c8f24 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 2 Sep 2013 14:46:48 +0200 Subject: [PATCH] [FIX]account: field partner_id, define store param to handle updates of partner changes in entries bzr revid: dle@openerp.com-20130902124648-340vz90i1ng1zh01 --- addons/account/account.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/account/account.py b/addons/account/account.py index cbbaa15a5c5..e48a20388bb 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1272,6 +1272,10 @@ class account_move(osv.osv): return [('id', 'in', tuple(ids))] return [('id', '=', '0')] + def _get_move_from_lines(self, cr, uid, ids, context=None): + line_obj = self.pool.get('account.move.line') + return [line.move_id.id for line in line_obj.browse(cr, uid, ids, context=context)] + _columns = { 'name': fields.char('Number', size=64, required=True), 'ref': fields.char('Reference', size=64), @@ -1281,7 +1285,10 @@ class account_move(osv.osv): help='All manually created new journal entries are usually in the status \'Unposted\', but you can set the option to skip that status on the related journal. In that case, they will behave as journal entries automatically created by the system on document validation (invoices, bank statements...) and will be created in \'Posted\' status.'), 'line_id': fields.one2many('account.move.line', 'move_id', 'Entries', states={'posted':[('readonly',True)]}), 'to_check': fields.boolean('To Review', help='Check this box if you are unsure of that journal entry and if you want to note it as \'to be reviewed\' by an accounting expert.'), - 'partner_id': fields.related('line_id', 'partner_id', type="many2one", relation="res.partner", string="Partner", store=True), + 'partner_id': fields.related('line_id', 'partner_id', type="many2one", relation="res.partner", string="Partner", store={ + _name: (lambda self, cr,uid,ids,c: ids, ['line_id'], 10), + 'account.move.line': (_get_move_from_lines, ['partner_id'],10) + }), 'amount': fields.function(_amount_compute, string='Amount', digits_compute=dp.get_precision('Account'), type='float', fnct_search=_search_amount), 'date': fields.date('Date', required=True, states={'posted':[('readonly',True)]}, select=True), 'narration':fields.text('Internal Note'),