[FIX] sale_stock: Cancel all procurements linked to a sale order
During the creation of a Sale Order containing a product for which 'Make To Order' is activated in the Procurements, two procurements are created: - one for 'Partner Locations/Customers' location - one for 'WH/Stock' location If the Sale Order if cancelled, the user must first cancel the picking (delivery order). This will trigger the cancellation of the procurement with the 'Partner Locations/Customers' location. The new behavior is to cancel the procurements linked to the Sale Order, which will trigger the cancellation of the picking. opw: 630170 issue: https://github.com/odoo/odoo/issues/3805
This commit is contained in:
parent
3239d5fb74
commit
3d05ddab50
|
@ -581,6 +581,7 @@ class sale_order(osv.osv):
|
|||
context = {}
|
||||
sale_order_line_obj = self.pool.get('sale.order.line')
|
||||
account_invoice_obj = self.pool.get('account.invoice')
|
||||
procurement_obj = self.pool.get('procurement.order')
|
||||
for sale in self.browse(cr, uid, ids, context=context):
|
||||
for inv in sale.invoice_ids:
|
||||
if inv.state not in ('draft', 'cancel'):
|
||||
|
@ -588,6 +589,7 @@ class sale_order(osv.osv):
|
|||
_('Cannot cancel this sales order!'),
|
||||
_('First cancel all invoices attached to this sales order.'))
|
||||
inv.signal_workflow('invoice_cancel')
|
||||
procurement_obj.cancel(cr, uid, sum([l.procurement_ids.ids for l in sale.order_line],[]))
|
||||
sale_order_line_obj.write(cr, uid, [l.id for l in sale.order_line],
|
||||
{'state': 'cancel'})
|
||||
self.write(cr, uid, ids, {'state': 'cancel'})
|
||||
|
|
|
@ -147,21 +147,6 @@ class sale_order(osv.osv):
|
|||
move_obj.write(cr, uid, [x.id for x in picking.move_lines], {'invoice_state': 'invoiced'}, context=context)
|
||||
return res
|
||||
|
||||
def action_cancel(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
sale_order_line_obj = self.pool.get('sale.order.line')
|
||||
proc_obj = self.pool.get('procurement.order')
|
||||
stock_obj = self.pool.get('stock.picking')
|
||||
for sale in self.browse(cr, uid, ids, context=context):
|
||||
for pick in sale.picking_ids:
|
||||
if pick.state not in ('draft', 'cancel'):
|
||||
raise osv.except_osv(
|
||||
_('Cannot cancel sales order!'),
|
||||
_('You must first cancel all delivery order(s) attached to this sales order.'))
|
||||
stock_obj.signal_workflow(cr, uid, [p.id for p in sale.picking_ids], 'button_cancel')
|
||||
return super(sale_order, self).action_cancel(cr, uid, ids, context=context)
|
||||
|
||||
def action_wait(self, cr, uid, ids, context=None):
|
||||
res = super(sale_order, self).action_wait(cr, uid, ids, context=context)
|
||||
for o in self.browse(cr, uid, ids):
|
||||
|
|
Loading…
Reference in New Issue