Purpose of the task is be able to cancel an order if the products have been delivered or if an invoice has already been confirmed -the remaining pickings (back orders) should be cancelled. -the draft invoices should be cancelled too. [IMP] product_expiry: compute method should iterate on self task-1919761 Closes #29920 Signed-off-by: Damien Bouvy (dbo) <dbo@odoo.com> Co-authored-by: Hiral Bhavsar <hbh@odoo.com>
21 lines
807 B
Python
21 lines
807 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from odoo import api, fields, models
|
|
|
|
|
|
class SaleOrderCancel(models.TransientModel):
|
|
_name = 'sale.order.cancel'
|
|
_description = "Sales Order Cancel"
|
|
|
|
order_id = fields.Many2one('sale.order', string='Sale Order', required=True, ondelete='cascade')
|
|
display_invoice_alert = fields.Boolean('Invoice Alert', compute='_compute_display_invoice_alert')
|
|
|
|
@api.depends('order_id')
|
|
def _compute_display_invoice_alert(self):
|
|
for wizard in self:
|
|
wizard.display_invoice_alert = bool(wizard.order_id.invoice_ids.filtered(lambda inv: inv.state == 'draft'))
|
|
|
|
def action_cancel(self):
|
|
return self.order_id.with_context({'disable_cancel_warning': True}).action_cancel()
|