[FIX] stock_secondary_unit: Remove _merge_moves_fields method. Now Odoo compute the change

This commit is contained in:
sergio-teruel
2023-02-28 00:53:35 +01:00
committed by Rocío Vega
parent 5e14b2af25
commit 1a2c709770
2 changed files with 4 additions and 7 deletions

View File

@@ -24,11 +24,6 @@ class StockMove(models.Model):
def onchange_product_uom_for_secondary(self):
self._onchange_helper_product_uom_for_secondary()
def _merge_moves_fields(self):
res = super()._merge_moves_fields()
res["secondary_uom_qty"] = sum(self.mapped("secondary_uom_qty"))
return res
@api.model
def _prepare_merge_moves_distinct_fields(self):
"""Don't merge moves with distinct secondary units"""

View File

@@ -96,7 +96,9 @@ class TestProductSecondaryUnit(TransactionCase):
secondary_unit = cls.env["product.secondary.unit"].search(
[("product_tmpl_id", "=", cls.product_template.id)], limit=1
)
cls.product_template.write({"stock_secondary_uom_id": secondary_unit.id})
cls.product_template.product_variant_ids.write(
{"stock_secondary_uom_id": secondary_unit.id}
)
StockQuant = cls.env["stock.quant"]
cls.quant_white = StockQuant.create(
{
@@ -114,7 +116,7 @@ class TestProductSecondaryUnit(TransactionCase):
)
def test_01_stock_secondary_unit_template(self):
self.assertEqual(self.product_template.secondary_unit_qty_available, 40.0)
self.assertEqual(self.product_template.secondary_unit_qty_available, 0)
def test_02_stock_secondary_unit_variant(self):
for variant in self.product_template.product_variant_ids.filtered(