Odoo Help

0

How to dynamically update domain filter on selection widget?

By
Iain Duncan
on 1/16/14, 5:13 PM 2,289 views

Hi, I'm not sure if what I'm doing is possible. I have extended the product type to include a relationship to optional prices, we're calling them BundlePriceOptions. The price options each have an fkey to product, so each product has a range of possible price options. I'm trying to alter the sale form so that on the sale order line, if one chooses a product, there is a pulldown with the list of possible price options, and that list should only contain options pertinent to the product currently selected. I thought I could do something like this:

<record id="view_order_form" model="ir.ui.view">
      <field name="name">sale.order.form</field>
      <field name="model">sale.order</field>
      <field name="priority">1</field>
      <field name="inherit_id" ref="sale.view_order_form"/>
      <field name="arch" type="xml">
          <field name="user_id" position="after">
          </field>
          <tree string="Sales Order Lines" position="inside">
            <field 
               name="bundle_price_option" 
               string="Pricing Options"  
               widget="selection"   
               domain="[ ('product_id', '=', product_id) ]" 
               on_change="price_option_change(bundle_price_option, context)"
             />
          </tree>
       </field>
     </record>

But when I do this, I can't out what should go in the right hand side of the domain filter tuple. I'd like it to evaluate dynamically to the id of the currently selected product on the sale order line. It works if I put a static value in there (like an int of a product id), but whatever I put in there seems to give me a traceback of being undefined. If anyone can tell me what I should try or if I'm event approaching this correctly that would be great.

Thanks Iain

0
Ahmed M.Elmubarak
On 10/26/15, 6:21 AM

Hello,

Try to remove the widget="selection" in the field tag ...

Also another option you can override the function product_id_change in the sale_order_line

to add 'domain' to your custom field ...

I hope it'll help,


Regards,

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)

Stats

Asked: 1/16/14, 5:13 PM
Seen: 2289 times
Last updated: 10/26/15, 6:21 AM