inheriting the inherit view in xml - odoo

In 'product.template' I need to add two fields for that I written one view in xml file but the problem is 'inherit_id' of 'accounts' is inheriting from 'product.product_template_form_view'.so how should I use inherit_id in my file.
I tried with below code but it was showing error please help me
account.product_view.xml code:
<record id="product_template_form_view" model="ir.ui.view">
<field name="name">product.template.form.inherit</field>
<field name="model">product.template</field>
<field name="priority">5</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<page string="Sales" position="after">
<page string="Accounting" groups="account.group_account_invoice">
<group>
<label for="categ_id" string="Internal Category"/>
<div><field name="categ_id" colspan="3" nolabel="1"/></div>
</group>
<group name="properties">
<group>
<field name="property_account_income" domain="[('type','=','other')]" groups="account.group_account_user"/>
<field name="taxes_id" colspan="2" widget="many2many_tags" required="1"/>
</group>
<group>
<field name="property_account_expense" domain="[('type','=','other')]" groups="account.group_account_user"/>
<field name="supplier_taxes_id" colspan="2" widget="many2many_tags" required="1"/>
</group>
</group>
</page>
</page>
</field>
</record>
mycode:
<record model="ir.ui.view" id="gst_account_view_inherit">
<field name="name">gst_account_view_add_form_inherit</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="account.product_template_form_view"/>
<field name="arch" type="xml">
<data>
<xpath expr="//field/page/page/group/group/field[#name='taxes_id']" position="after">
<field name="cgst_id"/>
</xpath>
</data>
</field>
</record>
I need to add my 'cgst_id' field under 'taxes_id' field.

You don't need to give full path.
Try with these code:
<field name="taxes_id" position="after">
<field name="cgst_id"/>
</field>

Related

Odoo How to add a editable tree view inside a new page?

I want to display the fields as editable in tree view inside a new tab in the sale.order? My code does not make any errors, but shows the fields in form view rather than tree view. How to correct it?
.xml
<record model="ir.ui.view" id="contract_custom">
<field name="name">sale.order.custom.form.inherited</field>
<field name="model">sale.order</field>
<field name="type">tree</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//page[#string='Other Information']" position="after">
<page string="Salesman Commission">
<tree editable="bottom">
<group>
<field name="user_select"/>
<field name="sales_value" on_change="on_change_commission(sales_value,sale_percent)"/>
<field name="sale_percent" on_change="on_change_commission(sales_value,sale_percent)"/>
<field name="sale_commission"/>
</group>
</tree>
</page>
</xpath>
</field>
</record>
Here is a possible solution
<record model="ir.ui.view" id="contract_custom">
<field name="name">sale.order.custom.form.inherited</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//page[#string='Other Information']" position="after">
<page string="Salesman Commission">
<field name="field_name"> <!-- field you want to show as tree -->
<tree editable="bottom">
<field name="user_select"/>
<field name="sales_value" on_change="on_change_commission(sales_value,sale_percent)"/>
<field name="sale_percent" on_change="on_change_commission(sales_value,sale_percent)"/>
<field name="sale_commission"/>
</tree>
</field>
</page>
</xpath>
</field>
</record>

Odoo : make form fields show/hide based on dropdown

My custom module view looks like this
<odoo>
<data>
<record model="ir.ui.view" id="session_form_view">
<field name="name">item.form</field>
<field name="model">inventory.item</field>
<field name="arch" type="xml">
<form string="Items Form">
<sheet>
<group>
<field name="name"/>
<field name="code"/>
<field name="department"/>
<field name="state"/>
</group>
<group>
<field name="measurement" position="attributes">
<attribute name="attrs">{'invisible': [('state', '=', True)]}</attribute>
</field>
</group>
</sheet>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="items_tree">
<field name="name">Item</field>
<field name="res_model">inventory.item</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<!-- <field name="context" eval="{'state':True}" /> -->
</record>
<menuitem id="main_openacademy_menu" name="Inventory"></menuitem>
<menuitem id="openacademy_menu" name="Store" parent="main_openacademy_menu"></menuitem>
<menuitem id="store_items_menu" name="Store items" parent="openacademy_menu" action="items_tree"/>
</data>
</odoo>
I have a simple model
I want to hide/show based on the department drop down. But some how for a lot of cases attrs is not working. I am begginer and using odoo 10.
Thanks

OpenERP - Page referenced in xpath not found in parent view

I have the following code in my xml view file that inherits from another view:
<xpath expr="//notebook/page[#string='Accounting']/group" position="replace"></xpath>
but it gives me the error:
Element "'<xpath expr="//notebook/page[#string='Accounting']/group">'" cannot be located in parent view
although the 'Accounting' tab is in the parent view. What I am doing wrong? Thanks for your help.
Here is the view I inherited from:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="product_template_form_view" model="ir.ui.view">
<field name="name">product.template.form.inherit</field>
<field name="model">product.template</field>
<field name="priority">5</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<page string="Sales" position="after">
<page string="Accounting" groups="account.group_account_invoice">
<group>
<label for="categ_id" string="Internal Category"/>
<div><field name="categ_id" colspan="3" nolabel="1"/></div>
</group>
<group name="properties">
<group>
<field name="property_account_income" domain="[('type','=','other')]" groups="account.group_account_user"/>
<field name="taxes_id" colspan="2" widget="many2many_tags"/>
</group>
<group>
<field name="property_account_expense" domain="[('type','=','other')]" groups="account.group_account_user"/>
<field name="supplier_taxes_id" colspan="2" widget="many2many_tags"/>
</group>
</group>
</page>
</page>
</field>
</record>
<record id="product_template_search_view" model="ir.ui.view">
<field name="name">product.template.search</field>
<field name="model">product.template</field>
<field name="mode">primary</field>
<field name="inherit_id" ref="product.product_template_search_view"/>
<field name="arch" type="xml">
<field name="product_variant_ids" position="after">
<field name="categ_id"/>
</field>
<xpath expr="//group[#string='Group by...']" position="inside">
<filter string='Category' icon="terp-stock_symbol-selection" domain="[]" context="{'group_by' : 'categ_id'}"/>
</xpath>
</field>
</record>
<record id="view_category_property_form" model="ir.ui.view">
<field name="name">product.category.property.form.inherit</field>
<field name="model">product.category</field>
<field name="inherit_id" ref="product.product_category_form_view"/>
<field name="arch" type="xml">
<data>
<xpath expr="//group[#name='parent']" position="inside">
<group name="account_property" string="Account Properties" colspan="2">
<field name="property_account_income_categ" domain="[('type','<>','view'),('type','<>','consolidation')]"/>
<field name="property_account_expense_categ" domain="[('type','<>','view'),('type','<>','consolidation')]"/>
</group>
</xpath>
</data>
</field>
</record>
</data>
</openerp>
and here is the view that inherited previous view and gave me the error:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="product_config_form_view" model="ir.ui.view">
<field name="name">product.config.form.view</field>
<field name="model">product.template</field>
<field name="type">form</field>
<field name="inherit_id" ref="product.product_template_only_form_view" />
<field name="arch" type="xml">
<label for="name" position="replace">
<label for="name" invisible="1"/>
</label>
<field name="name" position="replace">
<div style="font-size:10pt;">
<label for="class_id" string="Item Class" />
</div>
<div style="font-size:10pt;">
<field name="class_id" colspan="3" nolabel="1" on_change="onchange_class_id(class_id)"
/> </div>
<div style="font-size:10pt;">
<label for="name" string="Item Description"/>
</div>
<div style="font-size:10pt;" >
<field name="name" colspan="3" nolabel="1"/>
</div>
</field>
<field name="default_code" position="replace" >
<field name="default_code" string="Item Number" />
</field>
<xpath expr="//notebook/page[#string='Accounting']/group" position="replace">
</xpath>
</field>
</record>
<record id="product_config_tree_view" model="ir.ui.view">
<field name="name">product.config.tree.view</field>
<field name="model">product.class</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Product">
<field name="default_code" string="Class ID" colspan="3" nolabel="1" />
<field name="name" string="Class Description" colspan="3" nolabel="1"/>
</tree>
</field>
</record>
<record id="class_search_view" model="ir.ui.view">
<field name="name">class.search.view</field>
<field name="model">product.class</field>
<field name="arch" type="xml">
<search string="Class">
<field name="name" string="Class Description" filter_domain="['|',('default_code','ilike',self),
('name','ilike',self)]" />
</search>
</field>
</record>
</data>
</openerp>
You start your xpath expression with //notebook.
So your xpath selects all notebook elements, regardless of where they appear in the document.
But I don't see any xml tag that contains notebook.
This expression:
<xpath expr="//page[#string='Accounting']/group" position="replace"></xpath>
selects all the group elements under:
<page string="Accounting" groups="account.group_account_invoice">

on_change in override view field in openerp not working

the parent of action_type field
<group>
<field name="action_type"/>
</group>
this is my code on_change not working while it works without overriding
<record id="hr_custom_action_form" model="ir.ui.view">
<field name="name">hr.infraction.action.wizard.form</field>
<field name="model">hr.infraction.action.wizard</field>
<field name="inherit_id" ref="hr_infraction.hr_infraction_action_wizard_form"/>
<field name="arch" type="xml">
<xpath expr="/form/group/group/field[#name='action_type']">
<field name="action_type" on_change="take_action(context)"/>
</xpath>
<xpath expr="/form/group[2]" position="after">
<group string="Discount Days" attrs="{'invisible': [('action_type','!=','discount_days')]}">
<group>
<field name="penalty_days_value"/>
</group>
<group></group>
</group>
</xpath>
</field>
</record>
try this one,
<field name="action_type" position="attributes">
<attribute name="on_change">take_action(context)</attribute>
</field>

I need to show Tree view instead of Form view after i inherit CRM Module to my Custom Module in Openerp

I had successfully inherited the CRM module into my custom module.I'm able to view the Form view but i need to show Tree view first.When i click Lead button in the main menu i'm able to show the form view (like in img1), but i need to show the tree view(like in img 2)
img 1
img 2
lead_view.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_lead_tree" model="ir.ui.view">
<field name="name">bala.lead</field>
<field name="model">bala.lead</field>
<field name="arch" type="xml">
<tree string="Leads">
<field name="contact_name"/>
<field name="lead_source"/>
<field name="lead_status"/>
</tree>
</field>
</record>
<!-- ========================This is Form layout===============================-->
<record id="crm_case_form_view_leads_extended" model="ir.ui.view">
<field name="name">CRM - Leads Form</field>
<field name="model">bala.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_leads" />
<field name="arch" type="xml">
<field name="email_from" postion="replace"/>
<field name="contact_name" position="replace"/>
<label for="contact_name" position="replace">
<br/>
</label>
<xpath expr="//label[#for='street']" position="before">
<field name="contact_name"/>
</xpath>
<xpath expr="//label[#for='section_id']" position="before">
<field name="lead_source"/>
<field name="lead_status"/>
</xpath>
<field name="function" position="replace"/>
<field name="partner_name" position="replace"/>
<field name="priority" position="replace"/>
<field name="categ_ids" position="replace"/>
<field name="partner_id" position="replace"/>
</field>
</record>
<!-- ===========================Action layout=========================== -->
<record id="new_lead" model="ir.actions.act_window">
<field name="name">Leads</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">bala.lead</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_lead_tree"/>
</record>
<!-- ===========================Menu Settings=========================== -->
<menuitem name ="Lead" id = "menu_lis_lab" />
<menuitem name="Leads" id="sub_lead" parent="menu_lis_lab" />
<menuitem name="Create Lead" id="create_lead" parent="sub_lead" action="new_lead"/>
</data>
</openerp>
then on click of any lead i'm getting img 3 (invalid view)and on click on Create button img 4 is being displyed , but i need to get img1
img 3
img 4
Add tree view to your xml file, and you can add more fields in this according to requirement,
<record id="view_lead_tree" model="ir.ui.view">
<field name="name">bala.lead</field>
<field name="model">bala.lead</field>
<field name="arch" type="xml">
<tree string="Leads">
<field name="contact_name"/>
<field name="lead_source"/>
<field name="lead_status"/>
</tree>
</field>
</record>
update your act_window
<record id="new_lead" model="ir.actions.act_window">
<field name="name">Lead</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">bala.lead</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_lead_tree"/>
</record>
Hope this will help you.