Odoo Help


How to copy value of a "company_dependent" field (Property field in Odoo 7 and before) from one company to another?

Tanveer Singh
on 4/4/16, 6:20 AM 1,327 views

I have a setup with multiple companies. (lets call them A, B, C)

There are some property fields (called company_dependent field from 8.0 onwards).

How to copy the value of a property field value from one company to another company.

Suppose for many2many field "worker" if a user (with company currently set to 'A') changes the value and selects a particular worker, I need a way to set similar value for the field "worker" for companies B & C also.

Is there a way to just copy of the value of the field and somehow change the 'company' it is associated with or do I have to edit the 'ir.property' Object and create the property records manually to achieve the result I need above.


Try this:

// property_name -> name of the property to copy
// model -> model that contains the property
// ids -> ids of the objects from "model" to copy the property values
// source_company_id -> source company
// target_company_id -> target company


def copy_multi_property(self, property_name, model, ids, source_company_id, target_company_id):
  property = self.env['ir.property']
  source_property = property.with_context(force_company=source_company_id)
  target_property = property.with_context(force_company=target_company_id)
  values = source_property.get_multi(property_name, model, ids)
  target_property.set_multi(property_name, model, values)

Ideally synchronized but just copy once will work for us for the time being...

Tanveer Singh
on 4/6/16, 1:38 AM

If you extend the ir.property object then use "self" instead "property"

Yurdik Cervantes Mendoza
on 4/6/16, 10:09 AM

For the syncronization think about using "action rules". Look at this: http://bit.ly/1qrvy3L

Yurdik Cervantes Mendoza
on 4/6/16, 10:11 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 4/4/16, 6:20 AM
Seen: 1327 times
Last updated: 4/6/16, 4:58 PM