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.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
Odoo 18.0 has a Catalog button, which already filters all products by the Vendor.
UPDATED for Odoo 16.0, Odoo 17.0
You need to modify the domain on the product_id field:
Code:
<!-- for Odoo 16.0 -->
<field name="product_id" position="attributes">
<attribute name="domain">
[('purchase_ok', '=', True),
('seller_ids.partner_id','=',parent.partner_id),
'|',('company_id', '=', False),('company_id', '=', parent.company_id)]
</attribute>
</field>
<!-- for Odoo 17.0 -->
<field name="product_id" position="attributes">
<attribute name="domain">
[('purchase_ok', '=', True),
('seller_ids.partner_id','=',parent.partner_id),
'|',('company_id', '=', False),('company_id', 'parent_of', parent.company_id)]
</attribute>
</field>
For Odoo 13.0, Odoo 14.0 and Odoo 15.0:
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:
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.
Mikko, this should be possible with conditional domain attributes as listed here https://www.odoo.com/forum/help-1/14-how-to-set-conditional-domain-on-res-partner-based-on-move-type-in-account-move-form-193782 and here https://www.odoo.com/forum/help-1/conditionally-apply-domain-on-a-field-25468
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">['|', '&', (True, '=',parent.partner_id),
('seller_ids.name','=',parent.partner_id),
('purchase_ok', '=', True), '|',
('company_id', '=', False),
('company_id', '=',parent.company_id),
'&', (False, '=', parent.partner_id),
('purchase_ok', '=', True), '|',
('company_id', '=', False),
('company_id', '=', parent.company_id)]
</attribute>
</field>
Hi Ray
In v17 there seems to be some changes in the parent fields. Do you know how to set the domain to get this code to work in v17?
I updated my answer.
The field on the Vendor Pricelist representing the Vendor was renamed from NAME to PARTNER_ID.
Please select JUST the section of XML relevant to your version if using Odoo 16.0, 17.0. (XML for both versions is shown but this customization will only work with one or the other).
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.
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
1
Feb 19
|
2734 | ||
|
2
May 24
|
648 | ||
|
0
Jan 23
|
1019 | ||
|
3
Dec 24
|
2358 | ||
|
1
Jul 24
|
705 |