Skip to content

[18.0][IMP] rma_lot: Add methods to improve inheritance and extension#603

Merged
OCA-git-bot merged 1 commit into
OCA:18.0from
Tecnativa:18.0-imp-rma_lot-multi-warehouse
Jun 23, 2026
Merged

[18.0][IMP] rma_lot: Add methods to improve inheritance and extension#603
OCA-git-bot merged 1 commit into
OCA:18.0from
Tecnativa:18.0-imp-rma_lot-multi-warehouse

Conversation

@victoralmau

Copy link
Copy Markdown
Member

Add methods to improve inheritance and extension

Please @pedrobaeza and @carlos-lopez-tecnativa can you review it?

@Tecnativa

@pedrobaeza pedrobaeza added this to the 18.0 milestone Jun 18, 2026
Comment thread rma_lot/models/rma.py Outdated
Comment thread rma_lot/wizards/rma_delivery.py
@victoralmau victoralmau force-pushed the 18.0-imp-rma_lot-multi-warehouse branch from b2aa02b to ee960e2 Compare June 18, 2026 14:54
@victoralmau victoralmau force-pushed the 18.0-imp-rma_lot-multi-warehouse branch from ee960e2 to 61e071f Compare June 19, 2026 06:03

@carlos-lopez-tecnativa carlos-lopez-tecnativa left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this approach could be simpler. What do you think?

Or alternatively, move this method to stock.warehouse.

Comment thread rma_lot/models/rma.py
Comment on lines +23 to +31
def _get_lot_id_quant_domain_locations(self):
"""This method retrieves the location(s) that will later be used in
_domain_lot_id_quant_domain(). It will be useful to extend this method if,
for example, you want to search across different multi-warehouse
locations.
"""
self.ensure_one()
warehouse = self.warehouse_id
return warehouse.lot_stock_id + warehouse.rma_loc_id

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if you pass the warehouse as a parameter? This way, you can reuse the same method, can't you?

Suggested change
def _get_lot_id_quant_domain_locations(self):
"""This method retrieves the location(s) that will later be used in
_domain_lot_id_quant_domain(). It will be useful to extend this method if,
for example, you want to search across different multi-warehouse
locations.
"""
self.ensure_one()
warehouse = self.warehouse_id
return warehouse.lot_stock_id + warehouse.rma_loc_id
def _get_lot_id_quant_domain_locations(self, warehouse):
"""This method retrieves the location(s) that will later be used in
_domain_lot_id_quant_domain(). It will be useful to extend this method if,
for example, you want to search across different multi-warehouse
locations.
"""
return warehouse.lot_stock_id + warehouse.rma_loc_id

Comment thread rma_lot/models/rma.py
stock.quant values and is useful for extending to other modules.
"""
self.ensure_one()
locations = self._get_lot_id_quant_domain_locations()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
locations = self._get_lot_id_quant_domain_locations()
locations = self._get_lot_id_quant_domain_locations(self.warehouse_id)

Comment on lines +19 to +27
def _get_lot_id_quant_domain_locations(self):
"""This method retrieves the location(s) that will later be used in
_domain_lot_id_quant_domain(). It will be useful to extend this method if,
for example, you want to search across different multi-warehouse
locations.
"""
self.ensure_one()
warehouse = self.warehouse_id
return warehouse.lot_stock_id + warehouse.rma_loc_id

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def _get_lot_id_quant_domain_locations(self):
"""This method retrieves the location(s) that will later be used in
_domain_lot_id_quant_domain(). It will be useful to extend this method if,
for example, you want to search across different multi-warehouse
locations.
"""
self.ensure_one()
warehouse = self.warehouse_id
return warehouse.lot_stock_id + warehouse.rma_loc_id

stock.quant values and is useful for extending to other modules.
"""
self.ensure_one()
locations = self._get_lot_id_quant_domain_locations()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
locations = self._get_lot_id_quant_domain_locations()
locations = self.env["rma"]._get_lot_id_quant_domain_locations(self.warehouse_id)

@victoralmau

Copy link
Copy Markdown
Member Author

I think this approach could be simpler. What do you think?

Or alternatively, move this method to stock.warehouse.

I understand your suggestion, and I think it's a great one, but... it's not a viable option if, for example, we want to override the method to use all of the company's warehouses from an RMA.

@carlos-lopez-tecnativa carlos-lopez-tecnativa left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this approach could be simpler. What do you think?
Or alternatively, move this method to stock.warehouse.

I understand your suggestion, and I think it's a great one, but... it's not a viable option if, for example, we want to override the method to use all of the company's warehouses from an RMA.

I don't fully understand what would change in another module. My suggestion was based only on the code shown here, where you are working with a single warehouse.

In any case, I don't think this PR should be blocked because of this. Let's move forward.

@pedrobaeza

Copy link
Copy Markdown
Member

/ocabot merge patch

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 18.0-ocabot-merge-pr-603-by-pedrobaeza-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 53474a1 into OCA:18.0 Jun 23, 2026
7 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at ab0f21a. Thanks a lot for contributing to OCA. ❤️

@pedrobaeza pedrobaeza deleted the 18.0-imp-rma_lot-multi-warehouse branch June 23, 2026 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants