Skip to content

Commit 40d8029

Browse files
committed
[IMP] stock_product_pack: Extract pack move removal check into method
1 parent c4c83cc commit 40d8029

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

stock_product_pack/models/stock_rule.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,21 @@
66
class ProcurementGroup(models.Model):
77
_inherit = "procurement.group"
88

9+
def is_pack_dont_create_move(self, product):
10+
return (
11+
product
12+
and product.pack_ok
13+
and product.dont_create_move
14+
and product.pack_type == "detailed"
15+
)
16+
917
@api.model
1018
def run(self, procurements, raise_user_error=True):
1119
"""If 'run' is called on a pack product storable.
1220
we remove the procurement with this product pack.
1321
"""
1422
for procurement in procurements:
15-
if (
16-
procurement.product_id
17-
and procurement.product_id.pack_ok
18-
and procurement.product_id.dont_create_move
19-
and procurement.product_id.pack_type == "detailed"
20-
):
23+
if self.is_pack_dont_create_move(procurement.product_id):
2124
procurements.remove(procurement)
2225

2326
return super().run(procurements, raise_user_error=raise_user_error)

0 commit comments

Comments
 (0)