From afde04dd54e4051143fe6e642a4e0a9523e65457 Mon Sep 17 00:00:00 2001 From: RomainLibert Date: Thu, 31 Jan 2019 09:45:22 +0000 Subject: [PATCH] [IMP] point_of_sale: make pos_session multi company aware When creating a pos session we try to link the session to the first cash journal we find. The problem is that we cannot link a journal comming from another company this is strictly forbidden by a constraint. This is why we should make sure that we search only for journals in the same company as the config. Task 1913733 --- addons/point_of_sale/models/pos_session.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/point_of_sale/models/pos_session.py b/addons/point_of_sale/models/pos_session.py index f1034572ecc..f6bcb05d656 100644 --- a/addons/point_of_sale/models/pos_session.py +++ b/addons/point_of_sale/models/pos_session.py @@ -179,11 +179,11 @@ class PosSession(models.Model): # define some cash journal if no payment method exists if not pos_config.journal_ids: Journal = self.env['account.journal'] - journals = Journal.with_context(ctx).search([('journal_user', '=', True), ('type', '=', 'cash')]) + journals = Journal.with_context(ctx).search([('journal_user', '=', True), ('type', '=', 'cash'), ('company_id', '=', pos_config.company_id.id)]) if not journals: - journals = Journal.with_context(ctx).search([('type', '=', 'cash')]) + journals = Journal.with_context(ctx).search([('type', '=', 'cash'), ('company_id', '=', pos_config.company_id.id)]) if not journals: - journals = Journal.with_context(ctx).search([('journal_user', '=', True)]) + journals = Journal.with_context(ctx).search([('journal_user', '=', True), ('company_id', '=', pos_config.company_id.id)]) journals.sudo().write({'journal_user': True}) pos_config.sudo().write({'journal_ids': [(6, 0, journals.ids)]})