[FIX] purchase_stock: trigger RR with a defined supplied
In a 2-steps configuration, trigger a reordering rule with the vendor
defined will raise an error
To reproduce the issue:
1. In Settings, enable "Multi-Step Routes"
2. Edit the existing warehouse:
- Incoming Shipments: 2 steps
3. Create a product P:
- Type: Storable
- Add a vendor V
- Routes: Buy
4. Create a reordering rule R for P:
- Trigger: Manual
- Min = Max = 1
5. Open the Replenishment page and edit R:
- Preferred Route: Buy
- Vendor: V
6. Trigger the orderpoint
Error: An Odoo Server Error is displayed "AttributeError:
'product.supplierinfo' object has no attribute 'name'"
When triggering the orderpoint, it leads to
https://github.com/odoo/odoo/blob/c75a1a8ac9eef6c7d7c95b7bbbb22d919b952e26/addons/purchase_stock/models/stock_rule.py#L331
However, since [1], the `name` of a `product.supplierinfo` has been
renamed to `partner_id`
[1] f3fe2d50d9
OPW-2780562
closes odoo/odoo#90597
X-original-commit: bda8b0e610f7ec9b0bcb76de3bb52fb6049f62ff
Signed-off-by: Arnold Moyaux <arm@odoo.com>
Signed-off-by: Adrien Widart <awt@odoo.com>
This commit is contained in:
@@ -328,6 +328,6 @@ class StockRule(models.Model):
|
||||
if values.get('supplierinfo_name'):
|
||||
move_values['restrict_partner_id'] = values['supplierinfo_name'].id
|
||||
elif values.get('supplierinfo_id'):
|
||||
partner = values['supplierinfo_id'].name
|
||||
partner = values['supplierinfo_id'].partner_id
|
||||
move_values['restrict_partner_id'] = partner.id
|
||||
return move_values
|
||||
|
||||
@@ -656,3 +656,29 @@ class TestReorderingRule(TransactionCase):
|
||||
{'product_id': self.product_01.id, 'qty_done': 1.0, 'state': 'done', 'location_dest_id': stock_location.id},
|
||||
{'product_id': self.product_01.id, 'qty_done': 2.0, 'state': 'done', 'location_dest_id': sub_location.id},
|
||||
])
|
||||
|
||||
def test_2steps_and_partner_on_orderpoint(self):
|
||||
"""
|
||||
Suppose a 2-steps receipt
|
||||
This test ensures that an orderpoint with its route and supplied defined correctly works
|
||||
"""
|
||||
warehouse = self.env['stock.warehouse'].search([('company_id', '=', self.env.company.id)])
|
||||
route_buy_id = self.ref('purchase_stock.route_warehouse0_buy')
|
||||
|
||||
warehouse.reception_steps = 'two_steps'
|
||||
|
||||
orderpoint = self.env['stock.warehouse.orderpoint'].create({
|
||||
'name': 'RR for %s' % self.product_01.name,
|
||||
'warehouse_id': warehouse.id,
|
||||
'location_id': warehouse.lot_stock_id.id,
|
||||
'trigger': 'manual',
|
||||
'product_id': self.product_01.id,
|
||||
'product_min_qty': 1,
|
||||
'product_max_qty': 5,
|
||||
'route_id': route_buy_id,
|
||||
'supplier_id': self.product_01.seller_ids.id,
|
||||
})
|
||||
orderpoint.action_replenish()
|
||||
|
||||
po_line = self.env['purchase.order.line'].search([('partner_id', '=', self.partner.id), ('product_id', '=', self.product_01.id)])
|
||||
self.assertEqual(po_line.product_qty, 5)
|
||||
|
||||
Reference in New Issue
Block a user