Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • coopdevs/comunitats-energetiques/odoo-ce
1 result
Show changes
Commits on Source (44)
Showing
with 225 additions and 202 deletions
# -*- coding: utf-8 -*-
{
"name": "Cooperator Account Banking Mandate",
"version": "14.0.1.0.3",
"version": "14.0.1.0.5",
"license": "AGPL-3",
"summary": """
This module adds mandate selection to cooperator subscription request.""",
......
......@@ -3,9 +3,9 @@
<data>
<record id="subscription_request_form_inherit" model="ir.ui.view">
<field name="name">account_banking_mandate_cooperator.subscription_request.form</field>
<field name="name">cooperator_account_banking_mandate.subscription_request.form</field>
<field name="model">subscription.request</field>
<field name="inherit_id" ref="account_payment_cooperator.subscription_request_form_inherit"/>
<field name="inherit_id" ref="cooperator_account_payment.subscription_request_form_inherit"/>
<field name="priority" eval="8"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='payment_mode_id']" position="after">
......
# -*- coding: utf-8 -*-
{
"name": "Cooperator Account Payment",
"version": "14.0.1.0.1",
"version": "14.0.1.0.2",
"license": "AGPL-3",
"summary": """
This module adds support for payment mode to cooperator.""",
......
......@@ -3,7 +3,7 @@
<data>
<record id="subscription_request_form_inherit" model="ir.ui.view">
<field name="name">account_payment_cooperator.subscription_request.form</field>
<field name="name">cooperator_account_payment.subscription_request.form</field>
<field name="model">subscription.request</field>
<field name="inherit_id" ref="cooperator.subscription_request_view_form"/>
<field name="priority" eval="8"/>
......@@ -14,4 +14,4 @@
</field>
</record>
</data>
</odoo>
\ No newline at end of file
</odoo>
{
'name': "Energy Community",
'version': '14.0.1.1.8',
'version': '14.0.1.1.11',
'depends': [
'account',
'cooperator_account_banking_mandate',
......
......@@ -5,7 +5,3 @@ class MainController(main.RestController):
_root_path = "/api/"
_collection_name = "ce.services"
_default_auth = "api_key"
class CrmLeadController(MainController):
pass
......@@ -2152,6 +2152,13 @@ msgstr ""
msgid "Wordpress DB Admin Username"
msgstr ""
#. module: energy_communities
#: code:addons/energy_communities/models/res_company.py:0
#: model:ir.model.fields,field_description:energy_communities.field_res_company__wordpress_base_url
#, python-format
msgid "Wordpress Base URL (JWT auth)"
msgstr ""
#. module: energy_communities
#: model_terms:ir.ui.view,arch_db:energy_communities.connect_res_config_settings_view_form
msgid "Wordpress DB Credentials"
......@@ -2161,14 +2168,21 @@ msgstr ""
#: code:addons/energy_communities/models/res_config_settings.py:0
#: model:ir.model.fields,field_description:energy_communities.field_res_config_settings__wordpress_db_password
#, python-format
msgid "Wordpress DB Password"
msgid "Wordpress DB Admin Password"
msgstr ""
#. module: energy_communities
#: code:addons/energy_communities/models/res_config_settings.py:0
#: model:ir.model.fields,field_description:energy_communities.field_res_config_settings__wordpress_db_username
#, python-format
msgid "Wordpress DB Username"
msgid "Wordpress DB Admin Username"
msgstr ""
#. module: energy_communities
#: code:addons/energy_communities/models/res_config_settings.py:0
#: model:ir.model.fields,field_description:energy_communities.field_res_config_settings__wordpress_base_url
#, python-format
msgid "Wordpress Base URL (JWT auth)"
msgstr ""
#. module: energy_communities
......
......@@ -2159,6 +2159,13 @@ msgstr ""
msgid "Wordpress DB Admin Username"
msgstr ""
#. module: energy_communities
#: code:addons/energy_communities/models/res_company.py:0
#: model:ir.model.fields,field_description:energy_communities.field_res_company__wordpress_base_url
#, python-format
msgid "Wordpress Base URL (JWT auth)"
msgstr ""
#. module: energy_communities
#: model_terms:ir.ui.view,arch_db:energy_communities.connect_res_config_settings_view_form
msgid "Wordpress DB Credentials"
......@@ -2168,14 +2175,21 @@ msgstr ""
#: code:addons/energy_communities/models/res_config_settings.py:0
#: model:ir.model.fields,field_description:energy_communities.field_res_config_settings__wordpress_db_password
#, python-format
msgid "Wordpress DB Password"
msgid "Wordpress DB Admin Password"
msgstr ""
#. module: energy_communities
#: code:addons/energy_communities/models/res_config_settings.py:0
#: model:ir.model.fields,field_description:energy_communities.field_res_config_settings__wordpress_db_username
#, python-format
msgid "Wordpress DB Username"
msgid "Wordpress DB Admin Username"
msgstr ""
#. module: energy_communities
#: code:addons/energy_communities/models/res_config_settings.py:0
#: model:ir.model.fields,field_description:energy_communities.field_res_config_settings__wordpress_base_url
#, python-format
msgid "Wordpress Base URL (JWT auth)"
msgstr ""
#. module: energy_communities
......
......@@ -2162,6 +2162,13 @@ msgstr ""
msgid "Wordpress DB Admin Username"
msgstr ""
#. module: energy_communities
#: code:addons/energy_communities/models/res_company.py:0
#: model:ir.model.fields,field_description:energy_communities.field_res_company__wordpress_base_url
#, python-format
msgid "Wordpress Base URL (JWT auth)"
msgstr ""
#. module: energy_communities
#: model_terms:ir.ui.view,arch_db:energy_communities.connect_res_config_settings_view_form
msgid "Wordpress DB Credentials"
......@@ -2171,14 +2178,21 @@ msgstr ""
#: code:addons/energy_communities/models/res_config_settings.py:0
#: model:ir.model.fields,field_description:energy_communities.field_res_config_settings__wordpress_db_password
#, python-format
msgid "Wordpress DB Password"
msgid "Wordpress DB Admin Password"
msgstr ""
#. module: energy_communities
#: code:addons/energy_communities/models/res_config_settings.py:0
#: model:ir.model.fields,field_description:energy_communities.field_res_config_settings__wordpress_db_username
#, python-format
msgid "Wordpress DB Username"
msgid "Wordpress DB Admin Username"
msgstr ""
#. module: energy_communities
#: code:addons/energy_communities/models/res_config_settings.py:0
#: model:ir.model.fields,field_description:energy_communities.field_res_config_settings__wordpress_base_url
#, python-format
msgid "Wordpress Base URL (JWT auth)"
msgstr ""
#. module: energy_communities
......
from odoo import SUPERUSER_ID, api
import logging
logger = logging.getLogger(__name__)
def migrate(cr, version):
logger.info("Running post migration {}".format(version))
env = api.Environment(cr, SUPERUSER_ID, {})
internal_user_role = env['res.users.role'].search([
('code', '=', 'role_internal_user')
])
role_lines = env['res.users.role.line'].search([
("role_id.code", "in", ['role_ce_member', 'role_ce_admin', 'role_platform_admin'])
])
logger.info("Founded this role lines: {}".format(role_lines))
for line in role_lines:
logger.info("Processing line {line_id} from user {user}".format(
line_id=line.id, user=line.user_id.login
))
is_internal_user = self.env['res.users.role.line'].search([
("user_id.id", "=", line.user_id.id),
("role_id.id", "=", internal_user_role.id),
])
if not is_internal_user:
self.env['res.users.role.line'].sudo().create({
"user_id": line.user_id.id,
"active": line.active,
"role_id": internal_user_role.id,
})
elif is_internal_user and is_internal_user.active == False and line.active == True:
is_internal_user.write({
"active": line.active
})
......@@ -242,7 +242,8 @@ class CrmLead(models.Model):
_("Unable to create the KeyCloack entities from Lead: {}, because it is not yet related to any Community company").format(lead.name))
lead.community_company_id._create_keycloak_realm()
def post_template_to_chatter(self, template_id):
self.message_post_with_template(template_id)
def _create_community_initial_users(self):
for lead in self:
......
......@@ -73,14 +73,17 @@ class LandingPage(models.Model):
instance_company = self.env['res.company'].search(
[('hierarchy_level', '=', 'instance')])
if instance_company:
baseurl = instance_company.wordpress_base_url
username = instance_company.wordpress_db_username
password = instance_company.wordpress_db_password
auth = Authenticate(username, password).authenticate()
auth = Authenticate(baseurl, username, password).authenticate()
token = "Bearer %s" % auth["token"]
landing_page_data = record.to_dict()
landing_page_data["status"] = new_status
landing_page_resource = LandingPageResource(
record.wp_landing_page_id)
landing_page_resource.update(token, landing_page_data)
LandingPageResource(
token,
baseurl,
record.wp_landing_page_id
).update(landing_page_data)
record.write({"status": new_status})
......@@ -7,7 +7,7 @@ import re
import os
from odoo.exceptions import UserError
from ..pywordpress_client.resources.authenticate import Authenticate
from ..pywordpress_client.resources.landing_page import LandingPage
from ..pywordpress_client.resources.landing_page import LandingPage as LandingPageResource
_HIERARCHY_LEVEL_VALUES = [
('instance', _('Instance')),
......@@ -69,6 +69,9 @@ class ResCompany(models.Model):
wordpress_db_password = fields.Char(
string=_("Wordpress DB Admin Password")
)
wordpress_base_url = fields.Char(
string=_("Wordpress Base URL (JWT auth)")
)
@api.constrains('hierarchy_level', 'parent_id')
def _check_hierarchy_level(self):
......@@ -183,13 +186,14 @@ class ResCompany(models.Model):
{
"id": tag.id,
"name": tag.name,
"ext_id": tag.tag_ext_id
}
)
return res
def get_public_web_landing_url(self):
# TODO Get from community_maps
return "https://somcomunitats.coop/ce/comunitat-energetica-prova/"
# TODO: Get from landing page or company, for now we don't need
return ""
def get_keycloak_odoo_login_url(self):
login_provider_id = self.env.ref(
......@@ -198,7 +202,7 @@ class ResCompany(models.Model):
def create_landing(self):
landing_page = self.env["landing.page"]
vals = {"company_id": self.id, "name": self.name, "status": "publish"}
vals = {"company_id": self.id, "name": self.name, "status": "draft"}
new_landing = landing_page.create(vals)
context = {
"__last_update": {},
......@@ -221,13 +225,16 @@ class ResCompany(models.Model):
instance_company = self.env['res.company'].search(
[('hierarchy_level', '=', 'instance')])
if instance_company:
baseurl = instance_company.wordpress_base_url
username = instance_company.wordpress_db_username
password = instance_company.wordpress_db_password
auth = Authenticate(username, password).authenticate()
auth = Authenticate(baseurl, username, password).authenticate()
token = "Bearer %s" % auth["token"]
landing_page_data = self.landing_page_id.to_dict()
landing_page = LandingPage.create(token, landing_page_data)
self.landing_page_id.write({"wp_landing_page_id": landing_page.id})
landing_page = LandingPageResource(
token, baseurl).create(landing_page_data)
self.landing_page_id.write(
{"wp_landing_page_id": landing_page['id']})
def get_landing_page_form(self):
return {
......
......@@ -5,20 +5,17 @@ from odoo import fields, models, _
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
wordpress_base_url = fields.Char(
related='company_id.wordpress_base_url',
string=_("Wordpress Base URL (JWT auth)"),
readonly=False
)
''' WORDPRESS DB CREDENTIALS '''
wordpress_db_username = fields.Char(
related='company_id.wordpress_db_username',
string=_("Wordpress DB Username"),
string=_("Wordpress DB Admin Username"),
readonly=False)
wordpress_db_password = fields.Char(
related='company_id.wordpress_db_password',
string=_("Wordpress DB Password"),
string=_("Wordpress DB Admin Password"),
readonly=False)
def get_wordpress_db_credentials(company):
return {
"data": {
"username": company.wordpress_db_username,
"password": company.wordpress_db_password,
}
}
\ No newline at end of file
......@@ -13,8 +13,8 @@ class Client(object):
This class manages the HTTP requests and this class only can send a request.
"""
def __init__(self):
self.baseurl = "https://web-testing.somcomunitats.coop/wp-json"
def __init__(self, baseurl):
self.baseurl = baseurl
def post(self, route, token=None, body=None):
"""Send a POST HTTP requests
......@@ -78,7 +78,8 @@ class Client(object):
if headers.get("Content-Type") == "application/json":
payload = json.dumps(payload)
logger.info("{verb} {url} \n {body}".format(verb=verb, url=url, body=payload))
logger.info("{verb} {url} \n {body}".format(
verb=verb, url=url, body=payload))
try:
response = requests.request(
......
......@@ -5,16 +5,16 @@ class Authenticate:
_name = "authenticate"
_url_path = "/jwt-auth/v1/token"
def __init__(self, username, password, token=None, **kwargs):
def __init__(self, baseurl, username, password):
self.baseurl = baseurl
self.username = username
self.password = password
self.token = token
def authenticate(self):
"""
Get auth token
"""
response_data = Client().post(
response_data = Client(self.baseurl).post(
"{}".format(self._url_path),
body={"username": self.username, "password": self.password},
)
......
......@@ -5,29 +5,32 @@ class LandingPage:
_name = "landing_page"
_url_path = "/wp/v2/rest-ce-landing"
def __init__(self, id, **kwargs):
def __init__(self, token, baseurl, id=False):
self.baseurl = baseurl
self.token = token
self.id = id
@classmethod
def create(cls, token, body):
def create(self, body):
"""
Creates a Landing Page instance.
"""
response_data = Client().post(
"{}".format(cls._url_path),
token,
response_data = Client(self.baseurl).post(
"{}".format(self._url_path),
self.token,
body
)
return response_data
return cls(**response_data)
def update(self, token, body):
def update(self, body):
"""
Updates a Landing Page instance.
"""
response_data = Client().put(
"{url_path}/{id}".format(url_path=self._url_path, id=self.id),
token,
response_data = Client(self.baseurl).put(
"{url_path}/{id}".format(
url_path=self._url_path,
id=self.id
),
self.token,
body
)
......
......@@ -18,11 +18,6 @@
<field name="category_id" ref="energy_communities_category"/>
</record>
<record model="res.groups" id="group_coordinator">
<field name="name">Coordinator</field>
<field name="category_id" ref="energy_communities_category"/>
</record>
<record model="res.groups" id="group_platform_manager">
<field name="name">Platform Manager</field>
<field name="category_id" ref="energy_communities_category"/>
......@@ -58,11 +53,53 @@
]"/>
</record>
<record model="res.users.role" id="role_coordination">
<field name="name">Coordination role</field>
<field name="code">role_coordination</field>
<record model="res.users.role" id="role_ce_manager">
<field name="name">Energy Community Manager</field>
<field name="code">role_ce_manager</field>
<field name="implied_ids" eval="[
(4, ref('group_admin')),
(4, ref('sale.group_delivery_invoice_address')),
(4, ref('account.group_account_invoice')),
(4, ref('base.group_partner_manager')),
(4, ref('base.group_multi_company')),
(4, ref('base.group_allow_export')),
(4, ref('cooperator.cooperator_group_manager')),
(4, ref('sales_team.group_sale_manager')),
(4, ref('purchase.group_purchase_manager')),
(4, ref('account.group_account_manager')),
(4, ref('account_payment_order.group_account_payment')),
(4, ref('crm.group_use_lead')),
(4, ref('mass_mailing.group_mass_mailing_user')),
(4, ref('l10n_es_aeat.group_account_aeat')),
]"/>
</record>
<record model="res.users.role" id="role_coord_admin">
<field name="name">Coordinator Admin</field>
<field name="code">role_coord_admin</field>
<field name="implied_ids" eval="[
(4, ref('group_admin')),
(4, ref('sale.group_delivery_invoice_address')),
(4, ref('account.group_account_invoice')),
(4, ref('base.group_partner_manager')),
(4, ref('base.group_multi_company')),
(4, ref('base.group_allow_export')),
(4, ref('cooperator.cooperator_group_manager')),
(4, ref('sales_team.group_sale_manager')),
(4, ref('purchase.group_purchase_manager')),
(4, ref('account.group_account_manager')),
(4, ref('account_payment_order.group_account_payment')),
(4, ref('crm.group_use_lead')),
(4, ref('mass_mailing.group_mass_mailing_user')),
(4, ref('l10n_es_aeat.group_account_aeat')),
]"/>
</record>
<record model="res.users.role" id="role_coord_worker">
<field name="name">Coordinator Worker</field>
<field name="code">role_coord_worker</field>
<field name="implied_ids" eval="[
(4, ref('group_coordinator')),
(4, ref('group_user')),
(4, ref('sale.group_delivery_invoice_address')),
(4, ref('account.group_account_invoice')),
(4, ref('base.group_partner_manager')),
......@@ -84,6 +121,7 @@
<field name="code">role_platform_admin</field>
<field name="implied_ids" eval="[
(4, ref('group_platform_manager')),
(4, ref('group_admin')),
(4, ref('base.group_erp_manager')),
(4, ref('sale.group_delivery_invoice_address')),
(4, ref('account.group_account_invoice')),
......
......@@ -3,3 +3,4 @@ from . import ce_landing_service
from . import ce_member_service
from . import ce_member_profile_service
from . import ce_community_service
from . import crm_lead_service
import json
import logging
from odoo.addons.component.core import Component
from odoo.addons.base_rest.http import wrapJsonException
from werkzeug.exceptions import BadRequest
from odoo import _
from . import schemas
_logger = logging.getLogger(__name__)
class CRMLeadService(Component):
_inherit = "base.rest.service"
_name = "crm.lead.services"
_collection = "ce.services"
_usage = "crm-lead"
_inherit = "crm.lead.service"
_name = "crm.lead.service"
_description = """
CRMLead requests
"""
def create(self, **params):
company_id = self.env['res.company'].get_real_ce_company_id(params['odoo_company_id']).id
params.update({'odoo_company_id': company_id})
sources = {s.name:s.res_id for s in self.env['ir.model.data'].search([
('module','=','ce'), ('model','=','utm.source')])}
if params['source_xml_id'] not in sources:
raise wrapJsonException(
BadRequest(
_("Source {} not found").format(
params["source_xml_id"])
),
include_description=True,
create_dict = super().create(params)
crm_lead = json.loads(create_dict.response[0].decode("utf-8"))
metadata = params["metadata"]
target_source_xml_id = None
for data in metadata:
if data["key"] == "source_xml_id":
target_source_xml_id = data["value"]
template_external_id = None
if target_source_xml_id == "ce_source_creation_ce_proposal":
template_external_id = "email_templ_lead_ce_creation_receipt_confirm_id"
elif target_source_xml_id == "ce_source_existing_ce_contact":
template_external_id = "email_templ_lead_request_contact_confirm_id"
elif target_source_xml_id == "ce_source_existing_ce_info":
template_external_id = "email_templ_lead_request_ce_news_confirm_id"
elif target_source_xml_id == "ce_source_future_location_ce_info":
template_external_id = (
"email_templ_lead_request_advise_future_ce_confirm_id"
)
elif target_source_xml_id == "ce_source_general_info":
template_external_id = "email_templ_lead_request_platform_news_confirm_id"
target_source_xml_id = params['source_xml_id']
params.update({'source_xml_id': sources[params['source_xml_id']]})
try:
tag_ids = params['tag_ids']
except:
tag_ids = False
if tag_ids:
for tag_id in tag_ids:
tag_id_res = self.env['crm.lead.tag'].search([('id','=',tag_id)]).id
if not tag_id_res:
raise wrapJsonException(
BadRequest(
_("Tag {} not found").format(tag_id)
),
include_description=True,
)
params = self._prepare_create(params)
sr = self.env["crm.lead"].sudo().create(params)
# send the receipt confirmation email
email_template = None
if target_source_xml_id == 'ce_source_creation_ce_proposal':
email_template = 'email_templ_lead_ce_creation_receipt_confirm_id'
elif target_source_xml_id == 'ce_source_existing_ce_contact':
email_template = 'email_templ_lead_request_contact_confirm_id'
elif target_source_xml_id == 'ce_source_existing_ce_info':
email_template = 'email_templ_lead_request_ce_news_confirm_id'
elif target_source_xml_id == 'ce_source_future_location_ce_info':
email_template = 'email_templ_lead_request_advise_future_ce_confirm_id'
elif target_source_xml_id == 'ce_source_general_info':
email_template = 'email_templ_lead_request_platform_news_confirm_id'
if email_template:
self.env.ref('ce.{}'.format(email_template)).sudo().send_mail(sr.id)
return self._to_dict(sr)
def _validator_create(self):
source = self.work and hasattr(self.work, 'request') and self.work.request.params.get('source_xml_id', False) or None
if source and source == 'ce_source_creation_ce_proposal':
return schemas.S_CRM_LEAD_CREATE_ALTA_CE
return schemas.S_CRM_LEAD_CREATE
email_values = {"email_to": params["email_from"]}
def _validator_return_create(self):
return schemas.S_CRM_LEAD_RETURN_CREATE
@staticmethod
def _to_dict(crm_lead):
return {
"id": crm_lead.id
}
def _prepare_create(self, params):
contact_name = params.get("partner_firstname", None) or params.get("partner_lastname",None) or None
if params.get("partner_firstname",None) and params.get("partner_lastname",None):
contact_name = "{} {}".format(params.get("partner_firstname",""),params.get("partner_lastname",""))
target_lang = None
if params.get("partner_language", None):
active_langs = self.env['res.lang'].search([('active','=', True)])
active_code_langs = [l.code.split('_')[0] for l in active_langs]
if params.get('partner_language').lower() not in active_code_langs:
raise wrapJsonException(
BadRequest(),
include_description=False,
extra_info={'message': _("This language code %s is not active in Odoo. Active ones: %s") % (
params.get('partner_language').lower(),
str(active_code_langs))}
)
target_lang = [l for l in active_langs if l.code.split('_')[0] == params.get('partner_language').lower()][0]
vals = {
"submission_type": 'place_proposal_submission',
"type": 'opportunity',
"contact_name": contact_name,
"name": params.get("partner_name"),
"description": params.get("partner_description"),
"street": params.get("partner_full_address"),
"zip": params.get("partner_zip"),
"city": params.get("partner_city"),
"email_from": params.get("partner_email"),
"phone": params.get("partner_phone"),
"tag_ids": [(6, 0, params.get("tag_ids", []))],
"company_id": params.get("odoo_company_id"),
"source_id": params.get("source_xml_id"),
"form_submission_metadata_ids": [
(0,0,{'key':'partner_qty_members','value':params.get("partner_qty_members"),'type':'string'}),
(0,0,{'key':'partner_legal_state','value':params.get("partner_legal_state"),'type':'string'}),
(0,0,{'key':'partner_foundation_date','value':params.get("partner_foundation_date"),'type':'string'}),
(0,0,{'key':'partner_vat','value':params.get("partner_vat"),'type':'string'}),
(0,0,{'key':'partner_comments','value':params.get("partner_comments"),'type':'string'}),
(0,0,{'key':'partner_state','value':params.get("partner_state"),'type':'string'}),
(0,0,{'key':'partner_firstname','value':params.get("partner_firstname"),'type':'string'}),
(0,0,{'key':'partner_lastname','value':params.get("partner_lastname"),'type':'string'}),
(0,0,{'key':'contact_email','value':params.get("partner_email"),'type':'string'}),
(0,0,{'key':'contact2_firstname','value':params.get("contact2_firstname"),'type':'string'}),
(0,0,{'key':'contact2_lastname','value':params.get("contact2_lastname"),'type':'string'}),
(0,0,{'key':'contact2_email','value':params.get("contact2_email"),'type':'string'}),
(0,0,{'key':'contact2_mobile','value':params.get("contact2_mobile"),'type':'string'}),
(0,0,{'key':'partner_map_place_form_url','value':params.get("partner_map_place_form_url"),'type':'string'}),
(0,0,{'key':'partner_language','value':target_lang and target_lang.code or 'en_US','type':'string'}),
(0,0,{'key':'partner_twitter','value':'','type':'string'}),
(0,0,{'key':'partner_facebook','value':'','type':'string'}),
(0,0,{'key':'partner_instagram','value':'','type':'string'}),
(0,0,{'key':'partner_telegram','value':'','type':'string'}),
(0,0,{'key':'partner_group_image_url','value':'','type':'string'}),
(0,0,{'key':'partner_latitude','value':'','type':'string'}),
(0,0,{'key':'partner_longitude','value':'','type':'string'}),
(0,0,{'key':'partner_initial_share_amount','value':'100','type':'string'})
],
}
if params.get("partner_phone", False) and params.get("partner_phone").strip()[:1] in ('6','7'):
vals['mobile'] = params.get("partner_phone")
return vals
if template_external_id:
template = self.env.ref(
"energy_communities.{}".format(template_external_id)
)
template.sudo().send_mail(crm_lead["id"], email_values=email_values)
# Add template to chatter message
self.env["crm.lead"].post_template_to_chatter(template.id)