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

Hi,

I have a field in account.invoice

class AccountInvoiceInherited(models.Model):
_inherit = 'account.invoice'

 
company_selection = fields.Many2one('account.analytic.account', string="Company")

I want to access the value of the field company_selection in another model so i did it using a related field like below.

class AccountMoveInherited(models.Model):
_inherit = "account.move"

rel_account_invoice = fields.Many2one('account.invoice', string='Related Account Invoice')
rel_company_selection = fields.Many2one(related='rel_account_invoice.company_selection')

but when i check the value in rel_company_selection it gives me none i.e., account.analytic.account()

How to access the value of company_selection in account.move model?

Thank you

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

Hi,

you need to mention its Model name.

rel_company_selection = fields.Many2one('account.analytic.account', string="Company", related='rel_account_invoice.company_selection')

Regards,

Silvestar


อวตาร
ละทิ้ง
ผู้เขียน

It still gives me nothing, when i print the rel_company_selection it just gives me account.analytic.account()

ผู้เขียน

Do you think it's happening because the record hasn't yet been written to database and we are trying to access it, hence the empty value?

do you have value for that model?

ผู้เขียน

Value for model? I didn't get you

Related Posts ตอบกลับ มุมมอง กิจกรรม
Why can't i find some models in db? แก้ไขแล้ว
1
มี.ค. 19
3281
5
พ.ค. 25
9439
0
ธ.ค. 24
1350
Import Data From Another Model แก้ไขแล้ว
1
มี.ค. 24
2413
1
มิ.ย. 23
12431