[FIX] *sale*: exception when cancel SO
The commit ca7d5701c6a46f7781bdc9af9f2d26cca880eb93 fixes issue with
backorder being to quickly canceled but as it call `action_cancel`
before the condition who's looking on the SO state, the condition can
never be matched as the SO state will always be `cancel`.
So, the exception about the SO being cancelled will not be logged on
following documents.
How to reproduce:
- Create a product and enable route MTO + Manufacture on it and create
a BoM for this product;
- Create a SO for this product and confirm it;
- Cancel the SO and check the generated MO => There is no exception
about the cancellation of the SO.
This commit fixes this issue and doesn't impact the previous fix.
task-2657799
closes odoo/odoo#79215
closes odoo/odoo#81178
closes odoo/odoo#81401
Related: odoo/enterprise#22008
Related: odoo/enterprise#22814
Related: odoo/enterprise#22896
Signed-off-by: Arnold Moyaux <arm@odoo.com>
This commit is contained in:
@@ -29,9 +29,9 @@ class SaleOrder(models.Model):
|
||||
._for_xml_id('event_sale.action_sale_order_event_registration')
|
||||
return res
|
||||
|
||||
def action_cancel(self):
|
||||
def _action_cancel(self):
|
||||
self.order_line._cancel_associated_registrations()
|
||||
return super(SaleOrder, self).action_cancel()
|
||||
return super()._action_cancel()
|
||||
|
||||
def action_view_attendee_list(self):
|
||||
action = self.env["ir.actions.actions"]._for_xml_id("event.event_registration_action_tree")
|
||||
|
||||
@@ -877,6 +877,9 @@ class SaleOrder(models.Model):
|
||||
'context': {'default_order_id': self.id},
|
||||
'target': 'new'
|
||||
}
|
||||
return self._action_cancel()
|
||||
|
||||
def _action_cancel(self):
|
||||
inv = self.invoice_ids.filtered(lambda inv: inv.state == 'draft')
|
||||
inv.button_cancel()
|
||||
return self.write({'state': 'cancel'})
|
||||
|
||||
@@ -49,8 +49,8 @@ class SaleOrder(models.Model):
|
||||
self._send_reward_coupon_mail()
|
||||
return super(SaleOrder, self).action_confirm()
|
||||
|
||||
def action_cancel(self):
|
||||
res = super(SaleOrder, self).action_cancel()
|
||||
def _action_cancel(self):
|
||||
res = super()._action_cancel()
|
||||
self.generated_coupon_ids.write({'state': 'expired'})
|
||||
self.applied_coupon_ids.write({'state': 'new'})
|
||||
self.applied_coupon_ids.sales_order_id = False
|
||||
|
||||
@@ -174,10 +174,7 @@ class SaleOrder(models.Model):
|
||||
def action_view_delivery(self):
|
||||
return self._get_action_view_picking(self.picking_ids)
|
||||
|
||||
def action_cancel(self):
|
||||
res = super(SaleOrder, self).action_cancel()
|
||||
if(isinstance(res, dict)):
|
||||
return res
|
||||
def _action_cancel(self):
|
||||
documents = None
|
||||
for sale_order in self:
|
||||
if sale_order.state == 'sale' and sale_order.order_line:
|
||||
@@ -192,7 +189,7 @@ class SaleOrder(models.Model):
|
||||
continue
|
||||
filtered_documents[(parent, responsible)] = rendering_context
|
||||
self._log_decrease_ordered_quantity(filtered_documents, cancel=True)
|
||||
return res
|
||||
return super()._action_cancel()
|
||||
|
||||
def _get_action_view_picking(self, pickings):
|
||||
'''
|
||||
|
||||
Reference in New Issue
Block a user