diff --git a/addons/point_of_sale/models/pos_session.py b/addons/point_of_sale/models/pos_session.py index 5c4d2cc73dc..ffc1b83f06d 100644 --- a/addons/point_of_sale/models/pos_session.py +++ b/addons/point_of_sale/models/pos_session.py @@ -330,7 +330,7 @@ class PosSession(models.Model): self.move_id.sudo().with_company(self.company_id)._post() #We need to write the price_subtotal and price_total here because if we do it earlier the compute functions will overwrite it here /account/models/account_move_line.py _compute_totals for dummy, amount_data in data['sales'].items(): - self.env['account.move.line'].browse(amount_data['move_line_id']).sudo().write({ + self.env['account.move.line'].browse(amount_data['move_line_id']).sudo().with_company(self.company_id).write({ 'price_subtotal': abs(amount_data['amount_converted']), 'price_total': abs(amount_data['amount_converted']) + abs(amount_data['tax_amount']), }) diff --git a/addons/point_of_sale/tests/test_point_of_sale_flow.py b/addons/point_of_sale/tests/test_point_of_sale_flow.py index 8fc9777ca6e..fdbec7dc3a5 100644 --- a/addons/point_of_sale/tests/test_point_of_sale_flow.py +++ b/addons/point_of_sale/tests/test_point_of_sale_flow.py @@ -1675,7 +1675,17 @@ class TestPointOfSaleFlow(TestPointOfSaleCommon): }) order_payment.with_context(**payment_context).check() session_id = self.pos_config.current_session_id - self.pos_config.current_session_id.action_pos_session_closing_control() + + # closing the session with basic pos access + pos_user = self.env['res.users'].create({ + 'name': "PoS user", + 'login': "pos_user", + 'email': "pos_user@yourcompany.com", + 'groups_id': [(6, 0, [self.ref('base.group_user'), self.ref('point_of_sale.group_pos_user')])], + }) + + self.pos_config.current_session_id.with_user(pos_user).action_pos_session_closing_control() + #get journal entries created aml = session_id.move_id.line_ids.filtered(lambda x: x.account_id == self.account1 and x.tax_ids == self.tax1) self.assertEqual(aml.price_total, 220)