تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
18384 أدوات العرض

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
مارس 19
3273
5
مايو 25
9417
0
ديسمبر 24
1336
1
مارس 24
2402
1
يونيو 23
12423