Automated Actions: set company on contacts (Odoo 13)

Multicompany has changed in Odoo 13. When contacts (e.g. customers) are created the company is set to blank. This means that they are shared across companies.

To change this behaviour and set the company the same way that it was in Odoo 12, we can use an Automated Action:

Python Code:

record['company_id'] = env.company

You might want to only apply this to customers (though that is more difficult in Odoo 13). This can be done using Domain:

The effect of adding domain should be that if you create a customer from the “Customers” menu in the sales app then the company will be set. If you create contacts elsewhere it will not be set.

Handling “individual” contacts

Odoo contacts can be partners (companies) or individuals.

It makes sense to use the current company for partners (companies), whereas individual contacts should be in the same company as the “parent” contact (partner / company):

This only requires one small change.

  • Domain: Related Company (parent_id) is not set

For the individual contact the domain and Python code will be different:

  • Domain: Related Company (parent_id) is set
  • Python Code:
record['company_id'] = record.parent_id.company_id

Obviously you can adapt this to meet your specific requirements.

A similar change has been made for Products, and we can use Automated Actions in a similar way

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s