Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
6057 มุมมอง

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

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ต.ค. 20
2982
1
ต.ค. 20
4389
0
พ.ค. 22
2637
0
ก.ค. 24
1978
1
ก.ย. 21
7049