Skip to content

Commit

Permalink
[IMP] stock_inventory_verification_request: compute involved lines an…
Browse files Browse the repository at this point in the history
…d quants
  • Loading branch information
JoanSForgeFlow committed Nov 5, 2024
1 parent 413f8fe commit a28c24c
Showing 1 changed file with 25 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ def _compute_created_inventory_count(self):
column1="slot_verification_request_id",
column2="move_line_id",
string="Involved Stock Moves",
compute="_compute_involved_move_lines",
store=False,
)
involved_move_line_count = fields.Integer(
compute="_compute_involved_move_line_count"
Expand All @@ -110,6 +112,8 @@ def _compute_created_inventory_count(self):
column1="slot_verification_request_id",
column2="quant_id",
string="Involved Inventory Quants",
compute="_compute_involved_quants",
store=False,
)
involved_quant_count = fields.Integer(compute="_compute_involved_quant_count")
created_inventory_ids = fields.One2many(
Expand All @@ -120,6 +124,27 @@ def _compute_created_inventory_count(self):
)
created_inventory_count = fields.Integer(compute="_compute_created_inventory_count")

@api.depends("location_id", "product_id", "lot_id", "state")
def _compute_involved_move_lines(self):
for rec in self:
# Solo calcular si el estado es 'open'
if rec.state == "open":
rec.involved_move_line_ids = self.env["stock.move.line"].search(
rec._get_involved_move_lines_domain()
)
else:
rec.involved_move_line_ids = self.env["stock.move.line"]

Check warning on line 136 in stock_inventory_verification_request/models/stock_slot_verification_request.py

View check run for this annotation

Codecov / codecov/patch

stock_inventory_verification_request/models/stock_slot_verification_request.py#L136

Added line #L136 was not covered by tests

@api.depends("location_id", "product_id", "lot_id", "state")
def _compute_involved_quants(self):
for rec in self:
if rec.state == "open":
rec.involved_quant_ids = self.env["stock.quant"].search(
rec._get_involved_quants_domain()
)
else:
rec.involved_quant_ids = self.env["stock.quant"]

Check warning on line 146 in stock_inventory_verification_request/models/stock_slot_verification_request.py

View check run for this annotation

Codecov / codecov/patch

stock_inventory_verification_request/models/stock_slot_verification_request.py#L146

Added line #L146 was not covered by tests

def _get_involved_move_lines_domain(self):
domain = [
"|",
Expand All @@ -140,24 +165,8 @@ def _get_involved_quants_domain(self):
domain.append(("lot_id", "=", self.lot_id.id))
return domain

def _get_involved_quants_and_locations(self):
involved_move_lines = self.env["stock.move.line"].search(
self._get_involved_move_lines_domain()
)
involved_quants = self.env["stock.quant"].search(
self._get_involved_quants_domain()
)
return involved_move_lines, involved_quants

def action_confirm(self):
self.write({"state": "open"})
for rec in self:
(
involved_moves_lines,
involved_quants,
) = rec._get_involved_quants_and_locations()
rec.involved_move_line_ids = involved_moves_lines
rec.involved_quant_ids = involved_quants
return True

def action_cancel(self):
Expand Down

0 comments on commit a28c24c

Please sign in to comment.