Before Commit: -Current Functionality doesn't Restrict Unlink of Order Based on States. -if we delete the invoice linked to repair order the state button of invoice still visible in reapir order and when we click on state button it open new draft invoice. After Commit: -Add Validation on Unlink the order based on State,link unlink order only on draft and cancel state. -Always show the "cancel" button on repair orders.When the orders have been cancelled, only allow to delete them if there is no invoice linked, or if the invoice which is linked can be deleted (is still draft and has never been posted). If we are not in one of those conditions, raise the following error "You cannot delete a repair order which is linked to an invoice which has been posted once." -Add wizard when cancelling a repair order which has a draft invoice linked. task-id: 2198997
21 lines
634 B
Python
21 lines
634 B
Python
# -*- coding: utf-8 -*-
|
|
|
|
from odoo import models, fields
|
|
|
|
|
|
class AccountMove(models.Model):
|
|
_inherit = 'account.move'
|
|
|
|
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'
|
|
return super().unlink()
|
|
|
|
|
|
class AccountMoveLine(models.Model):
|
|
_inherit = 'account.move.line'
|
|
|
|
repair_line_ids = fields.One2many('repair.line', 'invoice_line_id', readonly=True, copy=False)
|
|
repair_fee_ids = fields.One2many('repair.fee', 'invoice_line_id', readonly=True, copy=False)
|