From 1ec1168605ebca890f7f3d2fb4e7b15ffc75b9e1 Mon Sep 17 00:00:00 2001 From: MerlinGuillaume Date: Fri, 6 Jan 2023 13:02:30 +0000 Subject: [PATCH] [FIX] point_of_sale: allow closing control for pos user The closing control of a POS session doesn't work if the user doesn't have invoicing rights Steps to reproduce: 1. Install Point of Sale 2. Go to Settings > Users and open Marc Demo 3. Remove Marc Demo rights on Invoicing 4. Connect as Marc Demo 5. Open a session in any POS 6. Do the opening control and then the closing control of the session (with a difference) 7. An error is raised Solution: Post the difference during closing control using sudo Problem: When posting a difference in the closing control, the user didn't have enough rights to post the statement opw-3116907 closes odoo/odoo#109684 X-original-commit: 3225fdcaaf20da0aa54db4161cee4cb9b48506ee Signed-off-by: Trinh Jacky (trj) Signed-off-by: Guillaume Merlin (megu) --- 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 4fa75429ed0..afe5bbf94d2 100644 --- a/addons/point_of_sale/models/pos_session.py +++ b/addons/point_of_sale/models/pos_session.py @@ -316,7 +316,7 @@ class PosSession(models.Model): self.env.cr.rollback() return self._close_session_action(balance) - self._post_statement_difference(cash_difference_before_statements) + self.sudo()._post_statement_difference(cash_difference_before_statements) if self.move_id.line_ids: self.move_id.sudo().with_company(self.company_id)._post() # Set the uninvoiced orders' state to 'done' @@ -325,7 +325,7 @@ class PosSession(models.Model): self.move_id.sudo().unlink() self.sudo().with_company(self.company_id)._reconcile_account_move_lines(data) else: - self._post_statement_difference(self.cash_register_difference) + self.sudo()._post_statement_difference(self.cash_register_difference) self.write({'state': 'closed'}) return True @@ -1479,7 +1479,7 @@ class PosSession(models.Model): self.opening_notes = notes difference = cashbox_value - self.cash_register_balance_start self.cash_register_balance_start = cashbox_value - self._post_statement_difference(difference) + self.sudo()._post_statement_difference(difference) self._post_cash_details_message('Opening', difference, notes) def _post_cash_details_message(self, state, difference, notes):