diff --git a/energy_communities/data/mail_template_data.xml b/energy_communities/data/mail_template_data.xml index dc58f639aa7b0a7226c9456380e0db7123b6ecd2..2940c25731d369ca456e17ea8d27db5c036a199d 100644 --- a/energy_communities/data/mail_template_data.xml +++ b/energy_communities/data/mail_template_data.xml @@ -2,6 +2,28 @@ <odoo> <data noupdate="1"> + <record id="email_templ_lead_assigned_to_coordinator_id" model="mail.template"> + <field name="name">Request for registration of the Energy Community on the platform</field> + <field name="email_from">${object.company_id.email}</field> + <field name="subject">[Somcomunitats.coop] Request for registration of the Energy Community on the platform</field> + <field name="email_to">${ctx.get('email_to')}</field> + <field name="model_id" ref="model_crm_lead" /> + <field name="auto_delete" eval="True" /> + <field name="lang">${object.company_id.partner_id.lang}</field> + <field name="body_html"> + <![CDATA[ + <div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; "> + <p>Hello,</p><br/> + <p>There is a new Energy Community registration request.</p> + <p>Go to Odoo to track this registration.</p><br/> + <p>Yours faithfully,</p> + <p>Somcomunitats.coop team</p> + <p><a href="https://web-test.somcomunitats.coop/recursos/">Resources and FAQs</a></p> + </div> + ]]> + </field> + </record> + <record id="email_templ_lead_ce_creation_receipt_confirm_id" model="mail.template"> <field name="name">Confirmation Email for CE Creation Lead Receipt</field> <field name="email_from"> diff --git a/energy_communities/i18n/ca_ES.po b/energy_communities/i18n/ca_ES.po index d94925e36df7ef56ea8c19eb1431578552779a8d..b753886e845dae36114ff9439bbe3be8ba144fe9 100644 --- a/energy_communities/i18n/ca_ES.po +++ b/energy_communities/i18n/ca_ES.po @@ -17,6 +17,45 @@ msgstr "" "Plural-Forms: \n" "X-Generator: Poedit 3.0.1\n" +#. module: energy_communities +#: model:mail.template,body_html:energy_communities.email_templ_lead_assigned_to_coordinator_id +msgid "" +"\n" +" \n" +" <div style=\"font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; \">\n" +"\n" +" <p>Hello,</p>\n" +"\n" +" <p>There is a new Energy Community registration request.</p>\n" +"\n" +" <p>Go to Odoo to track this registration.</p>\n" +"\n" +" <p>Yours faithfully,</p>\n" +" <p>Somcomunitats.coop team </p>\n" +" <p><a href=\"https://web-test.somcomunitats.coop/recursos/\">Resources and FAQs</a></p>\n" +"\n" +" </div>\n" +" \n" +" " +msgstr "" +"\n" +" \n" +" <div style=\"font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; \">\n" +"\n" +" <p>Hola,</p>\n" +"\n" +" <p>Hi ha una nova sol·licitud d’alta de Comunitat Energètica.</p>\n" +"\n" +" <p>Vés al Odoo a fer seguiment d’aquesta alta.</p>\n" +"\n" +" <p>Atentament,</p>\n" +" <p>Equip de somcomunitats.coop</p>\n" +" <p><a href=\"https://web-test.somcomunitats.coop/recursos/\">Recursos i preguntes freqüents</a></p>\n" +"\n" +" </div>\n" +" \n" +" " + #. module: energy_communities #: model:ir.model.fields,help:energy_communities.field_subscription_request__vat msgid "" @@ -2400,6 +2439,15 @@ msgstr "" msgid "[Somcomunitats.coop] Platform Newsletter Subscription Request" msgstr "[Somcomunitats.coop] Subscripció al butlletÃ" +#. module: energy_communities +#: model:mail.template,subject:energy_communities.email_templ_lead_assigned_to_coordinator_id +msgid "" +"[Somcomunitats.coop] Request for registration of the Energy Community on the" +" platform" +msgstr "" +"[Somcomunitats.coop] Sol·licitud d’Alta de Comunitat Energètica a la " +"plataforma" + #. module: energy_communities #: model_terms:ir.ui.view,arch_db:energy_communities.voluntary_share_text_template msgid "and" diff --git a/energy_communities/i18n/energy_communities.pot b/energy_communities/i18n/energy_communities.pot index f0dcb92945ae6ea0f02ed5d7c62b372aa0f2e9e9..adde0f7f8fc0a52ed2706da1197b3cfccc220c0c 100644 --- a/energy_communities/i18n/energy_communities.pot +++ b/energy_communities/i18n/energy_communities.pot @@ -15,6 +15,28 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" +#. module: energy_communities +#: model:mail.template,body_html:energy_communities.email_templ_lead_assigned_to_coordinator_id +msgid "" +"\n" +" \n" +" <div style=\"font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; \">\n" +"\n" +" <p>Hello,</p>\n" +"\n" +" <p>There is a new Energy Community registration request.</p>\n" +"\n" +" <p>Go to Odoo to track this registration.</p>\n" +"\n" +" <p>Yours faithfully,</p>\n" +" <p>Somcomunitats.coop team </p>\n" +" <p><a href=\"https://web-test.somcomunitats.coop/recursos/\">Resources and FAQs</a></p>\n" +"\n" +" </div>\n" +" \n" +" " +msgstr "" + #. module: energy_communities #: model:ir.model.fields,help:energy_communities.field_subscription_request__vat msgid "" @@ -2045,6 +2067,13 @@ msgstr "" msgid "[Somcomunitats.coop] Platform Newsletter Subscription Request" msgstr "" +#. module: energy_communities +#: model:mail.template,subject:energy_communities.email_templ_lead_assigned_to_coordinator_id +msgid "" +"[Somcomunitats.coop] Request for registration of the Energy Community on the" +" platform" +msgstr "" + #. module: energy_communities #: model_terms:ir.ui.view,arch_db:energy_communities.voluntary_share_text_template msgid "and" diff --git a/energy_communities/i18n/es.po b/energy_communities/i18n/es.po index 0adb008bebac083d4c7999208604d090b67f2877..22ef24b19512b77eda6494adf734e69c92ace94f 100644 --- a/energy_communities/i18n/es.po +++ b/energy_communities/i18n/es.po @@ -17,6 +17,45 @@ msgstr "" "Plural-Forms: \n" "X-Generator: Take .POT and make magic\n" +#. module: energy_communities +#: model:mail.template,body_html:energy_communities.email_templ_lead_assigned_to_coordinator_id +msgid "" +"\n" +" \n" +" <div style=\"font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; \">\n" +"\n" +" <p>Hello,</p>\n" +"\n" +" <p>There is a new Energy Community registration request.</p>\n" +"\n" +" <p>Go to Odoo to track this registration.</p>\n" +"\n" +" <p>Yours faithfully,</p>\n" +" <p>Somcomunitats.coop team </p>\n" +" <p><a href=\"https://web-test.somcomunitats.coop/recursos/\">Resources and FAQs</a></p>\n" +"\n" +" </div>\n" +" \n" +" " +msgstr "" +"\n" +" \n" +" <div style=\"font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; \">\n" +"\n" +" <p>Hola,</p>\n" +"\n" +" <p>Hay una nueva solicitud de alta de Comunidad Energética.</p>\n" +"\n" +" <p>Ve a Odoo a hacer seguimiento de esta alta.</p>\n" +"\n" +" <p>Atentamente,</p>\n" +" <p>Equipo de Somcomunitats.coop</p>\n" +" <p><a href=\"https://web-test.somcomunitats.coop/recursos/\">Recursos y preguntas frecuentes</a></p>\n" +"\n" +" </div>\n" +" \n" +" " + #. module: energy_communities #: model:ir.model.fields,help:energy_communities.field_subscription_request__vat msgid "" @@ -2161,6 +2200,15 @@ msgstr "" msgid "[Somcomunitats.coop] Platform Newsletter Subscription Request" msgstr "[Somcomunitats.coop] Suscripción boletÃn plataforma" +#. module: energy_communities +#: model:mail.template,subject:energy_communities.email_templ_lead_assigned_to_coordinator_id +msgid "" +"[Somcomunitats.coop] Request for registration of the Energy Community on the" +" platform" +msgstr "" +"[Somcomunitats.coop] Solicitud de alta de Comunidad Energética en la " +"plataforma" + #. module: energy_communities #: model_terms:ir.ui.view,arch_db:energy_communities.voluntary_share_text_template msgid "and" diff --git a/energy_communities/i18n/eu_ES.po b/energy_communities/i18n/eu_ES.po index ce5a6ffa4af20e8e60fb6cdc1c04fda017366d19..50f618d252dd13b9906aaf92e2cbbe91b91d34b7 100644 --- a/energy_communities/i18n/eu_ES.po +++ b/energy_communities/i18n/eu_ES.po @@ -17,6 +17,45 @@ msgstr "" "Plural-Forms: \n" "X-Generator: Poedit 3.0.1\n" +#. module: energy_communities +#: model:mail.template,body_html:energy_communities.email_templ_lead_assigned_to_coordinator_id +msgid "" +"\n" +" \n" +" <div style=\"font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; \">\n" +"\n" +" <p>Hello,</p>\n" +"\n" +" <p>There is a new Energy Community registration request.</p>\n" +"\n" +" <p>Go to Odoo to track this registration.</p>\n" +"\n" +" <p>Yours faithfully,</p>\n" +" <p>Somcomunitats.coop team </p>\n" +" <p><a href=\"https://web-test.somcomunitats.coop/recursos/\">Resources and FAQs</a></p>\n" +"\n" +" </div>\n" +" \n" +" " +msgstr "" +"\n" +" \n" +" <div style=\"font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; \">\n" +"\n" +" <p>Kaixo,</p>\n" +"\n" +" <p>Comunidad Energétican izena emateko eskaera berri bat dago.</p>\n" +"\n" +" <p>Zoaz Odoo erregistro honi jarraipena emateko.</p>\n" +"\n" +" <p>Zinez,</p>\n" +" <p>Taldea Somcomunitats.coop</p>\n" +" <p><a href=\"https://web-test.somcomunitats.coop/recursos/\">Baliabideak eta ohiko galderak</a></p>\n" +"\n" +" </div>\n" +" \n" +" " + #. module: energy_communities #: model:ir.model.fields,help:energy_communities.field_subscription_request__vat msgid "" @@ -2395,6 +2434,15 @@ msgstr "[Somcomunitats.coop] Plataformari Komunitatea Sortzeko Eskaera Berria" msgid "[Somcomunitats.coop] Platform Newsletter Subscription Request" msgstr "[Somcomunitats.coop] Plataformaren Buletina Harpidetza eskaera" +#. module: energy_communities +#: model:mail.template,subject:energy_communities.email_templ_lead_assigned_to_coordinator_id +msgid "" +"[Somcomunitats.coop] Request for registration of the Energy Community on the" +" platform" +msgstr "" +"[Somcomunitats.coop] Energia Erkidegoa inskribatzeko eskaera " +"plataforma" + #. module: energy_communities #: model_terms:ir.ui.view,arch_db:energy_communities.voluntary_share_text_template msgid "and" diff --git a/energy_communities/wizards/assign_crm_to_coordinator_company.py b/energy_communities/wizards/assign_crm_to_coordinator_company.py index 6cd0b348c5fec811eaedfe46f438106b6066270e..7818e9025b8549dc1e90466a4cde0d2755c4e3e1 100644 --- a/energy_communities/wizards/assign_crm_to_coordinator_company.py +++ b/energy_communities/wizards/assign_crm_to_coordinator_company.py @@ -2,25 +2,56 @@ from odoo import models, fields, api class AssignCRMToCoordinatorCompanyWizard(models.TransientModel): - _name = 'assign.crm.to.coordinator.company.wizard' - _description = 'Assign CRM to coordinator company wizard' + _name = "assign.crm.to.coordinator.company.wizard" + _description = "Assign CRM to coordinator company wizard" - crm_lead_id = fields.Many2one('crm.lead') + crm_lead_id = fields.Many2one("crm.lead") assigned_company_id = fields.Many2one( - 'res.company', - string='Assigned company', + "res.company", + string="Assigned company", required=True, - domain=[('hierarchy_level', '=', 'coordinator')] + domain=[("hierarchy_level", "=", "coordinator")], ) @api.model def default_get(self, fields_list): defaults = super().default_get(fields_list) - defaults['crm_lead_id'] = self.env.context['active_id'] + defaults["crm_lead_id"] = self.env.context["active_id"] return defaults def assign_to_coordinator_company(self): self.ensure_one() - self.crm_lead_id.write( - {'company_id': self.assigned_company_id} + self.remove_follower() + self.crm_lead_id.write({"company_id": self.assigned_company_id}) + self.add_follower() + + def remove_follower(self): + instance_admin = self.env.ref("energy_communities.role_ce_manager").id + company_id = self.crm_lead_id.company_id.id + followers = self.env["res.users"].search( + [ + ("role_line_ids.role_id", "=", instance_admin), + ("company_ids.id", "=", company_id), + ] + ) + if followers: + self.crm_lead_id.message_unsubscribe(partner_ids=followers.partner_id.ids) + + def add_follower(self): + coordinator_admin = self.env.ref("energy_communities.role_coord_admin").id + company_id = self.crm_lead_id.company_id.id + followers = self.env["res.users"].search( + [ + ("role_line_ids.role_id", "=", coordinator_admin), + ("company_ids.id", "=", company_id), + ] ) + if followers: + self.crm_lead_id.message_subscribe(partner_ids=followers.partner_id.ids) + # notify followers + for follower in followers: + email_values = {"email_to": follower.partner_id.email} + template = self.env.ref( + "energy_communities.email_templ_lead_assigned_to_coordinator_id" + ).with_context(email_values) + self.crm_lead_id.message_post_with_template(template.id)