コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
18369 ビュー

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

関連投稿 返信 ビュー 活動
1
3月 19
3266
5
5月 25
9403
0
12月 24
1330
1
3月 24
2386
1
6月 23
12414