This question has been flagged

In recent versions of odoo we have the company_dependent attribute instead of the property definitions....

It seems not to work in One2Many and Many2Many fields.

I see no use of the company_dependent attribute in those kind of fields when I search into the code:

http://bit.ly/1oI7WpB

My question is:

Is that supposed to work ? Or should the code raise an Exception in those cases?

Which alternatives do we have ? Implement that by hand with domains ?

Maybe the ORM could check if the related entity has a company_id field and add the restriction to the domain automatically, also it could add the company_id field to the related model or comodel.


Avatar
Discard
Best Answer

Hi Yurdik

The fields marked as company_dependent are transformed internally into old fields.property that relays on ir.property model to store the values and that one only support this types of fields:

'type' : fields.selection([

('char', 'Char'),

('float', 'Float'),

('boolean', 'Boolean'),

('integer', 'Integer'),

('text', 'Text'),

('binary', 'Binary'),

('many2one', 'Many2One'),

('date', 'Date'),

('datetime', 'DateTime'),

('selection', 'Selection'),

],'Type', required=True, select=1),

As you see there is no support for One2many or Many2many fields. To do it you could use the combination of the a company_id field on the comodel and an ir.rule record that will restrict the values that you could use in the relation fields depending on the users companies. The record rules will restrict the records for all the users except for admin.

Avatar
Discard
Author

Thank you for this confirmation. Anyway I think that should be managed automatically by the ORM or raise an exception "company_dependent attribute not supported for One2Many and Many2Many fields"

Author

I did submit a new issue: https://github.com/odoo/odoo/issues/11647