OCA / pylint-odoo

Odoo plugin for Pylint
http://www.pylint.org
143 stars 168 forks source link

[ADD] bad-builtin-groupby: Prefer `odoo.tools.groupby` instead #442

Closed moylop260 closed 1 year ago

moylop260 commented 1 year ago

More info about https://github.com/odoo/odoo/issues/105376

moylop260 commented 1 year ago

@tde-banana-odoo @tivisse

Odoo has the following line of code with an issue since the generator is not ordered with the key so it losing data:

I have created this lint in order to detect similar cases

The following were reported:

https://github.com/odoo/odoo/tree/a138875b/addons/account/wizard/account_automatic_entry_wizard.py#L221 https://github.com/odoo/odoo/tree/a138875b/addons/lunch/populate/lunch.py#L38 https://github.com/odoo/odoo/tree/a138875b/addons/point_of_sale/models/pos_order.py#L1111 https://github.com/odoo/odoo/tree/a138875b/addons/point_of_sale/models/product.py#L83 https://github.com/odoo/odoo/tree/a138875b/addons/point_of_sale/models/stock_picking.py#L124 https://github.com/odoo/odoo/tree/a138875b/addons/point_of_sale/models/stock_picking.py#L89 https://github.com/odoo/odoo/tree/a138875b/addons/pos_restaurant/models/pos_order.py#L132 https://github.com/odoo/odoo/tree/a138875b/addons/pos_restaurant/models/pos_order.py#L47 https://github.com/odoo/odoo/tree/a138875b/addons/pos_restaurant/models/pos_order.py#L94 https://github.com/odoo/odoo/tree/a138875b/addons/purchase_stock/models/stock_rule.py#L120 https://github.com/odoo/odoo/tree/a138875b/addons/purchase_stock/models/stock_rule.py#L205 https://github.com/odoo/odoo/tree/a138875b/addons/purchase/models/purchase.py#L544 https://github.com/odoo/odoo/tree/a138875b/addons/sale/models/sale_order.py#L784 https://github.com/odoo/odoo/tree/a138875b/addons/stock/models/stock_move.py#L1058 https://github.com/odoo/odoo/tree/a138875b/addons/stock/models/stock_move.py#L1421 https://github.com/odoo/odoo/tree/a138875b/addons/stock/models/stock_move.py#L1446 https://github.com/odoo/odoo/tree/a138875b/addons/stock/models/stock_move.py#L1451 https://github.com/odoo/odoo/tree/a138875b/addons/stock/models/stock_package_level.py#L182 https://github.com/odoo/odoo/tree/a138875b/addons/stock/models/stock_package_level.py#L186 https://github.com/odoo/odoo/tree/a138875b/addons/stock/models/stock_picking.py#L1218 https://github.com/odoo/odoo/tree/a138875b/addons/stock/models/stock_picking.py#L890 https://github.com/odoo/odoo/tree/a138875b/addons/stock/models/stock_picking.py#L894 https://github.com/odoo/odoo/tree/a138875b/addons/web/controllers/main.py#L1754 https://github.com/odoo/odoo/tree/a138875b/addons/website_blog/controllers/main.py#L57 https://github.com/odoo/odoo/tree/a138875b/odoo/addons/base/models/ir_model.py#L2153 https://github.com/odoo/odoo/tree/a138875b/odoo/addons/base/models/ir_model.py#L2153 https://github.com/odoo/odoo/tree/a138875b/odoo/addons/base/models/ir_translation.py#L896 https://github.com/odoo/odoo/tree/a138875b/odoo/addons/base/models/ir_translation.py#L896

https://github.com/odoo/enterprise/tree/9988b9aae/account_asset/report/account_assets_report.py#L133 https://github.com/odoo/enterprise/tree/9988b9aae/hr_holidays_gantt/models/hr_leave.py#L68 https://github.com/odoo/enterprise/tree/9988b9aae/l10n_be_reports/models/partner_vat_listing.py#L189 https://github.com/odoo/enterprise/tree/9988b9aae/l10n_cl_edi_boletas/models/l10n_cl_daily_sales_book.py#L70 https://github.com/odoo/enterprise/tree/9988b9aae/l10n_de_pos_res_cert/models/pos_order.py#L98 https://github.com/odoo/enterprise/tree/9988b9aae/l10n_in_reports/report/account_gst_report.py#L229 https://github.com/odoo/enterprise/tree/9988b9aae/l10n_lu_reports/models/account_general_ledger.py#L110 https://github.com/odoo/enterprise/tree/9988b9aae/pos_blackbox_be/models/pos_blackbox_be.py#L320 https://github.com/odoo/enterprise/tree/9988b9aae/pos_hr_l10n_be/models/hr_employee.py#L88 https://github.com/odoo/enterprise/tree/9988b9aae/sale_subscription_dashboard/models/sale_subscription.py#L280

I even don't think all them are non-ordered generator but it is better ping you in order to analyze them

Also, I have created the following issue: