[IMP] procurement_auto_create_group: pull flow

When the pull flow is coming from an SO, a procurement group is already
preset. When the option to auto create a procurement group, replace that
procurement group by a new one.
This commit is contained in:
Jacques-Etienne Baudoux
2023-08-25 19:44:40 +02:00
committed by Sébastien Alix
parent 44592fefa9
commit 99932368ce
2 changed files with 10 additions and 9 deletions

View File

@@ -13,11 +13,6 @@ class ProcurementGroup(models.Model):
rule = super()._get_rule(product_id, location_id, values)
# If there isn't a date planned in the values it means that this
# method has been called outside of a procurement process.
if (
rule
and not values.get("group_id")
and rule.auto_create_group
and values.get("date_planned")
):
if rule and rule.auto_create_group and values.get("date_planned"):
values["group_id"] = rule._get_auto_procurement_group(product_id)
return rule

View File

@@ -116,9 +116,13 @@ class TestProcurementAutoCreateGroup(TransactionCase):
}
)
cls.group = cls.group_obj.create({"name": "SO0001"})
@classmethod
def _procure(cls, product):
values = {}
values = {
"group_id": cls.group,
}
cls.group_obj.run(
[
cls.env["procurement.group"].Procurement(
@@ -175,8 +179,10 @@ class TestProcurementAutoCreateGroup(TransactionCase):
[("product_id", "=", self.prod_no_auto_pull_push.id)]
)
self.assertTrue(move)
self.assertFalse(
move.group_id, "Procurement Group should not have been assigned."
self.assertEqual(
move.group_id,
self.group,
"Procurement Group should not have been assigned.",
)
def test_02_pull_push_auto_create_group(self):