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

I can't figure out what's wrong with my related Many2one field in the ORM API.

If I do the same with Boolean or Float fields it works perfect, but with the Many2one field I get a key error when I open the form with this fields. Without opening a form no error occurs.

Code that works:

account_type = fields.Selection(
'Account Type', related='template_id.account_type',
readonly=True)
external_db = fields.Boolean(
     'External DB', related='template_id.external_db',
     readonly=True)

Code that doesn't work:

type_prefix = fields.Many2one(
'Account Type Prefix', related='template_id.type_prefix',
readonly=True)
currency_base = fields.Many2one(
'Currency', related='template_id.currency_id',
readonly=True)

 

A bit special is that the the related model is in OSV instead:

'type_prefix': fields.many2one(
'exchange.account.type', 'Account Number Prefix/Type', required=False, size=2,
help="Prefix for Number of the Accounts"),
'currency_id'
: fields.many2one(
'res.currency', 'Currency', required=True),

الصورة الرمزية
إهمال
أفضل إجابة

Hello, 
You are missing model name in defination of m2o field, try this :

type_prefix = fields.Many2one('exchange.account.type',
'Account Type Prefix', related='template_id.type_prefix',
readonly=True)
currency_base = fields.Many2one('res.currency'
'Currency', related='template_id.currency_id',
readonly=True)

الصورة الرمزية
إهمال
الكاتب

Thanks a lot this are the missing information.

you are welcome, if that works for you, you should mark as correct answer :)

المنشورات ذات الصلة الردود أدوات العرض النشاط
6
نوفمبر 19
17531
0
سبتمبر 19
98
1
يوليو 17
3624
4
أغسطس 16
7395
1
مايو 16
4392