-
-
Notifications
You must be signed in to change notification settings - Fork 197
[18.0][MIG] maintenance_purchase: Migration to version 18.0 #536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 18.0
Are you sure you want to change the base?
[18.0][MIG] maintenance_purchase: Migration to version 18.0 #536
Conversation
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/
…tegory before creating it
…houldn't be maintained
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/
|
/ocabot migration maintenance_purchase |
pedrobaeza
left a comment
There was a problem hiding this 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_productdependency 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_stockfor inhibiting the equipment creation when confirming, so better to refactor this creation into a separate method.
|
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 |
310eaca to
cb3ee02
Compare
victoralmau
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review OK
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 |
|
Instead of removing the dependency to |
123aff4 to
fb0261f
Compare
|
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. |
82fee59 to
3867104
Compare
|
Added the posibility of changing the quantity to a higher value and creating the remaining equipments when re-confirming the purchase |
3867104 to
f7a7f99
Compare
f7a7f99 to
27f6e3f
Compare
|
Done! @pedrobaeza |
pedrobaeza
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there!
| SET equipment_category_id = sub.equipment_category_id | ||
| FROM ( | ||
| SELECT mec.product_category_id AS product_category_id, | ||
| mec.id AS equipment_category_id | ||
| FROM maintenance_equipment_category mec | ||
| WHERE mec.product_category_id IS NOT NULL | ||
| ) AS sub | ||
| WHERE pt.categ_id = sub.product_category_id | ||
| AND pt.equipment_category_id IS NULL""", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can short this SQL:
| SET equipment_category_id = sub.equipment_category_id | |
| FROM ( | |
| SELECT mec.product_category_id AS product_category_id, | |
| mec.id AS equipment_category_id | |
| FROM maintenance_equipment_category mec | |
| WHERE mec.product_category_id IS NOT NULL | |
| ) AS sub | |
| WHERE pt.categ_id = sub.product_category_id | |
| AND pt.equipment_category_id IS NULL""", | |
| SET equipment_category_id = mec.equipment_category_id | |
| FROM maintenance_equipment_category mec | |
| WHERE pt.categ_id = mec.product_category_id | |
| AND pt.equipment_category_id IS NULL""", | |
| ) |
| item.equipment_category_id = ( | ||
| item.product_id.product_tmpl_id.equipment_category_id | ||
| ) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this extra empty line
| class ProductTemplate(models.Model): | ||
| _inherit = "product.template" | ||
|
|
||
| equipment_category_id = fields.Many2one( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should be more specific? purchase_equipment_category_id

Replaced the dependency on
maintenance_accountwithmaintenance_product, as the module works correctly without the accounting dependencyEDIT:
Also removed
purchase_stockdependency topurchase@Tecnativa TT59851
@pedrobaeza @victoralmau