mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[IMP] stock_reserve_rule: Don't evaluate strategies if needed quantity is already taken
This commit is contained in:
@@ -98,6 +98,15 @@ class StockMove(models.Model):
|
||||
strict=strict,
|
||||
)
|
||||
still_need -= taken_in_loc
|
||||
# We should break between quants if original needs is fulfilled
|
||||
# TODO: Check if float_is_zero should be more appropriate
|
||||
need_zero = (
|
||||
float_compare(still_need, 0, precision_rounding=rounding)
|
||||
!= 1
|
||||
)
|
||||
if need_zero:
|
||||
# useless to eval the other rules when still_need <= 0
|
||||
break
|
||||
except StopIteration:
|
||||
break
|
||||
|
||||
|
||||
@@ -717,3 +717,39 @@ class TestReserveRule(common.TransactionCase):
|
||||
ml, [{"location_id": self.loc_zone2_bin1.id, "reserved_uom_qty": 80.0}]
|
||||
)
|
||||
self.assertEqual(move.state, "assigned")
|
||||
|
||||
def test_several_rules_same_loc_negative(self):
|
||||
"""
|
||||
We have several rules for the same location
|
||||
We have two quants in the location with one negative
|
||||
|
||||
"""
|
||||
|
||||
self.env["stock.quant"].create(
|
||||
{
|
||||
"location_id": self.loc_zone1_bin1.id,
|
||||
"quantity": 10.0,
|
||||
"product_id": self.product1.id,
|
||||
}
|
||||
)
|
||||
self.env["stock.quant"].create(
|
||||
{
|
||||
"location_id": self.loc_zone1_bin1.id,
|
||||
"quantity": -2.0,
|
||||
"product_id": self.product1.id,
|
||||
}
|
||||
)
|
||||
|
||||
picking = self._create_picking(self.wh, [(self.product1, 1.0)])
|
||||
self._create_rule(
|
||||
{},
|
||||
[
|
||||
{
|
||||
"location_id": self.loc_zone1_bin1.id,
|
||||
"removal_strategy": "packaging",
|
||||
"sequence": 1,
|
||||
},
|
||||
{"location_id": self.loc_zone1_bin1.id, "sequence": 2},
|
||||
],
|
||||
)
|
||||
picking.action_assign()
|
||||
|
||||
Reference in New Issue
Block a user