[IMP] sale_stock: custom group on so line
Allow to create a specific procurement group for each so line. The purpose for different group is to have a specific behavior for each delivery depending it's group. It also allow to pass extra values to procurement group creation that would be common between multiple line (instead of passing the common values to each lines values argument). closes odoo/odoo#33765 Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
This commit is contained in:
committed by
Arnold Moyaux
parent
cbd77876fc
commit
c470c08e30
@@ -370,6 +370,17 @@ class SaleOrderLine(models.Model):
|
||||
qty -= move.product_uom._compute_quantity(move.product_uom_qty, self.product_uom, rounding_method='HALF-UP')
|
||||
return qty
|
||||
|
||||
def _get_procurement_group(self):
|
||||
return self.order_id.procurement_group_id
|
||||
|
||||
def _prepare_procurement_group_vals(self):
|
||||
return {
|
||||
'name': self.order_id.name,
|
||||
'move_type': self.order_id.picking_policy,
|
||||
'sale_id': self.order_id.id,
|
||||
'partner_id': self.order_id.partner_shipping_id.id,
|
||||
}
|
||||
|
||||
@api.multi
|
||||
def _action_launch_stock_rule(self, previous_product_uom_qty=False):
|
||||
"""
|
||||
@@ -386,13 +397,9 @@ class SaleOrderLine(models.Model):
|
||||
if float_compare(qty, line.product_uom_qty, precision_digits=precision) >= 0:
|
||||
continue
|
||||
|
||||
group_id = line.order_id.procurement_group_id
|
||||
group_id = line._get_procurement_group()
|
||||
if not group_id:
|
||||
group_id = self.env['procurement.group'].create({
|
||||
'name': line.order_id.name, 'move_type': line.order_id.picking_policy,
|
||||
'sale_id': line.order_id.id,
|
||||
'partner_id': line.order_id.partner_shipping_id.id,
|
||||
})
|
||||
group_id = self.env['procurement.group'].create(line._prepare_procurement_group_vals())
|
||||
line.order_id.procurement_group_id = group_id
|
||||
else:
|
||||
# In case the procurement group is already created and the order was
|
||||
|
||||
Reference in New Issue
Block a user