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

I am currently running Odoo v13 Community Edition and I am trying to create new fields.

These fields I am creating are inside the purchase.order.line model. These fields are computed but for me to do that I need to get a field called "currency_rate" from the purchase.order model.

I tried to add this before the function:

@api.depends("purchase.order.currency_rate")

but it did not work.

Then I also tried to get the field by using the following 2 methods

x_unit_price = ... * self.super.currency_rate

and

x_unit_price = ... * super.currency_rate

and both did not work

Does anyone know what can I do to get the field?

PS the currency rate field is different between each Purchase Order

I need help please :)

Thank you in advance

Awatar
Odrzuć
Najlepsza odpowiedź

Hi,

There is a related Many2one field order_id of purchase.order in the model purchase.order.line.So you can get any field of the corresponding purchase order by referring order_id.

If you want to get a field from the purchase.order model in the method which is defined in the purchase.order.line please follow the given steps.

custom_field = self.order_id.custom_field

Regards

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
paź 20
2892
1
paź 20
4293
0
maj 22
2547
0
lip 24
1950
1
wrz 21
6946