OCA / odoo-pre-commit-hooks

Linters of Odoo addons that complement pylint-odoo
GNU Affero General Public License v3.0
10 stars 12 forks source link

xml_duplicate_fields: Support special case for 'Duplicate xml field "company_id"' #10

Closed moylop260 closed 2 years ago

moylop260 commented 2 years ago

I have checked the lint in odoo project itself and it is detecting the following cases:

odoo/addons/account/views/account_move_views.xml:166 Duplicate xml field "company_id" in lines 167
odoo/addons/account/views/account_account_views.xml:92 Duplicate xml field "company_id" in lines 104
odoo/addons/account/views/account_journal_views.xml:253 Duplicate xml field "company_id" in lines 257
odoo/addons/hr/views/hr_employee_views.xml:276 Duplicate xml field "company_id" in lines 281
odoo/addons/hr_holidays/views/hr_leave_stress_day_views.xml:32 Duplicate xml field "company_id" in lines 34
odoo/addons/hr_recruitment/views/hr_recruitment_views.xml:52 Duplicate xml field "company_id" in lines 53
odoo/addons/product/views/product_pricelist_item_views.xml:60 Duplicate xml field "company_id" in lines 85
odoo/addons/project/views/project_views.xml:691 Duplicate xml field "company_id" in lines 692
odoo/addons/project/views/project_views.xml:1509 Duplicate xml field "company_id" in lines 1510
odoo/addons/resource/views/resource_views.xml:61 Duplicate xml field "company_id" in lines 64
odoo/addons/stock/views/product_strategy_views.xml:8 Duplicate xml field "company_id" in lines 37
odoo/addons/stock/views/stock_quant_views.xml:111 Duplicate xml field "company_id" in lines 120
odoo/addons/stock/views/stock_quant_views.xml:363 Duplicate xml field "company_id" in lines 387
odoo/addons/stock/views/stock_orderpoint_views.xml:43 Duplicate xml field "company_id" in lines 62
odoo/addons/stock_picking_batch/views/stock_picking_batch_views.xml:63 Duplicate xml field "company_id" in lines 76

Also, check the following OCA case:

So, It could be a false red if there are invisible + known extra attributes e.g. groups

pedrobaeza commented 2 years ago

I don't think it's just company_id, but any field with groups, but also being part of a domain.

moylop260 commented 2 years ago

@pedrobaeza

Good point!

Thank you!

In order to create the test_repo could you share me a whole xml with valid cases and another one similar but with invalid cases related to groups and ... "being part of a domain." part too, please?

Regards!

pedrobaeza commented 2 years ago

What about just checking if there's more than one visible occurrence of the field? I think that can be the real reason of this linter. Although there's sometimes legit reasons to show the same field several times... Is this linter really helpful?