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

I'm trying to create new many2many field inside Contact model. I have this code inside models.py

# -*- coding: utf-8 -*-

from odoo import models, fields, api

class custom_partner_fields(models.Model):
_inherit = 'res.partner'

company_ids = fields.Many2many(comodel_name='res.company' string='Related user\'s Allowed companies', readonly=True)

But it does not work and no field is created. When I add another test field like this:

class custom_partner_fields(models.Model):
_inherit = 'res.partner'

company_ids = fields.Many2many(comodel_name='res.company' string='Related user\'s Allowed companies', readonly=True)
test = fields.Char(string='Test field')

It isn't created as well. I works only when I comment the "company_ids".

I'm also having trouble with figuring out how to assign values to that field in other way than automatic action. Can I use realted field to update it every time when the source record changes? How do I do this? I couldn't find any examples.

الصورة الرمزية
إهمال

Add the ',' after comodel_name='res company'

الكاتب

Sadly still does not work

الكاتب

After couple more attempts and server restarts the field appeard. But how do I make it related to the field "company_ids" inside Users model.

المنشورات ذات الصلة الردود أدوات العرض النشاط
2
ديسمبر 23
15615
0
أكتوبر 23
33
3
أكتوبر 23
790
1
أكتوبر 23
569
1
أغسطس 23
2947