openerp - How to correct add domain to a field inside a one2many field in Odoo? -


i created model version, add relation product model this:

class product_template(models.model):     _inherit = 'product.template'      versions_ids = fields.many2many('mymodel.version',string='versions')  class sale_order(models.model):     _inherit = 'sale.order'      version_filter = fields.many2one('mymodel.version') 

i add field "version_filter sale.order view, , want filter product search relation, ones being adding not previous ones addded

like this:

<record id="sale_filter_append" model="ir.ui.view">     <field name="name">sale.order.form</field>     <field name="model">sale.order</field>     <field name="inherit_id" ref="sale.view_order_form"/>     <field name="arch" type="xml">         <xpath expr="//field[@name='order_line']" position="before">             <group colspan="4">                 <field name="version_filter"/>             </group>         </xpath>         <xpath expr="//field[@name='product_id']" position="replace">             <field name="product_id"                    context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom, 'company_id': parent.company_id}"                    attrs="{'readonly': ['|', ('qty_invoiced', '&gt;', 0), ('procurement_ids', '!=', [])]}"                    domain="[('version_filter', 'in', versions_ids)]"             />         </xpath>     </field> </record> 

but "product_id" field never replace.

i rather make modal form in "search more" option in many2one fields... if me filter domain order_line product_id search more ok

thanks reading!

problem there xpath. should try following.

if want add domain in sales order line -> product_id in form view , tree view both example given below.

<xpath expr="//notebook/page[@string='order lines']/field[@name='order_line']/form/group[1]/group/field[@name='product_id']" position="attributes">                      <attribute name = "domain">add domain</attribute> </xpath>  <xpath expr="//notebook/page[@string='order lines']/field[@name='order_line']/tree[@string='sales order lines']/field[@name='product_id']" position="replace">     <field name="product_id" context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'uom':product_uom, 'company_id': parent.company_id}"         attrs="{'readonly': ['|', ('qty_invoiced', '&gt;', 0), ('procurement_ids', '!=', [])]}"         domain="[('version_filter', 'in', versions_ids)]" />         </xpath> 

Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -