Hi,
You're trying to pass a custom field from the Sales Order Line to the corresponding Purchase Order Line, but during the procurement process, your custom value isn’t flowing through—even though you extended _prepare_procurement_values() and _prepare_purchase_order_line().
Try with the following.
1- Add field to sale.order.line
x_reference_code = fields.Char("Reference Code")
2-Extend _prepare_procurement_values() in sale.order.line
def _prepare_procurement_values(self, group_id=False):
res = super()._prepare_procurement_values(group_id)
res.update({
'x_reference_code': self.x_reference_code,
})
return res
3- Extend _prepare_purchase_order_line() in purchase.order
def _prepare_purchase_order_line(self, product_id, product_qty, product_uom, company_id, values, po):
res = super()._prepare_purchase_order_line(product_id, product_qty, product_uom, company_id, values, po)
if 'x_reference_code' in values:
res.update({
'x_reference_code': values['x_reference_code'],
})
return res
Also, make sure purchase.order.line has this custom field.
x_reference_code = fields.Char("Reference Code")
Follow the three-step override above, and ensure the correct routes (Make To Order, Dropship, etc.) are active on your sale order line.
Hope it helps
Next time please use punctuation in your sentences and format your code so your question is actually readable.