Odoo14 tag tree can customize 2 rows of headers? - odoo

As the title says, I want to know if the tag tree can be rendered. Can you have this kind of information?
If yes, please show me how to write the code. thank you very much
This is my sample code.
<page name="test_header" string="test header">
<tree string="My Tree">
<field name="field1"/>
<field name="field2"/>
</tree>
</page>

Related

Tree child can only have one of field, button, control, groupby, widget, header tag (not feild) [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 months ago.
Improve this question
Odoo Server Error
Error while validating view near:
<tree>
<feild name="CustomerDetailIds">
</feild>
1. Tree child can only have one of field, button, control, groupby, widget, header tag (not feild)
Code XML:
<record id="view_tailor_detail_form" model="ir.ui.view">
<field name="name">tailor detail form</field>
<field name="model">tailor.data.detail</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<group>
<field name="name"/>
<field name="Phone"/>
</group>
<group>
<field name="table_no"/>
<field name="Catagory"/>
<field name="costumer_detail_id"/>
</group>
</group>
<notebook>
<page string="Customer detail">
<tree>
<feild name="CustomerDetailIds">
</feild>
<feild name="C_ids">
</feild>
<feild name="details">
</feild>
</tree>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
But when I remove the tree tag it works fine but not find any output fields on UI side.
"feild" is incorrect, change it to "field"
We can use tree tag inside a one2many or many2many field.
In your case, you declared tree tag inside page tag. So Odoo can not find a valid field.
So removing the tree tag will work or use it inside one2many or many2many field.
For example:
<field name="one2many_field">
<tree>
<field name="x">
<field name="y">
</tree>
<form>
<group>
<field name="x">
<field name="y">
</group>
</tree>
</field>

Odoo-8 -- How can I add a button next to the "Create" button in the "Human Resources" -> "Employees" Kanban view?

Unfortunately I can't post pictures with a reputation lower than 10. 8-/
In a inherited view I want to add a button beside the red "Create" Button in the employees Kanban view. You can reach it over the menus "Human Resources"->"Employees".
I've searched for that button in the "hr_view.xml" file but couldn't find it so I assume that it isn't part of the view but it reacts on switching through the views (kanban to list to form view) so there must be a relation anywhere!?
But where is this relation defined?
Now I tried the following code out to add a simple action button which I wanted to place in the (new) "header" of the view:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_kanban_hr_employees_inherited" model="ir.ui.view">
<field name="name">HR - Employees Kanban extension</field>
<field name="model">hr.employee</field>
<field name="inherit_id" ref="hr.hr_kanban_view_employees" />
<field name="arch" type="xml">
<field name="name" position="before">
<header>
<button string="Calculate Employee Timeaccounts" name="button_calc_employee_timeaccounts" type="object"/>
</header>
</field>
</field>
</record>
</data>
</openerp>
The result is that every kanban vignette now has that (small) button with no text in it.
What I wanted to achieve was to only add one button at th top of the page and didn't want to add a button to every single kanban vignette.
Does anyone have suggestions for me? Where should I insert the button??
The nicest solution would be right beside the red "Create" button on top. But like I mentioned before I think this isn't part of the inheritable view.
Seeing forward for great solutions and thank you for reading!

What is the use of ir.ui.menu in OpenERP 7.0?

I am new to OpenERP and I wish to know about that what is model="ir.ui.menu" in OpenERP. Like this there are many other models also there.
For eg:
model="ir.ui.view"
model="ir.actions.act_window"
Can any one explain all this?
With the ir.ui.menu model you can create new menu items. You can use the menuitem tag, it is shortcut:
<record id="menu_human_readable_name" model="ir.ui.menu" >
<field name="name">Human readable name</field>
<field name="sequence" eval="10" />
<field name="action" ref="action_name" />
<field name="parent_id" ref="base.menu_custom" />
</record>
And you have a small explanation of the ir.actions.act_window model in the Odoo documentation. You can assign the id of this kind of action in the field action of the ir.ui.menu model
The most common action type, used to present visualisations of a model
through views: a window action defines a set of view types (and
possibly specific views) for a model (and possibly specific record of
the model).
<record id="action_human_readable_name_act_window" model="ir.actions.act_window">
<field name="type">ir.actions.act_window</field>
<field name="name">Human readable name</field>
<field name="res_model">model.name</field>
<field name="view_mode">tree,form</field>
<field name="view_type">form</field>
<field name="target">current</field>
<field name="domain">[]</field>
<field name="context">{}</field>
<field name="search_view_id" ref="ir.ui.view" />
</record>
The ir.ui.view is used for the views where you show the field or tree list
You have more information in the Odoo Documentation:
Views define the way the records of a model are displayed. Each type
of view represents a mode of visualization (a list of records, a graph
of their aggregation, …). Views can either be requested generically
via their type (e.g. a list of partners) or specifically via their id.
For generic requests, the view with the correct type and the lowest
priority will be used (so the lowest-priority view of each type is the
default view for that type).
<record model="ir.ui.view" id="view_id">
<field name="name">view.name</field>
<field name="model">object_name</field>
<field name="priority" eval="16"/>
<field name="arch" type="xml">
<!-- view content: <form>, <tree>, <graph>, ... -->
[...]
<field name="field_name" />
[...]
</field>
</record>
Menus and Actions
Menus are records in the ir.ui.menu table. In order to create a new menu entry, you can directly create a record using the record tag.
<record id="menu_external_id" model="ir.ui.menu">
<field name="name">New Menu</field>
<field name="action" ref="action_external_id"/>
<field name="sequence" eval="<integer value>" />
<field name="parent_id" ref="parent_menu_external_id"/>
</record>
There is a shortcut by using the menuitem tag that you should use preferentially. It offers a flexible way to easily define the menu entry along with icons and other fields.
<menuitem id="menu_external_id"
name="New Menu"
action="action_external_id"
icon="ICON_NAME"
groups="groupname"
sequence="<integer value>"
parent="parent_menu_external_id"
/>
If you remove parent/parent_id from menu/menuitem then it becames top level menu.
Actions
action specifies the identifier of the attached action defined in the action table (ir.actions.act_window). This field is not mandatory : you can define menu elements without associating actions to them.
This is useful when defining custom icons for menu elements that will act as folders. This is how custom icons for “Projects” or “Human Resources” in OpenERP are defined).
The actions define the behavior of the system in response to the actions of the users ; login of a new user, double-click on an invoice, click on the action button, ...
There are different types of simple actions:
Window: Opening of a new window
Report: The printing of a report
- Custom Report: The personalized reports
- RML Report: The XSL:RML reports
Execute: The execution of a method on the server side
Group: Gather some actions in one group
The actions are used for the following events:
User connection.
The user clicks on a menu.
The user clicks on the icon ‘print’ or ‘action’.
<record id="action_external_id" model="ir.actions.act_window">
<field name="name">action.name</field>
<field name="view_id" ref="view_external_id" />
<field name="domain">[('field','operator','value')]</field>
<field name="context">{'key':value}</field>
<field name="res_model">Model Name</field>
<field name="view_type">form|tree</field>
<field name="view_mode">form,tree|tree,form|form|tree</field>
<field name="target">new/current</field>
</record>
I hope you will easily understand my explanation below:
"ir.ui.menu" is a model which is mapped as ir_ui_menu table of database that stores data of menus in Odoo (OpenERP). Every menu in Odoo (OpenERP) is inserted via xml file and stored in database. Also, "ir.ui.view" stores view data (such as form, tree, and search views) and "ir.actions.act_window" stores action data.
Conclusion: Mostly (not all), models inside OpenERP are manifestation of tables inside database.
http://useopenerp.com/v8/model/ir-ui-view#pagetop
https://www.odoo.com/documentation/8.0/reference/actions.html#window-actions-ir-actions-act-window
See the above references for detail.
hope this will help you.

OpenERP - field not showing in a tree view

Here is my XML file. For some reason the field "product_uom" is not showing in view's tree view. Any insights why it is happening and how I can make it show?
<tree string="Components" editable="bottom">
<field name="sequence" widget="handle"/>
<field name="product_id" on_change="onchange_product_id(product_id,
product_qty)"/>
<field name="type"/>
<field name="product_qty"/>
<field name="product_uom" on_change="onchange_uom(product_id,
product_uom)" groups="product.group_uom"/>
<field name="product_rounding"/>
<field name="product_efficiency"/>
<field name="date_start"/>
<field name="date_stop"/>
<field name="attribute_value_ids" widget="many2many_tags" domain="
[('product_ids.product_tmpl_id', '=', parent.product_tmpl_id)]"/>
</tree>
The product_uom field has a groups="product.group_uom" attribute.
This makes it visible only to the users in that Group.
Either remove it from the tree definition, or make sure your user in in that group.
Probably what you need is just to activate the "Allow using different units of measures" feature on Settings / Configuration / Sales, Product Features section. Behind the scenes this activates the group_uom for all users.

OpenERP always displays inherited view instead of original

Original views:
<record id='view_1' model='ir.ui.view'>
<field name="name">view.name</field>
<field name="model">my.object</field>
<field name="priority" eval="17"/>
<field name="type">form</field>
<field name="arch" type="xml">
...
</field>
</record>
inherited view from the original:
<record id='view_2' model='ir.ui.view'>
<field name="name">view.name</field>
<field name="model">my.object</field>
<field name="priority" eval="10"/>
<field name="inherit_id" ref="view_1"/>
<field name="type">form</field>
<field name="arch" type="xml">
...
</field>
</record>
So what happens is OpenERP always displays the inherited view ignoring the priority value. Is this expected behaviour, or there's something else I am missing?
If this is the expected behaviour, then please read further :-)
I have my.second.object with many2one field to my.object, and when I want to create my.object from this field, I want to open a bit different form view of my.object. I am trying to create a different view just for that purpose, but as you see it doesn't work so easily (or does it?).
Any help is appreciated.
Yes it is the expected behavior. The priority of a view only serves to select the main view to use when no specific view was requested. Inherited views are "patch views" that act like children of the view they inherit from, and may never be selected as "main views". They always apply on top of their parent view when that view is displayed.
If you want an alternative view for a certain model you should define a new stand-alone view that does not inherit from any other. If that view is meant to be used only in the context of the view of my.second.object, there are two common tricks to make OpenERP use it:
Define it inline in the form view of my.second.object, as a child of the <field> element. This may not work in all OpenERP clients depending on the version, and works best for declaring inline form views for o2m lines, normally.
Declare it as a stand-alone view with a low priority (e.g. 32) and put a magic context key in the many2one field of the my.second.object view that should use it. The magic key is in the form <view_type>_view_ref, and the value must be the XML ID of the desired view. This should work everywhere.
<!-- Example 1: inline form view -->
<form string="My second object">
<field name="my_object_id">
<form string="My object inline view">
<field name="name"/>
</form>
</field>
</form>
<!-- Example 2: explicitly ask for special view using magic key -->
<form string="My second object">
<field name="my_object_id" context="{'form_view_ref': 'module.my_object_form2'}"/>
</form>
For reference, have a look at this page of the OpenERP documentation that explains most of the options for making and using context-specific views.
NOTE: If you have used form_view_ref and from form view if you have
any button which is opening another form view of some other model then
it will give you error . It will try to open the same form view you
have passed in form_view_ref for another model also.
What "position" you defined in <field name="field_from_original_view">?
<record id='view_2' model='ir.ui.view'>
<field name="name">view.name</field>
<field name="model">my.object</field>
<field name="priority" eval="10"/>
<field name="inherit_id" ref="view_1"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="field_from_original_view" position="after" (or before)>
<field name="inherit1" />
<field name="inherit2" />
<field name="inherit3" />
</field>
</field>
</record>
There may not be a possibility to make an inherited form the standard form of your model so that it will be presented automatically.
BUT If you look at a specific task --> open an inherited form view for a one2many field e.g.; there is. Set the context variable 'form_view_ref' to 'MODULE.VIEW_ID'.
<field name="myOne2ManyField" context="{'form_view_ref': 'myModule.myInheritedView'}/>
Still works with Odoo 9.0.