Skip to content

Commit

Permalink
[FIX] get only valid procurement group stock_orderpoint_origin
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiocorato committed Jul 19, 2024
1 parent 0c3d8da commit fef30fc
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions stock_orderpoint_origin/models/procurement_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,23 @@ def run(self, procurements, raise_user_error=True):
# stock.picking object doesn't have field procurement_group_id,
# so we check if the source document is a picking to use the
# correct field (group_id)
source_groups = [
x.procurement_group_id if x._name != "stock.picking" else x.group_id
for x in source_docs
]
source_groups = []

Check warning on line 32 in stock_orderpoint_origin/models/procurement_group.py

View check run for this annotation

Codecov / codecov/patch

stock_orderpoint_origin/models/procurement_group.py#L32

Added line #L32 was not covered by tests
for source_doc in source_docs:
if (
source_doc._name != "stock.picking"
and source_doc.procurement_group_id
or source_doc.group_id
):
source_groups.append(

Check warning on line 39 in stock_orderpoint_origin/models/procurement_group.py

View check run for this annotation

Codecov / codecov/patch

stock_orderpoint_origin/models/procurement_group.py#L39

Added line #L39 was not covered by tests
source_doc.procurement_group_id
if source_doc._name != "stock.picking"
else source_doc.group_id
)
source_names = ", ".join([x.name for x in source_docs])
new_origin = "%s (from %s)" % (source_names, procurement.origin)
new_procurement = procurement._replace(origin=new_origin)
new_procurement.values["source_group_ids"] = source_groups
if source_groups:
new_procurement.values["source_group_ids"] = source_groups

Check warning on line 48 in stock_orderpoint_origin/models/procurement_group.py

View check run for this annotation

Codecov / codecov/patch

stock_orderpoint_origin/models/procurement_group.py#L48

Added line #L48 was not covered by tests
new_procurements.append(new_procurement)
else:
new_procurements.append(procurement)
Expand Down

0 comments on commit fef30fc

Please sign in to comment.