[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) <trj@odoo.com> Signed-off-by: Guillaume Merlin (megu) <megu@odoo.com>
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user