Skip to content

Commit

Permalink
stock_warehouse_archive: fix purging inventory
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienbeau committed Feb 5, 2024
1 parent 0fe329e commit ef17e16
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions stock_warehouse_archive/models/stock_warehouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ def _action_cancel_related_move_from_location(self, locations):
def _action_purge_with_inventory(self, locations):
for location in locations:
if location.usage == "internal":
if not location.active:
location.active = True

Check warning on line 137 in stock_warehouse_archive/models/stock_warehouse.py

View check run for this annotation

Codecov / codecov/patch

stock_warehouse_archive/models/stock_warehouse.py#L137

Added line #L137 was not covered by tests

inventory = self.env["stock.inventory"].create(

Check warning on line 139 in stock_warehouse_archive/models/stock_warehouse.py

View check run for this annotation

Codecov / codecov/patch

stock_warehouse_archive/models/stock_warehouse.py#L139

Added line #L139 was not covered by tests
{
"name": _("Archive %(warehouse)s %(location)s")
Expand All @@ -142,11 +145,14 @@ def _action_purge_with_inventory(self, locations):
}
)
inventory.action_start()

Check warning on line 147 in stock_warehouse_archive/models/stock_warehouse.py

View check run for this annotation

Codecov / codecov/patch

stock_warehouse_archive/models/stock_warehouse.py#L147

Added line #L147 was not covered by tests

# Compatibility with stock_inventory_location_state
if "sub_location_ids" in inventory._fields:
inventory.sub_location_ids.state = "done"
inventory._action_done()
if inventory.line_ids:
# Compatibility with stock_inventory_location_state
if "sub_location_ids" in inventory._fields:
inventory.sub_location_ids.state = "done"
inventory._action_done()

Check warning on line 152 in stock_warehouse_archive/models/stock_warehouse.py

View check run for this annotation

Codecov / codecov/patch

stock_warehouse_archive/models/stock_warehouse.py#L151-L152

Added lines #L151 - L152 were not covered by tests
else:
inventory.action_cancel_draft()
inventory.unlink()

Check warning on line 155 in stock_warehouse_archive/models/stock_warehouse.py

View check run for this annotation

Codecov / codecov/patch

stock_warehouse_archive/models/stock_warehouse.py#L154-L155

Added lines #L154 - L155 were not covered by tests

def force_archive(self):

Expand Down

0 comments on commit ef17e16

Please sign in to comment.