I'm trying to understand the Odoo source code. It is my current understanding that the purpose of an ir.ui.view record is to be the target of an ir.actions.act_window action, which in turn might be the target of a menu item.
However, in the Odoo source I've noticed an ir.ui.view record with an full XML ID of "sale.view_order_line_tree" that appears to be "orphaned". I would have thought nothing of it if it weren't for the fact that I also found a Studio customization that inherits it. So what's confusing me is how a user was even able to get to the view in order to customize it if there was no associated action or menu item, and how doing so benefited them in any way.
Here is a link to the view in the Odoo source: JUST KIDDING—thanks to the karma system I can't post a link. Instead, here is a path: /addons/sale/views/sale_order_line_views.xml.
My question can be essentially boiled down to this: Where is this view being used (actually seen, not simply inherited as the base for another view such as a Studio view), if anywhere, and how can I find out in the future where views like this are being used?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Bogføring
- Lager
- PoS
- Project
- MRP
Dette spørgsmål er blevet anmeldt
The "sale" prefix of the XML / External ID means it is defined in the module with that same name.
Views additionally serve to define what happens when a View is shown inside another View, which is usually the most common reason they won't be linked to a Window Action. The most common pattern is the View of MANY records in a one2many relationship - such as between a Sales Order and a series of Sales Order Lines. There is no menu by default for Sales Order Lines but they still need a View to define how the are displayed.
Grep the source code to see that this View is
- inherited by the sale_subscription module.
- inherited by the sale_stock module.
When rendering, Odoo looks for one or more Views and based on the sequence/priority makes adjustments. Learn more about how Views can be requested and how matching works at https://www.odoo.com/documentation/16.0/developer/reference/backend/views.html#view-matching
I can post an answer but I can't comment; so I'm using this "answer" to ask for additional clarification on the other answer above, because it doesn't completely answer my question. I understand the purpose of the prefix in the XML ID. The answer also is helpful in clarifying some of the view matching behavior of Odoo.
However in the case of a sale order line, for example, I can't find anywhere in Odoo where it appears that the view I mentioned is being used. On the typical sale order form "sale.view_order_form", the views for the sale order lines that appear in the first "notebook page" are all declared inline, so the view "sale.view_order_line_tree" I mentioned in the question is not being used. This is also evident from the fact that in my case the "sale.view_order_line_tree" view is extended via Odoo Studio, yet none of these customization are visible on the sale order form.
So then, how do I find out where it is being used? Perhaps you could look at it like this: If I were to delete the view, I'm sure something would break—how could I identify what would break short of literally going through Odoo and clicking every button?
This is part of the exercise of looking at source code and being able to identify what each piece is used for. In my case, I'm wanting to get rid of some Odoo studio customizations, but before doing so I want to look at them in context to understand their purpose so I can make a correct decision on what to do with them. But in this case I can't figure out how to actually identify where a user would go to see the view.
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Tilmeld dig