From 729232785a0895de3c6185c8cea729ab4034d442 Mon Sep 17 00:00:00 2001 From: Alexandre Fayolle Date: Sat, 8 Jun 2013 11:25:34 +0200 Subject: [PATCH] [FIX] fix failure to confirm invoice when both account_credit_control and account_constraints are installed --- account_credit_control/account.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/account_credit_control/account.py b/account_credit_control/account.py index 5fc7a8418..6dc31dbe6 100644 --- a/account_credit_control/account.py +++ b/account_credit_control/account.py @@ -54,11 +54,17 @@ class AccountInvoice(orm.Model): def action_move_create(self, cr, uid, ids, context=None): """ Write the id of the invoice in the generated moves. """ - res = super(AccountInvoice, self).action_move_create(cr, uid, ids, context=context) - for inv in self.browse(cr, uid, ids, context=context): + if context is None: + context = {} + # add from_parent_object to the conxtext to let the line.write + # call pass through account_constraints + ctxt = context.copy() + ctxt['from_parent_object'] = True + res = super(AccountInvoice, self).action_move_create(cr, uid, ids, context=ctxt) + for inv in self.browse(cr, uid, ids, context=ctxt): if inv.move_id: for line in inv.move_id.line_id: - line.write({'invoice_id': inv.id}) + line.write({'invoice_id': inv.id}, context=ctxt) return res