diff options
| author | Djamel (otd) <otd@odoo.com> | 2021-04-22 14:12:41 +0000 |
|---|---|---|
| committer | Djamel (otd) <otd@odoo.com> | 2021-04-27 08:51:23 +0000 |
| commit | b5588246a0e032c92b8443e67875ff4146858fe8 (patch) | |
| tree | 7e9c9bf5f58892d1c7cfaa183786cb984c146929 /addons/repair | |
| parent | c462782f66d720266e7e8e7f616fc26c23f009c8 (diff) | |
[FIX]repair: fix invoice deletion
Steps to follow to reproduce the bug :
- Install the Repairs and Accounting application
- Create a new user and give him only access to Accounting
- Connect with this user
- Create a draft invoice
- Try to delete it
- Access rights error is triggered.
Problem:
When we delete an invoice and the Repairs app is installed, we check if it is not an invoice related to a repair.
But the user does not have access to “repair.order”, so we can not check the field "repair_ids".
opw-2507867
closes odoo/odoo#69701
Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
Diffstat (limited to 'addons/repair')
| -rw-r--r-- | addons/repair/models/account_move.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/addons/repair/models/account_move.py b/addons/repair/models/account_move.py index dc617e4da2f..6ee2b2e6b6f 100644 --- a/addons/repair/models/account_move.py +++ b/addons/repair/models/account_move.py @@ -9,7 +9,9 @@ class AccountMove(models.Model): repair_ids = fields.One2many('repair.order', 'invoice_id', readonly=True, copy=False) def unlink(self): - self.repair_ids.filtered(lambda repair: repair.state != 'cancel').state = '2binvoiced' + repairs = self.sudo().repair_ids.filtered(lambda repair: repair.state != 'cancel') + if repairs: + repairs.sudo(False).state = '2binvoiced' return super().unlink() |
