[FIX] purchase_stock: clean non deterministic test
test_reordering_rule_1 try to ressuply 10 from RR. However since 15.0 the picking `action_confirm` will launch himself the required orderpoints to order the missing quantity. So the run scheduler is useless but should not order the quantity again since it's already process. But in the test the cache for the orderpoint is not always consistent with the data. It happens that the quantity forecast remains -10 even after the RFQ creation. It happens due to the savepoint. It will flush the data and take a random env. However in the enviroment, the active_test key could be there. And it will recompute all the fields. So it goes through `_compute_rules` that call `search_rule`. There is an archived route from supplier to stock. So it will pick this rule instead of the buy route. `_compute_lead_days` will not have the supplier delay as a result and a wrong forecasted date. `_compute_quantities` on product will check the virtual available for this date and will only have the out move and not the in since the domain is incorrect with the wrong lead days date... I can't do much since it's due to the orm. - Remove the savepoint but it will require a global refactoring - Fix the ORM, it's planned but difficult. So for now I just remove the context key form the context in the compute. Note: this could happens outside the test when there is more than 1000 RR. closes odoo/odoo#121106 Signed-off-by: Tiffany Chang <tic@odoo.com>
This commit is contained in:
@@ -566,7 +566,7 @@ class Product(models.Model):
|
||||
warehouse = location.warehouse_id
|
||||
if not warehouse and seen_rules:
|
||||
warehouse = seen_rules[-1].propagate_warehouse_id
|
||||
rule = self.env['procurement.group']._get_rule(self, location, {
|
||||
rule = self.env['procurement.group'].with_context(active_test=True)._get_rule(self, location, {
|
||||
'route_ids': route_ids,
|
||||
'warehouse_id': warehouse,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user