Conversation
|
/ocabot migration sale_rental |
remi-filament
left a comment
There was a problem hiding this comment.
Thanks @edescalona for porting this module.
I discovered it with your PR, it seems to be working fine.
However, display on products and sale order could be improved !
Hi @remi-filament thank you for your comments, I will review them and comment on them, greetings |
8342b4a to
01a286b
Compare
|
Hello @remi-filament , ready for review, thanks. |
remi-filament
left a comment
There was a problem hiding this comment.
Thanks for your work on that module !
I made a first review, and I think there are some improvements to be made to that module, I made some suggestions inline (for aligning UI with the rest of Odoo interface, for handling multi-company properly), documentation also would need to be updated.
Regarding PR process, you need to clean up bot commits as specified here : https://github.com/OCA/maintainer-tools/wiki/Migration-to-version-17.0 :
"Squash administrative commits (if any) with the previous commit for reducing commit noise. Check https://github.com/OCA/maintainer-tools/wiki/Merge-commits-in-pull-requests#mergesquash-the-commits-generated-by-bots-or-weblate for details."
| <record id="stock.warehouse0" model="stock.warehouse"> | ||
| <field name="rental_allowed" eval="True" /> | ||
| </record> |
There was a problem hiding this comment.
I do not think we should do that in data, maybe in demo data rather.
When installing the module on existing DB with multiple companies or warehouses, we do not know on which one they want to allow rental, so it is probably better if this is done manually and added to configuration part of readme.
| if "rental_allowed" in vals: | ||
| rental_route = self.env.ref("sale_rental.route_warehouse0_rental") | ||
| sell_rented_route = self.env.ref( | ||
| "sale_rental.route_warehouse0_sell_rented_product" | ||
| ) | ||
| if vals.get("rental_allowed"): | ||
| self._create_rental_locations() | ||
| self.write( | ||
| { | ||
| "route_ids": [(4, rental_route.id)], | ||
| "rental_route_id": rental_route.id, | ||
| "sell_rented_product_route_id": sell_rented_route.id, | ||
| } | ||
| ) | ||
| rental_rules = self.env["stock.rule"].search( | ||
| [ | ||
| ("route_id", "in", [rental_route.id, sell_rented_route.id]), | ||
| ("active", "=", False), | ||
| ] | ||
| ) | ||
| if rental_rules: | ||
| rental_rules.write({"active": True}) | ||
| else: | ||
| for rule_vals in self._get_rental_push_pull_rules(): | ||
| self.env["stock.rule"].create(rule_vals) | ||
| else: | ||
| for wh in self: | ||
| rules_to_archive = self.env["stock.rule"].search( | ||
| [ | ||
| ( | ||
| "route_id", | ||
| "in", | ||
| ( | ||
| wh.rental_route_id.id, | ||
| wh.sell_rented_product_route_id.id, | ||
| ), | ||
| ), | ||
| ("company_id", "=", wh.company_id.id), | ||
| ] | ||
| ) | ||
| rules_to_archive.write({"active": False}) | ||
| wh.write( | ||
| { | ||
| "route_ids": [(3, rental_route.id)], | ||
| "rental_route_id": False, | ||
| "sell_rented_product_route_id": False, | ||
| } | ||
| ) |
There was a problem hiding this comment.
This should be done in function create as well.
Otherwise if you create a new warehouse, setting rental_allowed to true the locations / rules will not be created and routes will not be assigned.
| <group name="sale" position="after"> | ||
| <group | ||
| name="rental" | ||
| string="Rental" | ||
| invisible="detailed_type != 'service'" | ||
| > | ||
| <field name="rented_product_id" /> | ||
| </group> | ||
| <group | ||
| string="Rental Services" | ||
| name="rental_services" | ||
| invisible="detailed_type == 'service'" | ||
| > | ||
| <button | ||
| colspan="2" | ||
| type="action" | ||
| name="%(sale_rental.create_rental_product_action)d" | ||
| string="Create Rental Service" | ||
| /> | ||
| <field | ||
| colspan="2" | ||
| name="rental_service_ids" | ||
| nolabel="1" | ||
| readonly="1" | ||
| invisible="rental_service_ids == []" | ||
| /> | ||
| </group> | ||
| </group> |
There was a problem hiding this comment.
I suggest to add a page specific for Rental and to add cols and colspan for avoiding getting a full width button.
| <group name="sale" position="after"> | |
| <group | |
| name="rental" | |
| string="Rental" | |
| invisible="detailed_type != 'service'" | |
| > | |
| <field name="rented_product_id" /> | |
| </group> | |
| <group | |
| string="Rental Services" | |
| name="rental_services" | |
| invisible="detailed_type == 'service'" | |
| > | |
| <button | |
| colspan="2" | |
| type="action" | |
| name="%(sale_rental.create_rental_product_action)d" | |
| string="Create Rental Service" | |
| /> | |
| <field | |
| colspan="2" | |
| name="rental_service_ids" | |
| nolabel="1" | |
| readonly="1" | |
| invisible="rental_service_ids == []" | |
| /> | |
| </group> | |
| </group> | |
| <page name="sales" position="after"> | |
| <page | |
| name="rental" | |
| string="Rental" | |
| invisible="not sale_ok and detailed_type=='service'" | |
| > | |
| <group> | |
| <group | |
| name="rental_product" | |
| invisible="detailed_type != 'service'" | |
| > | |
| <field name="rented_product_id" /> | |
| </group> | |
| <group | |
| name="rental_services" | |
| string="Rental Services" | |
| invisible="detailed_type == 'service'" | |
| col="1" | |
| colspan="3" | |
| > | |
| <field | |
| colspan="2" | |
| name="rental_service_ids" | |
| nolabel="1" | |
| readonly="1" | |
| invisible="rental_service_ids == []" | |
| /> | |
| <button | |
| colspan="2" | |
| type="action" | |
| name="%(sale_rental.create_rental_product_action)d" | |
| string="Create Rental Service" | |
| /> | |
| </group> | |
| </group> | |
| </page> | |
| </page> |
| <group name="sale" position="inside"> | ||
| <label | ||
| for="rented_product_tmpl_id" | ||
| string="Rental" | ||
| invisible="detailed_type != 'service' or product_variant_count > 1" | ||
| /> | ||
| <field | ||
| name="rented_product_tmpl_id" | ||
| invisible="detailed_type != 'service' or product_variant_count > 1" | ||
| /> | ||
| <label | ||
| for="rental_service_tmpl_ids" | ||
| string="Rental Services" | ||
| invisible="detailed_type == 'service' or product_variant_count > 1" | ||
| /> | ||
| <field | ||
| name="rental_service_tmpl_ids" | ||
| nolabel="1" | ||
| invisible="rental_service_tmpl_ids == []" | ||
| /> | ||
| <button | ||
| type="action" | ||
| name="%(sale_rental.create_rental_product_action)d" | ||
| string="Create Rental Service" | ||
| invisible="detailed_type == 'service' or product_variant_count > 1" | ||
| /> | ||
| </group> |
There was a problem hiding this comment.
Same here :
| <group name="sale" position="inside"> | |
| <label | |
| for="rented_product_tmpl_id" | |
| string="Rental" | |
| invisible="detailed_type != 'service' or product_variant_count > 1" | |
| /> | |
| <field | |
| name="rented_product_tmpl_id" | |
| invisible="detailed_type != 'service' or product_variant_count > 1" | |
| /> | |
| <label | |
| for="rental_service_tmpl_ids" | |
| string="Rental Services" | |
| invisible="detailed_type == 'service' or product_variant_count > 1" | |
| /> | |
| <field | |
| name="rental_service_tmpl_ids" | |
| nolabel="1" | |
| invisible="rental_service_tmpl_ids == []" | |
| /> | |
| <button | |
| type="action" | |
| name="%(sale_rental.create_rental_product_action)d" | |
| string="Create Rental Service" | |
| invisible="detailed_type == 'service' or product_variant_count > 1" | |
| /> | |
| </group> | |
| <page name="sales" position="after"> | |
| <page | |
| name="rental" | |
| string="Rental" | |
| invisible="not sale_ok and detailed_type=='service'" | |
| > | |
| <group> | |
| <group | |
| name="rental-product" | |
| invisible="detailed_type != 'service' or product_variant_count > 1" | |
| > | |
| <field name="rented_product_tmpl_id" /> | |
| </group> | |
| <group | |
| name="rental-services" | |
| string="Rental Services" | |
| col="1" | |
| colspan="3" | |
| invisible="detailed_type == 'service' or product_variant_count > 1" | |
| > | |
| <field | |
| nolabel="1" | |
| name="rental_service_tmpl_ids" | |
| invisible="not rental_service_tmpl_ids" | |
| > | |
| <tree create="0" delete="0"> | |
| <field name="name" /> | |
| <field | |
| name="list_price" | |
| string="Rental Price per Day" | |
| /> | |
| </tree> | |
| </field> | |
| <button | |
| type="action" | |
| name="%(sale_rental.create_rental_product_action)d" | |
| string="Create Rental Service" | |
| colspan="3" | |
| /> | |
| </group> | |
| </group> | |
| </page> | |
| </page> |
|
Hi @remi-filament , I'll take your comments into account, but this is a PR for the migration itself. It would be better to add the improvements you mentioned to a separate PR so as not to change the original format. Thanks for your feedback. |
Replace openerp by odoo in import declarations
Convert readme to new subdir format
the creation of the stock location for rental respects the translations
01a286b to
9657bf3
Compare
No more need to add users to the packaging group View of rental group is now possible on product.template form view
Standard migration + add some tests
9657bf3 to
3152d32
Compare
|
Hi @remi-filament , I've corrected some of your suggestions. I think the rest should be addressed in a pull request, unless @rousseldenis thinks they can be done in this same pull request? I also cleaned up the commit history a bit. Let me know what you think. Thanks. |
@BinhexTeam
Some minor changes were made to it.