Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
5678 Widoki

I want to ask users to select a Product Category on every Sales Quotation and have Odoo restrict the products that can be added to only those in the selected category.

How can I do this?

Awatar
Odrzuć
Najlepsza odpowiedź

For version 13, this approach might work:

1. Create a new field to link the sale.order model to the product.category model, allowing users a place to store the selected Category for each order:



2. Add this field to the User Interface, together with a domain on the order_line field to restrict products to those in the currently selected category:


<field name="partner_shipping_id" position="after">
<field name="x_product_category"/>
</field>

<xpath expr="//page/field[@name='order_line']/tree/field[@name='product_id']" position="attributes">
<attribute name="domain">[('categ_id','=',parent.x_product_category)]</attribute>
</xpath>


This restricts Users to only the products from the category they select:


Awatar
Odrzuć

Hi Ray - this is useful (as ever), but is it possible to handle a user not selecting a product category?

Also, is it possible to pass the product category when creating a new product? (I tried to add context, but couldn't get it work)

(1) not with this approach (2) you would need to pass context from the sale order line to the product, rather than the order to the product. So this means context would need access to a custom field on the sale order line that stores the current category on that line. "parent." from the perspective of the product is the line, not the order.

Powiązane posty Odpowiedzi Widoki Czynność
15
mar 21
12067
1
lis 22
2172
0
mar 16
3723
3
gru 19
4111
4
paź 15
3837