Skip to content
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

[FIX] duplicate-xml-fields: False red using 2 tree sub-views *2M fields #96

Merged
merged 5 commits into from
Dec 31, 2016

Conversation

moylop260
Copy link
Collaborator

@moylop260 moylop260 commented Dec 23, 2016

Fix #76

exclude = list(set(parents) - set(same_parent))
for item in items:
if item.getparent() in exclude:
items.remove(item)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@pedrobaeza
Here we will have a issue with this remove, right?
cc @hugho-ad

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@hugho-ad
Please, review the following good comments from @pedrobaeza and fix them
#63 (comment)

We have the same case here

Copy link
Member

Choose a reason for hiding this comment

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

I see that you have fixed it, so no problem now 😉

@moylop260 moylop260 self-assigned this Dec 23, 2016
</form>
</field>
</record>

Copy link
Collaborator Author

@moylop260 moylop260 Dec 23, 2016

Choose a reason for hiding this comment

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

@hugho-ad
Could you add the following test case?

diff --git a/pylint_odoo/test_repo/broken_module/model_view_odoo2.xml b/pylint_odoo/test_repo/broken_module/model_view_odoo2.xml
index 31d9e57..08c1b34 100644
--- a/pylint_odoo/test_repo/broken_module/model_view_odoo2.xml
+++ b/pylint_odoo/test_repo/broken_module/model_view_odoo2.xml
@@ -104,6 +104,28 @@
                 </form>
             </field>
         </record>
+        <!-- double duplicate record field "name" in *2M field-->
+        <record id="view_model_form6" model="ir.ui.view">
+            <field name="name">view.model.form</field>
+            <field name="model">test.model</field>
+            <field name="arch" type="xml">
+                <form string="Test model6">
+                    <field name="picking_ids">
+                        <tree>
+                            <field name="name"/>
+                            <field name="name"/>
+                        </tree>
+                    </field>
+                    <field name="value_ids">
+                        <tree>
+                            <field name="name"/>
+                            <field name="name"/>
+                        </tree>
+                    </field>
+                </form>
+            </field>
+        </record>
+
 
     </data>
 </odoo>

Here we should have 2 new messages emitted (increase the expected checkers)

-  'duplicate-xml-fields': 6,
+  'duplicate-xml-fields': 8,

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@hugho-ad
FYI I ran the test and duplicated-xml-fields was emitted 7 times.
Maybe we need add the parent in the key in order to group all items, I mean:

- all_fields.setdefault(field_xml, []).append(field)
+ all_fields.setdefault((field_xml, field.getparent()), []).append(field)

And process even this multi key in all other part of code where is used.

@lasley
Copy link
Contributor

lasley commented Dec 23, 2016

cc @YannickB - this will fix the duplicate xml ID lint in Clouder 😄

@hugho-ad
Copy link

@moylop260 increased the expected checkers, and travis is green
please give your feadback

@hugho-ad
Copy link

@moylop260 please give your feadback here

Regards

parents.setdefault(
parent, {}).setdefault((field_xml, parent), []).append(field)
all_fields.setdefault((field_xml, parent), []).append(field)
return parents, all_fields
Copy link
Collaborator Author

@moylop260 moylop260 Dec 26, 2016

Choose a reason for hiding this comment

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

You don't need 2 dictionaries to detect duplicated.
I mean, you could use just 1 dictionary since that you have the complex key:

  • field_xml <- str
  • parent <- node object (this is different although name string of parent is equal)

And the appended values are fields
Then you could detect them with
duplicated = [(field_xml, nodes) for (field_xml, parent), nodes in all_fields.items() if len(nodes) >= 2)

@hugho-ad hugho-ad force-pushed the master-oca-xml-false-dev-hugho-ad branch from f5cd958 to ccf20dd Compare December 26, 2016 22:42
@hugho-ad
Copy link

@moylop260 comments Done! thks!

Copy link
Collaborator Author

@moylop260 moylop260 left a comment

Choose a reason for hiding this comment

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

Lgtm

@moylop260
Copy link
Collaborator Author

Feedback is welcome team

@moylop260
Copy link
Collaborator Author

ping

Copy link
Contributor

@lasley lasley left a comment

Choose a reason for hiding this comment

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

Woot thanks @moylop260

@yaniaular
Copy link
Member

👍

@pedrobaeza pedrobaeza merged commit ab3e078 into OCA:master Dec 31, 2016
@moylop260 moylop260 deleted the master-oca-xml-false-dev-hugho-ad branch January 26, 2017 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants