From cf488682c82a320589b1241f4b6bd9d59018bfed Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 14 Nov 2014 11:10:15 +0100 Subject: [PATCH] [FIX] stock: multicompany reception When a picking is confirmed, the generated account.move(.line) should take the company, accounts, journals and period with the same company as the picking, not the one of the current user. This was problematic if a user in a company confirm a picking linked to a purchase order done in another company. For real time valuations, the generated accounting entries were mixing both companies. Fixes #3466 --- addons/stock/stock.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 16565871de3..bd15c45e421 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2355,6 +2355,9 @@ class stock_move(osv.osv): context = {} src_company_ctx = dict(context,force_company=move.location_id.company_id.id) dest_company_ctx = dict(context,force_company=move.location_dest_id.company_id.id) + # do not take the company of the one of the user + # used to select the correct period + company_ctx = dict(context, company_id=move.company_id.id) account_moves = [] # Outgoing moves (or cross-company output part) if move.location_id.company_id \ @@ -2386,7 +2389,8 @@ class stock_move(osv.osv): { 'journal_id': j_id, 'line_id': move_lines, - 'ref': move.picking_id and move.picking_id.name}, context=context) + 'company_id': move.company_id.id, + 'ref': move.picking_id and move.picking_id.name}, context=company_ctx) def action_done(self, cr, uid, ids, context=None): """ Makes the move done and if all moves are done, it will finish the picking.