Skip to content

Conversation

@christian-ramos-tecnativa
Copy link
Contributor

@christian-ramos-tecnativa christian-ramos-tecnativa commented Dec 16, 2025

Replaced the dependency on maintenance_account with maintenance_product, as the module works correctly without the accounting dependency
EDIT:
Also removed purchase_stock dependency to purchase
@Tecnativa TT59851
@pedrobaeza @victoralmau

etobella and others added 20 commits December 16, 2025 16:15
Currently translated at 100.0% (12 of 12 strings)

Translation: maintenance-14.0/maintenance-14.0-maintenance_purchase
Translate-URL: https://translation.odoo-community.org/projects/maintenance-14-0/maintenance-14-0-maintenance_purchase/it/
Currently translated at 100.0% (12 of 12 strings)

Translation: maintenance-14.0/maintenance-14.0-maintenance_purchase
Translate-URL: https://translation.odoo-community.org/projects/maintenance-14-0/maintenance-14-0-maintenance_purchase/it/
Currently translated at 100.0% (12 of 12 strings)

Translation: maintenance-14.0/maintenance-14.0-maintenance_purchase
Translate-URL: https://translation.odoo-community.org/projects/maintenance-14-0/maintenance-14-0-maintenance_purchase/it/
Currently translated at 100.0% (12 of 12 strings)

Translation: maintenance-14.0/maintenance-14.0-maintenance_purchase
Translate-URL: https://translation.odoo-community.org/projects/maintenance-14-0/maintenance-14-0-maintenance_purchase/es/
Currently translated at 100.0% (12 of 12 strings)

Translation: maintenance-14.0/maintenance-14.0-maintenance_purchase
Translate-URL: https://translation.odoo-community.org/projects/maintenance-14-0/maintenance-14-0-maintenance_purchase/it/
Currently translated at 100.0% (9 of 9 strings)

Translation: maintenance-16.0/maintenance-16.0-maintenance_purchase
Translate-URL: https://translation.odoo-community.org/projects/maintenance-16-0/maintenance-16-0-maintenance_purchase/fr/
@pedrobaeza
Copy link
Member

/ocabot migration maintenance_purchase

@OCA-git-bot OCA-git-bot added this to the 18.0 milestone Dec 16, 2025
@OCA-git-bot OCA-git-bot mentioned this pull request Dec 16, 2025
16 tasks
Copy link
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

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

Several comments:

  • I don't think we need the maintenance_product dependency as well. It's not adding value.
  • We should remove the flag at product level, as if you put a equipment category is enough for determining that you want to create an equipment. Why would you want to set an equipment category, but not to create an equipment? I know there's an automatism for setting the equipment category according the product category, but this is inherited from the other module, and we come back to the first point.
  • Prepare the creation method to be inheritable for maintenance_product_stock for inhibiting the equipment creation when confirming, so better to refactor this creation into a separate method.

@christian-ramos-tecnativa
Copy link
Contributor Author

I think I get what you mean, but that would be a mayor refactor on how the module works right now, as instead of everything working by default configurations at product level using maintenance_product you will need to mannually set up the category everytime you create the purchase. Which IMO is a bad approach, unless we add a maintenance category at product level but in that case we are repeating configuration if the module maintenance_product is installed.
I totally agree on making the equipment creation easier to extend and just saw the method _prepare_account_move_line that need to be also removed.

Copy link
Member

@victoralmau victoralmau left a comment

Choose a reason for hiding this comment

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

Code review OK

type="object"
class="oe_stat_button"
icon="fa-cubes"
invisible="not equipment_count"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
invisible="not equipment_count"
invisible="not equipment_count"
groups="base_maintenance_group.group_maintenance_user"

expr="//notebook//field[@name='order_line']/list/field[@name='product_qty']"
position="before"
>
<field name="equipment_category_id" optional="hide" />
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<field name="equipment_category_id" optional="hide" />
<field name="equipment_category_id" optional="hide" groups="base_maintenance_group.group_maintenance_user" />

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure about adding dependency to base_maintenance_group ngl

@pedrobaeza
Copy link
Member

I think I get what you mean, but that would be a mayor refactor on how the module works right now, as instead of everything working by default configurations at product level using maintenance_product you will need to mannually set up the category everytime you create the purchase. Which IMO is a bad approach, unless we add a maintenance category at product level but in that case we are repeating configuration if the module maintenance_product is installed. I totally agree on making the equipment creation easier to extend and just saw the method _prepare_account_move_line that need to be also removed.

Right now is as well not direct, as even linking the equipment category in the product category, you need to put the check at product level, so it's very counter-intuitive (and the reason we weren't able to generate the equipment in our first tests), so I still think it's good to refactor it that way.

Changing the boolean at product level to be by default True is as well counter-intuitive, as it won't work unless the equipment category is put at product category, so both options are very bad combined.

You can keep the equipment category at product category level as default value for the purchase, but without depending on maintenance_product, and the way to not create the equipment is to empty the column, the same as in account_asset_management.

@christian-ramos-tecnativa
Copy link
Contributor Author

Instead of removing the dependency to maintenance_product as all the logic between product_category and equipment_category is there and changing the module behavior, what about adding: if we fill the equipments category at purchase line level force the creation of the equipment even if the product doesn't have the check active. This way we cover both options. WDYT @pedrobaeza

@pedrobaeza
Copy link
Member

I'm still seeing like "black magic" behind the curtains, which is confusing for the user, so I prefer to have it explicitly set.

guy-long-hair

@christian-ramos-tecnativa christian-ramos-tecnativa force-pushed the 18.0-mig-maintenance_purchase branch 4 times, most recently from 123aff4 to fb0261f Compare December 23, 2025 12:49
@christian-ramos-tecnativa
Copy link
Contributor Author

No more "black magic" here. Now, if the category is removed, the equipment will not be created. If the category is set, the equipment will be created even if the product does not have the maintenance check.

"author": "CreuBlanca,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/maintenance",
"depends": [
"maintenance_product",
Copy link
Member

Choose a reason for hiding this comment

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

Why maintaining then this dependency? I want to be a stand-alone module.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To retain part of the old behavior, the equipment category is auto-filled from the product category, to avoid setting it on every purchase line.

Copy link
Member

Choose a reason for hiding this comment

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

I prefer to not have it for not dragging that module that is half baked imo

@christian-ramos-tecnativa christian-ramos-tecnativa force-pushed the 18.0-mig-maintenance_purchase branch 2 times, most recently from 82fee59 to 3867104 Compare December 23, 2025 13:23
@christian-ramos-tecnativa
Copy link
Contributor Author

Added the posibility of changing the quantity to a higher value and creating the remaining equipments when re-confirming the purchase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants