[FIX] purchase: Canceling the receipt of a receipt
Canceling the delivery order created for a "Make to order" product cancels the related procurement. But canceling the receipt order created for a "Buy" product" with reordering rule didn't cancel the related procurement. In some cases, it can block the application of the reordering rules. Now the related procurement is canceled when the receipt order is canceled. opw:1845345
This commit is contained in:
committed by
Goffin Simon
parent
8b9b56bd73
commit
9a810565b0
@@ -917,10 +917,23 @@ class ProcurementOrder(models.Model):
|
||||
|
||||
@api.multi
|
||||
def _check(self):
|
||||
if self.purchase_line_id:
|
||||
if self.rule_id.action == 'buy':
|
||||
# In case Phantom BoM splits only into procurements
|
||||
if not self.move_ids:
|
||||
if self.purchase_line_id and self.purchase_line_id.order_id.state not in ('purchase', 'done', 'cancel'):
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
move_all_done_or_cancel = all(move.state in ['done', 'cancel'] for move in self.move_ids)
|
||||
move_all_cancel = all(move.state == 'cancel' for move in self.move_ids)
|
||||
if not move_all_done_or_cancel:
|
||||
return False
|
||||
elif move_all_done_or_cancel and not move_all_cancel:
|
||||
return True
|
||||
else:
|
||||
self.message_post(body=_('All stock moves have been cancelled for this procurement.'))
|
||||
self.write({'state': 'cancel'})
|
||||
return False
|
||||
return all(move.state in ('done', 'cancel') for move in self.move_ids) and any(move.state == 'done' for move in self.move_ids)
|
||||
return super(ProcurementOrder, self)._check()
|
||||
|
||||
def _get_purchase_schedule_date(self):
|
||||
|
||||
Reference in New Issue
Block a user