OCA / odoo-community.org

The Odoo Community Association Website
http://odoo-community.org
Creative Commons Attribution 4.0 International
91 stars 123 forks source link

File naming for views #30

Closed pabloqb closed 5 years ago

pabloqb commented 6 years ago

According to section 1.5 File naming

... in XML files, a suffix should be included with its category. For model named the following files may be created: views/<main_model>_view.xml

In this point the suffix is singular mode view. However the complete tree structure states:

|-- views/
|   |-- <main_model>.xml
|   |-- <inherited_main_model>_views.xml

There is no suffix for main_model.xml and it is in plural for the inherited_mainmodelviews.xml example.

Which would be the correct way?

Best, Pablo.

pedrobaeza commented 6 years ago

Thanks for pointing this out. Most of the documentation is in singular, but I prefer plural, as it expresses more what contains: it can be more than one view inside the XML file.

@OCA/board what do you think about this?

max3903 commented 6 years ago

I don't see the point of repeating views in <inherited_main_model>_views.xml. We already know it is a view as it is in the views directory.

I would make a change to have:

|-- views/
|   |-- <main_model>.xml
|   |-- <inherited_main_model>.xml
pedrobaeza commented 6 years ago

@max3903 this has been discussed other times, and it's because if you perform a file name search, you want to know which can of data it is: demo, data, views, etc.

max3903 commented 6 years ago

ok, then

|-- views/
|   |-- <main_model>_view.xml
|   |-- <inherited_main_model>_view.xml
pedrobaeza commented 6 years ago

So, you prefer in singular? Have you seen my argument about the plural?

max3903 commented 6 years ago

As you said, the idea is to know the kind of data, not if there is one or more record.

pedrobaeza commented 6 years ago

OK, let's be inline with module naming in singular. Any other opinion?

Tardo commented 6 years ago

I prefer use "views" because normally a "view .xml" defines multiple views.. The 'basics' are "form" and "tree" views... Perhaps can use "view" for new view definition (google maps view, calendar view, etc..)

Filter "_views.xml" to know files that implement or inherit (if have the inhertied_ prefix) a Odoo base view type Filter "_view.xml" to know files that implement a new view type

I have other questions about Code Guidelines... perhaps best open other issue for this questions?

pedrobaeza commented 6 years ago

@Tardo about this topic, it's better to keep only one way of naming things (plural or singular), because if not, it's more difficult to know which to use, and would force also to rename if we change conditions of the files, etc.

About the other thing, better to open a new issue and to not mix things :wink:

Tardo commented 6 years ago

@pedrobaeza ok, it makes sense what you say. Odoo uses "views" in their guidelines... https://www.odoo.com/documentation/12.0/reference/guidelines.html#file-naming

pedrobaeza commented 6 years ago

If Odoo uses plural then I think we should stick to that. @max3903 what do you think?

max3903 commented 6 years ago

Ok

El vie., 9 de nov. de 2018 10:06, Pedro M. Baeza notifications@github.com escribió:

If Odoo uses plural then I think we should stick to that. @max3903 https://github.com/max3903 what do you think?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/OCA/odoo-community.org/issues/30#issuecomment-437407028, or mute the thread https://github.com/notifications/unsubscribe-auth/AA5XsCwXBlqIwvKXxxcnX-YNkQToK3Pbks5utaf8gaJpZM4YREoH .

sbidoul commented 6 years ago

Yes, alignement with Odoo guidelines is a good thing in general.

pabloqb commented 5 years ago

Thank you for the feedbacks and indications.

Best, Pablo.