Skip to content

Conversation

@CarlosRoca13
Copy link

This PR supersedes #631 to replace the use of SQL with a filtered_domain on the commission items. The authorship of the migration commit has been preserved.

cc @Tecnativa TT57153

ping @carlosdauden @pedrobaeza @PolComas

ilyasProgrammer and others added 23 commits August 26, 2025 08:08
Currently translated at 100.0% (65 of 65 strings)

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

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

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

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

Translation: commission-14.0/commission-14.0-sale_commission_product_criteria
Translate-URL: https://translation.odoo-community.org/projects/commission-14-0/commission-14-0-sale_commission_product_criteria/it/
_name = "commission.item"
_description = "Commission Item"
_order = "applied_on, based_on, categ_id desc, id desc"
_order = "applied_on, based_on, category_complete_name desc, id desc"
Copy link
Member

Choose a reason for hiding this comment

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

I don't think you need this change, but change _order of the category itself.

Copy link
Author

Choose a reason for hiding this comment

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

Do you think it's more convenient to change the order of the category than to add this order at the commission.item level?

Copy link
Member

@pedrobaeza pedrobaeza Aug 26, 2025

Choose a reason for hiding this comment

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

But why the default category order is not valid? It should be...

Copy link
Author

Choose a reason for hiding this comment

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

As I understand it, adding a many2one field in the order evaluates the ID of the related record, but what we need is for it to be ordered by grandchild > child > parent. If we create the child record first, then the parent, and then the grandchild, the order would be incorrect (grandchild > parent > child). By ordering by complete_name (as categories do), we solve the problem. Am I wrong?

Copy link
Member

Choose a reason for hiding this comment

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

When adding a many2one, first you get the IDs ordered by their native model order, and then it's applied here, so you don't need to reorder them (this also means 2 queries, but Odoo does it this way for UX convenience).

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for the clarification

Choose a reason for hiding this comment

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

This change leads to worse performance at a rather delicate moment, but if you want we can leave it for the time being until we can measure it in an instance with a lot of records.

Copy link
Member

Choose a reason for hiding this comment

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

Is it the number of records to be very high for the commission definition? Do you think it has a big impact? Other thing it can be done is to put auto_joint=True on categ_id for resolving everything in one query.

@CarlosRoca13 CarlosRoca13 force-pushed the 15.0-mig-sale_commission_product_criteria branch from c2ab1a8 to aee82ad Compare August 26, 2025 07:06
@CarlosRoca13 CarlosRoca13 force-pushed the 15.0-mig-sale_commission_product_criteria branch from aee82ad to 595b009 Compare August 26, 2025 07:13
@pedrobaeza pedrobaeza added this to the 15.0 milestone Aug 26, 2025
_name = "commission.item"
_description = "Commission Item"
_order = "applied_on, based_on, categ_id desc, id desc"
_order = "applied_on, based_on, category_complete_name desc, id desc"
Copy link
Member

Choose a reason for hiding this comment

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

Is it the number of records to be very high for the commission definition? Do you think it has a big impact? Other thing it can be done is to put auto_joint=True on categ_id for resolving everything in one query.

@CarlosRoca13 CarlosRoca13 force-pushed the 15.0-mig-sale_commission_product_criteria branch from 595b009 to bdb5a88 Compare August 27, 2025 05:52
@CarlosRoca13 CarlosRoca13 force-pushed the 15.0-mig-sale_commission_product_criteria branch from bdb5a88 to f868e6b Compare October 3, 2025 10:35
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.

10 participants