How to display an existing tree view inside notebook form view in odoo? - odoo-15

I have a tree view of model X and I want to display it in a form view of model Y
How can I achieve that?

Found the answer here https://stackoverflow.com/a/49748791/15879546
<field name="xxx" context="{'tree_view_ref': 'your_modual.your_tree_view_id'}"/>

Related

How can add condition on tree view and change color according to conditions using odoo?

How can add condition on tree view and change color according to conditions using odoo 10
With colors attribute on the tree node. Example:
<tree colors="red:notes!=False">
Generic:
<tree colors="<color_name>:<condition>">

Can't add items to Many2many in Odoo 12 EE

I defined a Many2many field for ir.attachemnt. The problem is i can' see the Add an item link to add the records.
*.py
attachment_ids = fields.Many2many('ir.attachment', string='Attachments')
*.xml
<notebook>
<page string='Attachments'>
<field name="attachment_ids"/>
</page>
</notebook>
I also tried this:
<field name="attachment_ids" widget="many2many" />
Any idea?
There is only two thing that make Odoo behave like this.
Your view is in edit mode but I think I'm seeing a place holder comments this means it's not the case
Your user is not allowed to create an ir.attachment which is more likely not the case
Your field is readonly.
If not one of this cases these is wired but if you didn't understand what happen you can force that link to appear by using embedded tree with create attribute set to true
<field..... >
<tree create='1'>
....
It'a a bug. If you have more many2many fields in the some class and for one of this you haven't right access rules, all the many2many fields are showed in readonly mode.

Calendar View in X2Many from field

I have a form with a many2manyfield, the field is related to model (say x.y) at which I have defined both kanban and calendar view
I can successfully see both views of model x.y when I open records of this model
But when I look form view of an other model x.z (this model has relation to x.y via my_manay2manyfield), it shows me the kanban view (twice) in its form successfully according to following code, but shows nothing for mode="calendar"
<field name="my_manay2manyfield" mode="kanban"/>
<field name="my_manay2manyfield" mode="calendar"/>
<field name="my_manay2manyfield" mode="kanban"/>

OpenERP. Add image into field dynamically in a tree view

I am using v7 and I want to show in a tree view a field with image icons (like a semaphore) depending of other field values in the same row.
Actually, I get the functionality I want with a function field and put the result as string but I really want it as an image. I don't know if is possible to return HTML from the function so I decided to do that with jQuery.
I implemented the jQuery code using the browser console and works but when I put the jQuery code in the view the "data-field" selector does not selected.
Please, can anyone explain me why or tell me another way to get my objective?
Lists
The root element of list views is tree. The list view's root can have the following attributes:
editable, default_order, colors, fonts, create, edit, delete, on_write, string
See more about ListView
You can achieve this by defining child elements button in list view.
I have added icon in product to show whether product is available / hold / sold based on product's status.
button
icon: icon to use to display the button
Xml code to display icon in listview.
<xpath expr="//notebook/page[#string='Order Lines']/field[#name='order_line']/tree[#string='Sales Order Lines']/field[#name='product_id']" position="before">
<field name="product_status" invisible="1" />
<button icon='Hold' readonly="1" attrs="{'invisible':[('product_status', '!=', 'hold')]}"/>
<button icon='Available' readonly="1" attrs="{'invisible':[('product_status', '!=', 'available')]}"/>
<button icon='sold' readonly="1" attrs="{'invisible':[('product_status', '!=', 'sold')]}"/>
</xpath>
NOTE
Remember base field on which you defined button's visibility must be
present on listview, doesn't matter whether it's visible or not but it
must be there, like product_status in above example.
base field must be store=True.
Why store=True ?
Reason: when you set any function field store=True then it will physically created in database, while you give this field name in
domain the odoo framework add this field directly in WHERE clause,
it will not access through browsable object, so if your field is
store=False then it won't be able to find that field and gives you an error.
icons must be present in web/static/src/img/icons.
if you want to keep icons in your custom module then you have to create the same hierarchy for that in side your module folder create /static/src/img/icons and keep all the icons there.
xpath is used to define at which location you want to add/update fields.
See more about xpath

OpenERP custom module on mobile

I am making a custom module in OpenERP. I have a list(tree) view and a form view. I can view and edit records.
When I take the mobile view of the same module, I can see the main menu and browse to the sub menu, but no list view or form view is visible. All I can see is a blank page. Is my list definition worng?
<?xml version="1.0"?>
<tree string = "Camera">
<field name = "a"/>
<field name = "b"/>
</tree>
I believe that after a menu option is selected, the following menu is a simple list with the name of each record.
It may be that you don't have any record yet.
Or it may be that you don't have a name field on the object model and views. Add that field (make it required) or, alternatively, set the object's _rec_name attribute (example: _rec_name = 'a').
OE Mobile View is read-only mode
It does not have any type of view(like, tree or for, or kanban), It just show the view of record and show you have value. It hos wht name filed valeu on list then if you click on it it open detail view which show thw other detail. and yes try and add the record on your model.
Thank You