Skip to content

[17.0][MIG] sale_rental#52

Open
edescalona wants to merge 31 commits intoOCA:17.0from
BinhexTeam:17.0-mig-sale_rental
Open

[17.0][MIG] sale_rental#52
edescalona wants to merge 31 commits intoOCA:17.0from
BinhexTeam:17.0-mig-sale_rental

Conversation

@edescalona
Copy link
Copy Markdown

@edescalona edescalona commented Nov 27, 2024

@BinhexTeam

Some minor changes were made to it.

@rousseldenis
Copy link
Copy Markdown

/ocabot migration sale_rental

Copy link
Copy Markdown

@remi-filament remi-filament left a comment

Choose a reason for hiding this comment

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

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 !

@edescalona
Copy link
Copy Markdown
Author

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

@edescalona edescalona force-pushed the 17.0-mig-sale_rental branch 2 times, most recently from 8342b4a to 01a286b Compare May 15, 2025 14:23
@edescalona
Copy link
Copy Markdown
Author

Hello @remi-filament , ready for review, thanks.

Copy link
Copy Markdown

@remi-filament remi-filament left a comment

Choose a reason for hiding this comment

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

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."

Comment on lines +22 to +24
<record id="stock.warehouse0" model="stock.warehouse">
<field name="rental_allowed" eval="True" />
</record>
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 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.

Comment on lines +203 to +250
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,
}
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment on lines +13 to +40
<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>
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 suggest to add a page specific for Rental and to add cols and colspan for avoiding getting a full width button.

Suggested change
<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>

Comment on lines +49 to +75
<group name="sale" position="inside">
<label
for="rented_product_tmpl_id"
string="Rental"
invisible="detailed_type != 'service' or product_variant_count &gt; 1"
/>
<field
name="rented_product_tmpl_id"
invisible="detailed_type != 'service' or product_variant_count &gt; 1"
/>
<label
for="rental_service_tmpl_ids"
string="Rental Services"
invisible="detailed_type == 'service' or product_variant_count &gt; 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 &gt; 1"
/>
</group>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same here :

Suggested change
<group name="sale" position="inside">
<label
for="rented_product_tmpl_id"
string="Rental"
invisible="detailed_type != 'service' or product_variant_count &gt; 1"
/>
<field
name="rented_product_tmpl_id"
invisible="detailed_type != 'service' or product_variant_count &gt; 1"
/>
<label
for="rental_service_tmpl_ids"
string="Rental Services"
invisible="detailed_type == 'service' or product_variant_count &gt; 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 &gt; 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 &gt; 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 &gt; 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>

@edescalona
Copy link
Copy Markdown
Author

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.

Copy link
Copy Markdown

@chaule97 chaule97 left a comment

Choose a reason for hiding this comment

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

LGTM

@edescalona
Copy link
Copy Markdown
Author

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.

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.