[18.0][IMP] rma_lot: Add methods to improve inheritance and extension#603
Conversation
b2aa02b to
ee960e2
Compare
ee960e2 to
61e071f
Compare
carlos-lopez-tecnativa
left a comment
There was a problem hiding this comment.
I think this approach could be simpler. What do you think?
Or alternatively, move this method to stock.warehouse.
| 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 |
There was a problem hiding this comment.
What if you pass the warehouse as a parameter? This way, you can reuse the same method, can't you?
| 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 |
| stock.quant values and is useful for extending to other modules. | ||
| """ | ||
| self.ensure_one() | ||
| locations = self._get_lot_id_quant_domain_locations() |
There was a problem hiding this comment.
| locations = self._get_lot_id_quant_domain_locations() | |
| locations = self._get_lot_id_quant_domain_locations(self.warehouse_id) |
| 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 |
There was a problem hiding this comment.
| 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() |
There was a problem hiding this comment.
| locations = self._get_lot_id_quant_domain_locations() | |
| locations = self.env["rma"]._get_lot_id_quant_domain_locations(self.warehouse_id) |
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
left a comment
There was a problem hiding this comment.
I think this approach could be simpler. What do you think?
Or alternatively, move this method tostock.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.
|
/ocabot merge patch |
|
Hey, thanks for contributing! Proceeding to merge this for you. |
|
Congratulations, your PR was merged at ab0f21a. Thanks a lot for contributing to OCA. ❤️ |
Add methods to improve inheritance and extension
Please @pedrobaeza and @carlos-lopez-tecnativa can you review it?
@Tecnativa