[FIX] point_of_sale: cannot close POS session without accounting rights
The commit f5ce6c5979e5fba1ccb7e30c8125cd7b97534925 introduced a regression that prevents closing a POS session if the user does not have accounting and inventory access rights. opw-3487462 closes odoo/odoo#134055 X-original-commit: 6f43bc1972ac60e9365b40f53ee8966270e78848 Signed-off-by: Joseph Caburnay (jcb) <jcb@odoo.com> Signed-off-by: Pedram Bi Ria (pebr) <pebr@odoo.com>
This commit is contained in:
@@ -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']),
|
||||
})
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user