[FIX] purchase : Missing access right for User in Purchase group

Issue: When closing a PoS session, the user can Cash In/Out of the
register but it requires Accounting/Billing group or Purchase/User
group. However with Purchase/User group, there was an access right
error (not allowed to create account.move.line

Steps to reproduce :
 1) Install PoS Module
 2) PoS > Your Shop > Settings and enable Advanced Cash Control
 3) As administrator and in debug mode go to
  Settings > Users & Companies > Users
 4) Remove Accounting, Inventory and Purchase group of [User A]
 5) Log in with [User A], open a PoS Session, close it, and in Cash
 Control form, click Cash In/Out
 6) Remove or add money
 -> Access right error, you need to be Accounting/Billing or
 Purchase/User
 7) As administrator, add the User group to Purchase for [User A]
 8) As [User A], click Cash In/Out, removed or add money
 -> Still access right error

Why is that a bug:
 The first warning asks us to give the Purchase/User group to the user
 if we want to Cash In/Out but even when doing that, the access rights
 are still not enough to allow the creation of the entry

opw-2611298

closes odoo/odoo#75156

X-original-commit: a28c9c1dd773f26151d6734d476e7f8d5a3d971b
Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
Signed-off-by: Nathan Marotte <nmarotte@users.noreply.github.com>
This commit is contained in:
Nathan Marotte (nama)
2021-08-16 13:13:24 +00:00
parent a48a30f954
commit 2a0ae1114c
+1 -1
View File
@@ -34,7 +34,7 @@ class CashBox(models.TransientModel):
raise UserError(_("You cannot put/take money in/out for a bank statement which is closed."))
values = box._calculate_values_for_statement_line(record)
account = record.journal_id.company_id.transfer_account_id
self.env['account.bank.statement.line'].with_context(counterpart_account_id=account.id).create(values)
self.env['account.bank.statement.line'].with_context(counterpart_account_id=account.id).sudo().create(values)
class CashBoxOut(CashBox):