Use case: - Have a stockable product A, with enough quantity on hand - Have a stockable product B, without enough quantity on hand but configured on "Make To Order" - Create a SO, confirm. The picking is in status "Waiting Availability", althought one product is available. The picking should be in "Partially Available", which is actually the case if we simply "Reserve" it manually. opw-683974
19 lines
700 B
Python
19 lines
700 B
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
from openerp import api, fields, models, _
|
|
|
|
class SaleOrderLine(models.Model):
|
|
_inherit = "sale.order.line"
|
|
|
|
@api.multi
|
|
def _action_procurement_create(self):
|
|
res = super(SaleOrderLine, self)._action_procurement_create()
|
|
orders = list(set(x.order_id for x in self))
|
|
for order in orders:
|
|
reassign = order.picking_ids.filtered(lambda x: x.state=='confirmed' or ((x.state in ['partially_available', 'waiting']) and not x.printed))
|
|
if reassign:
|
|
reassign.do_unreserve()
|
|
reassign.action_assign()
|
|
return res
|