Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
1 Antworten
5479 Ansichten

I'm trying to add a domain to an Odoo V10 field for a `sale.order.line`. Specifically, I'm trying to ensure that the only Route available to choose are ones with the same name as the product related to the order line. Here is my attempt:

Here is the original out-of-the-box field definition for `route_id` on a `sale.order.line`:

     <field name="route_id" groups="sale_stock.group_route_so_lines">

I modified it to include a domain like so:

    <field name="route_id" groups="sale_stock.group_route_so_lines" domain="[('name', '=', product_id.name)]"/>

However, I seem to be unable to access the related `product.product` via the `product_id` attribute. From what I can tell, the `product_id` is simply returning the id, rather than the actual record itself. Therefore, when I try to chain the call to `name`, it doesn't work.

I get the following error when clicking into the Routes field on the order line:

    Uncaught Error: AttributeError: object has no attribute 'name'

Does anybody know the proper way to add this domain to the view?

Avatar
Verwerfen
Beste Antwort

Create a computed field that return the proper value to compare with using the field argument related with that path or use the computed field argument to calculate the value of the field using a function.

You will also need to setup an onchange for product changes to update the value on the view

Hope this hep you

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
2
Dez. 19
3002
0
Nov. 18
3269
2
Dez. 16
5216
2
Nov. 23
7510
2
Mai 23
7789