mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[FIX] stock_pull_list: do not show any lines when there's no quantity needed
This commit is contained in:
committed by
Lois Rilo
parent
09fe21a759
commit
4eded5860e
@@ -14,6 +14,7 @@ class TestPullListCommon(TransactionCase):
|
||||
self.move_obj = self.env["stock.move"]
|
||||
self.picking_obj = self.env["stock.picking"]
|
||||
self.wiz_obj = self.env["stock.pull.list.wizard"]
|
||||
self.stock_change_obj = self.env["stock.change.product.qty"]
|
||||
|
||||
self.company = self.env.ref("base.main_company")
|
||||
self.warehouse = self.env.ref("stock.warehouse0")
|
||||
@@ -79,3 +80,15 @@ class TestPullListCommon(TransactionCase):
|
||||
)
|
||||
picking.action_confirm()
|
||||
return picking
|
||||
|
||||
def _update_product_qty(self, product, quantity):
|
||||
"""Update Product quantity."""
|
||||
change_product_qty = self.stock_change_obj.create(
|
||||
{
|
||||
"product_id": product.id,
|
||||
"product_tmpl_id": product.product_tmpl_id.id,
|
||||
"new_quantity": quantity,
|
||||
}
|
||||
)
|
||||
change_product_qty.change_product_qty()
|
||||
return change_product_qty
|
||||
|
||||
@@ -30,3 +30,14 @@ class TestStockPullList(TestPullListCommon):
|
||||
expected = 50 + 70
|
||||
self.assertEqual(line.raw_demand_qty, expected)
|
||||
self.assertEqual(line.needed_qty, expected)
|
||||
|
||||
def test_03_no_needed_qty(self):
|
||||
"""Tests that no line is created in the wizard if there's no
|
||||
quantity needed."""
|
||||
quantity = 120.00
|
||||
self._update_product_qty(self.product_a, quantity)
|
||||
self._generate_moves()
|
||||
wiz = self.wiz_obj.create({"consolidate_by_product": True})
|
||||
wiz.action_prepare()
|
||||
line = wiz.line_ids.filtered(lambda l: l.product_id == self.product_a)
|
||||
self.assertEqual(len(line), 0)
|
||||
|
||||
@@ -169,7 +169,9 @@ class PullListWizard(models.TransientModel):
|
||||
qty_assigned = {}
|
||||
for key, demand_qty in demand_dict.items():
|
||||
supply_qty = incoming_dict.get(key, 0.0)
|
||||
lines.append((0, 0, self._prepare_line_values(key, demand_qty, supply_qty)))
|
||||
line_data = self._prepare_line_values(key, demand_qty, supply_qty)
|
||||
if line_data["needed_qty"] > 0.0:
|
||||
lines.append((0, 0, line_data))
|
||||
self.update({"line_ids": lines})
|
||||
res = self._act_window_pull_list_step_2()
|
||||
return res
|
||||
|
||||
Reference in New Issue
Block a user