Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.0][FIX] repair_stock_move: proper main lot management & default location for remove operations #58

Open
wants to merge 2 commits into
base: 15.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions repair_stock_move/models/repair_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@
res.move_id = move
return res

@api.onchange("product_id")
def _onchange_location(self):
if self.state == "draft":
@api.onchange("type")
def onchange_operation_type(self):
res = super().onchange_operation_type()

Check warning on line 50 in repair_stock_move/models/repair_line.py

View check run for this annotation

Codecov / codecov/patch

repair_stock_move/models/repair_line.py#L50

Added line #L50 was not covered by tests
if self.state == "draft" and self.type == "add":
self.location_id = self.repair_id.location_id
return res

Check warning on line 53 in repair_stock_move/models/repair_line.py

View check run for this annotation

Codecov / codecov/patch

repair_stock_move/models/repair_line.py#L53

Added line #L53 was not covered by tests

# TODO: write qty - update stock move.
# TODO: default repair location in repair lines.
6 changes: 5 additions & 1 deletion repair_stock_move/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
):
if self.repair_line_id and self.repair_line_id.lot_id:
lot_id = self.repair_line_id.lot_id
if self.repair_id and not self.repair_line_id and self.repair_id.lot_id:
lot_id = self.repair_id.lot_id

Check warning on line 28 in repair_stock_move/models/stock_move.py

View check run for this annotation

Codecov / codecov/patch

repair_stock_move/models/stock_move.py#L28

Added line #L28 was not covered by tests

return super()._get_available_quantity(
location_id,
Expand All @@ -46,6 +48,8 @@
):
if self.repair_line_id and self.repair_line_id.lot_id:
lot_id = self.repair_line_id.lot_id
if self.repair_id and not self.repair_line_id and self.repair_id.lot_id:
lot_id = self.repair_id.lot_id

Check warning on line 52 in repair_stock_move/models/stock_move.py

View check run for this annotation

Codecov / codecov/patch

repair_stock_move/models/stock_move.py#L52

Added line #L52 was not covered by tests
return super(StockMove, self)._update_reserved_quantity(
need,
available_quantity,
Expand All @@ -62,6 +66,6 @@
)
if self.repair_line_id and self.repair_line_id.lot_id:
vals["lot_id"] = self.repair_line_id.lot_id.id
elif self.repair_id and self.repair_id.lot_id:
elif self.repair_id and not self.repair_line_id and self.repair_id.lot_id:
dalonsod marked this conversation as resolved.
Show resolved Hide resolved
vals["lot_id"] = self.repair_id.lot_id.id
return vals
Loading