Skip to Content
Menu
This question has been flagged

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

Avatar
Discard
Best Answer

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

Avatar
Discard
Related Posts Replies Views Activity
2
Oct 20
1963
1
Oct 20
3338
0
May 22
1191
0
Jul 24
862
1
Sep 21
4938