[FIX] purchase_stock: wrong supplier from orderpoint:
Use case to reproduce: - Set "receive good in input and then stock" on the warehouse. - Set two suppliers on a product. one from a partner (higher priority) and one from a child partner (lower priority). - Set the child partner as the vendor on the replenishment report. - Order a replenishment for the product. It happens due to an hack that use a field on `stock.move` in order to temporaly store the partner among the moves until the RFQ. But this field is a many2one on `res.partner` model and not on `product.supplierinfo` `_run_buy` receive a partner and still use `_select_seller` with the partner in order to find the best pricelist. But it won't use the specific supplier price list set on the orderpoint. In order to fix, we don't store anymore the price list partner on the intermediate move. In run_buy we receive the orderpoint if it's the origin of the procurement. On the orderpoint the supplierinfo is set. So we take it from there. opw-3180945 closes odoo/odoo#119063 X-original-commit: 3cd5b9b7688ef7e6c6fa4fce1c0ad319fb577745 Signed-off-by: William Henrotin (whe) <whe@odoo.com>
This commit is contained in:
committed by
William Henrotin
parent
373c3008be
commit
e1e8f33ca9
@@ -151,13 +151,6 @@ class StockMove(models.Model):
|
||||
vals['purchase_line_id'] = self.purchase_line_id.id
|
||||
return vals
|
||||
|
||||
def _prepare_procurement_values(self):
|
||||
proc_values = super()._prepare_procurement_values()
|
||||
if self.restrict_partner_id:
|
||||
proc_values['supplierinfo_name'] = self.restrict_partner_id
|
||||
self.restrict_partner_id = False
|
||||
return proc_values
|
||||
|
||||
def _clean_merged(self):
|
||||
super(StockMove, self)._clean_merged()
|
||||
self.write({'created_purchase_line_ids': [Command.clear()]})
|
||||
|
||||
@@ -56,6 +56,8 @@ class StockRule(models.Model):
|
||||
supplier = False
|
||||
if procurement.values.get('supplierinfo_id'):
|
||||
supplier = procurement.values['supplierinfo_id']
|
||||
elif procurement.values.get('orderpoint_id') and procurement.values['orderpoint_id'].supplier_id:
|
||||
supplier = procurement.values['orderpoint_id'].supplier_id
|
||||
else:
|
||||
supplier = procurement.product_id.with_company(procurement.company_id.id)._select_seller(
|
||||
partner_id=procurement.values.get("supplierinfo_name"),
|
||||
@@ -321,12 +323,3 @@ class StockRule(models.Model):
|
||||
res = super(StockRule, self)._push_prepare_move_copy_values(move_to_copy, new_date)
|
||||
res['purchase_line_id'] = None
|
||||
return res
|
||||
|
||||
def _get_stock_move_values(self, product_id, product_qty, product_uom, location_id, name, origin, company_id, values):
|
||||
move_values = super()._get_stock_move_values(product_id, product_qty, product_uom, location_id, name, origin, company_id, values)
|
||||
if values.get('supplierinfo_name'):
|
||||
move_values['restrict_partner_id'] = values['supplierinfo_name'].id
|
||||
elif values.get('supplierinfo_id'):
|
||||
partner = values['supplierinfo_id'].partner_id
|
||||
move_values['restrict_partner_id'] = partner.id
|
||||
return move_values
|
||||
|
||||
Reference in New Issue
Block a user