I have 13 column in my one2many field and I can't reduce cause of requirement. The problem is my many2one column is very less space. When I remove some column , many2one field take perfect column width.But I can't reduce. How can I do that? I try to write css class for my tree view but not working.In image, I can only see Ac text but the really name is Account.
<page string="Yearly Budget">
<field name="budget_yearly_line">
<tree string="Yearly" editable="buttom" class="custom_class">
<field name="account_id"/>
<field name="jan"/>
<field name="feb"/>
<field name="march"/>
<field name="april"/>
<field name="may"/>
<field name="june"/>
<field name="july"/>
<field name="auguest"/>
<field name="sep"/>
<field name="october"/>
<field name="november"/>
<field name="dec"/>
<field name="amount"/>
</tree>
</field>
<group class="oe_subtotal_footer oe_right">
<field name="amount_untaxed"/>
</group>
</page>
Related
I want to hide field from tree view depends on the condition. I tried some techniques, but didn't work for me. Currently I can hide just value not all column. I want to hide whole column.
This is my tree view. And this code just hide the value not column.
<record id="view_tai_approval_tree" model="ir.ui.view">
<field name="name">tai.approval.tree</field>
<field name="model">tai.approval</field>
<field name="arch" type="xml">
<tree create="false">
<field name="tai_reference"/>
<field name="tai_project_name"/>
<field name="responsible_name"/>
<field name="tai_purchase_date"/>
<field name="tai_supplier_name"/>
<field name="state" class="bg-danger" attrs="{'invisible': [('state', '!=', 'unapproved')]}"/>
<field name="state" class="bg-success" attrs="{'invisible': [('state', '!=', 'approved')]}"/>
<field name="state" class="bg-warning" attrs="{'invisible': [('state', '!=', 'pending')]}"/>
</tree>
</field>
</record>
Actually, as you can see in the code, I just want to change the colors depends on the states. So is there any simple solution for this?
Odoo allows you to change the behavior of the text based on the attributes of the corresponding record.
This documentation is for tree views, but what they describe also works for fields.
<record id="view_tai_approval_tree" model="ir.ui.view">
<field name="name">tai.approval.tree</field>
<field name="model">tai.approval</field>
<field name="arch" type="xml">
<tree create="false">
<field name="tai_reference"/>
<field name="tai_project_name"/>
<field name="responsible_name"/>
<field name="tai_purchase_date"/>
<field name="tai_supplier_name"/>
<field name="state"
decoration-danger=="state != 'unapproved'"
decoration-success="state != approved'"
decoration-warning="state != 'pending'"/>
</tree>
</field>
</record>
Many2many field in a tree view, how to show it in two or more columns.
For example in Orders view i want to show journal_id and statement_id of journal from statement_ids in point of sale.
<record id="pos_order_tree" model="ir.ui.view">
<field name="name">order.tree</field><field name="model">pos.order</field><field name="inherit_id" ref="point_of_sale.view_pos_order_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[#name='partner_id']" position="after">
<field name="statement_ids" widget="many2many_tag">
<tree >
<field name="journal_id"/>
<field name="statement_id"/>
</tree>
</field>
</xpath>
</field>
</record>
I have added widget="many2many_tag" so that may be it is not displaying the other two columns.
We can show more then two columns for many2many or one2many field using following example:
<field name="many2many_ids">
<tree>
<field name="field_1"/>
<field name="field_2"/>
<!-- <field name="field_n"> -->
</tree>
<!-- <form>
Design your form view
</form> -->
</field>
Add this to your many2many field:
style="column-count:2;"
I want Create two graph view for one model openerp, I like to define Two menu for each one display a graph view,
exemple one content graph by country the ather by gender
You need to create two graph view in xml.
<record id="country_graph_id" model="ir.ui.view">
<field name="name">country.graph</field>
<field name="model">your.model</field>
<field name="arch" type="xml">
<graph string="By Country" type="bar">
<field name="your fields"/>
<field name="your_field2"/>
</graph>
</field>
</record>
<record id="country_gender_id" model="ir.ui.view">
<field name="name">gender.graph</field>
<field name="model">your.model</field>
<field name="arch" type="xml">
<graph string="By Gender" type="bar">
<field name="your_field3"/>
<field name="your_field4"/>
</graph>
</field>
</record>
after that, you need to create two actions and two menus like,
<record id="action_for_country_graph" model="ir.actions.act_window">
<field name="name">By Country</field>
<field name="res_model">your.model</field>
<field name="view_type">form</field>
<field name="view_mode">graph</field>
<field name="view_id" ref="country_graph_id"/>
</record>
<record id="action_for_gender_graph" model="ir.actions.act_window">
<field name="name">By gender</field>
<field name="res_model">your.model</field>
<field name="view_type">form</field>
<field name="view_mode">graph</field>
<field name="view_id" ref="gender_graph_id"/>
</record>
<menuitem action="action_for_country_graph" id="menu_country_graph_id"
sequence="1" name='Country Graph' parent='parent.menu'/>
<menuitem action="action_for_gender_graph" id="menu_gender_graph_id"
sequence="2" name='Gender Graph' parent='parent.menu'/>
I have a tree view with a many2many field require_weekday:
<record model="ir.ui.view"
id="sale_order_email_collection_form">
<field name="name">sale.order_email.collection.form</field>
<field name="model">sale.order_email.collection</field>
<field name="arch" type="xml">
<form string="Collection">
<group>
<field name="name"/>
</group>
<field name="emails">
<tree string="Lines" editable="bottom">
<field name="required_weekday"/>
</tree>
</field>
</form>
</field>
</record>
When I click the many2many field it's basically unusable with some blue text overlaying the tree view making it impossible to tell what's going on.
Is it possible to make it work decent?
You can use widget="many2many_tags" in xml.
for example :
<field name="fields_name" widget="many2many_tags"/>
You can use widget="one2many" in xml.
This will change many2many form view to one2many as you want.
For Example:
<field name="your_many2many_field" widget="one2many">
<tree string="your string" editable="top/bottom">
<field name="your_fields"/>#Define all your fields for tree view
</tree>
</field?
I want to show the product category in the sale.order.line.tree view of a sales order with the following code which I wrote. It shows the category button under the group by button but on clicking it, I get the following error and I have don't know how to solve the bug:assert groupby_def and groupby_def._classic_write, "Fields in 'groupby' must be regular database-persisted fields (no function or related fields), or function fields with store=True"
AssertionError: Fields in 'groupby' must be regular database-persisted fields (no function or related fields), or function fields with store=True
Here is my code:
from osv import fields, osv<code>
class sales_order_line_category(osv.osv):
_name='sale.order.line'
_inherit='sale.order.line'
_columns={'categ_id': fields.related('product_id', 'categ_id', type='many2one', relation='product.categ_id'),
}
sales_order_line_category()
My view:
`<?xml version="1.0" encoding="utf-8"?>
<record id="view_sale_orderlinecategory" model="ir.ui.view">
<field name="name">sale.order.line.categoryinherit</field>
<field name="model">sale.order.line</field>
<field name="type">tree</field>
<field name="inherit_id" ref="sale.view_order_line_tree"/>
<field name="arch" type="xml">
<field name="name" position="after">
<field name="categ_id" string="Category"/>
</field>
</field>
</record>
<record id="view_sale_orderlinecategory2" model="ir.ui.view">
<field name="name">sale.order.line.categoryinherit2</field>
<field name="model">sale.order.line</field>
<field name="type">search</field>
<field name="inherit_id" ref="sale.view_sales_order_uninvoiced_line_filter"/>
<field name="arch" type="xml">
<group expand="0" string="Group By..." >
<filter string="Category of Product" icon="terp-stock_symbol-selection" name="Category" context="{'group_by':'categ_id'}"/>
</group>
</field>
</record>
<record id="view_sale_orderlinecategory3" model="ir.ui.view">
<field name="name">sale.order.line.categoryinherit3</field>
<field name="model">sale.order,line</field>
<field name="type">search</field>
<field name="inherit_id" ref="sale.view_sales_order_uninvoiced_line_filter"/>
<field name="arch" type="xml">
<field name="name" position="before">
<field name="categ_id" string="Category"/>
</field>
</field>
</record>
</data>
`
WOuld you please try with following code replace?
'categ_id': fields.related('product_id', 'categ_id', type='many2one', relation='product.category', store=True),
Check that your field categ_id must be appear in tree view of sale.order.line where you try to do group by categ_id
Hope this help