Skip to content
Snippets Groups Projects
Commit afde04dd authored by RomainLibert's avatar RomainLibert Committed by Yannick Tivisse
Browse files

[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
parent ef048c24
No related branches found
No related tags found
No related merge requests found
......@@ -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)]})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment