on_change in override view field in openerp not working - openerp-7

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>

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>

How to hide discount field in Invoice form? Odoo

I have try to hide discount field in invoice form by xpath. However it doesn't work.
The following is my code :
<odoo>
<data>
<record model="ir.ui.view" id="hidden_discount">
<field name="name">account.invoice.hidden.discount</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<xpath expr="//field[#name='discount']" position="attributes">
<attribute name="invisible">True</attribute>
</xpath>
</field>
</record>
</data>
</odoo>
Do you have any solution or suggestion?
There is no direct form view design for One2many field. So we need to upgrade account.invoice.line form view directly.
Try with following code.
<record model="ir.ui.view" id="hidden_discount">
<field name="name">account.invoice.line.hidden.discount</field>
<field name="model">account.invoice.line</field>
<field name="inherit_id" ref="account.view_invoice_line_form"/>
<field name="arch" type="xml">
<field name="discount" position="attributes">
<attribute name="invisible">1</attribute>
</field>
</field>
</record>

inheriting the inherit view in xml

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>

Group by field name

I want to do Group by by City but this possibility doesn't shows up. where is my mistake? there is field city in python file and it's showing up in tree view but not really in Group by
<openerp>
<data>
<record id="vpicktree" model="ir.ui.view">
<field name="name">Picking tree city</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.vpicktree"/>
<field name="arch" type="xml">
<field name="location_dest_id" position="after">
<field name="city"/>
</field>
</field>
</record>
<record model="ir.ui.view" id="stock_picking_filter_city_search">
<field name="name">stock.picking.tree.filter_search</field>
<field name="model">stock.picking</field>
<field name="arch" type="xml">
<search string="City">
<filter name="city" string="City" context="{'group_by':'city'}"/>
</search>
</field>
</record>
<record id="action_picking_tree_city" model="ir.actions.act_window">
<field name="name">City</field>
<field name="res_model">stock.picking</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">tree,kanban,calendar</field>
<field name="domain"></field>
<field name="context">{ 'group_by':'city' }</field>
<field name="search_view_id" ref="stock.view_picking_internal_search"/>
</record>
</data>
</openerp>
The group by must be in search view not on the action setion as you did, so you have to edit your search view:
<record model="ir.ui.view" id="stock_picking_filter_city_search">
<field name="name">stock.picking.tree.filter_search</field>
<field name="model">stock.picking</field>
<field name="arch" type="xml">
<search string="City">
<filter name="city" string="City" context="{'group_by':'city'}"/>
<group expand="0" string="Grouper par">
<filter string="City" icon="terp-personal" domain="[]" context="{'group_by':'city'}"/>
</group>
</search>
</field>
</record>

readonly in invoice lines based on a value in line

I have a field 'uneditable' in 'account.invoice.line'.
I want to disable editing the line record if uneditable is true but creating enw line should be allowed.
my view code is as follows
<record model="ir.ui.view" id="invoice_supplier_form_ext">
<field name="name">account.invoice.supplier.form</field>
<field name="model">account.invoice</field>
<field name='inherit_id' ref='account.invoice_supplier_form'/>
<field name="type">form</field>
<field name="arch" type="xml">
<data>
<field name="product_id" position="before">
<field name="uneditable" invisible="1"/>
</field>
<field name="quantity" position="attributes">
<attribute name="attrs">{'readonly': [('uneditable','=', True)]}</attribute>
</field>
</data>
</field>
</record>
Please suggest me what i am doing wrong. I am getting error with this code in view and does not make the line readonly.
Actually your view is wrong. You have defined the fields 'quantity' and 'uneditable' in account.invoice.line and you are adding then in the invoice view. Please check the invoice_supplier_form view and add the fields correctly in the view.
<record model="ir.ui.view" id="invoice_line_form_ext">
<field name="name">account.invoice.line.form</field>
<field name="model">account.invoice.line</field>
<field name='inherit_id' ref='account.view_invoice_line_form'/>
<field name="type">form</field>
<field name="arch" type="xml">
<data>
<field name="product_id" position="before">
<field name="uneditable" invisible="1"/>
</field>
<field name="quantity" position="attributes">
<attribute name="attrs">{'readonly': [('uneditable','=', True)]}</attribute>
</field>
</data>
</field>
</record>