Skip to content
Snippets Groups Projects
Commit 8d37cf46 authored by Touati Djamel (otd)'s avatar Touati Djamel (otd)
Browse files

[FIX] repair: prevent cancelling a completed repair order


Steps to reproduce the bug:
- Create a repair:
    - Add any product to repair
    - Add any other product as part of the repair
    - Confirm the repair
    - Start the repair
    - End repair

Problem:
The cancel button becomes visible and clicking on it won't cancel the
moves, so it doesn't make sense to cancel a finished repair.

opw-3146606

closes odoo/odoo#111601

Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
parent 5bf0df88
No related branches found
No related tags found
No related merge requests found
......@@ -1271,6 +1271,12 @@ msgstr ""
msgid "You can not enter negative quantities."
msgstr ""
#. module: repair
#: code:addons/repair/models/repair.py:0
#, python-format
msgid "You cannot cancel a completed repair order."
msgstr ""
#. module: repair
#: code:addons/repair/models/repair.py:0 code:addons/repair/models/repair.py:0
#, python-format
......
......@@ -279,6 +279,8 @@ class Repair(models.Model):
return True
def action_repair_cancel(self):
if self.state == 'done':
raise UserError(_("You cannot cancel a completed repair order."))
invoice_to_cancel = self.filtered(lambda repair: repair.invoice_id.state == 'draft').invoice_id
if invoice_to_cancel:
invoice_to_cancel.button_cancel()
......
......@@ -38,7 +38,7 @@
<button name="print_repair_order" states="draft" string="Print Quotation" type="object"/>
<button name="action_repair_cancel_draft" states="cancel" string="Set to Draft" type="object"/>
<button name="action_repair_cancel" string="Cancel Repair" type="object" confirm="Draft invoices for this order will be cancelled. Do you confirm the action?" attrs="{'invisible':['|', ('state', '=', 'cancel'), ('invoice_state', '!=', 'draft')]}"/>
<button name="action_repair_cancel" string="Cancel Repair" type="object" attrs="{'invisible': ['|', ('state','=', 'cancel',), ('invoice_state', '=', 'draft')]}"/>
<button name="action_repair_cancel" string="Cancel Repair" type="object" attrs="{'invisible': ['|', ('state','in', ('cancel','done')), ('invoice_state', '=', 'draft')]}"/>
<field name="state" widget="statusbar" statusbar_visible="draft,confirmed,done"/>
</header>
<sheet string="Repairs order">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment