Skip to content
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
6 changes: 4 additions & 2 deletions rma_batch/models/rma.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@ def _compute_team_id(self):
rec.team_id = rec.batch_id.team_id
return res

@api.depends("picking_id", "product_id", "company_id", "batch_id")
@api.depends("picking_id", "product_id", "company_id", "batch_id.location_id")
def _compute_location_id(self):
"""Override to consider RMA Batch location"""
super()._compute_location_id()
# Apply RMA Batch location if set
for record in self:
if record.batch_id and record.batch_id.location_id:
if record.state != "draft":
continue
if record.batch_id.location_id:
record.location_id = record.batch_id.location_id

return
Expand Down
13 changes: 13 additions & 0 deletions rma_batch/tests/test_rma_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,19 @@ def test_onchange_sync_rmas_only(self):
self.assertEqual(rma.team_id, self.team)
self.assertEqual(rma.tag_ids, self.tag1)

def test_change_location_on_batch_propagates_to_rmas(self):
"""check that changing the location on a draft batch updates
the location on the associated RMAs"""
warehouse = self.env["stock.warehouse"].search(
[("company_id", "=", self.env.company.id)], limit=1
)
rma_location = warehouse.rma_loc_id
batch = self._create_batch([(self.product, 5), (self.product2, 3)])
self.assertEqual(batch.state, "draft")
batch.location_id = rma_location
for rma in batch.rma_ids:
self.assertEqual(rma.location_id, rma_location)

def test_unlink_forbidden_when_non_draft_rma(self):
"""ensure that a batch can't be deleted if it contains any RMA
not in draft state"""
Expand Down