From 7a13e9d74462604e5c8cef6688b215bd60afa283 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Tue, 16 Dec 2014 10:16:30 +0100 Subject: [PATCH] [FIX] point_of_sale: account selection for payments Registered payment uses the partner receivable account. As this field is a property field, it will select different accounts based on the user that registers the payment (in multicompany). Should use the company of selected journal instead of the one of the user. --- addons/point_of_sale/point_of_sale.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index 512e6aef3fa..15e42559a8c 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -850,7 +850,15 @@ class pos_order(osv.osv): 'name': order.name + ': ' + (data.get('payment_name', '') or ''), 'partner_id': order.partner_id and self.pool.get("res.partner")._find_accounting_partner(order.partner_id).id or False, } - account_def = property_obj.get(cr, uid, 'property_account_receivable', 'res.partner', context=context) + + journal_id = data.get('journal', False) + statement_id = data.get('statement_id', False) + assert journal_id or statement_id, "No statement_id or journal_id passed to the method!" + + journal = self.pool['account.journal'].browse(cr, uid, journal_id, context=context) + # use the company of the journal and not of the current user + company_cxt = dict(context, force_company=journal.company_id.id) + account_def = property_obj.get(cr, uid, 'property_account_receivable', 'res.partner', context=company_cxt) args['account_id'] = (order.partner_id and order.partner_id.property_account_receivable \ and order.partner_id.property_account_receivable.id) or (account_def and account_def.id) or False @@ -863,10 +871,6 @@ class pos_order(osv.osv): context.pop('pos_session_id', False) - journal_id = data.get('journal', False) - statement_id = data.get('statement_id', False) - assert journal_id or statement_id, "No statement_id or journal_id passed to the method!" - for statement in order.session_id.statement_ids: if statement.id == statement_id: journal_id = statement.journal_id.id