This question has been flagged
2 Replies
7345 Views

If I select "ACME" as the Vendor, I only want products to be shown if I have defined ACME as a Vendor on the product.

Avatar
Discard
Best Answer

You need to modify the domain on the product_id field.

Code:

<field name="product_id" position="attributes">
<attribute name="domain">[('seller_ids.name','=',parent.partner_id),
('purchase_ok', '=', True), '|',
('company_id', '=', False),
('company_id', '=', parent.company_id)]
</attribute>
</field>


This gives you this user experience:

Avatar
Discard

Nice idea !!!. But seems this will raise error if multiple vendors added.

~ Shameem Babu

There is no problem with having as many Vendors as you need for a product.

@Ray, tried this on v15EE no luck, also tried an xpath to select the field ... how can this be debugged? no msg's in the log.

Go back and check your work. I just tried this in v15EE and it worked fine. My guess is you didn't set the View Inheritance Mode.

Have finally had some time to look at this again ... managed to get this to work but only when I switch off Settings->Purchase->Variant Grid Entry. Switching Variant Grid Entry on seems to add some code and additional inheritance on the order form which causes a conflict and/or override. Looks like I would have to inherit a different view??

When Variant Grid Entry is turned on the product_id field is hidden and replace with product_template_id

<data><xpath expr="//tree/field[@name='product_id']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//tree/field[@name='product_id']" position="after">
<field name="product_template_id" string="Product" attrs="{ 'readonly': [('state', 'in', ('purchase', 'to approve','done', 'cancel'))], 'required': [('display_type', '=', False)], }" options="{'no_open': True}" context="{'partner_id': parent.partner_id}" widget="matrix_configurator"/>
<field name="product_template_attribute_value_ids" invisible="1"/>
<field name="product_no_variant_attribute_value_ids" invisible="1"/>
<field name="is_configurable_product" invisible="1"/>
</xpath>
<field name="partner_id" position="after">
<field name="grid" invisible="1"/>
<field name="grid_product_tmpl_id" invisible="1"/>
<field name="grid_update" invisible="1"/>
</field>
<xpath expr="//group[@name='other_info']" position="inside">
<field name="report_grids" groups="base.group_no_one"/>
</xpath>
</data>

What would be the correct action, inherit the inherited form and add a domain on product_template_id? Will this change be reflected in further inherited purchase.order.form views down stream?

What is / how is the resultant view determined (order?) when there are multiple inheritances and can there be sub-inheritances and what is processing order/result?

Also, is it possible to have conditional processing in an inherited view? Would the purchase.order.form contain the result of all previous inheritance processing and I could test weather product_id is hidden or not, if not hidden apply domain to product_id and if hidden apply to product_template_id?

Would it be possible to modify this filter so that also product with no associated vendors could be picked on the RFQ? For example if no vendor is selected the list of products would not be filtered and full list of products would be shown?

Our users would like to have the filtered list 99% of the time, but would need to be able to pick also products with no vendors associated in some special cases. I'm trying to figure out a way to do this.

Thank you Sven for pointing me in the right direction and valuable links. I think I managed to achieve what we were looking for, just have to verify the result tomorrow. Much appreciated!

Ok, so I got this solved, but our dev-server got overwriten along with my modifications. I had some notes, but it seems that I just can't get this to work again.

I had the following code on my notes. When I try to run this I get the following error "ValueError: Invalid leaf (True, '=', 744)". I guess there is something wrong with my syntax, but I just can't figure out what. Any thoughts?

<field name="product_id" position="attributes">
<attribute name="domain">['|', '&amp;', (True, '=',parent.partner_id),
('seller_ids.name','=',parent.partner_id),
('purchase_ok', '=', True), '|',
('company_id', '=', False),
('company_id', '=',parent.company_id),
'&amp;', (False, '=', parent.partner_id),
('purchase_ok', '=', True), '|',
('company_id', '=', False),
('company_id', '=', parent.company_id)]
</attribute>
</field>

Best Answer

If you are using Settings->Purchase->Products->Variant Grid Entry as an option then you need to apply this change to product_template_id field and inherit from the  purchase_product_matrix.purchase_order_form_matrix view.

Avatar
Discard