Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
How to copy value of a "company_dependent" field (Property field in Odoo 7 and before) from one company to another?
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.
// 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)
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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 4/4/16, 6:20 AM|
|Seen: 1003 times|
|Last updated: 4/6/16, 4:58 PM|