ProductOpener::CRM - manages integration with the Odoo CRM
ProductOpener::CRM
contains functions to interact with the Odoo CRM
For clarity: - user/org refers to the pro platform side - contact/company refers to the CRM side, where: contact => Odoo partner is an 'individual' company => Odoo partner is a 'company'
- tags => crm.tag - category => res.partner.category
Requirements before enabling CRM sync: - check required_tag_labels and required_category_labels
Attempts to find a contact, and if it doesn't exist, creates it
the user to which a 'contact' in the CRM should be linked
the id of the contact, or undef if an error occur
Set the off_username field of a contact to the user_id
1 if success, undef otherwise
Finds a contact that has the user_id or same email as the given user_ref
the contact id or undef
Creates a new contact in Odoo from a user
the id of the created contact
Get the country id from Odoo given a country tag (en:france, en:germany, ...)
Attempts to find a company, and if it doesn't exist, creates it
the organization to which a 'company' in the CRM should be linked
Helps the strategy to find the company
The id of the contact, or undef if an error occurred
Set the off_org field of a contact to the org_id
1 if success, undef otherwise
Finds the oldest company following this strategy:
1. if the company has the corresponding off_org_id, use this one 2. if the contact_id is defined and the company he belongs to has no off_org_id, use this one 3. if there is a company with the exact same name, use this one
the company if found, undef otherwise
Creates a new company in Odoo from an org
the id of the created company
Add a contact to a company in Odoo
1 if success, undef otherwise
create an opportunity attached to a
The name of the opportunity
The id of the partner to attach the opportunity to. It can be a contact or a company
The email of the salesperson to attach to the opportunity
the id of the created opportunity
Add a user to a company in Odoo. Attempts to find the contact, create it if it doesn't exist, and add it to the company.
side effect: update user_ref with the corresponding CRM contact_id
the contact_id, undef if an error occurred while getting the contact_id
Change the main contact of a company Will also update the main contact of the opportunity associated with the org.
If the user is not linked to a contact in the CRM, it will try to find or create it.
The given organization must have a crm_org_id
id of a member of the organization
1 if success, undef otherwise
Add a category to a partner (contact or company) in Odoo
$label
must match one of the values in @required_category_labels
1 if success, undef otherwise
Update the last import type of a company in Odoo
must match one of the values in CRM.pm @data_source
Returns the URL of the company in the CRM
the URL of the company in the CRM or undef if the company is not linked to the CRM
Calls Odoo's API with the given parameters
the response or undef if an error occurred
Initialize the CRM data from Odoo. It is called by lib/startup_apache.pl startup script
Die if CRM environment variables are set but required data can't be fetched from CRM nor be loaded from cache