From c6c9c5ecf774cc187d59519578c0c9e5a75f90b3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81lvaro=20Garc=C3=ADa?= <alvarogruiz8@gmail.com>
Date: Wed, 19 Feb 2025 11:33:10 +0100
Subject: [PATCH 01/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Change=20in=20a=20lit?=
 =?UTF-8?q?eral,=20hiding=20of=20a=20field=20and=20change=20in=20the=20fro?=
 =?UTF-8?q?m=20of=20the=20selfconsumption=20mailing=20templates?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: Alvaro Garcia <alvaro.garcia@somit.coop>
---
 energy_selfconsumption/data/mail_template.xml             | 8 ++++----
 energy_selfconsumption/views/distribution_table_views.xml | 1 +
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/energy_selfconsumption/data/mail_template.xml b/energy_selfconsumption/data/mail_template.xml
index c74f4cfdc..ed0e77167 100644
--- a/energy_selfconsumption/data/mail_template.xml
+++ b/energy_selfconsumption/data/mail_template.xml
@@ -4,7 +4,7 @@
         <record id="selfconsumption_energy_delivered_invoicing_reminder" model="mail.template">
             <field name="name">Selfconsumption Energy Delivered Invoicing Reminder</field>
             <field name="description">Email reminder for self-consumption billing of supplied energy</field>
-            <field name="email_from">info@somcomunitats.coop</field>
+            <field name="email_from">{{ (object.company_id.coop_email_contact or object.company_id.email_formatted) }}</field>
             <field name="subject">Selfconsumption - Energy Delivered Invoicing Reminder</field>
             <field name="model_id" ref="energy_selfconsumption.model_energy_selfconsumption_selfconsumption"/>
             <field name="body_html" type="html">
@@ -36,7 +36,7 @@
         <record id="selfconsumption_energy_delivered_custom_invoicing_reminder" model="mail.template">
             <field name="name">Selfconsumption Energy Delivered Custom Invoicing Reminder</field>
             <field name="description">E-mail reminder of personalized billing of self-consumption of energy supplied</field>
-            <field name="email_from">info@somcomunitats.coop</field>
+            <field name="email_from">{{ (object.company_id.coop_email_contact or object.company_id.email_formatted) }}</field>
             <field name="subject">Self-consumption billing reminder {{object.name}}</field>
             <field name="model_id" ref="energy_selfconsumption.model_energy_selfconsumption_selfconsumption"/>
             <field name="body_html" type="html">
@@ -78,7 +78,7 @@
         <record id="selfconsumption_power_acquired_invoicing_reminder" model="mail.template">
             <field name="name">Selfconsumption Power Acquired Invoicing Reminder</field>
             <field name="description">E-mail billing reminder of self-consumption of energy purchased</field>
-            <field name="email_from">info@somcomunitats.coop</field>
+            <field name="email_from">{{ (object.company_id.coop_email_contact or object.company_id.email_formatted) }}</field>
             <field name="subject">Selfconsumption - Power Acquired Invoicing Reminder</field>
             <field name="model_id" ref="energy_selfconsumption.model_energy_selfconsumption_selfconsumption"/>
             <field name="body_html" type="html">
@@ -104,7 +104,7 @@
         <record id="selfconsumption_insciption_form" model="mail.template">
             <field name="name">Registration in self-consumption project of the Energy Community</field>
             <field name="description">E-mail of inscription in the self-consumption project of the Energy Community</field>
-            <field name="email_from">info@somcomunitats.coop</field>
+            <field name="email_from">{{ (object.company_id.coop_email_contact or object.company_id.email_formatted) }}</field>
             <field name="subject">Registration in {{ object.name }}</field>
             <field name="model_id" ref="energy_selfconsumption.model_energy_selfconsumption_selfconsumption"/>
             <field name="body_html" type="html">
diff --git a/energy_selfconsumption/views/distribution_table_views.xml b/energy_selfconsumption/views/distribution_table_views.xml
index 0a00934b4..053ad6ce9 100644
--- a/energy_selfconsumption/views/distribution_table_views.xml
+++ b/energy_selfconsumption/views/distribution_table_views.xml
@@ -50,6 +50,7 @@
                   name="selfconsumption_project_id"
                   attrs="{'readonly': [('state', 'not in', ['draft'])]}"
                   options="{'no_create': True}"
+                  invisible="1"
                 />
                             </group>
                             <group>
-- 
GitLab


From 68df449976c10d765c904a5161942718aa34e0e8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81lvaro=20Garc=C3=ADa?= <alvarogruiz8@gmail.com>
Date: Wed, 19 Feb 2025 13:38:54 +0100
Subject: [PATCH 02/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Changes=20in=20the=20?=
 =?UTF-8?q?description=20of=20the=20contract=20lines=20and=20changes=20in?=
 =?UTF-8?q?=20the=20energy=20power=20invoice=20report.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: Alvaro Garcia <alvaro.garcia@somit.coop>
---
 energy_selfconsumption/i18n/ca_ES.po          | 215 +++++++++++++++++-
 .../i18n/energy_selfconsumption.pot           | 208 ++++++++++++++++-
 energy_selfconsumption/i18n/es.po             | 215 +++++++++++++++++-
 energy_selfconsumption/i18n/eu_ES.po          | 215 +++++++++++++++++-
 .../models/contract_line.py                   |  24 --
 .../reports/invoice_template.xml              |  33 +--
 .../wizards/contract_generation_wizard.py     |  19 +-
 7 files changed, 830 insertions(+), 99 deletions(-)

diff --git a/energy_selfconsumption/i18n/ca_ES.po b/energy_selfconsumption/i18n/ca_ES.po
index 9d3ae7601..013784ba6 100644
--- a/energy_selfconsumption/i18n/ca_ES.po
+++ b/energy_selfconsumption/i18n/ca_ES.po
@@ -6,8 +6,8 @@ msgid ""
 msgstr ""
 "Project-Id-Version: Odoo Server 16.0\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2025-02-13 10:05+0000\n"
-"PO-Revision-Date: 2025-02-13 10:05+0000\n"
+"POT-Creation-Date: 2025-02-19 12:09+0000\n"
+"PO-Revision-Date: 2025-02-19 12:09+0000\n"
 "Last-Translator: \n"
 "Language-Team: \n"
 "MIME-Version: 1.0\n"
@@ -18,21 +18,29 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
 #, python-format
 msgid ""
 "\n"
 "CAU: {cau}\n"
-"Total installed nominal power (kW): {power}\n"
-"Partition coefficient: {coefficient}"
+"                        Total installed nominal power (kW): {power}\n"
+"                        Partition coefficient: {coefficient}\n"
+"                        Daily nominal power acquired: {power} kWn * {coefficient} = {power_acquired} kWn/day\n"
+"                        Days to be invoiced: {days_invoiced} days\n"
+"                        Total amount invoiced:  {days_invoiced} days * {power_acquired} kWn/day = {total_amount}\n"
 msgstr ""
 "\n"
 "CAU: {cau}\n"
-"Potència nominal instal·lada total (kW): {power}\n"
-"Coeficient de partició: {coefficient}"
+"                        Potència nominal instal·lada total (kW): {power}\n"
+"                        Coeficient de partició: {coefficient}\n"
+"                        Potència nominal adquirida diària: {power} kWn * {coefficient} = {power_acquired} kWn/die\n"
+"                        Dies a facturar: {days_invoiced} dies\n"
+"                        Quantitat total a facturar:  {days_invoiced} dies * {power_acquired} kWn/die = {total_amount}\n"
 
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid ""
 "\n"
@@ -48,6 +56,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid ""
 "\n"
@@ -61,6 +70,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid ""
 "\n"
@@ -76,6 +86,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid ""
 "\n"
@@ -517,6 +528,8 @@ msgstr ""
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "<li>Line {line}: {error}</li>\n"
 msgstr "<li>Línia {line}: {error}</li>\n"
@@ -666,6 +679,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: model:ir.model.constraint,message:energy_selfconsumption.constraint_energy_selfconsumption_selfconsumption_unique_code
 #, python-format
 msgid "A project with this CAU already exists."
@@ -674,6 +688,7 @@ msgstr "Ja existeix un projecte amb aquesta CAU."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #: model:ir.model.constraint,message:energy_selfconsumption.constraint_energy_selfconsumption_supply_point_unique_code_company_id
 #, python-format
 msgid "A supply point with this code already exists."
@@ -717,6 +732,7 @@ msgstr "Número de compte"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/define_invoicing_mode_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/define_invoicing_mode_wizard.py:0
 #, python-format
 msgid "Accounting Journal not found."
 msgstr "No s'ha trobat cap diari de comptabilitat configurat"
@@ -741,8 +757,12 @@ msgstr "Activa el formulari"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/inscription.py:0
 #: code:addons/energy_selfconsumption/models/inscription.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_distribution_table__active
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__active
@@ -794,6 +814,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Address"
 msgstr "Adreça"
@@ -834,6 +855,7 @@ msgstr "Consum anual d'electricitat"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Annual electricity use?"
 msgstr "Consum anual d'electricitat?"
@@ -841,6 +863,7 @@ msgstr "Consum anual d'electricitat?"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Are you in a vulnerable situation?"
 msgstr "Estàs en una situació vulnerable?"
@@ -858,6 +881,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/clean_supply_point_assignation_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/clean_supply_point_assignation_wizard.py:0
 #, python-format
 msgid "Are you sure you want to delete all assigned distribution points?"
 msgstr "Estas segur que vols eliminar els punts de distribució?"
@@ -902,6 +926,7 @@ msgstr "Període de facturació"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Birthdate"
 msgstr "Data de naixement"
@@ -914,6 +939,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "CIF/NIF"
 msgstr ""
@@ -932,6 +958,7 @@ msgstr "COEFICIENT (α)"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid "CSV file could not be loaded"
 msgstr "No s'ha pogut carregar el fitxer CSV"
@@ -939,6 +966,7 @@ msgstr "No s'ha pogut carregar el fitxer CSV"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__code
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point__code
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point_assignation__code
@@ -951,6 +979,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "CUPS is the Unified Code of the Point of Supply. You can find it on "
@@ -962,6 +991,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/define_invoicing_mode_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/define_invoicing_mode_wizard.py:0
 #, python-format
 msgid ""
 "CUPS: {code}\n"
@@ -981,6 +1011,7 @@ msgstr "Referència cadastral"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Cadastral reference of the property"
 msgstr "Referència cadastral de l'immoble"
@@ -994,6 +1025,8 @@ msgstr "Cancel·lar"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/inscription.py:0
+#: code:addons/energy_selfconsumption/models/inscription.py:0
+#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_change_state_inscription_lines_wizard__state__change
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_inscription_selfconsumption__state__change
@@ -1021,6 +1054,7 @@ msgstr "Canviar estat d'inscripció"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__city
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point__city
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point_assignation__supply_point_town
@@ -1043,6 +1077,7 @@ msgstr "Assistent per a l'assignació de punts de subministrament nets"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #: model:ir.actions.server,name:energy_selfconsumption.manager_clean_supply_point_assignation_action
 #, python-format
 msgid "Clean supply point assignation"
@@ -1068,6 +1103,7 @@ msgstr "El coeficient és vàlid"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point_assignation.py:0
+#: code:addons/energy_selfconsumption/models/supply_point_assignation.py:0
 #, python-format
 msgid "Coefficient can't be negative."
 msgstr "El coeficient no pot ser negatiu."
@@ -1075,6 +1111,7 @@ msgstr "El coeficient no pot ser negatiu."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #, python-format
 msgid "Coefficient distribution must sum to 1."
 msgstr "El coeficient de distribució ha de sumar 1."
@@ -1091,6 +1128,7 @@ msgstr "Companyia"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Company Name"
 msgstr "Nom de l'empresa"
@@ -1172,6 +1210,7 @@ msgstr "Confirmar"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Confirm E-mail"
 msgstr "Confirmeu el correu electrònic"
@@ -1197,6 +1236,7 @@ msgstr "Contracte"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
 #, python-format
 msgid "Contract - %s - %s"
 msgstr "Contracte - %s - %s"
@@ -1370,6 +1410,7 @@ msgstr "Dies facturats"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_form_view
 #, python-format
 msgid "Define Invoicing Mode"
@@ -1484,6 +1525,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Do you currently have self-consumption?"
 msgstr "Actualment tens autoconsum?"
@@ -1491,6 +1533,7 @@ msgstr "Actualment tens autoconsum?"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "Dont exit participation for this project."
 msgstr "No abandonis la participació en aquest projecte."
@@ -1524,6 +1567,7 @@ msgstr "Descarregar Autorització del Gestor d'Autoconsum"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_distribution_table__state__draft
 #, python-format
 msgid "Draft"
@@ -1532,6 +1576,7 @@ msgstr "Esborrany"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "E-mail"
 msgstr "Correu electrònic"
@@ -1653,6 +1698,7 @@ msgstr "Final"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_define_invoicing_mode_wizard__invoicing_mode__energy_delivered
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_invoicing_wizard__invoicing_mode__energy_delivered
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_selfconsumption__invoicing_mode__energy_delivered
@@ -1663,6 +1709,7 @@ msgstr "Energia entregada"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_define_invoicing_mode_wizard__invoicing_mode__energy_custom
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_invoicing_wizard__invoicing_mode__energy_custom
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_selfconsumption__invoicing_mode__energy_custom
@@ -1673,6 +1720,7 @@ msgstr "Energia entregada personalitzada"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid "Energy Delivered Custom: {energy_delivered} kWh"
 msgstr "Energia entregada personalitzada: {energy_delivered} kWh"
@@ -1690,6 +1738,7 @@ msgstr "Fórmula variable d'energia entregada"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid "Energy Delivered: {energy_delivered} kWh"
 msgstr "Energia entregada: {energy_delivered} kWh"
@@ -1703,6 +1752,7 @@ msgstr "Projecte energètic"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Energy Project Name"
 msgstr "Nom del projecte energètic"
@@ -1735,6 +1785,7 @@ msgstr "Inscripció al projecte d'autoconsum compartit de la"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Error format date."
 msgstr "Error de format de data."
@@ -1742,8 +1793,11 @@ msgstr "Error de format de data."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "Error parsing the file"
 msgstr "S'ha produït un error en analitzar el fitxer"
@@ -1751,6 +1805,7 @@ msgstr "S'ha produït un error en analitzar el fitxer"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Error reading file"
 msgstr "Error de l'ectura d'arxiu"
@@ -1795,6 +1850,7 @@ msgstr "Data:"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Female"
 msgstr ""
@@ -1850,6 +1906,8 @@ msgstr "Nom de pila"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_create_distribution_table_wizard__type__fixed
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_distribution_table__type__fixed
@@ -1881,6 +1939,7 @@ msgstr "Icona de lletra impressionant, p. ex. fa-tasks"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid ""
 "For the 2.0TD rate, the maximum contracted power must be between 0 and 15 "
@@ -1892,6 +1951,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid ""
 "For the 3.0TD rate, the maximum contracted power must be greater than 15 kW."
@@ -1902,6 +1962,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Gender"
 msgstr "Gènere"
@@ -1914,6 +1975,7 @@ msgstr "Generar"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Generate Contracts"
 msgstr "Generar contractes"
@@ -1955,6 +2017,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "Have to accept and authorize being able to issue payments to this bank "
@@ -1968,6 +2031,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Have to accept politic privacy."
 msgstr "Cal acceptar la privadesa política."
@@ -1975,6 +2039,7 @@ msgstr "Cal acceptar la privadesa política."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__conf_header_description
 #, python-format
 msgid "Header description on website form"
@@ -1983,6 +2048,7 @@ msgstr "Descripció de la capçalera al formulari del lloc web"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "How much power of the collective PV installation you would like to purchase."
@@ -1992,6 +2058,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__accept
 #, python-format
 msgid ""
@@ -2006,6 +2073,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "I accept privacy policy"
 msgstr "Accepto la política de privadesa"
@@ -2013,6 +2081,7 @@ msgstr "Accepto la política de privadesa"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "I prefer to not share it"
 msgstr "Prefereixo no compartir-ho"
@@ -2020,6 +2089,7 @@ msgstr "Prefereixo no compartir-ho"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "IBAN"
 msgstr ""
@@ -2081,6 +2151,7 @@ msgstr "Importar"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #: model:ir.actions.act_window,name:energy_selfconsumption.distribution_table_import_wizard_action
 #, python-format
 msgid "Import Distribution Table"
@@ -2089,6 +2160,7 @@ msgstr "Importar Taula de Repartiment"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "Import Errors"
 msgstr "Errors d'importació"
@@ -2104,6 +2176,7 @@ msgstr "Importa arxiu (*.csv)"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Import Inscriptions and Supply Points"
 msgstr "Importa inscripcions i punts de subministrament"
@@ -2116,6 +2189,7 @@ msgstr "Importa dades"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "Import errors found: <ul>{list}</ul>"
 msgstr "S'han trobat errors d'importació: <ul>{list}</ul>"
@@ -2133,6 +2207,7 @@ msgstr "Importar Taula"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_distribution_table__state__process
 #, python-format
 msgid "In process"
@@ -2149,8 +2224,11 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/inscription.py:0
+#: code:addons/energy_selfconsumption/models/inscription.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_change_state_inscription_lines_wizard__state__inactive
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_inscription_selfconsumption__state__inactive
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_selfconsumption__conf_state__inactive
@@ -2161,6 +2239,7 @@ msgstr "Inactiu"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "Information necessary for the formalization of the distribution "
@@ -2209,6 +2288,7 @@ msgstr "Instal·lació:"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CAU: Last 3 digits are not numbers"
 msgstr "CAU no vàlid: els 3 últims dígits no són números"
@@ -2217,6 +2297,8 @@ msgstr "CAU no vàlid: els 3 últims dígits no són números"
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CAU: The CUPS does not start with 'ES'."
 msgstr "CAU no vàlid: el CUPS no comença amb \"ES\"."
@@ -2225,6 +2307,8 @@ msgstr "CAU no vàlid: el CUPS no comença amb \"ES\"."
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CAU: The CUPS has an incorrect format."
 msgstr "CAU no vàlid: el CUPS té un format incorrecte."
@@ -2232,6 +2316,7 @@ msgstr "CAU no vàlid: el CUPS té un format incorrecte."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CAU: The character after CUPS is not A"
 msgstr "CAU no vàlid: el caràcter després de CUPS no és A"
@@ -2240,6 +2325,8 @@ msgstr "CAU no vàlid: el caràcter després de CUPS no és A"
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CAU: The checksum of the CUPS is incorrect."
 msgstr "CAU no vàlid: la suma de comprovació del CUPS és incorrecta."
@@ -2248,6 +2335,8 @@ msgstr "CAU no vàlid: la suma de comprovació del CUPS és incorrecta."
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid ""
 "Invalid CAU: The first characters related to CUPS are incorrect. The length "
@@ -2259,6 +2348,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CAU: The length is not correct"
 msgstr "CAU no vàlid: la longitud no és correcta"
@@ -2266,6 +2356,7 @@ msgstr "CAU no vàlid: la longitud no és correcta"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CIL: Last 3 digits are not numbers"
 msgstr "CIL no vàlid: els 3 últims dígits no són números"
@@ -2274,6 +2365,8 @@ msgstr "CIL no vàlid: els 3 últims dígits no són números"
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CIL: The CUPS does not start with 'ES'."
 msgstr "CIL no vàlid: el CUPS no comença amb \"ES\"."
@@ -2282,6 +2375,8 @@ msgstr "CIL no vàlid: el CUPS no comença amb \"ES\"."
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CIL: The CUPS has an incorrect format."
 msgstr "CIL no vàlid: el CUPS té un format incorrecte."
@@ -2290,6 +2385,8 @@ msgstr "CIL no vàlid: el CUPS té un format incorrecte."
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CIL: The checksum of the CUPS is incorrect."
 msgstr "CIL no vàlid: la suma de comprovació del CUPS és incorrecta."
@@ -2298,6 +2395,8 @@ msgstr "CIL no vàlid: la suma de comprovació del CUPS és incorrecta."
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid ""
 "Invalid CIL: The first characters related to CUPS are incorrect. The length "
@@ -2309,6 +2408,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CIL: The length is not correct"
 msgstr "CIL no vàlid: la longitud no és correcta"
@@ -2316,6 +2416,7 @@ msgstr "CIL no vàlid: la longitud no és correcta"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "Invalid CUPS: The checksum is incorrect."
 msgstr "CUPS no vàlid: la suma de comprovació és incorrecta."
@@ -2323,6 +2424,7 @@ msgstr "CUPS no vàlid: la suma de comprovació és incorrecta."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "Invalid CUPS: The length is incorrect."
 msgstr "CUPS no vàlid: la longitud és incorrecta."
@@ -2330,6 +2432,7 @@ msgstr "CUPS no vàlid: la longitud és incorrecta."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "Invalid CUPS: does not start with 'ES'."
 msgstr "CUPS no vàlid: no comença amb \"ES\"."
@@ -2337,6 +2440,7 @@ msgstr "CUPS no vàlid: no comença amb \"ES\"."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "Invalid CUPS: has an incorrect format."
 msgstr "CUPS no vàlid: té un format incorrecte."
@@ -2344,6 +2448,8 @@ msgstr "CUPS no vàlid: té un format incorrecte."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "Invalid Cadastral Reference: {error}"
@@ -2352,6 +2458,7 @@ msgstr "Referència cadastral no vàlida: {error}"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "Invalid IBAN: {error}"
 msgstr "IBAN no vàlid: {error}"
@@ -2359,6 +2466,7 @@ msgstr "IBAN no vàlid: {error}"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "Invalid VAT: {error}"
 msgstr "NIF/CIF no vàlid: {error}"
@@ -2401,6 +2509,7 @@ msgstr "És Seguidor"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Is the owner the same partner?"
 msgstr "El propietari és el mateix soci?"
@@ -2418,6 +2527,7 @@ msgstr "Apunt comptable"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Lang"
 msgstr "Idioma"
@@ -2425,6 +2535,7 @@ msgstr "Idioma"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Language not found."
 msgstr "Idioma no trobat."
@@ -2512,6 +2623,7 @@ msgstr "Cognom"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Lastname"
 msgstr "Cognom"
@@ -2528,6 +2640,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_create_distribution_table_wizard__type_distribute_excess__linear
 #, python-format
 msgid "Linear"
@@ -2581,6 +2694,7 @@ msgstr "Línia principal"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Male"
 msgstr ""
@@ -2598,6 +2712,7 @@ msgstr "Mandat filtrat"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
 #, python-format
 msgid "Mandate not found for {partner}"
 msgstr "Mandat no trobat per {partner}"
@@ -2610,6 +2725,7 @@ msgstr "Potència màxima distribuïda"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point__contracted_power
 #, python-format
 msgid "Maximum contracted power"
@@ -2653,6 +2769,7 @@ msgstr "Modalitat"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Must have a valid Distribution Table."
 msgstr "Ha de tenir una taula de repartiment  validada."
@@ -2678,6 +2795,7 @@ msgstr "NOM I COGNOM (Titular del subministrament)"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_contract_contract__supply_point_name
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_distribution_table__name
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__name
@@ -2701,6 +2819,7 @@ msgstr "Dades necessàries per a la integració de la Comunitat:"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "New Supply Point"
 msgstr "Nou punt de subministrament"
@@ -2759,8 +2878,14 @@ msgstr "Inici del període següent"
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/models/partner.py:0
 #: code:addons/energy_selfconsumption/models/partner.py:0
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_create_distribution_table_wizard__distribute_excess__no
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_supply_point__used_in_selfconsumption__no
@@ -2772,6 +2897,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "No participation found for this project."
 msgstr "No s'ha trobat cap participació per a aquest projecte."
@@ -2779,7 +2905,10 @@ msgstr "No s'ha trobat cap participació per a aquest projecte."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "No valid encoding was found for the attached file"
@@ -2788,6 +2917,7 @@ msgstr "No s'ha trobat cap codificació vàlida per al fitxer adjunt"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Not binary"
 msgstr "No binari"
@@ -2838,8 +2968,11 @@ msgstr "ALTRES DADES NECESSARIS"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "Only csv format files are accepted."
 msgstr "Només s'accepten fitxers en format csv."
@@ -2847,6 +2980,7 @@ msgstr "Només s'accepten fitxers en format csv."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Other"
 msgstr "Altres"
@@ -2868,6 +3002,7 @@ msgstr "Propietari del subministrament"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "Owner could not be created or found."
 msgstr "No s'ha pogut crear ni trobar el propietari."
@@ -2894,6 +3029,7 @@ msgstr "Participació"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Participation does not exist."
 msgstr "La participació no existeix."
@@ -2917,6 +3053,7 @@ msgstr "Soci"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Partner does not exist."
 msgstr "El soci no existeix."
@@ -2924,6 +3061,7 @@ msgstr "El soci no existeix."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/inscription.py:0
+#: code:addons/energy_selfconsumption/models/inscription.py:0
 #, python-format
 msgid "Partner is already signed up in this project with that cups."
 msgstr "El soci ja està inscrit en aquest projecte amb aquestes copes."
@@ -2931,6 +3069,7 @@ msgstr "El soci ja està inscrit en aquest projecte amb aquestes copes."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Partner is not cooperator."
 msgstr "El soci no és col·laborador."
@@ -2938,6 +3077,7 @@ msgstr "El soci no és col·laborador."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "Partner with VAT {vat} is already registered in project {code}"
 msgstr "El soci amb CIF/NIF {vat} ja està registrat al projecte {code}"
@@ -2945,6 +3085,7 @@ msgstr "El soci amb CIF/NIF {vat} ja està registrat al projecte {code}"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "Partner with VAT:<b>{vat}</b> is not a cooperator."
 msgstr "Col·laborar amb CIF/NIF:<b>{vat}</b> no és un col·laborador."
@@ -2952,6 +3093,7 @@ msgstr "Col·laborar amb CIF/NIF:<b>{vat}</b> no és un col·laborador."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "Partner with VAT:<b>{vat}</b> was not found."
 msgstr "No s'ha trobat el soci amb CIF/NIF:<b>{vat}</b>."
@@ -2976,6 +3118,7 @@ msgstr "Percentatge de potència distribuïda"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Phone"
 msgstr "Telèfon"
@@ -2988,6 +3131,7 @@ msgstr "Potència (kW)"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_define_invoicing_mode_wizard__invoicing_mode__power_acquired
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_invoicing_wizard__invoicing_mode__power_acquired
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_selfconsumption__invoicing_mode__power_acquired
@@ -3023,6 +3167,7 @@ msgstr "Política de privadesa"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Privacy policy file text"
 msgstr "Text del fitxer de la política de privadesa"
@@ -3053,6 +3198,8 @@ msgstr "Projecte"
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Project must have a valid Code."
 msgstr "El projecte ha de tenir un CUP vàlid."
@@ -3061,6 +3208,8 @@ msgstr "El projecte ha de tenir un CUP vàlid."
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Project must have a valid Rated Power."
 msgstr "El projecte ha de tenir una potència nominal vàlida."
@@ -3068,6 +3217,7 @@ msgstr "El projecte ha de tenir una potència nominal vàlida."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Project must have defined a invoicing mode before activation."
 msgstr ""
@@ -3076,6 +3226,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_create_distribution_table_wizard__type_distribute_excess__proportional
 #, python-format
 msgid "Proportional"
@@ -3242,6 +3393,7 @@ msgstr "Recordatori de facturació autoconsum ${ object.name }"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #, python-format
 msgid "Self-consumption project already has a table in process"
 msgstr "El projecte d'autoconsum ja té una taula en tràmit"
@@ -3249,6 +3401,7 @@ msgstr "El projecte d'autoconsum ja té una taula en tràmit"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #, python-format
 msgid "Self-consumption project already has a validated table"
 msgstr "El projecte d'autoconsum ja té una taula validada"
@@ -3451,17 +3604,17 @@ msgstr "Data d’inici de la facturació"
 msgid "State"
 msgstr "Província"
 
+#. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point_assignation__supply_point_state
+msgid "State Name"
+msgstr "Nom de l'estat"
+
 #. module: energy_selfconsumption
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__state
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__state
 msgid "Status"
 msgstr "Estat"
 
-#. module: energy_selfconsumption
-#: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point_assignation__supply_point_state
-msgid "State Name"
-msgstr "Nom de l'estat"
-
 #. module: energy_selfconsumption
 #: model:ir.model.fields,help:energy_selfconsumption.field_energy_selfconsumption_distribution_table__activity_state
 #: model:ir.model.fields,help:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__activity_state
@@ -3565,6 +3718,7 @@ msgstr "Impost ID"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "The IBAN field cannot be empty."
 msgstr "El camp IBAN no pot estar buit."
@@ -3582,6 +3736,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid "The contract has no lines"
 msgstr "El contracte no té línies"
@@ -3589,6 +3744,7 @@ msgstr "El contracte no té línies"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "The email is not the same."
 msgstr "El correu electrònic no és el mateix."
@@ -3597,6 +3753,8 @@ msgstr "El correu electrònic no és el mateix."
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid "The energy generated must be greater than 0 (kWh)."
 msgstr "L'energia generada ha de ser superior a 0 (kWh)."
@@ -3604,6 +3762,7 @@ msgstr "L'energia generada ha de ser superior a 0 (kWh)."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "The file should contain 28 columns and not {header_length} columns."
 msgstr "El fitxer ha de contenir 28 columnes i no {header_length} columnes."
@@ -3611,6 +3770,7 @@ msgstr "El fitxer ha de contenir 28 columnes i no {header_length} columnes."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "The form is not open. For more information write to your Energy Community "
@@ -3622,6 +3782,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid ""
 "The number of contracts selected does not match the number of contracts "
@@ -3633,6 +3794,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point_assignation.py:0
+#: code:addons/energy_selfconsumption/models/supply_point_assignation.py:0
 #, python-format
 msgid "The partner of the supply point is not subscribed to the project"
 msgstr "El soci del punt de subministrament no està subscrit al projecte"
@@ -3640,6 +3802,7 @@ msgstr "El soci del punt de subministrament no està subscrit al projecte"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #, python-format
 msgid "The project has to have a power greater than 0."
 msgstr "El projecte ha de tenir una potència superior a 0."
@@ -3647,6 +3810,7 @@ msgstr "El projecte ha de tenir una potència superior a 0."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid ""
 "The report can be downloaded when the project is in activation or active "
@@ -3662,6 +3826,7 @@ msgstr "La suma de tots els coeficients ha de resultar 1"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
 #, python-format
 msgid ""
 "The sum of coefficients for the following hours is not equal to 1: %s, "
@@ -3670,6 +3835,7 @@ msgstr "La suma de coeficients per les hores següents no és igual a 1: %s, "
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
 #, python-format
 msgid "The sum of coefficients is not equal to 1: %s"
 msgstr "La suma de coeficients no és igual a 1: %s"
@@ -3677,6 +3843,7 @@ msgstr "La suma de coeficients no és igual a 1: %s"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #, python-format
 msgid ""
 "The supply point can't be removed because the distribution table state is "
@@ -3697,6 +3864,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "There is already an individual photovoltaic self-consumption or collective "
@@ -3708,6 +3876,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
 #, python-format
 msgid "There is no distribution table in proces of activation."
 msgstr "No hi ha cap taula de distribució en procés d’activació."
@@ -3732,6 +3901,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
 #, python-format
 msgid "There isn't any supply point with this code: {code}"
 msgstr "No hi ha cap punt de subministrament amb aquest CUPS: {code}"
@@ -3756,6 +3926,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #, python-format
 msgid ""
 "To change the type you must first delete the associated distribution points.\n"
@@ -3825,6 +3996,7 @@ msgstr "Rol actual de l'usuari"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "VAT of the partner"
 msgstr "CIF/NIF del soci"
@@ -3837,6 +4009,7 @@ msgstr "Validar"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_distribution_table__state__validated
 #, python-format
 msgid "Validated"
@@ -3845,6 +4018,7 @@ msgstr "Validat"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_distribution_table__type__hourly
 #, python-format
 msgid "Variable hourly"
@@ -3888,6 +4062,7 @@ msgstr "Historial de la comunicació del lloc web"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "What participation would you like?"
 msgstr "Quina participació t'agradaria?"
@@ -3897,9 +4072,15 @@ msgstr "Quina participació t'agradaria?"
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: code:addons/energy_selfconsumption/models/partner.py:0
+#: code:addons/energy_selfconsumption/models/partner.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_create_distribution_table_wizard__distribute_excess__yes
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_supply_point__used_in_selfconsumption__yes
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__res_partner__vulnerability_situation__yes
@@ -3910,6 +4091,7 @@ msgstr "Sí"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "You are already enrolled in this self-consumption project."
 msgstr "Ja estàs inscrit en aquest projecte d'autoconsum."
@@ -3940,6 +4122,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "You can find the annual electricity use on the electricity bill(Total annual"
@@ -3951,6 +4134,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/clean_supply_point_assignation_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/clean_supply_point_assignation_wizard.py:0
 #, python-format
 msgid ""
 "You can only delete assigned distribution points from a distribution table "
@@ -3962,6 +4146,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/contract_line.py:0
+#: code:addons/energy_selfconsumption/models/contract_line.py:0
 #, python-format
 msgid ""
 "You can't have a date of next invoice anterior to the start of the contract "
@@ -3973,6 +4158,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "You have a recognized situation of vulnerability due to energy poverty or "
@@ -3984,6 +4170,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "You have successfully registered."
 msgstr "Us heu registrat correctament."
@@ -3991,6 +4178,8 @@ msgstr "Us heu registrat correctament."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #, python-format
 msgid "You have to select at least one entry."
@@ -3999,6 +4188,7 @@ msgstr "Heu de seleccionar almenys una entrada."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid ""
 "You need to add the privacy policy file to display the form.To modify the "
@@ -4015,6 +4205,7 @@ msgstr "Les vostres dades s'han registrat correctament."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #, python-format
 msgid "Your distribution percentage cannot be 0."
 msgstr "El vostre percentatge de distribució no pot ser 0."
@@ -4022,6 +4213,7 @@ msgstr "El vostre percentatge de distribució no pot ser 0."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #, python-format
 msgid "Your distribution percentage cannot exceed 100%."
 msgstr "El vostre percentatge de distribució no pot superar el 100%."
@@ -4035,6 +4227,7 @@ msgstr "Codi Postal"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__zip
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point__zip
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point_assignation__supply_point_postalcode
diff --git a/energy_selfconsumption/i18n/energy_selfconsumption.pot b/energy_selfconsumption/i18n/energy_selfconsumption.pot
index 32b4c4509..4dd647183 100644
--- a/energy_selfconsumption/i18n/energy_selfconsumption.pot
+++ b/energy_selfconsumption/i18n/energy_selfconsumption.pot
@@ -6,8 +6,8 @@ msgid ""
 msgstr ""
 "Project-Id-Version: Odoo Server 16.0\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2025-02-13 10:06+0000\n"
-"PO-Revision-Date: 2025-02-13 10:06+0000\n"
+"POT-Creation-Date: 2025-02-19 12:08+0000\n"
+"PO-Revision-Date: 2025-02-19 12:08+0000\n"
 "Last-Translator: \n"
 "Language-Team: \n"
 "MIME-Version: 1.0\n"
@@ -18,17 +18,22 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
 #, python-format
 msgid ""
 "\n"
 "CAU: {cau}\n"
-"Total installed nominal power (kW): {power}\n"
-"Partition coefficient: {coefficient}"
+"                        Total installed nominal power (kW): {power}\n"
+"                        Partition coefficient: {coefficient}\n"
+"                        Daily nominal power acquired: {power} kWn * {coefficient} = {power_acquired} kWn/day\n"
+"                        Days to be invoiced: {days_invoiced} days\n"
+"                        Total amount invoiced:  {days_invoiced} days * {power_acquired} kWn/day = {total_amount}\n"
 msgstr ""
 
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid ""
 "\n"
@@ -40,6 +45,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid ""
 "\n"
@@ -50,6 +56,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid ""
 "\n"
@@ -61,6 +68,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid ""
 "\n"
@@ -391,6 +399,8 @@ msgstr ""
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "<li>Line {line}: {error}</li>\n"
 msgstr ""
@@ -522,6 +532,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: model:ir.model.constraint,message:energy_selfconsumption.constraint_energy_selfconsumption_selfconsumption_unique_code
 #, python-format
 msgid "A project with this CAU already exists."
@@ -530,6 +541,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #: model:ir.model.constraint,message:energy_selfconsumption.constraint_energy_selfconsumption_supply_point_unique_code_company_id
 #, python-format
 msgid "A supply point with this code already exists."
@@ -568,6 +580,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/define_invoicing_mode_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/define_invoicing_mode_wizard.py:0
 #, python-format
 msgid "Accounting Journal not found."
 msgstr ""
@@ -592,8 +605,12 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/inscription.py:0
 #: code:addons/energy_selfconsumption/models/inscription.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_distribution_table__active
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__active
@@ -643,6 +660,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Address"
 msgstr ""
@@ -682,6 +700,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Annual electricity use?"
 msgstr ""
@@ -689,6 +708,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Are you in a vulnerable situation?"
 msgstr ""
@@ -704,6 +724,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/clean_supply_point_assignation_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/clean_supply_point_assignation_wizard.py:0
 #, python-format
 msgid "Are you sure you want to delete all assigned distribution points?"
 msgstr ""
@@ -748,6 +769,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Birthdate"
 msgstr ""
@@ -760,6 +782,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "CIF/NIF"
 msgstr ""
@@ -778,6 +801,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid "CSV file could not be loaded"
 msgstr ""
@@ -785,6 +809,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__code
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point__code
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point_assignation__code
@@ -797,6 +822,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "CUPS is the Unified Code of the Point of Supply. You can find it on "
@@ -806,6 +832,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/define_invoicing_mode_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/define_invoicing_mode_wizard.py:0
 #, python-format
 msgid ""
 "CUPS: {code}\n"
@@ -822,6 +849,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Cadastral reference of the property"
 msgstr ""
@@ -835,6 +863,8 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/inscription.py:0
+#: code:addons/energy_selfconsumption/models/inscription.py:0
+#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_change_state_inscription_lines_wizard__state__change
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_inscription_selfconsumption__state__change
@@ -862,6 +892,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__city
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point__city
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point_assignation__supply_point_town
@@ -884,6 +915,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #: model:ir.actions.server,name:energy_selfconsumption.manager_clean_supply_point_assignation_action
 #, python-format
 msgid "Clean supply point assignation"
@@ -909,6 +941,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point_assignation.py:0
+#: code:addons/energy_selfconsumption/models/supply_point_assignation.py:0
 #, python-format
 msgid "Coefficient can't be negative."
 msgstr ""
@@ -916,6 +949,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #, python-format
 msgid "Coefficient distribution must sum to 1."
 msgstr ""
@@ -932,6 +966,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Company Name"
 msgstr ""
@@ -1001,6 +1036,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Confirm E-mail"
 msgstr ""
@@ -1026,6 +1062,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
 #, python-format
 msgid "Contract - %s - %s"
 msgstr ""
@@ -1193,6 +1230,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_form_view
 #, python-format
 msgid "Define Invoicing Mode"
@@ -1301,6 +1339,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Do you currently have self-consumption?"
 msgstr ""
@@ -1308,6 +1347,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "Dont exit participation for this project."
 msgstr ""
@@ -1339,6 +1379,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_distribution_table__state__draft
 #, python-format
 msgid "Draft"
@@ -1347,6 +1388,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "E-mail"
 msgstr ""
@@ -1440,6 +1482,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_define_invoicing_mode_wizard__invoicing_mode__energy_delivered
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_invoicing_wizard__invoicing_mode__energy_delivered
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_selfconsumption__invoicing_mode__energy_delivered
@@ -1450,6 +1493,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_define_invoicing_mode_wizard__invoicing_mode__energy_custom
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_invoicing_wizard__invoicing_mode__energy_custom
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_selfconsumption__invoicing_mode__energy_custom
@@ -1460,6 +1504,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid "Energy Delivered Custom: {energy_delivered} kWh"
 msgstr ""
@@ -1477,6 +1522,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid "Energy Delivered: {energy_delivered} kWh"
 msgstr ""
@@ -1490,6 +1536,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Energy Project Name"
 msgstr ""
@@ -1522,6 +1569,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Error format date."
 msgstr ""
@@ -1529,8 +1577,11 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "Error parsing the file"
 msgstr ""
@@ -1538,6 +1589,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Error reading file"
 msgstr ""
@@ -1577,6 +1629,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Female"
 msgstr ""
@@ -1632,6 +1685,8 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_create_distribution_table_wizard__type__fixed
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_distribution_table__type__fixed
@@ -1663,6 +1718,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid ""
 "For the 2.0TD rate, the maximum contracted power must be between 0 and 15 "
@@ -1672,6 +1728,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid ""
 "For the 3.0TD rate, the maximum contracted power must be greater than 15 kW."
@@ -1680,6 +1737,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Gender"
 msgstr ""
@@ -1692,6 +1750,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Generate Contracts"
 msgstr ""
@@ -1731,6 +1790,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "Have to accept and authorize being able to issue payments to this bank "
@@ -1741,6 +1801,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Have to accept politic privacy."
 msgstr ""
@@ -1748,6 +1809,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__conf_header_description
 #, python-format
 msgid "Header description on website form"
@@ -1756,6 +1818,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "How much power of the collective PV installation you would like to purchase."
@@ -1764,6 +1827,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__accept
 #, python-format
 msgid ""
@@ -1775,6 +1839,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "I accept privacy policy"
 msgstr ""
@@ -1782,6 +1847,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "I prefer to not share it"
 msgstr ""
@@ -1789,6 +1855,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "IBAN"
 msgstr ""
@@ -1850,6 +1917,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #: model:ir.actions.act_window,name:energy_selfconsumption.distribution_table_import_wizard_action
 #, python-format
 msgid "Import Distribution Table"
@@ -1858,6 +1926,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "Import Errors"
 msgstr ""
@@ -1873,6 +1942,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Import Inscriptions and Supply Points"
 msgstr ""
@@ -1885,6 +1955,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "Import errors found: <ul>{list}</ul>"
 msgstr ""
@@ -1902,6 +1973,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_distribution_table__state__process
 #, python-format
 msgid "In process"
@@ -1916,8 +1988,11 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/inscription.py:0
+#: code:addons/energy_selfconsumption/models/inscription.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_change_state_inscription_lines_wizard__state__inactive
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_inscription_selfconsumption__state__inactive
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_selfconsumption__conf_state__inactive
@@ -1928,6 +2003,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "Information necessary for the formalization of the distribution "
@@ -1974,6 +2050,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CAU: Last 3 digits are not numbers"
 msgstr ""
@@ -1982,6 +2059,8 @@ msgstr ""
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CAU: The CUPS does not start with 'ES'."
 msgstr ""
@@ -1990,6 +2069,8 @@ msgstr ""
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CAU: The CUPS has an incorrect format."
 msgstr ""
@@ -1997,6 +2078,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CAU: The character after CUPS is not A"
 msgstr ""
@@ -2005,6 +2087,8 @@ msgstr ""
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CAU: The checksum of the CUPS is incorrect."
 msgstr ""
@@ -2013,6 +2097,8 @@ msgstr ""
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid ""
 "Invalid CAU: The first characters related to CUPS are incorrect. The length "
@@ -2022,6 +2108,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CAU: The length is not correct"
 msgstr ""
@@ -2029,6 +2116,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CIL: Last 3 digits are not numbers"
 msgstr ""
@@ -2037,6 +2125,8 @@ msgstr ""
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CIL: The CUPS does not start with 'ES'."
 msgstr ""
@@ -2045,6 +2135,8 @@ msgstr ""
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CIL: The CUPS has an incorrect format."
 msgstr ""
@@ -2053,6 +2145,8 @@ msgstr ""
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CIL: The checksum of the CUPS is incorrect."
 msgstr ""
@@ -2061,6 +2155,8 @@ msgstr ""
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid ""
 "Invalid CIL: The first characters related to CUPS are incorrect. The length "
@@ -2070,6 +2166,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CIL: The length is not correct"
 msgstr ""
@@ -2077,6 +2174,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "Invalid CUPS: The checksum is incorrect."
 msgstr ""
@@ -2084,6 +2182,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "Invalid CUPS: The length is incorrect."
 msgstr ""
@@ -2091,6 +2190,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "Invalid CUPS: does not start with 'ES'."
 msgstr ""
@@ -2098,6 +2198,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "Invalid CUPS: has an incorrect format."
 msgstr ""
@@ -2105,6 +2206,8 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "Invalid Cadastral Reference: {error}"
@@ -2113,6 +2216,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "Invalid IBAN: {error}"
 msgstr ""
@@ -2120,6 +2224,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "Invalid VAT: {error}"
 msgstr ""
@@ -2162,6 +2267,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Is the owner the same partner?"
 msgstr ""
@@ -2179,6 +2285,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Lang"
 msgstr ""
@@ -2186,6 +2293,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Language not found."
 msgstr ""
@@ -2273,6 +2381,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Lastname"
 msgstr ""
@@ -2287,6 +2396,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_create_distribution_table_wizard__type_distribute_excess__linear
 #, python-format
 msgid "Linear"
@@ -2336,6 +2446,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Male"
 msgstr ""
@@ -2353,6 +2464,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
 #, python-format
 msgid "Mandate not found for {partner}"
 msgstr ""
@@ -2365,6 +2477,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point__contracted_power
 #, python-format
 msgid "Maximum contracted power"
@@ -2408,6 +2521,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Must have a valid Distribution Table."
 msgstr ""
@@ -2433,6 +2547,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_contract_contract__supply_point_name
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_distribution_table__name
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__name
@@ -2456,6 +2571,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "New Supply Point"
 msgstr ""
@@ -2514,8 +2630,14 @@ msgstr ""
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/models/partner.py:0
 #: code:addons/energy_selfconsumption/models/partner.py:0
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_create_distribution_table_wizard__distribute_excess__no
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_supply_point__used_in_selfconsumption__no
@@ -2527,6 +2649,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "No participation found for this project."
 msgstr ""
@@ -2534,7 +2657,10 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "No valid encoding was found for the attached file"
@@ -2543,6 +2669,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Not binary"
 msgstr ""
@@ -2590,8 +2717,11 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "Only csv format files are accepted."
 msgstr ""
@@ -2599,6 +2729,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Other"
 msgstr ""
@@ -2620,6 +2751,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "Owner could not be created or found."
 msgstr ""
@@ -2646,6 +2778,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Participation does not exist."
 msgstr ""
@@ -2669,6 +2802,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Partner does not exist."
 msgstr ""
@@ -2676,6 +2810,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/inscription.py:0
+#: code:addons/energy_selfconsumption/models/inscription.py:0
 #, python-format
 msgid "Partner is already signed up in this project with that cups."
 msgstr ""
@@ -2683,6 +2818,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Partner is not cooperator."
 msgstr ""
@@ -2690,6 +2826,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "Partner with VAT {vat} is already registered in project {code}"
 msgstr ""
@@ -2697,6 +2834,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "Partner with VAT:<b>{vat}</b> is not a cooperator."
 msgstr ""
@@ -2704,6 +2842,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "Partner with VAT:<b>{vat}</b> was not found."
 msgstr ""
@@ -2728,6 +2867,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Phone"
 msgstr ""
@@ -2740,6 +2880,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_define_invoicing_mode_wizard__invoicing_mode__power_acquired
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_invoicing_wizard__invoicing_mode__power_acquired
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_selfconsumption__invoicing_mode__power_acquired
@@ -2775,6 +2916,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Privacy policy file text"
 msgstr ""
@@ -2805,6 +2947,8 @@ msgstr ""
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Project must have a valid Code."
 msgstr ""
@@ -2813,6 +2957,8 @@ msgstr ""
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Project must have a valid Rated Power."
 msgstr ""
@@ -2820,6 +2966,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Project must have defined a invoicing mode before activation."
 msgstr ""
@@ -2827,6 +2974,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_create_distribution_table_wizard__type_distribute_excess__proportional
 #, python-format
 msgid "Proportional"
@@ -2990,6 +3138,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #, python-format
 msgid "Self-consumption project already has a table in process"
 msgstr ""
@@ -2997,6 +3146,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #, python-format
 msgid "Self-consumption project already has a validated table"
 msgstr ""
@@ -3190,14 +3340,14 @@ msgid "State"
 msgstr ""
 
 #. module: energy_selfconsumption
-#: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__state
-#: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__state
-msgid "Status"
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point_assignation__supply_point_state
+msgid "State Name"
 msgstr ""
 
 #. module: energy_selfconsumption
-#: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point_assignation__supply_point_state
-msgid "State Name"
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__state
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__state
+msgid "Status"
 msgstr ""
 
 #. module: energy_selfconsumption
@@ -3299,6 +3449,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "The IBAN field cannot be empty."
 msgstr ""
@@ -3314,6 +3465,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid "The contract has no lines"
 msgstr ""
@@ -3321,6 +3473,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "The email is not the same."
 msgstr ""
@@ -3329,6 +3482,8 @@ msgstr ""
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid "The energy generated must be greater than 0 (kWh)."
 msgstr ""
@@ -3336,6 +3491,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "The file should contain 28 columns and not {header_length} columns."
 msgstr ""
@@ -3343,6 +3499,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "The form is not open. For more information write to your Energy Community "
@@ -3352,6 +3509,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid ""
 "The number of contracts selected does not match the number of contracts "
@@ -3361,6 +3519,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point_assignation.py:0
+#: code:addons/energy_selfconsumption/models/supply_point_assignation.py:0
 #, python-format
 msgid "The partner of the supply point is not subscribed to the project"
 msgstr ""
@@ -3368,6 +3527,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #, python-format
 msgid "The project has to have a power greater than 0."
 msgstr ""
@@ -3375,6 +3535,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid ""
 "The report can be downloaded when the project is in activation or active "
@@ -3389,6 +3550,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
 #, python-format
 msgid ""
 "The sum of coefficients for the following hours is not equal to 1: %s, "
@@ -3397,6 +3559,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
 #, python-format
 msgid "The sum of coefficients is not equal to 1: %s"
 msgstr ""
@@ -3404,6 +3567,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #, python-format
 msgid ""
 "The supply point can't be removed because the distribution table state is "
@@ -3420,6 +3584,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "There is already an individual photovoltaic self-consumption or collective "
@@ -3429,6 +3594,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
 #, python-format
 msgid "There is no distribution table in proces of activation."
 msgstr ""
@@ -3451,6 +3617,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
 #, python-format
 msgid "There isn't any supply point with this code: {code}"
 msgstr ""
@@ -3472,6 +3639,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #, python-format
 msgid ""
 "To change the type you must first delete the associated distribution points.\n"
@@ -3537,6 +3705,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "VAT of the partner"
 msgstr ""
@@ -3549,6 +3718,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_distribution_table__state__validated
 #, python-format
 msgid "Validated"
@@ -3557,6 +3727,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_distribution_table__type__hourly
 #, python-format
 msgid "Variable hourly"
@@ -3598,6 +3769,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "What participation would you like?"
 msgstr ""
@@ -3607,9 +3779,15 @@ msgstr ""
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: code:addons/energy_selfconsumption/models/partner.py:0
+#: code:addons/energy_selfconsumption/models/partner.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_create_distribution_table_wizard__distribute_excess__yes
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_supply_point__used_in_selfconsumption__yes
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__res_partner__vulnerability_situation__yes
@@ -3620,6 +3798,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "You are already enrolled in this self-consumption project."
 msgstr ""
@@ -3646,6 +3825,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "You can find the annual electricity use on the electricity bill(Total annual"
@@ -3655,6 +3835,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/clean_supply_point_assignation_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/clean_supply_point_assignation_wizard.py:0
 #, python-format
 msgid ""
 "You can only delete assigned distribution points from a distribution table "
@@ -3664,6 +3845,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/contract_line.py:0
+#: code:addons/energy_selfconsumption/models/contract_line.py:0
 #, python-format
 msgid ""
 "You can't have a date of next invoice anterior to the start of the contract "
@@ -3673,6 +3855,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "You have a recognized situation of vulnerability due to energy poverty or "
@@ -3682,6 +3865,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "You have successfully registered."
 msgstr ""
@@ -3689,6 +3873,8 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #, python-format
 msgid "You have to select at least one entry."
@@ -3697,6 +3883,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid ""
 "You need to add the privacy policy file to display the form.To modify the "
@@ -3711,6 +3898,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #, python-format
 msgid "Your distribution percentage cannot be 0."
 msgstr ""
@@ -3718,6 +3906,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #, python-format
 msgid "Your distribution percentage cannot exceed 100%."
 msgstr ""
@@ -3731,6 +3920,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__zip
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point__zip
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point_assignation__supply_point_postalcode
diff --git a/energy_selfconsumption/i18n/es.po b/energy_selfconsumption/i18n/es.po
index 37f5a4743..45cdea263 100644
--- a/energy_selfconsumption/i18n/es.po
+++ b/energy_selfconsumption/i18n/es.po
@@ -6,8 +6,8 @@ msgid ""
 msgstr ""
 "Project-Id-Version: Odoo Server 16.0\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2025-02-13 10:04+0000\n"
-"PO-Revision-Date: 2025-02-13 10:04+0000\n"
+"POT-Creation-Date: 2025-02-19 12:10+0000\n"
+"PO-Revision-Date: 2025-02-19 12:10+0000\n"
 "Last-Translator: \n"
 "Language-Team: \n"
 "MIME-Version: 1.0\n"
@@ -18,21 +18,29 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
 #, python-format
 msgid ""
 "\n"
 "CAU: {cau}\n"
-"Total installed nominal power (kW): {power}\n"
-"Partition coefficient: {coefficient}"
+"                        Total installed nominal power (kW): {power}\n"
+"                        Partition coefficient: {coefficient}\n"
+"                        Daily nominal power acquired: {power} kWn * {coefficient} = {power_acquired} kWn/day\n"
+"                        Days to be invoiced: {days_invoiced} days\n"
+"                        Total amount invoiced:  {days_invoiced} days * {power_acquired} kWn/day = {total_amount}\n"
 msgstr ""
 "\n"
 "CAU: {cau}\n"
-"Potencia nominal total instalada (kW): {power}\n"
-"Coeficiente de partición: {coefficient}"
+"                        Poténcia nominal instalada total (kW): {power}\n"
+"                        Coeficient de partición: {coefficient}\n"
+"                        Poténcia nominal adquirida diaria: {power} kWn * {coefficient} = {power_acquired} kWn/día\n"
+"                        Días a facturar: {days_invoiced} días\n"
+"                        Cantidad total a facturar:  {days_invoiced} días * {power_acquired} kWn/día = {total_amount}\n"
 
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid ""
 "\n"
@@ -48,6 +56,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid ""
 "\n"
@@ -60,6 +69,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid ""
 "\n"
@@ -74,6 +84,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid ""
 "\n"
@@ -502,6 +513,8 @@ msgstr ""
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "<li>Line {line}: {error}</li>\n"
 msgstr "<li>Línea {line}: {error}</li>"
@@ -638,6 +651,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: model:ir.model.constraint,message:energy_selfconsumption.constraint_energy_selfconsumption_selfconsumption_unique_code
 #, python-format
 msgid "A project with this CAU already exists."
@@ -646,6 +660,7 @@ msgstr "Ya existe un proyecto con esta CAU."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #: model:ir.model.constraint,message:energy_selfconsumption.constraint_energy_selfconsumption_supply_point_unique_code_company_id
 #, python-format
 msgid "A supply point with this code already exists."
@@ -684,6 +699,7 @@ msgstr "Número de cuenta"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/define_invoicing_mode_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/define_invoicing_mode_wizard.py:0
 #, python-format
 msgid "Accounting Journal not found."
 msgstr "Diario de contabilidad no encontrado."
@@ -708,8 +724,12 @@ msgstr "Activar formulario"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/inscription.py:0
 #: code:addons/energy_selfconsumption/models/inscription.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_distribution_table__active
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__active
@@ -759,6 +779,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Address"
 msgstr "Dirección"
@@ -800,6 +821,7 @@ msgstr "Consumo anual de electricidad"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Annual electricity use?"
 msgstr "¿Consumo anual de electricidad?"
@@ -807,6 +829,7 @@ msgstr "¿Consumo anual de electricidad?"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Are you in a vulnerable situation?"
 msgstr "¿Se encuentra en una situación vulnerable?"
@@ -825,6 +848,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/clean_supply_point_assignation_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/clean_supply_point_assignation_wizard.py:0
 #, python-format
 msgid "Are you sure you want to delete all assigned distribution points?"
 msgstr ""
@@ -871,6 +895,7 @@ msgstr "Período de facturación"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Birthdate"
 msgstr "Fecha de nacimiento"
@@ -883,6 +908,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "CIF/NIF"
 msgstr ""
@@ -901,6 +927,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid "CSV file could not be loaded"
 msgstr "No se ha podido cargar el archivo CSV"
@@ -908,6 +935,7 @@ msgstr "No se ha podido cargar el archivo CSV"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__code
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point__code
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point_assignation__code
@@ -920,6 +948,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "CUPS is the Unified Code of the Point of Supply. You can find it on "
@@ -931,6 +960,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/define_invoicing_mode_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/define_invoicing_mode_wizard.py:0
 #, python-format
 msgid ""
 "CUPS: {code}\n"
@@ -950,6 +980,7 @@ msgstr "Referencia catastral"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Cadastral reference of the property"
 msgstr "Referencia catastral de la propiedad"
@@ -963,6 +994,8 @@ msgstr "Cancelar"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/inscription.py:0
+#: code:addons/energy_selfconsumption/models/inscription.py:0
+#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_change_state_inscription_lines_wizard__state__change
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_inscription_selfconsumption__state__change
@@ -990,6 +1023,7 @@ msgstr "Cambiar estado de inscripción"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__city
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point__city
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point_assignation__supply_point_town
@@ -1012,6 +1046,7 @@ msgstr "Asistente para la asignación de puntos de suministro limpios"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #: model:ir.actions.server,name:energy_selfconsumption.manager_clean_supply_point_assignation_action
 #, python-format
 msgid "Clean supply point assignation"
@@ -1037,6 +1072,7 @@ msgstr "El coeficiente es válido"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point_assignation.py:0
+#: code:addons/energy_selfconsumption/models/supply_point_assignation.py:0
 #, python-format
 msgid "Coefficient can't be negative."
 msgstr "El coeficiente no puede ser negativo."
@@ -1044,6 +1080,7 @@ msgstr "El coeficiente no puede ser negativo."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #, python-format
 msgid "Coefficient distribution must sum to 1."
 msgstr "La distribución de coeficientes debe sumar 1."
@@ -1060,6 +1097,7 @@ msgstr "Compañía"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Company Name"
 msgstr "Nombre de la empresa"
@@ -1133,6 +1171,7 @@ msgstr "Confirmar"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Confirm E-mail"
 msgstr "Confirmar e-mail"
@@ -1158,6 +1197,7 @@ msgstr "Contrato"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
 #, python-format
 msgid "Contract - %s - %s"
 msgstr "Contrato - %s - %s"
@@ -1325,6 +1365,7 @@ msgstr "Días facturados"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_form_view
 #, python-format
 msgid "Define Invoicing Mode"
@@ -1435,6 +1476,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Do you currently have self-consumption?"
 msgstr "¿Tiene actualmente autoconsumo?"
@@ -1442,6 +1484,7 @@ msgstr "¿Tiene actualmente autoconsumo?"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "Dont exit participation for this project."
 msgstr "No salga de la participación en este proyecto."
@@ -1475,6 +1518,7 @@ msgstr "Descargar Autorización del Gestor de Autoconsumo"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_distribution_table__state__draft
 #, python-format
 msgid "Draft"
@@ -1483,6 +1527,7 @@ msgstr "Borrador"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "E-mail"
 msgstr ""
@@ -1584,6 +1629,7 @@ msgstr "Final"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_define_invoicing_mode_wizard__invoicing_mode__energy_delivered
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_invoicing_wizard__invoicing_mode__energy_delivered
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_selfconsumption__invoicing_mode__energy_delivered
@@ -1594,6 +1640,7 @@ msgstr "Energía Entregada"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_define_invoicing_mode_wizard__invoicing_mode__energy_custom
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_invoicing_wizard__invoicing_mode__energy_custom
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_selfconsumption__invoicing_mode__energy_custom
@@ -1604,6 +1651,7 @@ msgstr "Energía entregada personalizada"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid "Energy Delivered Custom: {energy_delivered} kWh"
 msgstr "Energía entregada personalizada: {energy_delivered} kWh"
@@ -1621,6 +1669,7 @@ msgstr "Fórmula Variable de Energía Entregada"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid "Energy Delivered: {energy_delivered} kWh"
 msgstr "Energía Entregada: {energy_delivered} kWh"
@@ -1634,6 +1683,7 @@ msgstr "Proyecto Energético"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Energy Project Name"
 msgstr "Nombre del proyecto energético"
@@ -1666,6 +1716,7 @@ msgstr "Inscripción en el proyecto de autoconsumo compartido del"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Error format date."
 msgstr "Error de formato de fecha."
@@ -1673,8 +1724,11 @@ msgstr "Error de formato de fecha."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "Error parsing the file"
 msgstr "Error al analizar el archivo"
@@ -1682,6 +1736,7 @@ msgstr "Error al analizar el archivo"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Error reading file"
 msgstr "Error de lectura en archivo"
@@ -1721,6 +1776,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Female"
 msgstr "Mujer"
@@ -1776,6 +1832,8 @@ msgstr "Nombre"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_create_distribution_table_wizard__type__fixed
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_distribution_table__type__fixed
@@ -1807,6 +1865,7 @@ msgstr "Icono de fuente impresionante, p. fa-tasks"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid ""
 "For the 2.0TD rate, the maximum contracted power must be between 0 and 15 "
@@ -1818,6 +1877,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid ""
 "For the 3.0TD rate, the maximum contracted power must be greater than 15 kW."
@@ -1828,6 +1888,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Gender"
 msgstr "Género"
@@ -1840,6 +1901,7 @@ msgstr "Generar"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Generate Contracts"
 msgstr "Generar Contratos"
@@ -1879,6 +1941,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "Have to accept and authorize being able to issue payments to this bank "
@@ -1892,6 +1955,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Have to accept politic privacy."
 msgstr "Tienes que aceptar la política de privacidad."
@@ -1899,6 +1963,7 @@ msgstr "Tienes que aceptar la política de privacidad."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__conf_header_description
 #, python-format
 msgid "Header description on website form"
@@ -1907,6 +1972,7 @@ msgstr "Descripción de la cabecera en el formulario del sitio web"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "How much power of the collective PV installation you would like to purchase."
@@ -1916,6 +1982,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__accept
 #, python-format
 msgid ""
@@ -1930,6 +1997,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "I accept privacy policy"
 msgstr "Acepto la política de privacidad"
@@ -1937,6 +2005,7 @@ msgstr "Acepto la política de privacidad"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "I prefer to not share it"
 msgstr "Prefiero no compartirlo"
@@ -1944,6 +2013,7 @@ msgstr "Prefiero no compartirlo"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "IBAN"
 msgstr ""
@@ -2005,6 +2075,7 @@ msgstr "Importar"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #: model:ir.actions.act_window,name:energy_selfconsumption.distribution_table_import_wizard_action
 #, python-format
 msgid "Import Distribution Table"
@@ -2013,6 +2084,7 @@ msgstr "Importar tabla de distribución"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "Import Errors"
 msgstr "Importar errores"
@@ -2028,6 +2100,7 @@ msgstr "Importar archivo (*.csv)"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Import Inscriptions and Supply Points"
 msgstr "Importar inscripciones y puntos de suministro"
@@ -2040,6 +2113,7 @@ msgstr "Importar datos"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "Import errors found: <ul>{list}</ul>"
 msgstr "Se han encontrado errores de importación: <ul>{list}</ul>"
@@ -2057,6 +2131,7 @@ msgstr "Importar tabla"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_distribution_table__state__process
 #, python-format
 msgid "In process"
@@ -2073,8 +2148,11 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/inscription.py:0
+#: code:addons/energy_selfconsumption/models/inscription.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_change_state_inscription_lines_wizard__state__inactive
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_inscription_selfconsumption__state__inactive
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_selfconsumption__conf_state__inactive
@@ -2085,6 +2163,7 @@ msgstr "Inactivo"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "Information necessary for the formalization of the distribution "
@@ -2133,6 +2212,7 @@ msgstr "Instalación:"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CAU: Last 3 digits are not numbers"
 msgstr "CAU no válida: los últimos 3 dígitos no son números"
@@ -2141,6 +2221,8 @@ msgstr "CAU no válida: los últimos 3 dígitos no son números"
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CAU: The CUPS does not start with 'ES'."
 msgstr "CAU no válida: El CUPS no comienza con 'ES'."
@@ -2149,6 +2231,8 @@ msgstr "CAU no válida: El CUPS no comienza con 'ES'."
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CAU: The CUPS has an incorrect format."
 msgstr "CAU no válido: El CUPS tiene un formato incorrecto."
@@ -2156,6 +2240,7 @@ msgstr "CAU no válido: El CUPS tiene un formato incorrecto."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CAU: The character after CUPS is not A"
 msgstr "CAU no válida: el carácter después de CUPS no es A"
@@ -2164,6 +2249,8 @@ msgstr "CAU no válida: el carácter después de CUPS no es A"
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CAU: The checksum of the CUPS is incorrect."
 msgstr "CAU no válida: la suma de comprobación del CUPS es incorrecta."
@@ -2172,6 +2259,8 @@ msgstr "CAU no válida: la suma de comprobación del CUPS es incorrecta."
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid ""
 "Invalid CAU: The first characters related to CUPS are incorrect. The length "
@@ -2183,6 +2272,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CAU: The length is not correct"
 msgstr "CAU no válida: la longitud no es correcta"
@@ -2190,6 +2280,7 @@ msgstr "CAU no válida: la longitud no es correcta"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CIL: Last 3 digits are not numbers"
 msgstr "CIL no válido: los últimos 3 dígitos no son números"
@@ -2198,6 +2289,8 @@ msgstr "CIL no válido: los últimos 3 dígitos no son números"
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CIL: The CUPS does not start with 'ES'."
 msgstr "CIL no válido: CUPS no comienza con 'ES'."
@@ -2206,6 +2299,8 @@ msgstr "CIL no válido: CUPS no comienza con 'ES'."
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CIL: The CUPS has an incorrect format."
 msgstr "CIL no válido: El CUPS tiene un formato incorrecto."
@@ -2214,6 +2309,8 @@ msgstr "CIL no válido: El CUPS tiene un formato incorrecto."
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CIL: The checksum of the CUPS is incorrect."
 msgstr "CIL no válido: la suma de comprobación de CUPS es incorrecta."
@@ -2222,6 +2319,8 @@ msgstr "CIL no válido: la suma de comprobación de CUPS es incorrecta."
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid ""
 "Invalid CIL: The first characters related to CUPS are incorrect. The length "
@@ -2233,6 +2332,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CIL: The length is not correct"
 msgstr "CIL no válido: la longitud no es correcta"
@@ -2240,6 +2340,7 @@ msgstr "CIL no válido: la longitud no es correcta"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "Invalid CUPS: The checksum is incorrect."
 msgstr "CUPS no válidos: la suma de comprobación es incorrecta."
@@ -2247,6 +2348,7 @@ msgstr "CUPS no válidos: la suma de comprobación es incorrecta."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "Invalid CUPS: The length is incorrect."
 msgstr "CUPS no válidos: La longitud es incorrecta."
@@ -2254,6 +2356,7 @@ msgstr "CUPS no válidos: La longitud es incorrecta."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "Invalid CUPS: does not start with 'ES'."
 msgstr "CUPS no válidos: no comienza con 'ES'."
@@ -2261,6 +2364,7 @@ msgstr "CUPS no válidos: no comienza con 'ES'."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "Invalid CUPS: has an incorrect format."
 msgstr "CUPS no válidos: tiene un formato incorrecto."
@@ -2268,6 +2372,8 @@ msgstr "CUPS no válidos: tiene un formato incorrecto."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "Invalid Cadastral Reference: {error}"
@@ -2276,6 +2382,7 @@ msgstr "Referencia catastral no válida: {error}"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "Invalid IBAN: {error}"
 msgstr "IBAN no válido: {error}"
@@ -2283,6 +2390,7 @@ msgstr "IBAN no válido: {error}"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "Invalid VAT: {error}"
 msgstr "NIF/CIF no válido: {error}"
@@ -2325,6 +2433,7 @@ msgstr "Es seguidor"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Is the owner the same partner?"
 msgstr "¿El titular es el mismo socio?"
@@ -2342,6 +2451,7 @@ msgstr "Apunte contable"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Lang"
 msgstr "Idioma"
@@ -2349,6 +2459,7 @@ msgstr "Idioma"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Language not found."
 msgstr "Idioma no encontrado."
@@ -2436,6 +2547,7 @@ msgstr "Apellido"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Lastname"
 msgstr "Apellido"
@@ -2450,6 +2562,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_create_distribution_table_wizard__type_distribute_excess__linear
 #, python-format
 msgid "Linear"
@@ -2499,6 +2612,7 @@ msgstr "Línea principal"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Male"
 msgstr "Hombre"
@@ -2516,6 +2630,7 @@ msgstr "Mandato Filtrado"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
 #, python-format
 msgid "Mandate not found for {partner}"
 msgstr "Mandato no encontrado para {partner}"
@@ -2528,6 +2643,7 @@ msgstr "Potencia máxima distribuida"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point__contracted_power
 #, python-format
 msgid "Maximum contracted power"
@@ -2571,6 +2687,7 @@ msgstr "Modalidad"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Must have a valid Distribution Table."
 msgstr "Debe tener una tabla de distribución válida."
@@ -2596,6 +2713,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_contract_contract__supply_point_name
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_distribution_table__name
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__name
@@ -2619,6 +2737,7 @@ msgstr "Datos necesarios para la integración de la Comunidad:"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "New Supply Point"
 msgstr "Nuevo Punto de Suministro"
@@ -2677,8 +2796,14 @@ msgstr "Próximo Período de Comienzo"
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/models/partner.py:0
 #: code:addons/energy_selfconsumption/models/partner.py:0
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_create_distribution_table_wizard__distribute_excess__no
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_supply_point__used_in_selfconsumption__no
@@ -2690,6 +2815,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "No participation found for this project."
 msgstr "No se ha encontrado participación para este proyecto."
@@ -2697,7 +2823,10 @@ msgstr "No se ha encontrado participación para este proyecto."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "No valid encoding was found for the attached file"
@@ -2707,6 +2836,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Not binary"
 msgstr "No binario"
@@ -2756,8 +2886,11 @@ msgstr "OTROS DATOS NECESARIOS"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "Only csv format files are accepted."
 msgstr "Solo se aceptan archivos en formato csv."
@@ -2765,6 +2898,7 @@ msgstr "Solo se aceptan archivos en formato csv."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Other"
 msgstr "Otros"
@@ -2786,6 +2920,7 @@ msgstr "Suministro del propietario"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "Owner could not be created or found."
 msgstr "No se ha podido crear o encontrar al propietario."
@@ -2812,6 +2947,7 @@ msgstr "Participación"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Participation does not exist."
 msgstr "La participación no existe."
@@ -2835,6 +2971,7 @@ msgstr "Socio"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Partner does not exist."
 msgstr "El socio no existe."
@@ -2842,6 +2979,7 @@ msgstr "El socio no existe."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/inscription.py:0
+#: code:addons/energy_selfconsumption/models/inscription.py:0
 #, python-format
 msgid "Partner is already signed up in this project with that cups."
 msgstr "El socio ya está inscrito en este proyecto con esas copas."
@@ -2849,6 +2987,7 @@ msgstr "El socio ya está inscrito en este proyecto con esas copas."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Partner is not cooperator."
 msgstr "Socio no es cooperador."
@@ -2856,6 +2995,7 @@ msgstr "Socio no es cooperador."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "Partner with VAT {vat} is already registered in project {code}"
 msgstr "Socio con CIF/NIF {vat} ya está registrado en el proyecto {code}"
@@ -2863,6 +3003,7 @@ msgstr "Socio con CIF/NIF {vat} ya está registrado en el proyecto {code}"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "Partner with VAT:<b>{vat}</b> is not a cooperator."
 msgstr "Colaborador con CIF/NIF:<b>{vat}</b> no es un colaborador."
@@ -2870,6 +3011,7 @@ msgstr "Colaborador con CIF/NIF:<b>{vat}</b> no es un colaborador."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "Partner with VAT:<b>{vat}</b> was not found."
 msgstr "No se ha encontrado socio con CIF/NIF:<b>{vat}</b>."
@@ -2894,6 +3036,7 @@ msgstr "Porcentaje de energía distribuida"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Phone"
 msgstr "Teléfono"
@@ -2906,6 +3049,7 @@ msgstr "Potencia (kW)"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_define_invoicing_mode_wizard__invoicing_mode__power_acquired
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_invoicing_wizard__invoicing_mode__power_acquired
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_selfconsumption__invoicing_mode__power_acquired
@@ -2941,6 +3085,7 @@ msgstr "Política de privacidad"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Privacy policy file text"
 msgstr "Texto del archivo de política de privacidad"
@@ -2971,6 +3116,8 @@ msgstr "Proyecto"
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Project must have a valid Code."
 msgstr "El proyecto debe tener un código CUP válido."
@@ -2979,6 +3126,8 @@ msgstr "El proyecto debe tener un código CUP válido."
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Project must have a valid Rated Power."
 msgstr "El proyecto debe tener una potencia nominal válida."
@@ -2986,6 +3135,7 @@ msgstr "El proyecto debe tener una potencia nominal válida."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Project must have defined a invoicing mode before activation."
 msgstr ""
@@ -2995,6 +3145,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_create_distribution_table_wizard__type_distribute_excess__proportional
 #, python-format
 msgid "Proportional"
@@ -3162,6 +3313,7 @@ msgstr "Recordatorio de facturación autoconsumo ${ object.name }"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #, python-format
 msgid "Self-consumption project already has a table in process"
 msgstr "El proyecto de autoconsumo ya tiene una tabla en proceso"
@@ -3169,6 +3321,7 @@ msgstr "El proyecto de autoconsumo ya tiene una tabla en proceso"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #, python-format
 msgid "Self-consumption project already has a validated table"
 msgstr "El proyecto de autoconsumo ya tiene una tabla validada"
@@ -3370,17 +3523,17 @@ msgstr "Fecha de inicio de la facturación"
 msgid "State"
 msgstr "Provincia"
 
+#. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point_assignation__supply_point_state
+msgid "State Name"
+msgstr "Nombre del Estado"
+
 #. module: energy_selfconsumption
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__state
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__state
 msgid "Status"
 msgstr "Estado"
 
-#. module: energy_selfconsumption
-#: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point_assignation__supply_point_state
-msgid "State Name"
-msgstr "Nombre del Estado"
-
 #. module: energy_selfconsumption
 #: model:ir.model.fields,help:energy_selfconsumption.field_energy_selfconsumption_distribution_table__activity_state
 #: model:ir.model.fields,help:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__activity_state
@@ -3484,6 +3637,7 @@ msgstr "Impuesto ID"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "The IBAN field cannot be empty."
 msgstr "El campo IBAN no puede estar vacío."
@@ -3501,6 +3655,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid "The contract has no lines"
 msgstr "El contrato no tiene líneas"
@@ -3508,6 +3663,7 @@ msgstr "El contrato no tiene líneas"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "The email is not the same."
 msgstr "El correo electrónico no es el mismo."
@@ -3516,6 +3672,8 @@ msgstr "El correo electrónico no es el mismo."
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid "The energy generated must be greater than 0 (kWh)."
 msgstr "La energía generada debe ser superior a 0 (kWh)."
@@ -3523,6 +3681,7 @@ msgstr "La energía generada debe ser superior a 0 (kWh)."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "The file should contain 28 columns and not {header_length} columns."
 msgstr "El archivo debe contener 28 columnas y no {header_length} columnas."
@@ -3530,6 +3689,7 @@ msgstr "El archivo debe contener 28 columnas y no {header_length} columnas."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "The form is not open. For more information write to your Energy Community "
@@ -3541,6 +3701,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid ""
 "The number of contracts selected does not match the number of contracts "
@@ -3552,6 +3713,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point_assignation.py:0
+#: code:addons/energy_selfconsumption/models/supply_point_assignation.py:0
 #, python-format
 msgid "The partner of the supply point is not subscribed to the project"
 msgstr "El socio del punto de suministro no está suscrito al proyecto"
@@ -3559,6 +3721,7 @@ msgstr "El socio del punto de suministro no está suscrito al proyecto"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #, python-format
 msgid "The project has to have a power greater than 0."
 msgstr "El proyecto debe tener una potencia superior a 0."
@@ -3566,6 +3729,7 @@ msgstr "El proyecto debe tener una potencia superior a 0."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid ""
 "The report can be downloaded when the project is in activation or active "
@@ -3582,6 +3746,7 @@ msgstr "La suma de todos los coeficientes debe dar como resultado 1"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
 #, python-format
 msgid ""
 "The sum of coefficients for the following hours is not equal to 1: %s, "
@@ -3591,6 +3756,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
 #, python-format
 msgid "The sum of coefficients is not equal to 1: %s"
 msgstr "La suma de los coeficiente no es igual a 1: %s"
@@ -3598,6 +3764,7 @@ msgstr "La suma de los coeficiente no es igual a 1: %s"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #, python-format
 msgid ""
 "The supply point can't be removed because the distribution table state is "
@@ -3618,6 +3785,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "There is already an individual photovoltaic self-consumption or collective "
@@ -3629,6 +3797,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
 #, python-format
 msgid "There is no distribution table in proces of activation."
 msgstr "No existe tabla de distribución en proceso de activación."
@@ -3654,6 +3823,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
 #, python-format
 msgid "There isn't any supply point with this code: {code}"
 msgstr "No hay ningún punto de suministro con este código: {code}"
@@ -3678,6 +3848,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #, python-format
 msgid ""
 "To change the type you must first delete the associated distribution points.\n"
@@ -3747,6 +3918,7 @@ msgstr "Rol actual del usuario"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "VAT of the partner"
 msgstr "CIF/NIF del socio"
@@ -3759,6 +3931,7 @@ msgstr "Validar"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_distribution_table__state__validated
 #, python-format
 msgid "Validated"
@@ -3767,6 +3940,7 @@ msgstr "Validado"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_distribution_table__type__hourly
 #, python-format
 msgid "Variable hourly"
@@ -3810,6 +3984,7 @@ msgstr "Historial de comunicaciones del sitio web"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "What participation would you like?"
 msgstr "¿Qué participación le gustaría?"
@@ -3819,9 +3994,15 @@ msgstr "¿Qué participación le gustaría?"
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: code:addons/energy_selfconsumption/models/partner.py:0
+#: code:addons/energy_selfconsumption/models/partner.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_create_distribution_table_wizard__distribute_excess__yes
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_supply_point__used_in_selfconsumption__yes
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__res_partner__vulnerability_situation__yes
@@ -3832,6 +4013,7 @@ msgstr "Sí"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "You are already enrolled in this self-consumption project."
 msgstr "Ya estás inscrito en este proyecto de autoconsumo."
@@ -3862,6 +4044,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "You can find the annual electricity use on the electricity bill(Total annual"
@@ -3873,6 +4056,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/clean_supply_point_assignation_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/clean_supply_point_assignation_wizard.py:0
 #, python-format
 msgid ""
 "You can only delete assigned distribution points from a distribution table "
@@ -3884,6 +4068,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/contract_line.py:0
+#: code:addons/energy_selfconsumption/models/contract_line.py:0
 #, python-format
 msgid ""
 "You can't have a date of next invoice anterior to the start of the contract "
@@ -3895,6 +4080,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "You have a recognized situation of vulnerability due to energy poverty or "
@@ -3906,6 +4092,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "You have successfully registered."
 msgstr "Se ha registrado correctamente."
@@ -3913,6 +4100,8 @@ msgstr "Se ha registrado correctamente."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #, python-format
 msgid "You have to select at least one entry."
@@ -3921,6 +4110,7 @@ msgstr "Debe seleccionar al menos una entrada."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid ""
 "You need to add the privacy policy file to display the form.To modify the "
@@ -3938,6 +4128,7 @@ msgstr "Sus datos se han registrado correctamente."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #, python-format
 msgid "Your distribution percentage cannot be 0."
 msgstr "Su porcentaje de distribución no puede ser 0."
@@ -3945,6 +4136,7 @@ msgstr "Su porcentaje de distribución no puede ser 0."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #, python-format
 msgid "Your distribution percentage cannot exceed 100%."
 msgstr "Su porcentaje de distribución no puede superar el 100%."
@@ -3958,6 +4150,7 @@ msgstr "Código Postal"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__zip
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point__zip
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point_assignation__supply_point_postalcode
diff --git a/energy_selfconsumption/i18n/eu_ES.po b/energy_selfconsumption/i18n/eu_ES.po
index 47ddfa4a2..af1a7e630 100644
--- a/energy_selfconsumption/i18n/eu_ES.po
+++ b/energy_selfconsumption/i18n/eu_ES.po
@@ -6,8 +6,8 @@ msgid ""
 msgstr ""
 "Project-Id-Version: Odoo Server 16.0\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2025-02-13 10:05+0000\n"
-"PO-Revision-Date: 2025-02-13 10:05+0000\n"
+"POT-Creation-Date: 2025-02-19 12:09+0000\n"
+"PO-Revision-Date: 2025-02-19 12:09+0000\n"
 "Last-Translator: \n"
 "Language-Team: \n"
 "MIME-Version: 1.0\n"
@@ -18,21 +18,29 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
 #, python-format
 msgid ""
 "\n"
 "CAU: {cau}\n"
-"Total installed nominal power (kW): {power}\n"
-"Partition coefficient: {coefficient}"
+"                        Total installed nominal power (kW): {power}\n"
+"                        Partition coefficient: {coefficient}\n"
+"                        Daily nominal power acquired: {power} kWn * {coefficient} = {power_acquired} kWn/day\n"
+"                        Days to be invoiced: {days_invoiced} days\n"
+"                        Total amount invoiced:  {days_invoiced} days * {power_acquired} kWn/day = {total_amount}\n"
 msgstr ""
 "\n"
 "CAU: {cau}\n"
-"Instalatutako potentzia nominala guztira (kW): {power}\n"
-"Zatiketa koefizientea: {coefficient}"
+"                        Instalatutako potentzia nominala guztira (kW): {power}\n"
+"                        Zatiketa koefizientea: {coefficient}\n"
+"                        Eguneko potentzia nominala: {power} kWn * {coefficient} = {power_acquired} kWn/egun\n"
+"                        Fakturatzeko egunak: {days_invoiced} egun\n"
+"                        Fakturatzeko kopurua:  {days_invoiced} egun * {power_acquired} kWn/egun = {total_amount}\n"
 
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid ""
 "\n"
@@ -44,6 +52,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid ""
 "\n"
@@ -56,6 +65,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid ""
 "\n"
@@ -70,6 +80,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid ""
 "\n"
@@ -510,6 +521,8 @@ msgstr ""
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "<li>Line {line}: {error}</li>\n"
 msgstr "<li>Lerroa {line}: {error}</li>\n"
@@ -659,6 +672,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: model:ir.model.constraint,message:energy_selfconsumption.constraint_energy_selfconsumption_selfconsumption_unique_code
 #, python-format
 msgid "A project with this CAU already exists."
@@ -667,6 +681,7 @@ msgstr "Dagoeneko badago CAU honekin proiektu bat."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #: model:ir.model.constraint,message:energy_selfconsumption.constraint_energy_selfconsumption_supply_point_unique_code_company_id
 #, python-format
 msgid "A supply point with this code already exists."
@@ -705,6 +720,7 @@ msgstr "Kontu zenbakia"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/define_invoicing_mode_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/define_invoicing_mode_wizard.py:0
 #, python-format
 msgid "Accounting Journal not found."
 msgstr "Kontabilitate aldizkaria ez da aurkitu."
@@ -729,8 +745,12 @@ msgstr "Aktibatu formularioa"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/inscription.py:0
 #: code:addons/energy_selfconsumption/models/inscription.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_distribution_table__active
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__active
@@ -782,6 +802,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Address"
 msgstr "Helbidea"
@@ -823,6 +844,7 @@ msgstr "Urteko elektrizitatearen erabilera"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Annual electricity use?"
 msgstr "Urteko elektrizitatearen erabilera?"
@@ -830,6 +852,7 @@ msgstr "Urteko elektrizitatearen erabilera?"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Are you in a vulnerable situation?"
 msgstr "Egoera zaurgarrian al zaude?"
@@ -847,6 +870,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/clean_supply_point_assignation_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/clean_supply_point_assignation_wizard.py:0
 #, python-format
 msgid "Are you sure you want to delete all assigned distribution points?"
 msgstr "Ziur esleitutako banaketa puntu guztiak ezabatu nahi dituzula?"
@@ -891,6 +915,7 @@ msgstr "Fakturazio epea"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Birthdate"
 msgstr "Jaioteguna"
@@ -903,6 +928,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "CIF/NIF"
 msgstr "IFK/IFZ"
@@ -921,6 +947,7 @@ msgstr "Koefizientea (α)"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid "CSV file could not be loaded"
 msgstr "Ezin izan da CSV fitxategia kargatu"
@@ -928,6 +955,7 @@ msgstr "Ezin izan da CSV fitxategia kargatu"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__code
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point__code
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point_assignation__code
@@ -940,6 +968,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "CUPS is the Unified Code of the Point of Supply. You can find it on "
@@ -951,6 +980,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/define_invoicing_mode_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/define_invoicing_mode_wizard.py:0
 #, python-format
 msgid ""
 "CUPS: {code}\n"
@@ -970,6 +1000,7 @@ msgstr "Katastroaren erreferentzia"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Cadastral reference of the property"
 msgstr "Erreferentzia katastrala del inmueble"
@@ -983,6 +1014,8 @@ msgstr "Indargabetu"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/inscription.py:0
+#: code:addons/energy_selfconsumption/models/inscription.py:0
+#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_change_state_inscription_lines_wizard__state__change
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_inscription_selfconsumption__state__change
@@ -1010,6 +1043,7 @@ msgstr "Aldatu inscriptzioaren egoera lerroak"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__city
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point__city
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point_assignation__supply_point_town
@@ -1032,6 +1066,7 @@ msgstr "Garbitu hornidura-puntua esleitzeko morroia"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #: model:ir.actions.server,name:energy_selfconsumption.manager_clean_supply_point_assignation_action
 #, python-format
 msgid "Clean supply point assignation"
@@ -1057,6 +1092,7 @@ msgstr "Koefizientea Baliozkoa da"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point_assignation.py:0
+#: code:addons/energy_selfconsumption/models/supply_point_assignation.py:0
 #, python-format
 msgid "Coefficient can't be negative."
 msgstr "Koefizientea ezin da negatiboa izan."
@@ -1064,6 +1100,7 @@ msgstr "Koefizientea ezin da negatiboa izan."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #, python-format
 msgid "Coefficient distribution must sum to 1."
 msgstr "Koefizienteen banaketa 1 izan behar da."
@@ -1080,6 +1117,7 @@ msgstr "Enpresa"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Company Name"
 msgstr "Enpresaren izena"
@@ -1159,6 +1197,7 @@ msgstr "Berretsi"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Confirm E-mail"
 msgstr "Berretsi posta elektronikoa"
@@ -1184,6 +1223,7 @@ msgstr "Kontratu"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
 #, python-format
 msgid "Contract - %s - %s"
 msgstr "Kontratua - %s - %s"
@@ -1357,6 +1397,7 @@ msgstr "Fakturatutako egunak"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_form_view
 #, python-format
 msgid "Define Invoicing Mode"
@@ -1471,6 +1512,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Do you currently have self-consumption?"
 msgstr "Gaur egun autokontsumoa al duzu?"
@@ -1478,6 +1520,7 @@ msgstr "Gaur egun autokontsumoa al duzu?"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "Dont exit participation for this project."
 msgstr "Ez utzi proiektu honetan parte hartzea."
@@ -1511,6 +1554,7 @@ msgstr "Deskargatu Autokontsumo Kudeatzailearen Baimena"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_distribution_table__state__draft
 #, python-format
 msgid "Draft"
@@ -1519,6 +1563,7 @@ msgstr "Zirriborroa"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "E-mail"
 msgstr "Posta elektronikoa"
@@ -1637,6 +1682,7 @@ msgstr "Amaiera"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_define_invoicing_mode_wizard__invoicing_mode__energy_delivered
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_invoicing_wizard__invoicing_mode__energy_delivered
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_selfconsumption__invoicing_mode__energy_delivered
@@ -1647,6 +1693,7 @@ msgstr "Energia entregatu"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_define_invoicing_mode_wizard__invoicing_mode__energy_custom
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_invoicing_wizard__invoicing_mode__energy_custom
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_selfconsumption__invoicing_mode__energy_custom
@@ -1657,6 +1704,7 @@ msgstr "Energia entregatu pertsonalizatua"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid "Energy Delivered Custom: {energy_delivered} kWh"
 msgstr "Energia entregatu pertsonalizatua: {energy_delivered} kWh"
@@ -1674,6 +1722,7 @@ msgstr "Energia Entregatu Formula Aldakorra"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid "Energy Delivered: {energy_delivered} kWh"
 msgstr "Energia Entregatu: {energy_delivered} kWh"
@@ -1687,6 +1736,7 @@ msgstr "Energia Proiektua"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Energy Project Name"
 msgstr "Energia Proiektuaren izena"
@@ -1719,6 +1769,7 @@ msgstr "Partekatutako autokontsumo proiektuan izena ematea"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Error format date."
 msgstr "Errorearen formatuaren data."
@@ -1726,8 +1777,11 @@ msgstr "Errorearen formatuaren data."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "Error parsing the file"
 msgstr "Errore bat gertatu da fitxategia analizatzean"
@@ -1735,6 +1789,7 @@ msgstr "Errore bat gertatu da fitxategia analizatzean"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Error reading file"
 msgstr ""
@@ -1779,6 +1834,7 @@ msgstr "Data:"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Female"
 msgstr "Emakumezkoa"
@@ -1834,6 +1890,8 @@ msgstr "Izena"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_create_distribution_table_wizard__type__fixed
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_distribution_table__type__fixed
@@ -1865,6 +1923,7 @@ msgstr "Letra-tipo ikaragarria ikonoa adibidez. fa-tasks"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid ""
 "For the 2.0TD rate, the maximum contracted power must be between 0 and 15 "
@@ -1876,6 +1935,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid ""
 "For the 3.0TD rate, the maximum contracted power must be greater than 15 kW."
@@ -1886,6 +1946,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Gender"
 msgstr "Generoa"
@@ -1898,6 +1959,7 @@ msgstr "Sortu"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Generate Contracts"
 msgstr "Kontratuak Sortu"
@@ -1939,6 +2001,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "Have to accept and authorize being able to issue payments to this bank "
@@ -1952,6 +2015,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Have to accept politic privacy."
 msgstr "Pribatutasun politikoa onartu behar."
@@ -1959,6 +2023,7 @@ msgstr "Pribatutasun politikoa onartu behar."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__conf_header_description
 #, python-format
 msgid "Header description on website form"
@@ -1967,6 +2032,7 @@ msgstr "Goiburuaren deskribapena webguneko formularioan"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "How much power of the collective PV installation you would like to purchase."
@@ -1975,6 +2041,7 @@ msgstr "Erosi nahi duzun FV instalazio kolektiboaren zenbat potentzia."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__accept
 #, python-format
 msgid ""
@@ -1989,6 +2056,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "I accept privacy policy"
 msgstr "Pribatutasun politika onartzen dut"
@@ -1996,6 +2064,7 @@ msgstr "Pribatutasun politika onartzen dut"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "I prefer to not share it"
 msgstr "Nahiago dut ez partekatzea"
@@ -2003,6 +2072,7 @@ msgstr "Nahiago dut ez partekatzea"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "IBAN"
 msgstr ""
@@ -2064,6 +2134,7 @@ msgstr "Inportatu"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #: model:ir.actions.act_window,name:energy_selfconsumption.distribution_table_import_wizard_action
 #, python-format
 msgid "Import Distribution Table"
@@ -2072,6 +2143,7 @@ msgstr "Inportazioen Banaketa Taula"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "Import Errors"
 msgstr "Inportatu erroreak"
@@ -2087,6 +2159,7 @@ msgstr "Inportatu fitxategia (*.csv)"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Import Inscriptions and Supply Points"
 msgstr "Inportatu inskripzioak eta hornidura puntuak"
@@ -2099,6 +2172,7 @@ msgstr "Inportatu datuak"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "Import errors found: <ul>{list}</ul>"
 msgstr "Inportazio-erroreak aurkitu dira: <ul>{list}</ul>"
@@ -2116,6 +2190,7 @@ msgstr "Inportatu taula"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_distribution_table__state__process
 #, python-format
 msgid "In process"
@@ -2132,8 +2207,11 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/inscription.py:0
+#: code:addons/energy_selfconsumption/models/inscription.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_change_state_inscription_lines_wizard__state__inactive
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_inscription_selfconsumption__state__inactive
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_selfconsumption__conf_state__inactive
@@ -2144,6 +2222,7 @@ msgstr "Inaktibo"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "Information necessary for the formalization of the distribution "
@@ -2193,6 +2272,7 @@ msgstr "instalazioa:"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CAU: Last 3 digits are not numbers"
 msgstr "CAU baliogabea: azken 3 zifrak ez dira zenbakiak"
@@ -2201,6 +2281,8 @@ msgstr "CAU baliogabea: azken 3 zifrak ez dira zenbakiak"
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CAU: The CUPS does not start with 'ES'."
 msgstr "CAU baliogabea: CUPS ez da 'ES'-rekin hasten."
@@ -2209,6 +2291,8 @@ msgstr "CAU baliogabea: CUPS ez da 'ES'-rekin hasten."
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CAU: The CUPS has an incorrect format."
 msgstr "CAU baliogabea: CUPSak formatu okerra du."
@@ -2216,6 +2300,7 @@ msgstr "CAU baliogabea: CUPSak formatu okerra du."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CAU: The character after CUPS is not A"
 msgstr "CAU baliogabea: CUPS ondorengo karakterea ez da A"
@@ -2224,6 +2309,8 @@ msgstr "CAU baliogabea: CUPS ondorengo karakterea ez da A"
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CAU: The checksum of the CUPS is incorrect."
 msgstr "CAU baliogabea: CUPSen kontrol batura okerra da."
@@ -2232,6 +2319,8 @@ msgstr "CAU baliogabea: CUPSen kontrol batura okerra da."
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid ""
 "Invalid CAU: The first characters related to CUPS are incorrect. The length "
@@ -2243,6 +2332,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CAU: The length is not correct"
 msgstr "CAU baliogabea: luzera ez da zuzena"
@@ -2250,6 +2340,7 @@ msgstr "CAU baliogabea: luzera ez da zuzena"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CIL: Last 3 digits are not numbers"
 msgstr "CIL baliogabea: azken 3 zifrak ez dira zenbakiak"
@@ -2258,6 +2349,8 @@ msgstr "CIL baliogabea: azken 3 zifrak ez dira zenbakiak"
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CIL: The CUPS does not start with 'ES'."
 msgstr "CIL baliogabea: CUPS ez da 'ES'-rekin hasten."
@@ -2266,6 +2359,8 @@ msgstr "CIL baliogabea: CUPS ez da 'ES'-rekin hasten."
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CIL: The CUPS has an incorrect format."
 msgstr "CIL baliogabea: CUPSak formatu okerra du."
@@ -2274,6 +2369,8 @@ msgstr "CIL baliogabea: CUPSak formatu okerra du."
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CIL: The checksum of the CUPS is incorrect."
 msgstr "CIL baliogabea: CUPS-en kontrol batura okerra da."
@@ -2282,6 +2379,8 @@ msgstr "CIL baliogabea: CUPS-en kontrol batura okerra da."
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid ""
 "Invalid CIL: The first characters related to CUPS are incorrect. The length "
@@ -2293,6 +2392,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Invalid CIL: The length is not correct"
 msgstr "CIL baliogabea: luzera ez da zuzena"
@@ -2300,6 +2400,7 @@ msgstr "CIL baliogabea: luzera ez da zuzena"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "Invalid CUPS: The checksum is incorrect."
 msgstr "CUPS baliogabea: kontrol-bagaketa okerra da."
@@ -2307,6 +2408,7 @@ msgstr "CUPS baliogabea: kontrol-bagaketa okerra da."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "Invalid CUPS: The length is incorrect."
 msgstr "CUPS baliogabea: luzera okerra da."
@@ -2314,6 +2416,7 @@ msgstr "CUPS baliogabea: luzera okerra da."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "Invalid CUPS: does not start with 'ES'."
 msgstr "CUPS baliogabea: ez da 'ES'-rekin hasten."
@@ -2321,6 +2424,7 @@ msgstr "CUPS baliogabea: ez da 'ES'-rekin hasten."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "Invalid CUPS: has an incorrect format."
 msgstr "CUPS baliogabea: formatu okerra du."
@@ -2328,6 +2432,8 @@ msgstr "CUPS baliogabea: formatu okerra du."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "Invalid Cadastral Reference: {error}"
@@ -2336,6 +2442,7 @@ msgstr "Katastro-erreferentzia baliogabea: {error}"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "Invalid IBAN: {error}"
 msgstr "IBAN baliogabea: {error}"
@@ -2343,6 +2450,7 @@ msgstr "IBAN baliogabea: {error}"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "Invalid VAT: {error}"
 msgstr "IFK/IFZ baliogabea: {error}"
@@ -2385,6 +2493,7 @@ msgstr "Jarraitzailea da"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Is the owner the same partner?"
 msgstr "Jabea bikotekide bera al da?"
@@ -2402,6 +2511,7 @@ msgstr "Aldizkariaren elementua"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Lang"
 msgstr "Idioma"
@@ -2409,6 +2519,7 @@ msgstr "Idioma"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Language not found."
 msgstr "Hizkuntza ez da aurkitu."
@@ -2496,6 +2607,7 @@ msgstr "Abizena"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Lastname"
 msgstr "Abizena"
@@ -2512,6 +2624,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_create_distribution_table_wizard__type_distribute_excess__linear
 #, python-format
 msgid "Linear"
@@ -2565,6 +2678,7 @@ msgstr "Linea nagusia"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Male"
 msgstr "Gizonezkoa"
@@ -2582,6 +2696,7 @@ msgstr "Mandatua iragazita"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
 #, python-format
 msgid "Mandate not found for {partner}"
 msgstr "Ez da aurkitu komandoa {partner}rentzat"
@@ -2594,6 +2709,7 @@ msgstr "Gehienezko potentzia banatua"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point__contracted_power
 #, python-format
 msgid "Maximum contracted power"
@@ -2637,6 +2753,7 @@ msgstr "Modalitatea"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Must have a valid Distribution Table."
 msgstr "Baliozko Banaketa Taula izan behar du."
@@ -2662,6 +2779,7 @@ msgstr "IZENA ETA ABIZENAK (hornitzailearen titularra)"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_contract_contract__supply_point_name
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_distribution_table__name
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__name
@@ -2685,6 +2803,7 @@ msgstr "Erkidegoa integratzeko beharrezkoak diren datuak:"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #, python-format
 msgid "New Supply Point"
 msgstr "Hornidura Puntu berria"
@@ -2743,8 +2862,14 @@ msgstr "Hurrengo aldia hasiera"
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/models/partner.py:0
 #: code:addons/energy_selfconsumption/models/partner.py:0
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_create_distribution_table_wizard__distribute_excess__no
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_supply_point__used_in_selfconsumption__no
@@ -2756,6 +2881,7 @@ msgstr "ez"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "No participation found for this project."
 msgstr "Ez da parte-hartzerik aurkitu proiektu honetan."
@@ -2763,7 +2889,10 @@ msgstr "Ez da parte-hartzerik aurkitu proiektu honetan."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "No valid encoding was found for the attached file"
@@ -2772,6 +2901,7 @@ msgstr "Ez da aurkitu erantsitako fitxategirako baliozko kodeketarik"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Not binary"
 msgstr "Ez bitarra"
@@ -2821,8 +2951,11 @@ msgstr "BEHARREZKO BESTE DATU BATZUK"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "Only csv format files are accepted."
 msgstr "Csv formatuko fitxategiak bakarrik onartzen dira."
@@ -2830,6 +2963,7 @@ msgstr "Csv formatuko fitxategiak bakarrik onartzen dira."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Other"
 msgstr "Bestela"
@@ -2851,6 +2985,7 @@ msgstr "Jabeen hornidura"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "Owner could not be created or found."
 msgstr "Ezin izan da sortu edo aurkitu jabea."
@@ -2877,6 +3012,7 @@ msgstr "Parte hartzea"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Participation does not exist."
 msgstr "Parte hartzea ez da existitzen."
@@ -2900,6 +3036,7 @@ msgstr "Bazkidea"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Partner does not exist."
 msgstr "Bazkidea ez da existitzen."
@@ -2907,6 +3044,7 @@ msgstr "Bazkidea ez da existitzen."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/inscription.py:0
+#: code:addons/energy_selfconsumption/models/inscription.py:0
 #, python-format
 msgid "Partner is already signed up in this project with that cups."
 msgstr "Bazkidea dagoeneko izena emanda dago proiektu honetan kopa horrekin."
@@ -2914,6 +3052,7 @@ msgstr "Bazkidea dagoeneko izena emanda dago proiektu honetan kopa horrekin."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Partner is not cooperator."
 msgstr "Bazkidea ez da kolaboratzailea."
@@ -2921,6 +3060,7 @@ msgstr "Bazkidea ez da kolaboratzailea."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "Partner with VAT {vat} is already registered in project {code}"
 msgstr ""
@@ -2929,6 +3069,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "Partner with VAT:<b>{vat}</b> is not a cooperator."
 msgstr "IFK/NIF-ren bazkidea:<b>{vat}</b> ez da kolaboratzailea."
@@ -2936,6 +3077,7 @@ msgstr "IFK/NIF-ren bazkidea:<b>{vat}</b> ez da kolaboratzailea."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "Partner with VAT:<b>{vat}</b> was not found."
 msgstr "IFK/NIF-ko bazkidea:<b>{vat}</b> ez da aurkitu."
@@ -2960,6 +3102,7 @@ msgstr "Banatutako potentziaren ehunekoa"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Phone"
 msgstr "Telefonoa"
@@ -2972,6 +3115,7 @@ msgstr "Potentzia (kW)"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_define_invoicing_mode_wizard__invoicing_mode__power_acquired
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_invoicing_wizard__invoicing_mode__power_acquired
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_selfconsumption__invoicing_mode__power_acquired
@@ -3007,6 +3151,7 @@ msgstr "Pribatutasun politika"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "Privacy policy file text"
 msgstr "Pribatutasun politikaren fitxategiaren testua"
@@ -3037,6 +3182,8 @@ msgstr "Proiektua"
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Project must have a valid Code."
 msgstr "Proiektuak baliozko Kode bat izan behar du."
@@ -3045,6 +3192,8 @@ msgstr "Proiektuak baliozko Kode bat izan behar du."
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Project must have a valid Rated Power."
 msgstr "Proiektuak baliozko Potentzia Nominal bat izan behar du."
@@ -3052,6 +3201,7 @@ msgstr "Proiektuak baliozko Potentzia Nominal bat izan behar du."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid "Project must have defined a invoicing mode before activation."
 msgstr "Proiektuak fakturazio modua zehaztu behar du aktibatu aurretik."
@@ -3059,6 +3209,7 @@ msgstr "Proiektuak fakturazio modua zehaztu behar du aktibatu aurretik."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_create_distribution_table_wizard__type_distribute_excess__proportional
 #, python-format
 msgid "Proportional"
@@ -3224,6 +3375,7 @@ msgstr "Autokontsumoaren fakturazio abisua ${ object.name }"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #, python-format
 msgid "Self-consumption project already has a table in process"
 msgstr "Autokontsumo proiektuak dagoeneko badu mahai bat martxan"
@@ -3231,6 +3383,7 @@ msgstr "Autokontsumo proiektuak dagoeneko badu mahai bat martxan"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #, python-format
 msgid "Self-consumption project already has a validated table"
 msgstr "Autokontsumo proiektuak dagoeneko baliozkotutako taula bat du"
@@ -3434,17 +3587,17 @@ msgstr "Fakturaren hasiera data"
 msgid "State"
 msgstr "Probintzia"
 
+#. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point_assignation__supply_point_state
+msgid "State Name"
+msgstr "Estatuaren izena"
+
 #. module: energy_selfconsumption
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__state
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__state
 msgid "Status"
 msgstr "Egoera"
 
-#. module: energy_selfconsumption
-#: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point_assignation__supply_point_state
-msgid "State Name"
-msgstr "Estatuaren izena"
-
 #. module: energy_selfconsumption
 #: model:ir.model.fields,help:energy_selfconsumption.field_energy_selfconsumption_distribution_table__activity_state
 #: model:ir.model.fields,help:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__activity_state
@@ -3548,6 +3701,7 @@ msgstr "Zerga ID"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "The IBAN field cannot be empty."
 msgstr "IBAN eremua ezin da hutsik egon."
@@ -3565,6 +3719,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid "The contract has no lines"
 msgstr "Kontratuak ez du lerrorik"
@@ -3572,6 +3727,7 @@ msgstr "Kontratuak ez du lerrorik"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "The email is not the same."
 msgstr "Posta elektronikoa ez da berdina."
@@ -3580,6 +3736,8 @@ msgstr "Posta elektronikoa ez da berdina."
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid "The energy generated must be greater than 0 (kWh)."
 msgstr "Sortutako energia 0 (kWh) baino handiagoa izan behar da."
@@ -3587,6 +3745,7 @@ msgstr "Sortutako energia 0 (kWh) baino handiagoa izan behar da."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/selfconsumption_import_wizard.py:0
 #, python-format
 msgid "The file should contain 28 columns and not {header_length} columns."
 msgstr "Fitxategiak 28 zutabe izan behar ditu eta ez {header_length} zutabe."
@@ -3594,6 +3753,7 @@ msgstr "Fitxategiak 28 zutabe izan behar ditu eta ez {header_length} zutabe."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "The form is not open. For more information write to your Energy Community "
@@ -3605,6 +3765,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/invoicing_wizard.py:0
 #, python-format
 msgid ""
 "The number of contracts selected does not match the number of contracts "
@@ -3616,6 +3777,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point_assignation.py:0
+#: code:addons/energy_selfconsumption/models/supply_point_assignation.py:0
 #, python-format
 msgid "The partner of the supply point is not subscribed to the project"
 msgstr "Hornidura puntuko bazkidea ez da proiektuan harpidetuta"
@@ -3623,6 +3785,7 @@ msgstr "Hornidura puntuko bazkidea ez da proiektuan harpidetuta"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #, python-format
 msgid "The project has to have a power greater than 0."
 msgstr "Proiektuak 0 baino potentzia handiagoa izan behar du."
@@ -3630,6 +3793,7 @@ msgstr "Proiektuak 0 baino potentzia handiagoa izan behar du."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid ""
 "The report can be downloaded when the project is in activation or active "
@@ -3646,6 +3810,7 @@ msgstr "Koefiziente guztien baturak 1 izan behar du"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
 #, python-format
 msgid ""
 "The sum of coefficients for the following hours is not equal to 1: %s, "
@@ -3654,6 +3819,7 @@ msgstr "Hurrengo orduetako koefizienteen batura ez da 1ekoa: %s,"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
 #, python-format
 msgid "The sum of coefficients is not equal to 1: %s"
 msgstr "Koefizienteen batura ez da 1ekoa: %s"
@@ -3661,6 +3827,7 @@ msgstr "Koefizienteen batura ez da 1ekoa: %s"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #, python-format
 msgid ""
 "The supply point can't be removed because the distribution table state is "
@@ -3680,6 +3847,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "There is already an individual photovoltaic self-consumption or collective "
@@ -3691,6 +3859,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/contract_generation_wizard.py:0
 #, python-format
 msgid "There is no distribution table in proces of activation."
 msgstr "Ez dago banaketa taularik aktibatzeko prozesuan."
@@ -3715,6 +3884,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
 #, python-format
 msgid "There isn't any supply point with this code: {code}"
 msgstr "Ez dago hornidura punturik kode honekin: {code}"
@@ -3739,6 +3909,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #, python-format
 msgid ""
 "To change the type you must first delete the associated distribution points.\n"
@@ -3808,6 +3979,7 @@ msgstr "Erabiltzailearen egungo rola"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "VAT of the partner"
 msgstr "Bazkidearen IFK/IFZ"
@@ -3820,6 +3992,7 @@ msgstr "Baliozkotu"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_distribution_table__state__validated
 #, python-format
 msgid "Validated"
@@ -3828,6 +4001,7 @@ msgstr "Baliozkotua"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
+#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_distribution_table__type__hourly
 #, python-format
 msgid "Variable hourly"
@@ -3871,6 +4045,7 @@ msgstr "Webguneen komunikazioaren historia"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "What participation would you like?"
 msgstr "Zein parte hartzea gustatuko litzaizuke?"
@@ -3880,9 +4055,15 @@ msgstr "Zein parte hartzea gustatuko litzaizuke?"
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: code:addons/energy_selfconsumption/models/partner.py:0
+#: code:addons/energy_selfconsumption/models/partner.py:0
+#: code:addons/energy_selfconsumption/models/supply_point.py:0
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_create_distribution_table_wizard__distribute_excess__yes
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_supply_point__used_in_selfconsumption__yes
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__res_partner__vulnerability_situation__yes
@@ -3893,6 +4074,7 @@ msgstr "Bai"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid "You are already enrolled in this self-consumption project."
 msgstr "Dagoeneko matrikulatuta zaude autokontsumo proiektu honetan."
@@ -3923,6 +4105,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "You can find the annual electricity use on the electricity bill(Total annual"
@@ -3934,6 +4117,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/clean_supply_point_assignation_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/clean_supply_point_assignation_wizard.py:0
 #, python-format
 msgid ""
 "You can only delete assigned distribution points from a distribution table "
@@ -3943,6 +4127,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/contract_line.py:0
+#: code:addons/energy_selfconsumption/models/contract_line.py:0
 #, python-format
 msgid ""
 "You can't have a date of next invoice anterior to the start of the contract "
@@ -3954,6 +4139,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #, python-format
 msgid ""
 "You have a recognized situation of vulnerability due to energy poverty or "
@@ -3965,6 +4151,7 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/create_inscription.py:0
+#: code:addons/energy_selfconsumption/models/create_inscription.py:0
 #, python-format
 msgid "You have successfully registered."
 msgstr "Behar bezala erregistratu zara."
@@ -3972,6 +4159,8 @@ msgstr "Behar bezala erregistratu zara."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #, python-format
 msgid "You have to select at least one entry."
@@ -3980,6 +4169,7 @@ msgstr "Gutxienez sarrera bat hautatu behar duzu."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
+#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #, python-format
 msgid ""
 "You need to add the privacy policy file to display the form.To modify the "
@@ -3996,6 +4186,7 @@ msgstr "Zure datuak behar bezala erregistratu dira."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #, python-format
 msgid "Your distribution percentage cannot be 0."
 msgstr "Zure banaketa-ehunekoa ezin da 0 izan."
@@ -4003,6 +4194,7 @@ msgstr "Zure banaketa-ehunekoa ezin da 0 izan."
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/create_distribution_table_wizard.py:0
 #, python-format
 msgid "Your distribution percentage cannot exceed 100%."
 msgstr "Zure banaketa-ehunekoa ezin da %100etik gorakoa izan."
@@ -4016,6 +4208,7 @@ msgstr "Posta Kodea"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__zip
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point__zip
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point_assignation__supply_point_postalcode
diff --git a/energy_selfconsumption/models/contract_line.py b/energy_selfconsumption/models/contract_line.py
index 2b8b031b5..2ac8ae92c 100644
--- a/energy_selfconsumption/models/contract_line.py
+++ b/energy_selfconsumption/models/contract_line.py
@@ -5,11 +5,6 @@ from odoo.exceptions import ValidationError
 class ContractLine(models.Model):
     _inherit = "contract.line"
 
-    days_invoiced = fields.Integer(
-        string="Days invoiced",
-        compute="_compute_days_invoiced",
-        store=True,
-    )
     main_line = fields.Boolean("Main line", default=False)
     # This validation is raised when writing date_start on the contract and recurring_next_date is yet not computed
     # Fixed by just checking when the recurrence is at line level (line_recurrence)
@@ -41,22 +36,3 @@ class ContractLine(models.Model):
                         )
                         % line.name
                     )
-
-    @api.depends("last_date_invoiced", "recurring_next_date")
-    def _compute_days_invoiced(self):
-        for record in self:
-            (
-                first_date_invoiced,
-                last_date_invoiced,
-                _,  # recurring_next_date
-            ) = record._get_period_to_invoice(
-                record.last_date_invoiced,
-                record.recurring_next_date,
-                stop_at_date_end=True,
-            )
-
-            record.days_invoiced = (
-                (last_date_invoiced - first_date_invoiced).days + 1
-                if first_date_invoiced and last_date_invoiced
-                else 0
-            )
diff --git a/energy_selfconsumption/reports/invoice_template.xml b/energy_selfconsumption/reports/invoice_template.xml
index e03c259e8..cc203ef99 100644
--- a/energy_selfconsumption/reports/invoice_template.xml
+++ b/energy_selfconsumption/reports/invoice_template.xml
@@ -2,11 +2,7 @@
         <template id="selfconsumption_invoice_template" inherit_id="account.report_invoice_document">
             <xpath expr="//th[@name='th_quantity']" position="replace">
                 <th name="th_quantity" t-if="o.selfconsumption_invoicing_mode == 'none'" class="text-end"><span>Quantity</span></th>
-                <t t-if="o.selfconsumption_invoicing_mode == 'power_acquired'">
-                    <th name="th_power_acquired" class="text-end"><span>Power acquired</span></th>
-                    <th name="th_invoiced_days" class="text-end"><span>Invoiced days</span></th>
-                    <th name="th_quantity" class="text-end"><span>Quantity</span></th>
-                </t>
+                <th name="th_quantity" t-if="o.selfconsumption_invoicing_mode == 'power_acquired'" class="text-end"><span>Quantity</span></th>
                 <t t-if="o.selfconsumption_invoicing_mode == 'energy_delivered'">
                     <th name="th_total_installation_generation" class="text-end"><span>Total installation generation</span></th>
                     <th name="th_partition_coefficient" class="text-end"><span>Partition coefficient</span></th>
@@ -31,33 +27,6 @@
                 </th>
             </xpath>
             <xpath expr="//td[@name='account_invoice_line_name']" position="after">
-                <t t-if="o.selfconsumption_invoicing_mode == 'power_acquired'">
-                    <td name="td_power_acquired" class="text-end">
-                        <t t-set="found" t-value="False" />
-                        <t t-foreach="line.selfconsumption_id.distribution_table_ids.supply_point_assignation_ids" t-as="assignation">
-                            <t t-if="line.partner_id == assignation.owner_id and line.ref == assignation.code">
-                                <t t-set="power_acquired" t-value="'{:.2f}'.format(line.selfconsumption_id.power * assignation.coefficient)"/>
-                                <t t-esc="power_acquired" /><span> kWn/day</span>
-                                <t t-set="found" t-value="True" />
-                            </t>
-                        </t>
-                        <t t-if="not found">
-                            0 kW/day
-                        </t>
-                    </td>
-                    <td name="td_invoiced_days" class="text-end">
-                        <t t-foreach="o.invoice_line_ids" t-as="line">
-                            <t t-foreach="line.contract_line_id" t-as="contract_line">
-                                <t t-if="contract_line.contract_id.partner_id == line.partner_id">
-                                    <span t-field="contract_line.days_invoiced"/>
-                                </t>
-                                <t t-else="">
-                                    0
-                                </t>
-                            </t>
-                        </t>
-                    </td>
-                </t>
                 <t t-if="o.selfconsumption_invoicing_mode == 'energy_delivered'">
                     <td name="td_total_installation_generation" class="text-end">
                         <span t-field="line.selfconsumption_id.power"/><span> kWh</span>
diff --git a/energy_selfconsumption/wizards/contract_generation_wizard.py b/energy_selfconsumption/wizards/contract_generation_wizard.py
index c26374151..4fe62e43b 100644
--- a/energy_selfconsumption/wizards/contract_generation_wizard.py
+++ b/energy_selfconsumption/wizards/contract_generation_wizard.py
@@ -106,10 +106,27 @@ class ContractGenerationWizard(models.TransientModel):
                     contract_line_id.name += """\nCAU: {cau}\n"""
                 elif self.selfconsumption_id.invoicing_mode == "power_acquired":
                     contract_line_id.name += _(
-                        """\nCAU: {cau}\nTotal installed nominal power (kW): {power}\nPartition coefficient: {coefficient}"""
+                        """\nCAU: {cau}
+                        Total installed nominal power (kW): {power}
+                        Partition coefficient: {coefficient}
+                        Daily nominal power acquired: {power} kWn * {coefficient} = {power_acquired} kWn/day
+                        Days to be invoiced: {days_invoiced} days
+                        Total amount invoiced:  {days_invoiced} days * {power_acquired} kWn/day = {total_amount}\n"""
                     )
                     data["power"] = self.selfconsumption_id.power
                     data["coefficient"] = supply_point_assignation.coefficient
+                    first_date_invoiced, last_date_invoiced, recurring_next_date = contract_line_id._get_period_to_invoice(
+                        contract_line_id.last_date_invoiced,
+                        contract_line_id.recurring_next_date,
+                    )
+                    data["days_invoiced"] = (
+                        (last_date_invoiced - first_date_invoiced).days + 1
+                        if first_date_invoiced and last_date_invoiced
+                        else 0
+                    )
+                    data["power_acquired"] = (round(self.selfconsumption_id.power * supply_point_assignation.coefficient, 2)
+                                              if supply_point_assignation.coefficient else 0.0)
+                    data["total_amount"] = round(data["days_invoiced"] * data["power_acquired"], 2)
 
                 contract_line_id.write(
                     {"name": contract_line_id.name.format(**data), "main_line": True}
-- 
GitLab


From f0d2cf09cc1d44c5f4bbb18ec8d3ad161a7b037e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81lvaro=20Garc=C3=ADa?= <alvarogruiz8@gmail.com>
Date: Mon, 24 Feb 2025 10:11:49 +0100
Subject: [PATCH 03/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Controls=20of=200=20o?=
 =?UTF-8?q?r=20less=20or=20more=20than=20100=20percent=20are=20removed.=20?=
 =?UTF-8?q?It=20is=20calculated=20in=20both=20cases.=20Changes=20in=20the?=
 =?UTF-8?q?=20colors=20of=20the=20bars=20according=20to=20the=20percentage?=
 =?UTF-8?q?.=20And=20the=20excess=20above=20100=20is=20now=20calculated=20?=
 =?UTF-8?q?linearly=20and=20proportionally.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: Alvaro Garcia <alvaro.garcia@somit.coop>
---
 .../static/src/js/progress_bar.js             | 22 ++++++-----
 .../create_distribution_table_wizard.py       | 39 ++++++++++++-------
 ...create_distribution_table_wizard_views.xml | 22 ++++-------
 3 files changed, 46 insertions(+), 37 deletions(-)

diff --git a/energy_selfconsumption/static/src/js/progress_bar.js b/energy_selfconsumption/static/src/js/progress_bar.js
index 359949dd9..c7ea3699c 100644
--- a/energy_selfconsumption/static/src/js/progress_bar.js
+++ b/energy_selfconsumption/static/src/js/progress_bar.js
@@ -1,12 +1,12 @@
 /** @odoo-module **/
 
-import {Component, useState} from "@odoo/owl";
-import {registry} from "@web/core/registry";
+import { Component, useState } from "@odoo/owl";
+import { registry } from "@web/core/registry";
 
 class ProgressBarWidget extends Component {
   setup() {
     // Obtener valores desde this.props
-    const {record} = this.props;
+    const { record } = this.props;
 
     // Configurar el estado inicial usando hooks de OWL
     this.state = useState({
@@ -16,17 +16,21 @@ class ProgressBarWidget extends Component {
     });
 
     // Calcular el porcentaje basado en los valores actuales
-    this.state.percentage = Math.min(
-      (this.state.current_quantity / this.state.max_quantity) * 100,
-      100
-    );
+    this.state.percentage = (this.state.current_quantity / this.state.max_quantity) * 100;
   }
 
   get progressStyle() {
+    let background_color = '#7C7BAD';
+    if (this.state.percentage > 100) {
+      background_color = '#a10000';
+    } else if (this.state.percentage == 100) {
+      background_color = '#00a12a';
+    }
+    let width = this.state.percentage > 100 ? 100 : this.state.percentage;
     return `
-      width: ${this.state.percentage}%;
+      width: ${width}%;
       height: 100%;
-      background-color: #7C7BAD;
+      background-color: ${background_color};
     `;
   }
 
diff --git a/energy_selfconsumption/wizards/create_distribution_table_wizard.py b/energy_selfconsumption/wizards/create_distribution_table_wizard.py
index 4d604ee62..8116275e5 100644
--- a/energy_selfconsumption/wizards/create_distribution_table_wizard.py
+++ b/energy_selfconsumption/wizards/create_distribution_table_wizard.py
@@ -48,6 +48,11 @@ class CreateDistributionTableWizard(models.TransientModel):
         string="Type distribute excess",
     )
 
+    @api.onchange('distributed_power')
+    def _onchange_distributed_power(self):
+        if self.distributed_power > self.max_distributed_power or self.distributed_power <= 0:
+            self.distribute_excess = 'yes'
+
     @api.model
     def default_get(self, default_fields):
         # OVERRIDE
@@ -83,12 +88,6 @@ class CreateDistributionTableWizard(models.TransientModel):
             / default_fields["max_distributed_power"]
         ) * 100
 
-        if default_fields["percentage_of_distributed_power"] == 0:
-            raise ValidationError(_("Your distribution percentage cannot be 0."))
-
-        if default_fields["percentage_of_distributed_power"] > 100:
-            raise ValidationError(_("Your distribution percentage cannot exceed 100%."))
-
         return default_fields
 
     def create_distribution_table(self):
@@ -133,16 +132,28 @@ class CreateDistributionTableWizard(models.TransientModel):
         coefficient = inscription.participation_real_quantity
 
         if self.distribute_excess == "yes":
-            distribute_excess_float = (
-                self.max_distributed_power - self.distributed_power
-            )
-
-            if self.type_distribute_excess == "proportional":
-                coefficient += distribute_excess_float * (
-                    inscription.participation_real_quantity / self.distributed_power
+            if self.distributed_power < self.max_distributed_power:
+                distribute_excess_float = (
+                    self.max_distributed_power - self.distributed_power
                 )
+
+                if self.type_distribute_excess == "proportional":
+                    coefficient += distribute_excess_float * (
+                        inscription.participation_real_quantity / self.distributed_power
+                    )
+                else:
+                    coefficient += distribute_excess_float / len_inscriptions
             else:
-                coefficient += distribute_excess_float / len_inscriptions
+                distribute_excess_float = (
+                    self.distributed_power - self.max_distributed_power
+                )
+
+                if self.type_distribute_excess == "proportional":
+                    coefficient -= distribute_excess_float * (
+                        inscription.participation_real_quantity / self.distributed_power
+                    )
+                else:
+                    coefficient -= distribute_excess_float / len_inscriptions
 
         coefficient = coefficient / self.max_distributed_power
 
diff --git a/energy_selfconsumption/wizards/create_distribution_table_wizard_views.xml b/energy_selfconsumption/wizards/create_distribution_table_wizard_views.xml
index 170dbc061..92b25e333 100644
--- a/energy_selfconsumption/wizards/create_distribution_table_wizard_views.xml
+++ b/energy_selfconsumption/wizards/create_distribution_table_wizard_views.xml
@@ -13,24 +13,18 @@
                 <form>
                     <sheet>
                         <group>
+                            <field name="type" />
+                        </group>
+                        <group attrs="{'invisible':[('type','!=','fixed')]}">
                             <field name="max_distributed_power" invisible="1" />
                             <field
-                name="distributed_power"
-                widget="progress_bar_widget"
-                options="{'max_quantity': 'max_distributed_power', 'extra_label': 'kWn'}"
-              />
-                        <!-- <field name="distributed_power" widget="progress_bar_widget">
-                            <options>
-                                <option name="max_quantity" expr="max_distributed_power"/>
-                                <option name="extra_label">kW</option>
-                            </options>
-                        </field> -->
-                        </group>
-                        <group>
-                            <field name="type" />
+                                name="distributed_power"
+                                widget="progress_bar_widget"
+                                options="{'max_quantity': 'max_distributed_power', 'extra_label': 'kWn'}"
+                            />
                             <field name="distribute_excess" />
                         </group>
-                        <group attrs="{'invisible':[('distribute_excess','=','no')]}">
+                        <group attrs="{'invisible':['|',('type','!=','fixed'),('distribute_excess','=','no')]}">
                             <field name="type_distribute_excess" />
                         </group>
                     </sheet>
-- 
GitLab


From b6cc0f0debcb34cdd8d2c9c77833967a89fd5350 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81lvaro=20Garc=C3=ADa?= <alvarogruiz8@gmail.com>
Date: Thu, 6 Mar 2025 10:28:48 +0100
Subject: [PATCH 04/85] Modify an existing distribution table

Author: Alvaro Garcia <alvaro.garcia@somit.coop>
---
 energy_selfconsumption/__manifest__.py        |   1 +
 energy_selfconsumption/i18n/ca_ES.po          | 155 ++++++++++++----
 .../i18n/energy_selfconsumption.pot           | 150 ++++++++++++----
 energy_selfconsumption/i18n/es.po             | 155 ++++++++++++----
 energy_selfconsumption/i18n/eu_ES.po          | 153 ++++++++++++----
 .../security/ir.model.access.csv              |   5 +
 energy_selfconsumption/wizards/__init__.py    |   1 +
 ...change_distribution_table_import_wizard.py | 169 ++++++++++++++++++
 ...hange_distribution_table_import_wizard.xml |  62 +++++++
 9 files changed, 715 insertions(+), 136 deletions(-)
 create mode 100644 energy_selfconsumption/wizards/change_distribution_table_import_wizard.py
 create mode 100644 energy_selfconsumption/wizards/change_distribution_table_import_wizard.xml

diff --git a/energy_selfconsumption/__manifest__.py b/energy_selfconsumption/__manifest__.py
index b944919ba..94378c23b 100644
--- a/energy_selfconsumption/__manifest__.py
+++ b/energy_selfconsumption/__manifest__.py
@@ -59,6 +59,7 @@
         "wizards/change_state_inscription_wizard_views.xml",
         "reports/selfconsumption_reports.xml",
         "reports/invoice_template.xml",
+        "wizards/change_distribution_table_import_wizard.xml"
     ],
     "demo": [
         "demo/energy_selfconsumption_demo.xml",
diff --git a/energy_selfconsumption/i18n/ca_ES.po b/energy_selfconsumption/i18n/ca_ES.po
index 013784ba6..98d3fb55e 100644
--- a/energy_selfconsumption/i18n/ca_ES.po
+++ b/energy_selfconsumption/i18n/ca_ES.po
@@ -6,8 +6,8 @@ msgid ""
 msgstr ""
 "Project-Id-Version: Odoo Server 16.0\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2025-02-19 12:09+0000\n"
-"PO-Revision-Date: 2025-02-19 12:09+0000\n"
+"POT-Creation-Date: 2025-03-03 07:48+0000\n"
+"PO-Revision-Date: 2025-03-03 07:48+0000\n"
 "Last-Translator: \n"
 "Language-Team: \n"
 "MIME-Version: 1.0\n"
@@ -550,7 +550,7 @@ msgstr ""
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
 msgid ""
 "<span groups=\"account.group_show_line_subtotals_tax_excluded\">Amount</span>\n"
-"                                    <span groups=\"account.group_show_line_subtotals_tax_included\">Total Price</span>"
+"                    <span groups=\"account.group_show_line_subtotals_tax_included\">Total Price</span>"
 msgstr ""
 "<span groups=\"account.group_show_line_subtotals_tax_excluded\">Quantitat</span>\n"
 "                                    <span groups=\"account.group_show_line_subtotals_tax_included\">Preu Total</span>"
@@ -570,16 +570,6 @@ msgstr ""
 msgid "<span> kWn/day</span>"
 msgstr "<span> kWn/dia</span>"
 
-#. module: energy_selfconsumption
-#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
-msgid "<span>Description</span>"
-msgstr "<span>Descripció</span>"
-
-#. module: energy_selfconsumption
-#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
-msgid "<span>Disc.%</span>"
-msgstr "<span>Desc.%</span>"
-
 #. module: energy_selfconsumption
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
 msgid "<span>Import</span>"
@@ -620,16 +610,6 @@ msgstr "<span>Quantitat total facturada</span>"
 msgid "<span>Total installation generation</span>"
 msgstr "<span>Total de generació de la instal·lació</span>"
 
-#. module: energy_selfconsumption
-#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
-msgid "<span>Unit Price</span>"
-msgstr "<span>Preu unitat</span>"
-
-#. module: energy_selfconsumption
-#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
-msgid "<strong class=\"mr16\">Subtotal</strong>"
-msgstr ""
-
 #. module: energy_selfconsumption
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.inscription_data_headline_message_closed
 msgid "<strong>Closed form</strong>"
@@ -757,15 +737,13 @@ msgstr "Activa el formulari"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
-#: code:addons/energy_selfconsumption/models/distribution_table.py:0
-#: code:addons/energy_selfconsumption/models/inscription.py:0
 #: code:addons/energy_selfconsumption/models/inscription.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
-#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
-#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_distribution_table__active
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__active
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_line_wizard__state__active
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_change_state_inscription_lines_wizard__state__active
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_distribution_table__state__active
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_inscription_selfconsumption__state__active
@@ -1018,6 +996,7 @@ msgstr "Referència cadastral de l'immoble"
 
 #. module: energy_selfconsumption
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.contract_generation_wizard_form_view
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_clean_supply_point_assignation_wizard
 msgid "Cancel"
 msgstr "Cancel·lar"
@@ -1025,15 +1004,28 @@ msgstr "Cancel·lar"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/inscription.py:0
-#: code:addons/energy_selfconsumption/models/inscription.py:0
-#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_line_wizard__state__change
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_wizard__state__change
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_change_state_inscription_lines_wizard__state__change
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_inscription_selfconsumption__state__change
 #, python-format
 msgid "Change"
 msgstr "Canviar"
 
+#. module: energy_selfconsumption
+#: model:ir.actions.act_window,name:energy_selfconsumption.action_change_distribution_table_import_wizard
+msgid "Change distribution table"
+msgstr "Canvia la taula de distribució"
+
+#. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__change_distribution_table_import_line_wizard_ids
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__change_distribution_table_import_line_wizard_news_ids
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__change_distribution_table_import_line_wizard_views_ids
+msgid "Change distribution table import line wizard"
+msgstr "Canvia la taula de distribució"
+
 #. module: energy_selfconsumption
 #: model:ir.actions.act_window,name:energy_selfconsumption.change_state_inscription_wizard_action
 #: model:ir.actions.server,name:energy_selfconsumption.inscription_to_change_state_action
@@ -1047,10 +1039,28 @@ msgid "Change state inscription lines wizards"
 msgstr "Canviar estat d'inscripció"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__change_distribution_table_import_wizard_id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__change_state_inscription_wizard_id
 msgid "Change state inscription wizard"
 msgstr "Canviar estat d'inscripció"
 
+#. module: energy_selfconsumption
+#. odoo-python
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model,name:energy_selfconsumption.model_change_distribution_table_import_line_wizard
+#, python-format
+msgid "Change_distribution_table_import_line_wizard"
+msgstr "Canvia la taula de distribució"
+
+#. module: energy_selfconsumption
+#. odoo-python
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model,name:energy_selfconsumption.model_change_distribution_table_import_wizard
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+#, python-format
+msgid "Change_distribution_table_import_wizard"
+msgstr "Canvia la taula de distribució"
+
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
@@ -1304,6 +1314,8 @@ msgid "Create participant table"
 msgstr "Crea una taula de participants"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__create_uid
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__create_uid
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard__create_uid
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__create_uid
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard__create_uid
@@ -1324,6 +1336,8 @@ msgid "Created by"
 msgstr "Creat per"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__create_date
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__create_date
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard__create_date
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__create_date
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard__create_date
@@ -1434,6 +1448,14 @@ msgstr ""
 "                         mecanisme de compensació en el següent període de facturació des de la recepció d'aquest\n"
 "                         acord."
 
+#. module: energy_selfconsumption
+#. odoo-python
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_wizard__state__delete
+#, python-format
+msgid "Delete"
+msgstr "Eliminar"
+
 #. module: energy_selfconsumption
 #: model:ir.model.fields,help:energy_selfconsumption.field_energy_selfconsumption_distribution_table__hourly_coefficients_imported_delimiter
 #: model:ir.model.fields,help:energy_selfconsumption.field_energy_selfconsumption_distribution_table_import_wizard__delimiter
@@ -1453,6 +1475,8 @@ msgid "Description form"
 msgstr "Formulari de descripció"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__display_name
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__display_name
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard__display_name
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__display_name
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard__display_name
@@ -2095,6 +2119,8 @@ msgid "IBAN"
 msgstr ""
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__id
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard__id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard__id
@@ -2224,11 +2250,10 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/inscription.py:0
-#: code:addons/energy_selfconsumption/models/inscription.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
-#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
-#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_line_wizard__state__inactive
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_change_state_inscription_lines_wizard__state__inactive
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_inscription_selfconsumption__state__inactive
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_selfconsumption__conf_state__inactive
@@ -2249,6 +2274,7 @@ msgstr ""
 "encontrarlo en cadastro.es"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__inscription_id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__inscription_id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__inscription_id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__inscription_ids
@@ -2546,6 +2572,8 @@ msgid "Last Date Invoiced"
 msgstr "Última data facturada"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard____last_update
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard____last_update
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard____last_update
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard____last_update
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard____last_update
@@ -2576,6 +2604,8 @@ msgid "Last Period Start"
 msgstr "Inici de l'últim període"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__write_uid
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__write_uid
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard__write_uid
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__write_uid
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard__write_uid
@@ -2596,6 +2626,8 @@ msgid "Last Updated by"
 msgstr "Última actualització per"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__write_date
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__write_date
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard__write_date
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__write_date
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard__write_date
@@ -2816,6 +2848,14 @@ msgstr "Nom de l'empresa"
 msgid "Necessary data for the integration of the Community:"
 msgstr "Dades necessàries per a la integració de la Comunitat:"
 
+#. module: energy_selfconsumption
+#. odoo-python
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_wizard__state__new
+#, python-format
+msgid "New"
+msgstr "Nou"
+
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
@@ -2824,6 +2864,11 @@ msgstr "Dades necessàries per a la integració de la Comunitat:"
 msgid "New Supply Point"
 msgstr "Nou punt de subministrament"
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+msgid "New registrations"
+msgstr "Nous registres"
+
 #. module: energy_selfconsumption
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_distribution_table__activity_calendar_event_id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__activity_calendar_event_id
@@ -2873,10 +2918,14 @@ msgstr "Final del període següent"
 msgid "Next Period Start"
 msgstr "Inici del període següent"
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+msgid "Next step"
+msgstr "Següent pas"
+
 #. module: energy_selfconsumption
 #. odoo-python
-#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
-#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
@@ -2892,7 +2941,7 @@ msgstr "Inici del període següent"
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__res_partner__vulnerability_situation__no
 #, python-format
 msgid "No"
-msgstr ""
+msgstr "No"
 
 #. module: energy_selfconsumption
 #. odoo-python
@@ -2965,6 +3014,14 @@ msgstr "Nombre de missatges amb error de lliurament"
 msgid "OTHER NECESSARY DATA"
 msgstr "ALTRES DADES NECESSARIS"
 
+#. module: energy_selfconsumption
+#. odoo-python
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_wizard__state__old
+#, python-format
+msgid "Old"
+msgstr "Antigu"
+
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
@@ -3040,6 +3097,7 @@ msgid "Participation inscription"
 msgstr "Inscripció de participació"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__participation_real_quantity
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__participation_real_quantity
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__participation_real_quantity
 msgid "Participation real quantity"
@@ -3154,6 +3212,11 @@ msgstr "Informe de l'acord de compartició d'energia"
 msgid "Power acquired"
 msgstr "Potència adquirida"
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+msgid "Previous step"
+msgstr "Pas anterior"
+
 #. module: energy_selfconsumption
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_define_invoicing_mode_wizard__price
 msgid "Price"
@@ -3245,6 +3308,11 @@ msgstr "Quantitat"
 msgid "Quotechar in import CSV file."
 msgstr "Caràcter de citació al arxiu CSV d'importació."
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+msgid "Record deregistration"
+msgstr "Inscripció de desinscripció"
+
 #. module: energy_selfconsumption
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_define_invoicing_mode_wizard__recurring_rule_type
 msgid "Recurrence"
@@ -3312,6 +3380,11 @@ msgstr "Restableix a l'esborrany"
 msgid "Responsible User"
 msgstr "Usuari responsable"
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+msgid "Retain old records"
+msgstr "Mantenir registres antics"
+
 #. module: energy_selfconsumption
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_form_view
 msgid "Return to Draft"
@@ -3610,6 +3683,8 @@ msgid "State Name"
 msgstr "Nom de l'estat"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__state
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__state
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__state
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__state
 msgid "Status"
@@ -3710,6 +3785,11 @@ msgstr "Punt de subministrament filtrat"
 msgid "Supply Points"
 msgstr "Punts de subministrament"
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
+msgid "Tax 15%"
+msgstr ""
+
 #. module: energy_selfconsumption
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point_assignation__owner_vat
 msgid "Tax ID"
@@ -3982,6 +4062,11 @@ msgstr ""
 msgid "Unactivate form"
 msgstr "Desactiva el formulari"
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+msgid "Update old records"
+msgstr "Actualitza registres antics"
+
 #. module: energy_selfconsumption
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__used_in_selfconsumption
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point__used_in_selfconsumption
diff --git a/energy_selfconsumption/i18n/energy_selfconsumption.pot b/energy_selfconsumption/i18n/energy_selfconsumption.pot
index 4dd647183..fd3987eed 100644
--- a/energy_selfconsumption/i18n/energy_selfconsumption.pot
+++ b/energy_selfconsumption/i18n/energy_selfconsumption.pot
@@ -6,8 +6,8 @@ msgid ""
 msgstr ""
 "Project-Id-Version: Odoo Server 16.0\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2025-02-19 12:08+0000\n"
-"PO-Revision-Date: 2025-02-19 12:08+0000\n"
+"POT-Creation-Date: 2025-03-03 07:47+0000\n"
+"PO-Revision-Date: 2025-03-03 07:47+0000\n"
 "Last-Translator: \n"
 "Language-Team: \n"
 "MIME-Version: 1.0\n"
@@ -418,7 +418,7 @@ msgstr ""
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
 msgid ""
 "<span groups=\"account.group_show_line_subtotals_tax_excluded\">Amount</span>\n"
-"                                    <span groups=\"account.group_show_line_subtotals_tax_included\">Total Price</span>"
+"                    <span groups=\"account.group_show_line_subtotals_tax_included\">Total Price</span>"
 msgstr ""
 
 #. module: energy_selfconsumption
@@ -436,16 +436,6 @@ msgstr ""
 msgid "<span> kWn/day</span>"
 msgstr ""
 
-#. module: energy_selfconsumption
-#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
-msgid "<span>Description</span>"
-msgstr ""
-
-#. module: energy_selfconsumption
-#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
-msgid "<span>Disc.%</span>"
-msgstr ""
-
 #. module: energy_selfconsumption
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
 msgid "<span>Import</span>"
@@ -486,16 +476,6 @@ msgstr ""
 msgid "<span>Total installation generation</span>"
 msgstr ""
 
-#. module: energy_selfconsumption
-#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
-msgid "<span>Unit Price</span>"
-msgstr ""
-
-#. module: energy_selfconsumption
-#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
-msgid "<strong class=\"mr16\">Subtotal</strong>"
-msgstr ""
-
 #. module: energy_selfconsumption
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.inscription_data_headline_message_closed
 msgid "<strong>Closed form</strong>"
@@ -605,15 +585,13 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
-#: code:addons/energy_selfconsumption/models/distribution_table.py:0
-#: code:addons/energy_selfconsumption/models/inscription.py:0
 #: code:addons/energy_selfconsumption/models/inscription.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
-#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
-#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_distribution_table__active
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__active
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_line_wizard__state__active
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_change_state_inscription_lines_wizard__state__active
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_distribution_table__state__active
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_inscription_selfconsumption__state__active
@@ -856,6 +834,7 @@ msgstr ""
 
 #. module: energy_selfconsumption
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.contract_generation_wizard_form_view
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_clean_supply_point_assignation_wizard
 msgid "Cancel"
 msgstr ""
@@ -863,15 +842,28 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/inscription.py:0
-#: code:addons/energy_selfconsumption/models/inscription.py:0
-#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_line_wizard__state__change
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_wizard__state__change
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_change_state_inscription_lines_wizard__state__change
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_inscription_selfconsumption__state__change
 #, python-format
 msgid "Change"
 msgstr ""
 
+#. module: energy_selfconsumption
+#: model:ir.actions.act_window,name:energy_selfconsumption.action_change_distribution_table_import_wizard
+msgid "Change distribution table"
+msgstr ""
+
+#. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__change_distribution_table_import_line_wizard_ids
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__change_distribution_table_import_line_wizard_news_ids
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__change_distribution_table_import_line_wizard_views_ids
+msgid "Change distribution table import line wizard"
+msgstr ""
+
 #. module: energy_selfconsumption
 #: model:ir.actions.act_window,name:energy_selfconsumption.change_state_inscription_wizard_action
 #: model:ir.actions.server,name:energy_selfconsumption.inscription_to_change_state_action
@@ -885,10 +877,28 @@ msgid "Change state inscription lines wizards"
 msgstr ""
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__change_distribution_table_import_wizard_id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__change_state_inscription_wizard_id
 msgid "Change state inscription wizard"
 msgstr ""
 
+#. module: energy_selfconsumption
+#. odoo-python
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model,name:energy_selfconsumption.model_change_distribution_table_import_line_wizard
+#, python-format
+msgid "Change_distribution_table_import_line_wizard"
+msgstr ""
+
+#. module: energy_selfconsumption
+#. odoo-python
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model,name:energy_selfconsumption.model_change_distribution_table_import_wizard
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+#, python-format
+msgid "Change_distribution_table_import_wizard"
+msgstr ""
+
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
@@ -1130,6 +1140,8 @@ msgid "Create participant table"
 msgstr ""
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__create_uid
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__create_uid
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard__create_uid
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__create_uid
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard__create_uid
@@ -1150,6 +1162,8 @@ msgid "Created by"
 msgstr ""
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__create_date
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__create_date
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard__create_date
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__create_date
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard__create_date
@@ -1250,6 +1264,14 @@ msgid ""
 "                        acuerdo."
 msgstr ""
 
+#. module: energy_selfconsumption
+#. odoo-python
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_wizard__state__delete
+#, python-format
+msgid "Delete"
+msgstr ""
+
 #. module: energy_selfconsumption
 #: model:ir.model.fields,help:energy_selfconsumption.field_energy_selfconsumption_distribution_table__hourly_coefficients_imported_delimiter
 #: model:ir.model.fields,help:energy_selfconsumption.field_energy_selfconsumption_distribution_table_import_wizard__delimiter
@@ -1269,6 +1291,8 @@ msgid "Description form"
 msgstr ""
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__display_name
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__display_name
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard__display_name
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__display_name
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard__display_name
@@ -1861,6 +1885,8 @@ msgid "IBAN"
 msgstr ""
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__id
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard__id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard__id
@@ -1988,11 +2014,10 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/inscription.py:0
-#: code:addons/energy_selfconsumption/models/inscription.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
-#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
-#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_line_wizard__state__inactive
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_change_state_inscription_lines_wizard__state__inactive
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_inscription_selfconsumption__state__inactive
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_selfconsumption__conf_state__inactive
@@ -2011,6 +2036,7 @@ msgid ""
 msgstr ""
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__inscription_id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__inscription_id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__inscription_id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__inscription_ids
@@ -2304,6 +2330,8 @@ msgid "Last Date Invoiced"
 msgstr ""
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard____last_update
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard____last_update
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard____last_update
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard____last_update
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard____last_update
@@ -2334,6 +2362,8 @@ msgid "Last Period Start"
 msgstr ""
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__write_uid
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__write_uid
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard__write_uid
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__write_uid
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard__write_uid
@@ -2354,6 +2384,8 @@ msgid "Last Updated by"
 msgstr ""
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__write_date
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__write_date
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard__write_date
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__write_date
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard__write_date
@@ -2568,6 +2600,14 @@ msgstr ""
 msgid "Necessary data for the integration of the Community:"
 msgstr ""
 
+#. module: energy_selfconsumption
+#. odoo-python
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_wizard__state__new
+#, python-format
+msgid "New"
+msgstr ""
+
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
@@ -2576,6 +2616,11 @@ msgstr ""
 msgid "New Supply Point"
 msgstr ""
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+msgid "New registrations"
+msgstr ""
+
 #. module: energy_selfconsumption
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_distribution_table__activity_calendar_event_id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__activity_calendar_event_id
@@ -2625,6 +2670,11 @@ msgstr ""
 msgid "Next Period Start"
 msgstr ""
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+msgid "Next step"
+msgstr ""
+
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
@@ -2714,6 +2764,14 @@ msgstr ""
 msgid "OTHER NECESSARY DATA"
 msgstr ""
 
+#. module: energy_selfconsumption
+#. odoo-python
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_wizard__state__old
+#, python-format
+msgid "Old"
+msgstr ""
+
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
@@ -2789,6 +2847,7 @@ msgid "Participation inscription"
 msgstr ""
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__participation_real_quantity
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__participation_real_quantity
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__participation_real_quantity
 msgid "Participation real quantity"
@@ -2903,6 +2962,11 @@ msgstr ""
 msgid "Power acquired"
 msgstr ""
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+msgid "Previous step"
+msgstr ""
+
 #. module: energy_selfconsumption
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_define_invoicing_mode_wizard__price
 msgid "Price"
@@ -2993,6 +3057,11 @@ msgstr ""
 msgid "Quotechar in import CSV file."
 msgstr ""
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+msgid "Record deregistration"
+msgstr ""
+
 #. module: energy_selfconsumption
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_define_invoicing_mode_wizard__recurring_rule_type
 msgid "Recurrence"
@@ -3060,6 +3129,11 @@ msgstr ""
 msgid "Responsible User"
 msgstr ""
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+msgid "Retain old records"
+msgstr ""
+
 #. module: energy_selfconsumption
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_form_view
 msgid "Return to Draft"
@@ -3345,6 +3419,8 @@ msgid "State Name"
 msgstr ""
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__state
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__state
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__state
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__state
 msgid "Status"
@@ -3441,6 +3517,11 @@ msgstr ""
 msgid "Supply Points"
 msgstr ""
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
+msgid "Tax 15%"
+msgstr ""
+
 #. module: energy_selfconsumption
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point_assignation__owner_vat
 msgid "Tax ID"
@@ -3691,6 +3772,11 @@ msgstr ""
 msgid "Unactivate form"
 msgstr ""
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+msgid "Update old records"
+msgstr ""
+
 #. module: energy_selfconsumption
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__used_in_selfconsumption
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point__used_in_selfconsumption
diff --git a/energy_selfconsumption/i18n/es.po b/energy_selfconsumption/i18n/es.po
index 45cdea263..448184dab 100644
--- a/energy_selfconsumption/i18n/es.po
+++ b/energy_selfconsumption/i18n/es.po
@@ -6,8 +6,8 @@ msgid ""
 msgstr ""
 "Project-Id-Version: Odoo Server 16.0\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2025-02-19 12:10+0000\n"
-"PO-Revision-Date: 2025-02-19 12:10+0000\n"
+"POT-Creation-Date: 2025-03-03 07:47+0000\n"
+"PO-Revision-Date: 2025-03-03 07:47+0000\n"
 "Last-Translator: \n"
 "Language-Team: \n"
 "MIME-Version: 1.0\n"
@@ -535,7 +535,7 @@ msgstr ""
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
 msgid ""
 "<span groups=\"account.group_show_line_subtotals_tax_excluded\">Amount</span>\n"
-"                                    <span groups=\"account.group_show_line_subtotals_tax_included\">Total Price</span>"
+"                    <span groups=\"account.group_show_line_subtotals_tax_included\">Total Price</span>"
 msgstr ""
 "<span groups=\"account.group_show_line_subtotals_tax_excluded\">Cantidad</span>\n"
 "                                    <span groups=\"account.group_show_line_subtotals_tax_included\">Precio Total</span>"
@@ -555,16 +555,6 @@ msgstr ""
 msgid "<span> kWn/day</span>"
 msgstr "<span> kWn/día</span>"
 
-#. module: energy_selfconsumption
-#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
-msgid "<span>Description</span>"
-msgstr "<span>Descripción</span>"
-
-#. module: energy_selfconsumption
-#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
-msgid "<span>Disc.%</span>"
-msgstr "<span>Desc.%</span>"
-
 #. module: energy_selfconsumption
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
 msgid "<span>Import</span>"
@@ -605,16 +595,6 @@ msgstr "<span>Cantidad total facturada</span>"
 msgid "<span>Total installation generation</span>"
 msgstr "<span>Total generado de la instalación</span>"
 
-#. module: energy_selfconsumption
-#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
-msgid "<span>Unit Price</span>"
-msgstr "<span>Precio unidad</span>"
-
-#. module: energy_selfconsumption
-#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
-msgid "<strong class=\"mr16\">Subtotal</strong>"
-msgstr ""
-
 #. module: energy_selfconsumption
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.inscription_data_headline_message_closed
 msgid "<strong>Closed form</strong>"
@@ -724,15 +704,13 @@ msgstr "Activar formulario"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
-#: code:addons/energy_selfconsumption/models/distribution_table.py:0
-#: code:addons/energy_selfconsumption/models/inscription.py:0
 #: code:addons/energy_selfconsumption/models/inscription.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
-#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
-#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_distribution_table__active
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__active
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_line_wizard__state__active
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_change_state_inscription_lines_wizard__state__active
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_distribution_table__state__active
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_inscription_selfconsumption__state__active
@@ -987,6 +965,7 @@ msgstr "Referencia catastral de la propiedad"
 
 #. module: energy_selfconsumption
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.contract_generation_wizard_form_view
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_clean_supply_point_assignation_wizard
 msgid "Cancel"
 msgstr "Cancelar"
@@ -994,15 +973,28 @@ msgstr "Cancelar"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/inscription.py:0
-#: code:addons/energy_selfconsumption/models/inscription.py:0
-#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_line_wizard__state__change
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_wizard__state__change
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_change_state_inscription_lines_wizard__state__change
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_inscription_selfconsumption__state__change
 #, python-format
 msgid "Change"
 msgstr "Cambiar"
 
+#. module: energy_selfconsumption
+#: model:ir.actions.act_window,name:energy_selfconsumption.action_change_distribution_table_import_wizard
+msgid "Change distribution table"
+msgstr "Cambiar tabla de distribución"
+
+#. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__change_distribution_table_import_line_wizard_ids
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__change_distribution_table_import_line_wizard_news_ids
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__change_distribution_table_import_line_wizard_views_ids
+msgid "Change distribution table import line wizard"
+msgstr "Cambiar tabla de distribución"
+
 #. module: energy_selfconsumption
 #: model:ir.actions.act_window,name:energy_selfconsumption.change_state_inscription_wizard_action
 #: model:ir.actions.server,name:energy_selfconsumption.inscription_to_change_state_action
@@ -1016,10 +1008,28 @@ msgid "Change state inscription lines wizards"
 msgstr "Cambiar estado de inscripción"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__change_distribution_table_import_wizard_id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__change_state_inscription_wizard_id
 msgid "Change state inscription wizard"
 msgstr "Cambiar estado de inscripción"
 
+#. module: energy_selfconsumption
+#. odoo-python
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model,name:energy_selfconsumption.model_change_distribution_table_import_line_wizard
+#, python-format
+msgid "Change_distribution_table_import_line_wizard"
+msgstr "Cambiar tabla de distribución"
+
+#. module: energy_selfconsumption
+#. odoo-python
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model,name:energy_selfconsumption.model_change_distribution_table_import_wizard
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+#, python-format
+msgid "Change_distribution_table_import_wizard"
+msgstr "Cambiar tabla de distribución"
+
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
@@ -1265,6 +1275,8 @@ msgid "Create participant table"
 msgstr "Crear tabla de participantes"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__create_uid
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__create_uid
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard__create_uid
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__create_uid
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard__create_uid
@@ -1285,6 +1297,8 @@ msgid "Created by"
 msgstr "Creado por"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__create_date
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__create_date
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard__create_date
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__create_date
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard__create_date
@@ -1385,6 +1399,14 @@ msgid ""
 "                        acuerdo."
 msgstr ""
 
+#. module: energy_selfconsumption
+#. odoo-python
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_wizard__state__delete
+#, python-format
+msgid "Delete"
+msgstr "Eliminar"
+
 #. module: energy_selfconsumption
 #: model:ir.model.fields,help:energy_selfconsumption.field_energy_selfconsumption_distribution_table__hourly_coefficients_imported_delimiter
 #: model:ir.model.fields,help:energy_selfconsumption.field_energy_selfconsumption_distribution_table_import_wizard__delimiter
@@ -1404,6 +1426,8 @@ msgid "Description form"
 msgstr "Descripción del formulario"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__display_name
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__display_name
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard__display_name
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__display_name
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard__display_name
@@ -2019,6 +2043,8 @@ msgid "IBAN"
 msgstr ""
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__id
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard__id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard__id
@@ -2148,11 +2174,10 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/inscription.py:0
-#: code:addons/energy_selfconsumption/models/inscription.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
-#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
-#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_line_wizard__state__inactive
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_change_state_inscription_lines_wizard__state__inactive
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_inscription_selfconsumption__state__inactive
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_selfconsumption__conf_state__inactive
@@ -2173,6 +2198,7 @@ msgstr ""
 "encontrarlo en cadastro.es"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__inscription_id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__inscription_id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__inscription_id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__inscription_ids
@@ -2470,6 +2496,8 @@ msgid "Last Date Invoiced"
 msgstr "Última fecha facturada"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard____last_update
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard____last_update
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard____last_update
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard____last_update
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard____last_update
@@ -2500,6 +2528,8 @@ msgid "Last Period Start"
 msgstr "Inicio del último período"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__write_uid
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__write_uid
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard__write_uid
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__write_uid
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard__write_uid
@@ -2520,6 +2550,8 @@ msgid "Last Updated by"
 msgstr "Última actualización por"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__write_date
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__write_date
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard__write_date
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__write_date
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard__write_date
@@ -2734,6 +2766,14 @@ msgstr "Nombre de la empresa"
 msgid "Necessary data for the integration of the Community:"
 msgstr "Datos necesarios para la integración de la Comunidad:"
 
+#. module: energy_selfconsumption
+#. odoo-python
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_wizard__state__new
+#, python-format
+msgid "New"
+msgstr "Nuevo"
+
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
@@ -2742,6 +2782,11 @@ msgstr "Datos necesarios para la integración de la Comunidad:"
 msgid "New Supply Point"
 msgstr "Nuevo Punto de Suministro"
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+msgid "New registrations"
+msgstr "Nuevos registros"
+
 #. module: energy_selfconsumption
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_distribution_table__activity_calendar_event_id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__activity_calendar_event_id
@@ -2791,10 +2836,14 @@ msgstr "Próximo Período de Finalización"
 msgid "Next Period Start"
 msgstr "Próximo Período de Comienzo"
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+msgid "Next step"
+msgstr "Siguiente paso"
+
 #. module: energy_selfconsumption
 #. odoo-python
-#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
-#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
@@ -2810,7 +2859,7 @@ msgstr "Próximo Período de Comienzo"
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__res_partner__vulnerability_situation__no
 #, python-format
 msgid "No"
-msgstr ""
+msgstr "No"
 
 #. module: energy_selfconsumption
 #. odoo-python
@@ -2883,6 +2932,14 @@ msgstr "Número de mensajes con error de entrega"
 msgid "OTHER NECESSARY DATA"
 msgstr "OTROS DATOS NECESARIOS"
 
+#. module: energy_selfconsumption
+#. odoo-python
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_wizard__state__old
+#, python-format
+msgid "Old"
+msgstr "Antiguo"
+
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
@@ -2958,6 +3015,7 @@ msgid "Participation inscription"
 msgstr "Inscripción de participación"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__participation_real_quantity
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__participation_real_quantity
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__participation_real_quantity
 msgid "Participation real quantity"
@@ -3072,6 +3130,11 @@ msgstr "Informe del Acuerdo de Poder"
 msgid "Power acquired"
 msgstr "Potencia adquirida"
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+msgid "Previous step"
+msgstr "Paso anterior"
+
 #. module: energy_selfconsumption
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_define_invoicing_mode_wizard__price
 msgid "Price"
@@ -3164,6 +3227,11 @@ msgstr "Cantidad"
 msgid "Quotechar in import CSV file."
 msgstr "Quotechar en archivo CSV de importación."
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+msgid "Record deregistration"
+msgstr "Registro de desinscripción"
+
 #. module: energy_selfconsumption
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_define_invoicing_mode_wizard__recurring_rule_type
 msgid "Recurrence"
@@ -3232,6 +3300,11 @@ msgstr "Restablecer a borrador"
 msgid "Responsible User"
 msgstr "Usuario responsable"
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+msgid "Retain old records"
+msgstr "Mantener registros antiguos"
+
 #. module: energy_selfconsumption
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_form_view
 msgid "Return to Draft"
@@ -3529,6 +3602,8 @@ msgid "State Name"
 msgstr "Nombre del Estado"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__state
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__state
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__state
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__state
 msgid "Status"
@@ -3629,6 +3704,11 @@ msgstr "Punto de suministro filtrado"
 msgid "Supply Points"
 msgstr "Puntos de Suministro"
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
+msgid "Tax 15%"
+msgstr ""
+
 #. module: energy_selfconsumption
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point_assignation__owner_vat
 msgid "Tax ID"
@@ -3904,6 +3984,11 @@ msgstr ""
 msgid "Unactivate form"
 msgstr "Desactivar formulario"
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+msgid "Update old records"
+msgstr "Actualizar registros antiguos"
+
 #. module: energy_selfconsumption
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__used_in_selfconsumption
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point__used_in_selfconsumption
diff --git a/energy_selfconsumption/i18n/eu_ES.po b/energy_selfconsumption/i18n/eu_ES.po
index af1a7e630..f5bc4be74 100644
--- a/energy_selfconsumption/i18n/eu_ES.po
+++ b/energy_selfconsumption/i18n/eu_ES.po
@@ -6,8 +6,8 @@ msgid ""
 msgstr ""
 "Project-Id-Version: Odoo Server 16.0\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2025-02-19 12:09+0000\n"
-"PO-Revision-Date: 2025-02-19 12:09+0000\n"
+"POT-Creation-Date: 2025-03-03 07:48+0000\n"
+"PO-Revision-Date: 2025-03-03 07:48+0000\n"
 "Last-Translator: \n"
 "Language-Team: \n"
 "MIME-Version: 1.0\n"
@@ -543,7 +543,7 @@ msgstr ""
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
 msgid ""
 "<span groups=\"account.group_show_line_subtotals_tax_excluded\">Amount</span>\n"
-"                                    <span groups=\"account.group_show_line_subtotals_tax_included\">Total Price</span>"
+"                    <span groups=\"account.group_show_line_subtotals_tax_included\">Total Price</span>"
 msgstr ""
 "<span groups=\"account.group_show_line_subtotals_tax_excluded\">Zenbatekoa</span>\n"
 "                                    <span groups=\"account.group_show_line_subtotals_tax_included\">Prezioa guztira</span>"
@@ -563,16 +563,6 @@ msgstr ""
 msgid "<span> kWn/day</span>"
 msgstr "<span> kWn/egun</span>"
 
-#. module: energy_selfconsumption
-#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
-msgid "<span>Description</span>"
-msgstr ""
-
-#. module: energy_selfconsumption
-#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
-msgid "<span>Disc.%</span>"
-msgstr ""
-
 #. module: energy_selfconsumption
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
 msgid "<span>Import</span>"
@@ -613,16 +603,6 @@ msgstr "<span>Fakturatutako zenbatekoa, guztira</span>"
 msgid "<span>Total installation generation</span>"
 msgstr "<span>Instalazioen sorrera osoa</span>"
 
-#. module: energy_selfconsumption
-#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
-msgid "<span>Unit Price</span>"
-msgstr "<span>Unitatearen Prezioa</span>"
-
-#. module: energy_selfconsumption
-#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
-msgid "<strong class=\"mr16\">Subtotal</strong>"
-msgstr "<strong class=\"mr16\">Azpitotala</strong>"
-
 #. module: energy_selfconsumption
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.inscription_data_headline_message_closed
 msgid "<strong>Closed form</strong>"
@@ -745,15 +725,13 @@ msgstr "Aktibatu formularioa"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/distribution_table.py:0
-#: code:addons/energy_selfconsumption/models/distribution_table.py:0
 #: code:addons/energy_selfconsumption/models/inscription.py:0
-#: code:addons/energy_selfconsumption/models/inscription.py:0
-#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
-#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_distribution_table__active
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__active
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_line_wizard__state__active
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_change_state_inscription_lines_wizard__state__active
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_distribution_table__state__active
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_inscription_selfconsumption__state__active
@@ -1007,6 +985,7 @@ msgstr "Erreferentzia katastrala del inmueble"
 
 #. module: energy_selfconsumption
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.contract_generation_wizard_form_view
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_clean_supply_point_assignation_wizard
 msgid "Cancel"
 msgstr "Indargabetu"
@@ -1014,15 +993,28 @@ msgstr "Indargabetu"
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/inscription.py:0
-#: code:addons/energy_selfconsumption/models/inscription.py:0
-#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_line_wizard__state__change
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_wizard__state__change
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_change_state_inscription_lines_wizard__state__change
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_inscription_selfconsumption__state__change
 #, python-format
 msgid "Change"
 msgstr "Aldatu"
 
+#. module: energy_selfconsumption
+#: model:ir.actions.act_window,name:energy_selfconsumption.action_change_distribution_table_import_wizard
+msgid "Change distribution table"
+msgstr "Aldatu banaketa-taula"
+
+#. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__change_distribution_table_import_line_wizard_ids
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__change_distribution_table_import_line_wizard_news_ids
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__change_distribution_table_import_line_wizard_views_ids
+msgid "Change distribution table import line wizard"
+msgstr "Aldatu banaketa-taula lerroak"
+
 #. module: energy_selfconsumption
 #: model:ir.actions.act_window,name:energy_selfconsumption.change_state_inscription_wizard_action
 #: model:ir.actions.server,name:energy_selfconsumption.inscription_to_change_state_action
@@ -1036,10 +1028,28 @@ msgid "Change state inscription lines wizards"
 msgstr "Aldatu inscriptzioaren egoera lerroak"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__change_distribution_table_import_wizard_id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__change_state_inscription_wizard_id
 msgid "Change state inscription wizard"
 msgstr "Aldatu inscriptzioaren egoera lerroak"
 
+#. module: energy_selfconsumption
+#. odoo-python
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model,name:energy_selfconsumption.model_change_distribution_table_import_line_wizard
+#, python-format
+msgid "Change_distribution_table_import_line_wizard"
+msgstr "Aldatu banaketa-taula lerroak"
+
+#. module: energy_selfconsumption
+#. odoo-python
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model,name:energy_selfconsumption.model_change_distribution_table_import_wizard
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+#, python-format
+msgid "Change_distribution_table_import_wizard"
+msgstr "Aldatu banaketa-taula"
+
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
@@ -1291,6 +1301,8 @@ msgid "Create participant table"
 msgstr "Sortu parte-hartzaileen taula"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__create_uid
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__create_uid
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard__create_uid
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__create_uid
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard__create_uid
@@ -1311,6 +1323,8 @@ msgid "Created by"
 msgstr "Sortua"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__create_date
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__create_date
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard__create_date
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__create_date
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard__create_date
@@ -1421,6 +1435,14 @@ msgstr ""
 "                       konpentsazio-mekanismoa hurrengo fakturazio-aldian hau jasotzen denetik\n"
 "                       akordioa."
 
+#. module: energy_selfconsumption
+#. odoo-python
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_wizard__state__delete
+#, python-format
+msgid "Delete"
+msgstr "Ezabatu"
+
 #. module: energy_selfconsumption
 #: model:ir.model.fields,help:energy_selfconsumption.field_energy_selfconsumption_distribution_table__hourly_coefficients_imported_delimiter
 #: model:ir.model.fields,help:energy_selfconsumption.field_energy_selfconsumption_distribution_table_import_wizard__delimiter
@@ -1440,6 +1462,8 @@ msgid "Description form"
 msgstr "Deskribapen formularioa"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__display_name
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__display_name
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard__display_name
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__display_name
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard__display_name
@@ -2078,6 +2102,8 @@ msgid "IBAN"
 msgstr ""
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__id
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard__id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard__id
@@ -2207,11 +2233,10 @@ msgstr ""
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/inscription.py:0
-#: code:addons/energy_selfconsumption/models/inscription.py:0
-#: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/models/selfconsumption.py:0
 #: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
-#: code:addons/energy_selfconsumption/wizards/change_state_inscription_wizard.py:0
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_line_wizard__state__inactive
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_change_state_inscription_lines_wizard__state__inactive
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_inscription_selfconsumption__state__inactive
 #: model:ir.model.fields.selection,name:energy_selfconsumption.selection__energy_selfconsumption_selfconsumption__conf_state__inactive
@@ -2232,6 +2257,7 @@ msgstr ""
 "helbidean aurkituko duzu"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__inscription_id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__inscription_id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__inscription_id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__inscription_ids
@@ -2530,6 +2556,8 @@ msgid "Last Date Invoiced"
 msgstr "Azken data fakturatua"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard____last_update
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard____last_update
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard____last_update
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard____last_update
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard____last_update
@@ -2560,6 +2588,8 @@ msgid "Last Period Start"
 msgstr "Azken aldia hasiera"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__write_uid
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__write_uid
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard__write_uid
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__write_uid
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard__write_uid
@@ -2580,6 +2610,8 @@ msgid "Last Updated by"
 msgstr "Azken eguneratua"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__write_date
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__write_date
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_clean_supply_point_assignation_wizard__write_date
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__write_date
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_wizard__write_date
@@ -2800,6 +2832,14 @@ msgstr "Enpresaren izena"
 msgid "Necessary data for the integration of the Community:"
 msgstr "Erkidegoa integratzeko beharrezkoak diren datuak:"
 
+#. module: energy_selfconsumption
+#. odoo-python
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_wizard__state__new
+#, python-format
+msgid "New"
+msgstr "Berria"
+
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/models/supply_point.py:0
@@ -2808,6 +2848,11 @@ msgstr "Erkidegoa integratzeko beharrezkoak diren datuak:"
 msgid "New Supply Point"
 msgstr "Hornidura Puntu berria"
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+msgid "New registrations"
+msgstr "Erregistro berriak"
+
 #. module: energy_selfconsumption
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_distribution_table__activity_calendar_event_id
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_selfconsumption__activity_calendar_event_id
@@ -2857,10 +2902,14 @@ msgstr "Hurrengo aldia amaiera"
 msgid "Next Period Start"
 msgstr "Hurrengo aldia hasiera"
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+msgid "Next step"
+msgstr "Hurrengo pausoa"
+
 #. module: energy_selfconsumption
 #. odoo-python
-#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
-#: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
+
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
 #: code:addons/energy_selfconsumption/controllers/inscriptions_form_controllers.py:0
@@ -2948,6 +2997,14 @@ msgstr "Bidalketa-errorea duten mezu kopurua"
 msgid "OTHER NECESSARY DATA"
 msgstr "BEHARREZKO BESTE DATU BATZUK"
 
+#. module: energy_selfconsumption
+#. odoo-python
+#: code:addons/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py:0
+#: model:ir.model.fields.selection,name:energy_selfconsumption.selection__change_distribution_table_import_wizard__state__old
+#, python-format
+msgid "Old"
+msgstr "Antigu"
+
 #. module: energy_selfconsumption
 #. odoo-python
 #: code:addons/energy_selfconsumption/wizards/distribution_table_import_wizard.py:0
@@ -3023,6 +3080,7 @@ msgid "Participation inscription"
 msgstr "Parte hartzeko inskripzioa"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__participation_real_quantity
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__participation_real_quantity
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__participation_real_quantity
 msgid "Participation real quantity"
@@ -3138,6 +3196,11 @@ msgstr "Energia Partekatzeko Akordioaren Txostena"
 msgid "Power acquired"
 msgstr ""
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+msgid "Previous step"
+msgstr "Paso anterior"
+
 #. module: energy_selfconsumption
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_define_invoicing_mode_wizard__price
 msgid "Price"
@@ -3228,6 +3291,11 @@ msgstr "Kantitatea"
 msgid "Quotechar in import CSV file."
 msgstr "Quotechar inportazio CSV fitxategian."
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+msgid "Record deregistration"
+msgstr "Erregistro ezabatzea"
+
 #. module: energy_selfconsumption
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_define_invoicing_mode_wizard__recurring_rule_type
 msgid "Recurrence"
@@ -3295,6 +3363,11 @@ msgstr "Berrezarri zirriborrora"
 msgid "Responsible User"
 msgstr "Erabiltzaile arduratsua"
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+msgid "Retain old records"
+msgstr "Erregistro ezabatzea"
+
 #. module: energy_selfconsumption
 #: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_form_view
 msgid "Return to Draft"
@@ -3593,6 +3666,8 @@ msgid "State Name"
 msgstr "Estatuaren izena"
 
 #. module: energy_selfconsumption
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_line_wizard__state
+#: model:ir.model.fields,field_description:energy_selfconsumption.field_change_distribution_table_import_wizard__state
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_change_state_inscription_lines_wizard__state
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__state
 msgid "Status"
@@ -3693,6 +3768,11 @@ msgstr "Hornikuntza-puntua Iragazita"
 msgid "Supply Points"
 msgstr "Hornikuntza Puntuak"
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.selfconsumption_invoice_template
+msgid "Tax 15%"
+msgstr ""
+
 #. module: energy_selfconsumption
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point_assignation__owner_vat
 msgid "Tax ID"
@@ -3965,6 +4045,11 @@ msgstr ""
 msgid "Unactivate form"
 msgstr "Desaktibatu inprimakia"
 
+#. module: energy_selfconsumption
+#: model_terms:ir.ui.view,arch_db:energy_selfconsumption.view_change_distribution_table_import_wizard_form
+msgid "Update old records"
+msgstr "Aldatu antiguo erregistroak"
+
 #. module: energy_selfconsumption
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_inscription_selfconsumption__used_in_selfconsumption
 #: model:ir.model.fields,field_description:energy_selfconsumption.field_energy_selfconsumption_supply_point__used_in_selfconsumption
diff --git a/energy_selfconsumption/security/ir.model.access.csv b/energy_selfconsumption/security/ir.model.access.csv
index ce40451eb..76fc05246 100644
--- a/energy_selfconsumption/security/ir.model.access.csv
+++ b/energy_selfconsumption/security/ir.model.access.csv
@@ -29,3 +29,8 @@ access_energy_selfconsumption_change_state_inscription_wizard_user,energy.selfco
 access_energy_selfconsumption_change_state_inscription_wizard_admin,energy.selfconsumption.change.state.inscription.wizard.admin,model_energy_selfconsumption_change_state_inscription_wizard,energy_project.group_admin,1,1,1,1
 access_energy_selfconsumption_change_state_inscription_lines_wizard_user,energy.selfconsumption.change.state.inscription.lines.wizard.user,model_energy_selfconsumption_change_state_inscription_lines_wizard,energy_project.group_user,1,1,1,1
 access_energy_selfconsumption_change_state_inscription_lines_wizard_admin,energy.selfconsumption.change.state.inscription.lines.wizard.admin,model_energy_selfconsumption_change_state_inscription_lines_wizard,energy_project.group_admin,1,1,1,1
+access_change_distribution_table_import_wizard_user,change.distribution.table.import.wizard.user,model_change_distribution_table_import_wizard,energy_project.group_user,1,1,1,1
+access_change_distribution_table_import_wizard_admin,change.distribution.table.import.wizard.admin,model_change_distribution_table_import_wizard,energy_project.group_admin,1,1,1,1
+access_change_distribution_table_import_line_wizard_user,change.distribution.table.import.line.wizard.user,model_change_distribution_table_import_line_wizard,energy_project.group_user,1,1,1,1
+access_change_distribution_table_import_line_wizard_admin,change.distribution.table.import.line.wizard.admin,model_change_distribution_table_import_line_wizard,energy_project.group_admin,1,1,1,1
+
diff --git a/energy_selfconsumption/wizards/__init__.py b/energy_selfconsumption/wizards/__init__.py
index 4787ed8ec..d5dbd8a63 100644
--- a/energy_selfconsumption/wizards/__init__.py
+++ b/energy_selfconsumption/wizards/__init__.py
@@ -6,3 +6,4 @@ from . import distribution_table_import_wizard
 from . import invoicing_wizard
 from . import selfconsumption_import_wizard
 from . import change_state_inscription_wizard
+from . import change_distribution_table_import_wizard
diff --git a/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py b/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py
new file mode 100644
index 000000000..23b45d107
--- /dev/null
+++ b/energy_selfconsumption/wizards/change_distribution_table_import_wizard.py
@@ -0,0 +1,169 @@
+# -*- coding: utf-8 -*-
+import logging
+
+from odoo import models, fields, api, _
+from odoo.exceptions import UserError, ValidationError
+
+_logger = logging.getLogger(__name__)
+
+STATE_VALUES = [
+    ("active", _("Active")),
+    ("inactive", _("Inactive")),
+    ("change", _("Change")),
+]
+
+STATE_WIZARD_VALUES = [
+    ('old', _('Old')),
+    ('new', _('New')),
+    ('delete', _('Delete')),
+    ('change', _('Change'))
+]
+
+class Change_distribution_table_import_wizard(models.TransientModel):
+    _name = 'change.distribution.table.import.wizard'
+    _description = _('Change_distribution_table_import_wizard')
+
+    change_distribution_table_import_line_wizard_ids = fields.One2many(
+        "change.distribution.table.import.line.wizard",
+        "change_distribution_table_import_wizard_id",
+        string="Change distribution table import line wizard"
+    )
+
+    change_distribution_table_import_line_wizard_news_ids = fields.One2many(
+        "change.distribution.table.import.line.wizard",
+        "change_distribution_table_import_wizard_id",
+        string="Change distribution table import line wizard",
+        domain=[('state', '=', 'inactive')]
+    )
+
+    change_distribution_table_import_line_wizard_views_ids = fields.One2many(
+        "change.distribution.table.import.line.wizard",
+        string="Change distribution table import line wizard",
+        compute='_compute_change_distribution_table_import_line_wizard_ids'
+    )
+
+    state = fields.Selection(STATE_WIZARD_VALUES, required=True, string="Status", default='old')
+
+    @api.model
+    def default_get(self, default_fields):
+        # OVERRIDE
+        default_fields = super().default_get(default_fields)
+
+        inscription_ids = self.env['energy_selfconsumption.inscription_selfconsumption'].search([
+            ('selfconsumption_project_id', '=', self.env.context['default_selfconsumption_project_id']),
+            ('state', '!=', 'inactive')
+        ])
+
+        lines = []
+        for inscription in inscription_ids:
+            lines.append(
+                (
+                    0,
+                    0,
+                    {
+                        "change_distribution_table_import_wizard_id": self.id,
+                        "inscription_id": inscription.id,
+                        "state": inscription.state,
+                        "participation_real_quantity": inscription.participation_real_quantity,
+                    },
+                )
+            )
+
+        default_fields["change_distribution_table_import_line_wizard_ids"] = lines
+
+        inscription_ids = self.env['energy_selfconsumption.inscription_selfconsumption'].search([
+            ('selfconsumption_project_id', '=', self.env.context['default_selfconsumption_project_id']),
+            ('state', '=', 'inactive')
+        ])
+
+        lines = []
+        for inscription in inscription_ids:
+            lines.append(
+                (
+                    0,
+                    0,
+                    {
+                        "change_distribution_table_import_wizard_id": self.id,
+                        "inscription_id": inscription.id,
+                        "state": inscription.state,
+                        "participation_real_quantity": inscription.participation_real_quantity,
+                    },
+                )
+            )
+        default_fields["change_distribution_table_import_line_wizard_news_ids"] = lines
+        return default_fields
+    
+    @api.depends('state', 'change_distribution_table_import_line_wizard_ids')
+    def _compute_change_distribution_table_import_line_wizard_ids(self):
+        _logger.info(f"self.state: {self.state}")
+        if self.state == 'old':
+            self.change_distribution_table_import_line_wizard_views_ids = self.change_distribution_table_import_line_wizard_ids.filtered(lambda line: line.state == 'active')
+        elif self.state == 'delete':
+            self.change_distribution_table_import_line_wizard_views_ids = self.change_distribution_table_import_line_wizard_ids.filtered(lambda line: line.state == 'change' and line.participation_real_quantity == 0)
+        elif self.state == 'change':
+            self.change_distribution_table_import_line_wizard_views_ids = self.change_distribution_table_import_line_wizard_ids.filtered(lambda line: line.state == 'change' and line.participation_real_quantity > 0)
+        elif self.state == 'new':
+            self.change_distribution_table_import_line_wizard_views_ids = self.change_distribution_table_import_line_wizard_ids.filtered(lambda line: line.state == 'inactive')
+        else:
+            self.change_distribution_table_import_line_wizard_views_ids = self.change_distribution_table_import_line_wizard_ids
+    
+    def next_step(self):
+        if self.state == 'old':
+            self.state = 'delete'
+            return self.action_change_distribution_table_import()
+        elif self.state == 'delete':
+            self.state = 'change'
+            return self.action_change_distribution_table_import()
+        elif self.state == 'change':
+            self.state = 'new'
+            return self.action_change_distribution_table_import()
+        elif self.state == 'new':
+            return self.action_create_distribution_table_import()
+        else:
+            return self.action_change_distribution_table_import()
+
+    def previous_step(self):
+        if self.state == 'new':
+            self.state = 'change'
+            return self.action_change_distribution_table_import()
+        elif self.state == 'change':
+            self.state = 'delete'
+            return self.action_change_distribution_table_import()
+        elif self.state == 'delete':
+            self.state = 'old'
+            return self.action_change_distribution_table_import()
+        else:
+            return self.action_change_distribution_table_import()
+
+    def action_change_distribution_table_import(self):
+        action = self.env.ref('energy_selfconsumption.action_change_distribution_table_import_wizard').read()[0]
+        action.update({'res_id': self.id})
+        return action
+    
+    def action_create_distribution_table_import(self):
+        action = self.env.ref('energy_selfconsumption.create_distribution_table_wizard_action').read()[0]
+        inscription_ids = self.change_distribution_table_import_line_wizard_ids.filtered(lambda line: not (line.state == 'change' and line.participation_real_quantity == 0))
+        action.update({'context': {'active_ids': inscription_ids.inscription_id.ids}})
+        return action
+
+class Change_distribution_table_import_line_wizard(models.TransientModel):
+    _name = 'change.distribution.table.import.line.wizard'
+    _description = _('Change_distribution_table_import_line_wizard')
+
+    change_distribution_table_import_wizard_id = fields.Many2one(
+        "change.distribution.table.import.wizard",
+        string="Change state inscription wizard",
+        required=True,
+    )
+
+    inscription_id = fields.Many2one(
+        "energy_selfconsumption.inscription_selfconsumption",
+        string="Inscription",
+        required=True,
+    )
+
+    state = fields.Selection(STATE_VALUES, required=True, string="Status")
+
+    participation_real_quantity = fields.Float(
+        string="Participation real quantity", required=True
+    )
\ No newline at end of file
diff --git a/energy_selfconsumption/wizards/change_distribution_table_import_wizard.xml b/energy_selfconsumption/wizards/change_distribution_table_import_wizard.xml
new file mode 100644
index 000000000..612ca91ce
--- /dev/null
+++ b/energy_selfconsumption/wizards/change_distribution_table_import_wizard.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="utf-8"?>
+<odoo>
+    <data>
+
+        <!-- View change_distribution_table_import_wizard form -->
+        <record id="view_change_distribution_table_import_wizard_form" model="ir.ui.view">
+            <field name="name">view.change_distribution_table_import_wizard.form</field>
+            <field name="model">change.distribution.table.import.wizard</field>
+            <field name="arch" type="xml">
+                <form string="Change_distribution_table_import_wizard">
+                    <div class="oe_title">
+                        <field name="state" invisible="1"/>
+                        <field name="change_distribution_table_import_line_wizard_ids" invisible="1">
+                            <tree editable="bottom" create="0">
+                                <field name="change_distribution_table_import_wizard_id" readonly="1" force_save="1"/>
+                                <field name="inscription_id" readonly="1" force_save="1"/>
+                                <field name="state" readonly="1" force_save="1"/>
+                                <field name="participation_real_quantity" readonly="1" force_save="1"/>
+                            </tree>
+                        </field>
+                        <h1 attrs="{'invisible': [('state', '!=', 'old')]}">Retain old records</h1>
+                        <h1 attrs="{'invisible': [('state', '!=', 'delete')]}">Record deregistration</h1>
+                        <h1 attrs="{'invisible': [('state', '!=', 'change')]}">Update old records</h1>
+                        <h1 attrs="{'invisible': [('state', '!=', 'new')]}">New registrations</h1>
+                        <field name="change_distribution_table_import_line_wizard_views_ids" mode="tree" nolabel="1" attrs="{'invisible': [('state', '=', 'new')]}">
+                            <tree editable="bottom" create="0">
+                                <field name="inscription_id" />
+                                <field name="state" />
+                                <field name="participation_real_quantity" />
+                            </tree>
+                        </field>
+                        <field name="change_distribution_table_import_line_wizard_news_ids" attrs="{'invisible': [('state', '!=', 'new')]}">
+                            <tree editable="bottom" create="0">
+                                <field name="change_distribution_table_import_wizard_id" invisible="1" readonly="1" force_save="1"/>
+                                <field name="inscription_id" readonly="1" force_save="1"/>
+                                <field name="state" readonly="1" force_save="1"/>
+                                <field name="participation_real_quantity" readonly="1" force_save="1"/>
+                            </tree>
+                        </field>
+                    </div>
+                    <footer>
+                        <button name="next_step" type="object" string="Next step" class="oe_highlight"/>
+                        <button name="previous_step" type="object" string="Previous step" class="oe_highlight" attrs="{'invisible': [('state', '==', 'old')]}"/>
+                        <button special="cancel" string="Cancel"/>
+                    </footer>
+                </form>
+            </field>
+        </record>
+
+        <!-- Action change_distribution_table_import_wizard -->
+        <record id="action_change_distribution_table_import_wizard" model="ir.actions.act_window">
+            <field name="name">Change distribution table</field>
+            <field name="type">ir.actions.act_window</field>
+            <field name="res_model">change.distribution.table.import.wizard</field>
+            <field name="binding_model_id" ref="model_energy_selfconsumption_inscription_selfconsumption" />
+            <field name="view_mode">form</field>
+            <field name="target">new</field>
+        </record>
+
+    </data>
+
+</odoo>
-- 
GitLab


From 4ec6eef09133c9cf8044456751e33ba818096af8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81lvaro=20Garc=C3=ADa?= <alvarogruiz8@gmail.com>
Date: Tue, 4 Mar 2025 09:31:36 +0100
Subject: [PATCH 05/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20New=20field=20partici?=
 =?UTF-8?q?pation=20on=20distribution=20table?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: Alvaro Garcia <alvaro.garcia@somit.coop>
---
 energy_selfconsumption/models/supply_point_assignation.py | 6 ++++++
 energy_selfconsumption/views/distribution_table_views.xml | 1 +
 2 files changed, 7 insertions(+)

diff --git a/energy_selfconsumption/models/supply_point_assignation.py b/energy_selfconsumption/models/supply_point_assignation.py
index fc5c3841e..de6080ba0 100644
--- a/energy_selfconsumption/models/supply_point_assignation.py
+++ b/energy_selfconsumption/models/supply_point_assignation.py
@@ -36,6 +36,11 @@ class SupplyPointAssignation(models.Model):
                 record.selfconsumption_project_id.power * record.coefficient
             )
 
+    @api.depends("coefficient")
+    def _compute_participacion(self):
+        for record in self:
+            record.participacion = record.coefficient * record.selfconsumption_project_id.power
+
     distribution_table_id = fields.Many2one(
         "energy_selfconsumption.distribution_table", required=True
     )
@@ -50,6 +55,7 @@ class SupplyPointAssignation(models.Model):
     supply_point_id = fields.Many2one(
         "energy_selfconsumption.supply_point", required=True
     )
+    participacion = fields.Float(string="Participacion",compute="_compute_participacion", store=True)
     coefficient = fields.Float(
         string="Distribution coefficient",
         digits=(7, 6),
diff --git a/energy_selfconsumption/views/distribution_table_views.xml b/energy_selfconsumption/views/distribution_table_views.xml
index 053ad6ce9..a8d0dcb04 100644
--- a/energy_selfconsumption/views/distribution_table_views.xml
+++ b/energy_selfconsumption/views/distribution_table_views.xml
@@ -86,6 +86,7 @@
                   />
                                     <field name="owner_id" />
                                     <field name="code" />
+                                    <field name="participacion"  sum="True"/>
                                     <field
                     name="coefficient"
                     sum="True"
-- 
GitLab


From 75c37b7ab6658b7448f3447a324e19062681c918 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Mon, 20 Jan 2025 16:54:16 +0100
Subject: [PATCH 06/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20New=20ec=5Fservice=5F?=
 =?UTF-8?q?invoicing=5Fmodule.=20Relationship=20between=20SO/Contract=20an?=
 =?UTF-8?q?d=20Community?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../__init__.py                               |  2 ++
 .../__manifest__.py                           | 24 +++++++++++++++++++
 .../models/__init__.py                        |  2 ++
 .../models/contract.py                        | 13 ++++++++++
 .../models/sale_order.py                      | 23 ++++++++++++++++++
 .../security/ir.model.access.csv              |  2 ++
 .../views/contract_views.xml                  | 12 ++++++++++
 .../views/sale_order_views.xml                | 12 ++++++++++
 .../energy_communities_service_invoicing      |  1 +
 .../setup.py                                  |  6 +++++
 10 files changed, 97 insertions(+)
 create mode 100644 energy_communities_service_invoicing/__init__.py
 create mode 100644 energy_communities_service_invoicing/__manifest__.py
 create mode 100644 energy_communities_service_invoicing/models/__init__.py
 create mode 100644 energy_communities_service_invoicing/models/contract.py
 create mode 100644 energy_communities_service_invoicing/models/sale_order.py
 create mode 100644 energy_communities_service_invoicing/security/ir.model.access.csv
 create mode 100644 energy_communities_service_invoicing/views/contract_views.xml
 create mode 100644 energy_communities_service_invoicing/views/sale_order_views.xml
 create mode 120000 setup/energy_communities_service_invoicing/odoo/addons/energy_communities_service_invoicing
 create mode 100644 setup/energy_communities_service_invoicing/setup.py

diff --git a/energy_communities_service_invoicing/__init__.py b/energy_communities_service_invoicing/__init__.py
new file mode 100644
index 000000000..9d794022b
--- /dev/null
+++ b/energy_communities_service_invoicing/__init__.py
@@ -0,0 +1,2 @@
+# from . import controllers
+from . import models
diff --git a/energy_communities_service_invoicing/__manifest__.py b/energy_communities_service_invoicing/__manifest__.py
new file mode 100644
index 000000000..1abf492aa
--- /dev/null
+++ b/energy_communities_service_invoicing/__manifest__.py
@@ -0,0 +1,24 @@
+{
+    "name": "energy_communities_service_invoicing",
+    "summary": """
+        Short (1 phrase/line) summary of the module's purpose, used as
+        subtitle on modules listing or apps.openerp.com""",
+    "description": """
+        Long description of module's purpose
+    """,
+    "author": "Som comunitats",
+    "website": "https://coopdevs.org",
+    "category": "Contract Management",
+    "version": "16.0.0.1.1",
+    # any module necessary for this one to work correctly
+    "depends": ["base", "product_contract", "energy_communities"],
+    # always loaded
+    "data": [
+        # 'security/ir.model.access.csv',
+        "views/contract_views.xml",
+        "views/sale_order_views.xml",
+        # 'views/templates.xml',
+    ],
+    # only loaded in demonstration mode
+    "demo": [],
+}
diff --git a/energy_communities_service_invoicing/models/__init__.py b/energy_communities_service_invoicing/models/__init__.py
new file mode 100644
index 000000000..7b51a0ddc
--- /dev/null
+++ b/energy_communities_service_invoicing/models/__init__.py
@@ -0,0 +1,2 @@
+from . import contract
+from . import sale_order
diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
new file mode 100644
index 000000000..a85c3969c
--- /dev/null
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -0,0 +1,13 @@
+from odoo import api, fields, models
+from odoo.exceptions import AccessError
+from odoo.tools.translate import _
+
+
+class ContractContract(models.Model):
+    _inherit = "contract.contract"
+
+    community_company_id = fields.Many2one(
+        "res.company",
+        string="Related community",
+        domain="[('hierarchy_level','=','community')]",
+    )
diff --git a/energy_communities_service_invoicing/models/sale_order.py b/energy_communities_service_invoicing/models/sale_order.py
new file mode 100644
index 000000000..692affc57
--- /dev/null
+++ b/energy_communities_service_invoicing/models/sale_order.py
@@ -0,0 +1,23 @@
+# Copyright 2017 LasLabs Inc.
+# Copyright 2018 ACSONE SA/NV.
+# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
+
+from odoo import _, api, fields, models
+
+
+class SaleOrder(models.Model):
+    _name = "sale.order"
+    _inherit = "sale.order"
+
+    community_company_id = fields.Many2one(
+        "res.company",
+        string="Related community",
+        domain="[('hierarchy_level','=','community')]",
+    )
+
+    def action_create_contract(self):
+        contracts = super().action_create_contract()
+        if self.community_company_id:
+            for contract in contracts:
+                contract.write({"community_company_id": self.community_company_id.id})
+        return contracts
diff --git a/energy_communities_service_invoicing/security/ir.model.access.csv b/energy_communities_service_invoicing/security/ir.model.access.csv
new file mode 100644
index 000000000..9dff95140
--- /dev/null
+++ b/energy_communities_service_invoicing/security/ir.model.access.csv
@@ -0,0 +1,2 @@
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+access_energy_communities_service_invoicing_energy_communities_service_invoicing,energy_communities_service_invoicing.energy_communities_service_invoicing,model_energy_communities_service_invoicing_energy_communities_service_invoicing,base.group_user,1,1,1,1
diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
new file mode 100644
index 000000000..3242677dd
--- /dev/null
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -0,0 +1,12 @@
+<odoo>
+  <record id="contract_contract_customer_form_view" model="ir.ui.view">
+    <field name="name">contract.contract.form (in energy_communities service_invoicing)</field>
+    <field name="model">contract.contract</field>
+    <field name="inherit_id" ref="contract.contract_contract_customer_form_view" />
+    <field name="arch" type="xml">
+      <xpath expr="//field[@name='partner_id']" position="after">
+        <field name="community_company_id" />
+      </xpath>
+    </field>
+  </record>
+</odoo>
diff --git a/energy_communities_service_invoicing/views/sale_order_views.xml b/energy_communities_service_invoicing/views/sale_order_views.xml
new file mode 100644
index 000000000..0b330c7aa
--- /dev/null
+++ b/energy_communities_service_invoicing/views/sale_order_views.xml
@@ -0,0 +1,12 @@
+<odoo>
+  <record id="view_order_form" model="ir.ui.view">
+    <field name="name">sale.order.form (in energy_communities service_invoicing)</field>
+    <field name="model">sale.order</field>
+    <field name="inherit_id" ref="sale.view_order_form" />
+    <field name="arch" type="xml">
+        <xpath expr="//field[@name='partner_id']" position="after">
+          <field name="community_company_id" />
+        </xpath>
+    </field>
+  </record>
+</odoo>
diff --git a/setup/energy_communities_service_invoicing/odoo/addons/energy_communities_service_invoicing b/setup/energy_communities_service_invoicing/odoo/addons/energy_communities_service_invoicing
new file mode 120000
index 000000000..9bc8ee3e2
--- /dev/null
+++ b/setup/energy_communities_service_invoicing/odoo/addons/energy_communities_service_invoicing
@@ -0,0 +1 @@
+../../../../energy_communities_service_invoicing
\ No newline at end of file
diff --git a/setup/energy_communities_service_invoicing/setup.py b/setup/energy_communities_service_invoicing/setup.py
new file mode 100644
index 000000000..28c57bb64
--- /dev/null
+++ b/setup/energy_communities_service_invoicing/setup.py
@@ -0,0 +1,6 @@
+import setuptools
+
+setuptools.setup(
+    setup_requires=['setuptools-odoo'],
+    odoo_addon=True,
+)
-- 
GitLab


From d426c96d442fb83025b3647ebdc4c28393cf8a97 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Mon, 20 Jan 2025 17:55:47 +0100
Subject: [PATCH 07/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Service=20invoicing?=
 =?UTF-8?q?=20views?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 energy_communities/views/menus.xml            | 10 ++--
 .../__manifest__.py                           |  1 +
 .../views/contract_views.xml                  | 51 ++++++++++++++++++-
 .../views/menus.xml                           |  3 ++
 4 files changed, 57 insertions(+), 8 deletions(-)
 create mode 100644 energy_communities_service_invoicing/views/menus.xml

diff --git a/energy_communities/views/menus.xml b/energy_communities/views/menus.xml
index e51ce0a40..0c01b523a 100644
--- a/energy_communities/views/menus.xml
+++ b/energy_communities/views/menus.xml
@@ -4,23 +4,21 @@
      License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
 -->
 <odoo>
-    <menuitem
+  <menuitem
     id="ce_root_menu"
     name="Energy Communities"
     sequence="10"
     groups="group_platform_manager"
     web_icon="energy_communities,static/description/icon.png"
   />
-    <menuitem id="ce_config_menu" name="Configuration" parent="ce_root_menu" />
-
-        <menuitem
+  <menuitem id="ce_config_menu" name="Configuration" parent="ce_root_menu" sequence="99" />
+  <menuitem
     id="ce_config_sources_menu"
     name="Source types"
     parent="ce_config_menu"
     action="ce_utm_sources_action"
   />
-
-        <menuitem
+  <menuitem
     id="energy_actions_menu"
     name="Energy actions"
     parent="ce_config_menu"
diff --git a/energy_communities_service_invoicing/__manifest__.py b/energy_communities_service_invoicing/__manifest__.py
index 1abf492aa..1cc05078e 100644
--- a/energy_communities_service_invoicing/__manifest__.py
+++ b/energy_communities_service_invoicing/__manifest__.py
@@ -15,6 +15,7 @@
     # always loaded
     "data": [
         # 'security/ir.model.access.csv',
+        "views/menus.xml",
         "views/contract_views.xml",
         "views/sale_order_views.xml",
         # 'views/templates.xml',
diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index 3242677dd..1e3756eeb 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -1,12 +1,59 @@
 <odoo>
-  <record id="contract_contract_customer_form_view" model="ir.ui.view">
+
+  <record id="view_service_invoicing_tree" model="ir.ui.view">
+    <field name="name">service.invoicing.tree</field>
+    <field name="model">contract.contract</field>
+    <field name="type">tree</field>
+    <field name="arch" type="xml">
+      <tree>
+        <field name="name" />
+        <field name="partner_id" />
+        <field name="community_company_id" />
+        <field name="contract_template_id" />
+      </tree>
+    </field>
+  </record>
+
+  <record id="view_contract_contract_customer_form" model="ir.ui.view">
     <field name="name">contract.contract.form (in energy_communities service_invoicing)</field>
     <field name="model">contract.contract</field>
-    <field name="inherit_id" ref="contract.contract_contract_customer_form_view" />
+    <field name="inherit_id" ref="product_contract.contract_contract_customer_form_view" />
     <field name="arch" type="xml">
       <xpath expr="//field[@name='partner_id']" position="after">
         <field name="community_company_id" />
       </xpath>
     </field>
   </record>
+
+  <record
+      id="view_service_invoicing_window"
+      model="ir.actions.act_window"
+  >
+    <field name="name">Communities Services</field>
+    <field name="res_model">contract.contract</field>
+    <field name="view_mode">tree,form</field>
+    <field name="domain">[('community_company_id','!=',False)]</field>
+  </record>
+
+  <record model="ir.actions.act_window.view" id="action_view_service_invoicing_tree">
+    <field name="sequence" eval="1"/>
+    <field name="view_mode">tree</field>
+    <field name="view_id" ref="view_service_invoicing_tree"/>
+    <field name="act_window_id" ref="view_service_invoicing_window"/>
+  </record>
+
+  <record model="ir.actions.act_window.view" id="action_view_contract_contract_customer_form">
+    <field name="sequence" eval="2"/>
+    <field name="view_mode">form</field>
+    <field name="view_id" ref="view_contract_contract_customer_form"/>
+    <field name="act_window_id" ref="view_service_invoicing_window"/>
+  </record>
+
+  <menuitem
+    name="Communities Services"
+    id="view_service_invoicing_menu"
+    parent="ce_service_invoicing_menu"
+    action="view_service_invoicing_window"
+    sequence="170"
+  />
 </odoo>
diff --git a/energy_communities_service_invoicing/views/menus.xml b/energy_communities_service_invoicing/views/menus.xml
new file mode 100644
index 000000000..ae9428640
--- /dev/null
+++ b/energy_communities_service_invoicing/views/menus.xml
@@ -0,0 +1,3 @@
+<odoo>
+  <menuitem id="ce_service_invoicing_menu" name="Services" parent="energy_communities.ce_root_menu" sequence="1" />
+</odoo>
-- 
GitLab


From cf110bbebf5be9d3b07232f443b2c91aaf76aeaa Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Mon, 20 Jan 2025 18:35:52 +0100
Subject: [PATCH 08/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Service=20Invoicing?=
 =?UTF-8?q?=20Create=20Wizard=20base=20structure?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../__init__.py                               |  1 +
 .../__manifest__.py                           |  4 +-
 .../security/ir.model.access.csv              |  2 +-
 .../views/contract_views.xml                  |  2 +-
 .../wizards/__init__.py                       |  1 +
 .../wizards/service_invoicing_create.py       | 39 +++++++++++++++
 .../wizards/service_invoicing_create.xml      | 49 +++++++++++++++++++
 7 files changed, 94 insertions(+), 4 deletions(-)
 create mode 100644 energy_communities_service_invoicing/wizards/__init__.py
 create mode 100644 energy_communities_service_invoicing/wizards/service_invoicing_create.py
 create mode 100644 energy_communities_service_invoicing/wizards/service_invoicing_create.xml

diff --git a/energy_communities_service_invoicing/__init__.py b/energy_communities_service_invoicing/__init__.py
index 9d794022b..5eab8b2bb 100644
--- a/energy_communities_service_invoicing/__init__.py
+++ b/energy_communities_service_invoicing/__init__.py
@@ -1,2 +1,3 @@
 # from . import controllers
 from . import models
+from . import wizards
diff --git a/energy_communities_service_invoicing/__manifest__.py b/energy_communities_service_invoicing/__manifest__.py
index 1cc05078e..c7869284f 100644
--- a/energy_communities_service_invoicing/__manifest__.py
+++ b/energy_communities_service_invoicing/__manifest__.py
@@ -14,11 +14,11 @@
     "depends": ["base", "product_contract", "energy_communities"],
     # always loaded
     "data": [
-        # 'security/ir.model.access.csv',
+        "security/ir.model.access.csv",
         "views/menus.xml",
         "views/contract_views.xml",
         "views/sale_order_views.xml",
-        # 'views/templates.xml',
+        "wizards/service_invoicing_create.xml",
     ],
     # only loaded in demonstration mode
     "demo": [],
diff --git a/energy_communities_service_invoicing/security/ir.model.access.csv b/energy_communities_service_invoicing/security/ir.model.access.csv
index 9dff95140..c7434dda5 100644
--- a/energy_communities_service_invoicing/security/ir.model.access.csv
+++ b/energy_communities_service_invoicing/security/ir.model.access.csv
@@ -1,2 +1,2 @@
 id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
-access_energy_communities_service_invoicing_energy_communities_service_invoicing,energy_communities_service_invoicing.energy_communities_service_invoicing,model_energy_communities_service_invoicing_energy_communities_service_invoicing,base.group_user,1,1,1,1
+access_service_invoicing_create_wizard,service_invoicing_create_wizard,model_service_invoicing_create_wizard,base.group_user,1,1,1,1
diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index 1e3756eeb..2cfe1f1e4 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -54,6 +54,6 @@
     id="view_service_invoicing_menu"
     parent="ce_service_invoicing_menu"
     action="view_service_invoicing_window"
-    sequence="170"
+    sequence="100"
   />
 </odoo>
diff --git a/energy_communities_service_invoicing/wizards/__init__.py b/energy_communities_service_invoicing/wizards/__init__.py
new file mode 100644
index 000000000..ccd2ce8f9
--- /dev/null
+++ b/energy_communities_service_invoicing/wizards/__init__.py
@@ -0,0 +1 @@
+from . import service_invoicing_create
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_create.py
new file mode 100644
index 000000000..e094c7598
--- /dev/null
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_create.py
@@ -0,0 +1,39 @@
+from odoo import api, fields, models
+from odoo.exceptions import ValidationError
+from odoo.tools.translate import _
+
+
+class ServiceInvoicingCreateWizard(models.TransientModel):
+    _name = "service.invoicing.create.wizard"
+    _description = "Create service invoicing for an energy community"
+
+    company_id = fields.Many2one("res.company", string="Coordinator")
+    community_company_id = fields.Many2one("res.company", string="Community")
+    service_id = fields.Many2one("product.product", string="Service")
+
+    def execute_create(self):
+        return True
+        # self._consistency_validation()
+        # voluntary_share_interest_return = self.env[
+        #     "voluntary.share.interest.return"
+        # ].create(
+        #     {
+        #         "name": "{company_name} voluntary share interest return from {start_date_period} to {end_date_period}".format(
+        #             company_name=self.company_id.name,
+        #             start_date_period=self.start_date_period,
+        #             end_date_period=self.end_date_period,
+        #         ),
+        #         "start_date_period": self.start_date_period,
+        #         "end_date_period": self.end_date_period,
+        #         "payment_mode_id": self.payment_mode_id.id,
+        #     }
+        # )
+        # return {
+        #     "type": "ir.actions.act_window",
+        #     "name": _("Return voluntary shares interest"),
+        #     "res_model": "voluntary.share.interest.return",
+        #     "view_type": "form",
+        #     "view_mode": "form",
+        #     "target": "current",
+        #     "res_id": voluntary_share_interest_return.id,
+        # }
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_create.xml b/energy_communities_service_invoicing/wizards/service_invoicing_create.xml
new file mode 100644
index 000000000..feb1ff6bf
--- /dev/null
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_create.xml
@@ -0,0 +1,49 @@
+<odoo>
+  <record
+    id="view_service_invoicing_create_wizard_form"
+    model="ir.ui.view"
+  >
+    <field name="name">service.invoicing.create.wizard.form</field>
+    <field name="model">service.invoicing.create.wizard</field>
+    <field name="arch" type="xml">
+      <form string="Service invoicing">
+        <sheet>
+          <group>
+            <field name="company_id" required="1" domain="[('hierarchy_level','=','coordinator')]"/>
+            <field name="community_company_id" required="1" domain="[('hierarchy_level','=','community')]"/>
+            <field name="service_id" required="1" domain="[('is_contract','=',True)]"/>
+          </group>
+        </sheet>
+        <footer>
+          <button
+            name="execute_create"
+            string="create"
+            type="object"
+            class="btn-primary"
+          />
+          <button
+            string="Cancelar"
+            class="btn-secondary"
+            special="cancel"
+          />
+        </footer>
+      </form>
+    </field>
+  </record>
+  <record
+    model="ir.actions.act_window"
+    id="service_invoicing_create_wizard_action"
+  >
+      <field name="name">Create community service invoicing</field>
+      <field name="res_model">service.invoicing.create.wizard</field>
+      <field name="view_mode">form</field>
+      <field name="target">new</field>
+  </record>
+  <menuitem
+    id="service_invoicing_create_wizard_menu"
+    name="Create community service invoicing"
+    action="service_invoicing_create_wizard_action"
+    parent="ce_service_invoicing_menu"
+    sequence="200"
+  />
+</odoo>
-- 
GitLab


From 60a7fff37488a382119895946c898054e643b3d0 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Mon, 20 Jan 2025 19:02:43 +0100
Subject: [PATCH 09/85] =?UTF-8?q?type=20<description>=20[IMP]=20=E2=9C=A8?=
 =?UTF-8?q?=20Introducing=20sale=5Forder=5Futils=20component=20architectur?=
 =?UTF-8?q?e?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 energy_communities/components/__init__.py            |  1 +
 energy_communities/components/sale_order_utils.py    |  8 ++++++++
 energy_communities/utils.py                          | 12 ++++++++++++
 energy_communities_service_invoicing/__init__.py     |  2 +-
 .../components/__init__.py                           |  1 +
 .../components/sale_order_utils.py                   | 10 ++++++++++
 .../wizards/service_invoicing_create.py              |  8 ++++++++
 7 files changed, 41 insertions(+), 1 deletion(-)
 create mode 100644 energy_communities/components/sale_order_utils.py
 create mode 100644 energy_communities_service_invoicing/components/__init__.py
 create mode 100644 energy_communities_service_invoicing/components/sale_order_utils.py

diff --git a/energy_communities/components/__init__.py b/energy_communities/components/__init__.py
index 9cd2ec189..7671ffc6a 100644
--- a/energy_communities/components/__init__.py
+++ b/energy_communities/components/__init__.py
@@ -1,2 +1,3 @@
 from . import collections
 from .user_creator import UserCreator
+from .sale_order_utils import SaleOrderUtils
diff --git a/energy_communities/components/sale_order_utils.py b/energy_communities/components/sale_order_utils.py
new file mode 100644
index 000000000..f5d109ec5
--- /dev/null
+++ b/energy_communities/components/sale_order_utils.py
@@ -0,0 +1,8 @@
+from odoo.addons.component.core import Component
+
+
+class SaleOrderUtils(Component):
+    _name = "sale.order.utils"
+    _usage = "sale.order.utils"
+    _apply_on = "sale.order"
+    _collection = "utils.backend"
diff --git a/energy_communities/utils.py b/energy_communities/utils.py
index ad0831504..3bb961164 100644
--- a/energy_communities/utils.py
+++ b/energy_communities/utils.py
@@ -18,6 +18,18 @@ def user_creator(
     yield work.component(usage="user.create")
 
 
+@contextmanager
+def sale_order_utils(
+    env: Environment,
+) -> Component:
+    backend = env["utils.backend"].browse(1)
+    work = WorkContext(
+        model_name="sale.order",
+        collection=backend,
+    )
+    yield work.component(usage="sale.order.utils")
+
+
 def get_translation(source, lang, mods):
     translation = code_translations.get_web_translations(mods, lang)
     translation.update(code_translations.get_python_translations(mods, lang))
diff --git a/energy_communities_service_invoicing/__init__.py b/energy_communities_service_invoicing/__init__.py
index 5eab8b2bb..79dbb9408 100644
--- a/energy_communities_service_invoicing/__init__.py
+++ b/energy_communities_service_invoicing/__init__.py
@@ -1,3 +1,3 @@
-# from . import controllers
+from . import components
 from . import models
 from . import wizards
diff --git a/energy_communities_service_invoicing/components/__init__.py b/energy_communities_service_invoicing/components/__init__.py
new file mode 100644
index 000000000..d079f6930
--- /dev/null
+++ b/energy_communities_service_invoicing/components/__init__.py
@@ -0,0 +1 @@
+from . import sale_order_utils
diff --git a/energy_communities_service_invoicing/components/sale_order_utils.py b/energy_communities_service_invoicing/components/sale_order_utils.py
new file mode 100644
index 000000000..e35073b09
--- /dev/null
+++ b/energy_communities_service_invoicing/components/sale_order_utils.py
@@ -0,0 +1,10 @@
+from odoo.addons.component.core import Component
+
+
+class SaleOrderUtils(Component):
+    _inherit = "sale.order.utils"
+
+    def create_service_invoicing_activation_sale_order(
+        self, company_id, community_company_id, service_id
+    ):
+        print("CREATE SO on component!")
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_create.py
index e094c7598..3d2c0d309 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_create.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_create.py
@@ -2,6 +2,8 @@ from odoo import api, fields, models
 from odoo.exceptions import ValidationError
 from odoo.tools.translate import _
 
+from odoo.addons.energy_communities.utils import sale_order_utils
+
 
 class ServiceInvoicingCreateWizard(models.TransientModel):
     _name = "service.invoicing.create.wizard"
@@ -12,6 +14,12 @@ class ServiceInvoicingCreateWizard(models.TransientModel):
     service_id = fields.Many2one("product.product", string="Service")
 
     def execute_create(self):
+        with sale_order_utils(self.env) as component:
+            so = component.create_service_invoicing_activation_sale_order(
+                company_id=self.company_id,
+                community_company_id=self.community_company_id,
+                service_id=self.service_id,
+            )
         return True
         # self._consistency_validation()
         # voluntary_share_interest_return = self.env[
-- 
GitLab


From 2b21f338dbeb502a30c19c959441997589d977c4 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Tue, 21 Jan 2025 18:28:18 +0100
Subject: [PATCH 10/85] =?UTF-8?q?[WIP]=20=F0=9F=9A=A7=20service-invoicing?=
 =?UTF-8?q?=20module?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 energy_communities/components/__init__.py     |  1 +
 .../components/contract_utils.py              |  8 ++++
 energy_communities/utils.py                   | 48 ++++++++++++++-----
 .../__manifest__.py                           |  3 +-
 .../components/__init__.py                    |  1 +
 .../components/contract_utils.py              | 19 ++++++++
 .../components/sale_order_utils.py            | 28 ++++++++++-
 .../models/contract.py                        | 15 ++++++
 .../security/ir.model.access.csv              |  3 +-
 .../views/contract_views.xml                  |  9 ++++
 .../wizards/__init__.py                       |  3 +-
 .../wizards/service_invoicing_action.py       | 22 +++++++++
 .../wizards/service_invoicing_action.xml      | 42 ++++++++++++++++
 .../service_invoicing_action_create.py        | 43 +++++++++++++++++
 ...ml => service_invoicing_action_create.xml} | 14 +++---
 .../wizards/service_invoicing_create.py       | 47 ------------------
 16 files changed, 236 insertions(+), 70 deletions(-)
 create mode 100644 energy_communities/components/contract_utils.py
 create mode 100644 energy_communities_service_invoicing/components/contract_utils.py
 create mode 100644 energy_communities_service_invoicing/wizards/service_invoicing_action.py
 create mode 100644 energy_communities_service_invoicing/wizards/service_invoicing_action.xml
 create mode 100644 energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
 rename energy_communities_service_invoicing/wizards/{service_invoicing_create.xml => service_invoicing_action_create.xml} (72%)
 delete mode 100644 energy_communities_service_invoicing/wizards/service_invoicing_create.py

diff --git a/energy_communities/components/__init__.py b/energy_communities/components/__init__.py
index 7671ffc6a..66da3f6fc 100644
--- a/energy_communities/components/__init__.py
+++ b/energy_communities/components/__init__.py
@@ -1,3 +1,4 @@
 from . import collections
 from .user_creator import UserCreator
+from .contract_utils import ContractUtils
 from .sale_order_utils import SaleOrderUtils
diff --git a/energy_communities/components/contract_utils.py b/energy_communities/components/contract_utils.py
new file mode 100644
index 000000000..eb4a3d3b7
--- /dev/null
+++ b/energy_communities/components/contract_utils.py
@@ -0,0 +1,8 @@
+from odoo.addons.component.core import Component
+
+
+class ContractUtils(Component):
+    _name = "contract.utils"
+    _usage = "contract.utils"
+    _apply_on = "contract.contract"
+    _collection = "utils.backend"
diff --git a/energy_communities/utils.py b/energy_communities/utils.py
index 3bb961164..d0a440e78 100644
--- a/energy_communities/utils.py
+++ b/energy_communities/utils.py
@@ -6,28 +6,52 @@ from odoo.tools.translate import code_translations
 from odoo.addons.component.core import Component, WorkContext
 
 
-@contextmanager
-def user_creator(
-    env: Environment,
-) -> Component:
+def _get_component(env: Environment, model_name: str, usage: str) -> Component:
     backend = env["utils.backend"].browse(1)
     work = WorkContext(
-        model_name="res.users",
+        model_name=model_name,
         collection=backend,
     )
-    yield work.component(usage="user.create")
+    return work.component(usage=usage)
+
+
+@contextmanager
+def user_creator(
+    env: Environment,
+) -> Component:
+    # backend = env["utils.backend"].browse(1)
+    # work = WorkContext(
+    #     model_name="res.users",
+    #     collection=backend,
+    # )
+    # yield work.component(usage="user.create")
+    yield _get_component(env, "res.users", "user.create")
+
+
+@contextmanager
+def contract_utils(
+    env: Environment,
+) -> Component:
+    # backend = env["utils.backend"].browse(1)
+    # work = WorkContext(
+    #     model_name="contract.contract",
+    #     collection=backend,
+    # )
+    # yield work.component(usage="contract.utils")
+    yield _get_component(env, "contract.contract", "contract.utils")
 
 
 @contextmanager
 def sale_order_utils(
     env: Environment,
 ) -> Component:
-    backend = env["utils.backend"].browse(1)
-    work = WorkContext(
-        model_name="sale.order",
-        collection=backend,
-    )
-    yield work.component(usage="sale.order.utils")
+    # backend = env["utils.backend"].browse(1)
+    # work = WorkContext(
+    #     model_name="sale.order",
+    #     collection=backend,
+    # )
+    # yield work.component(usage="sale.order.utils")
+    yield _get_component(env, "sale.order", "sale.order.utils")
 
 
 def get_translation(source, lang, mods):
diff --git a/energy_communities_service_invoicing/__manifest__.py b/energy_communities_service_invoicing/__manifest__.py
index c7869284f..e0d2a3301 100644
--- a/energy_communities_service_invoicing/__manifest__.py
+++ b/energy_communities_service_invoicing/__manifest__.py
@@ -18,7 +18,8 @@
         "views/menus.xml",
         "views/contract_views.xml",
         "views/sale_order_views.xml",
-        "wizards/service_invoicing_create.xml",
+        "wizards/service_invoicing_action.xml",
+        "wizards/service_invoicing_action_create.xml",
     ],
     # only loaded in demonstration mode
     "demo": [],
diff --git a/energy_communities_service_invoicing/components/__init__.py b/energy_communities_service_invoicing/components/__init__.py
index d079f6930..f24c5e551 100644
--- a/energy_communities_service_invoicing/components/__init__.py
+++ b/energy_communities_service_invoicing/components/__init__.py
@@ -1 +1,2 @@
+from . import contract_utils
 from . import sale_order_utils
diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
new file mode 100644
index 000000000..6ceb7d5fb
--- /dev/null
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -0,0 +1,19 @@
+from odoo.addons.component.core import Component
+
+
+class ContractUtils(Component):
+    _inherit = "contract.utils"
+
+    def set_contract_on_hold(self, contract):
+        for line in contract.contract_line_ids:
+            line.cancel()
+
+    def set_contract_active(self, contract_id, activation_date):
+        for line in contract_id.contract_line_ids:
+            line.write(
+                {
+                    "date_start": activation_date,
+                    "next_period_date_start": activation_date,
+                    "recurring_next_date": activation_date,
+                }
+            )
diff --git a/energy_communities_service_invoicing/components/sale_order_utils.py b/energy_communities_service_invoicing/components/sale_order_utils.py
index e35073b09..c113003b0 100644
--- a/energy_communities_service_invoicing/components/sale_order_utils.py
+++ b/energy_communities_service_invoicing/components/sale_order_utils.py
@@ -1,3 +1,5 @@
+from datetime import datetime
+
 from odoo.addons.component.core import Component
 
 
@@ -7,4 +9,28 @@ class SaleOrderUtils(Component):
     def create_service_invoicing_activation_sale_order(
         self, company_id, community_company_id, service_id
     ):
-        print("CREATE SO on component!")
+        so_creation_dict = {
+            "partner_id": company_id.partner_id.id,
+            "community_company_id": community_company_id.id,
+            "order_line": [
+                (
+                    0,
+                    0,
+                    {
+                        "product_id": service_id.id,
+                        # "product_uom,qty": 1,
+                        "date_start": datetime.now(),
+                        "date_end": datetime.now(),
+                    },
+                )
+            ],
+        }
+        return self.env["sale.order"].create(so_creation_dict)
+        # print("CREATE SO on component!")
+
+    def get_related_contracts(self, sale_order):
+        return (
+            self.env["contract.line"]
+            .search([("sale_order_line_id", "in", sale_order.order_line.ids)])
+            .mapped("contract_id")
+        )
diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index a85c3969c..57c9cf48a 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -11,3 +11,18 @@ class ContractContract(models.Model):
         string="Related community",
         domain="[('hierarchy_level','=','community')]",
     )
+
+    def action_activate_contract(self):
+        self.ensure_one()
+        wizard = self.env["service.invoicing.action.wizard"].create(
+            {"service_invoicing_id": self.id}
+        )
+        return {
+            "type": "ir.actions.act_window",
+            "name": _("Activate srvice invoicing"),
+            "res_model": "service.invoicing.action.wizard",
+            "view_type": "form",
+            "view_mode": "form",
+            "target": "new",
+            "res_id": wizard.id,
+        }
diff --git a/energy_communities_service_invoicing/security/ir.model.access.csv b/energy_communities_service_invoicing/security/ir.model.access.csv
index c7434dda5..2d0b824de 100644
--- a/energy_communities_service_invoicing/security/ir.model.access.csv
+++ b/energy_communities_service_invoicing/security/ir.model.access.csv
@@ -1,2 +1,3 @@
 id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
-access_service_invoicing_create_wizard,service_invoicing_create_wizard,model_service_invoicing_create_wizard,base.group_user,1,1,1,1
+access_service_invoicing_action_wizard,service_invoicing_action_wizard,model_service_invoicing_action_wizard,base.group_user,1,1,1,1
+access_service_invoicing_action_create_wizard,service_invoicing_action_create_wizard,model_service_invoicing_action_create_wizard,base.group_user,1,1,1,1
diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index 2cfe1f1e4..805b869a7 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -19,6 +19,15 @@
     <field name="model">contract.contract</field>
     <field name="inherit_id" ref="product_contract.contract_contract_customer_form_view" />
     <field name="arch" type="xml">
+      <xpath expr="//button[@name='action_preview']" position="after">
+      <!--<xpath expr="//header" position="inside">-->
+        <button
+          name="action_activate_contract"
+          type="object"
+          string="Activate"
+        />
+        <!--groups="energy_communities.group_platform_manager"-->
+      </xpath>
       <xpath expr="//field[@name='partner_id']" position="after">
         <field name="community_company_id" />
       </xpath>
diff --git a/energy_communities_service_invoicing/wizards/__init__.py b/energy_communities_service_invoicing/wizards/__init__.py
index ccd2ce8f9..a58483082 100644
--- a/energy_communities_service_invoicing/wizards/__init__.py
+++ b/energy_communities_service_invoicing/wizards/__init__.py
@@ -1 +1,2 @@
-from . import service_invoicing_create
+from . import service_invoicing_action
+from . import service_invoicing_action_create
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action.py b/energy_communities_service_invoicing/wizards/service_invoicing_action.py
new file mode 100644
index 000000000..79f86e1dc
--- /dev/null
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action.py
@@ -0,0 +1,22 @@
+from odoo import api, fields, models
+from odoo.exceptions import ValidationError
+from odoo.tools.translate import _
+
+from odoo.addons.energy_communities.utils import contract_utils
+
+
+class ServiceInvoicingActionWizard(models.TransientModel):
+    _name = "service.invoicing.action.wizard"
+    _description = "Execute actions on service invoicing"
+
+    service_invoicing_id = fields.Many2one(
+        "contract.contract", string="Selected contract"
+    )
+    execution_date = fields.Date(string="Execution date")
+
+    def execute_activate(self):
+        with contract_utils(self.env) as component:
+            component.set_contract_active(
+                contract_id=self.service_invoicing_id,
+                activation_date="2025-03-01",
+            )
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action.xml b/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
new file mode 100644
index 000000000..d2dba0c29
--- /dev/null
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
@@ -0,0 +1,42 @@
+<odoo>
+  <record
+    id="view_service_invoicing_action_wizard_form"
+    model="ir.ui.view"
+  >
+    <field name="name">service.invoicing.action.wizard.form</field>
+    <field name="model">service.invoicing.action.wizard</field>
+    <field name="arch" type="xml">
+      <form string="Execute a service invoicing action">
+        <sheet>
+          <group>
+            <field name="service_invoicing_id" required="1" domain="[('community_company_id','!=',False)]"/>
+            <field name="execution_date" required="1"/>
+          </group>
+        </sheet>
+        <footer>
+          <button
+            name="execute_activate"
+            string="activate contract"
+            type="object"
+            class="btn-primary"
+          />
+          <button
+            string="Cancelar"
+            class="btn-secondary"
+            special="cancel"
+          />
+        </footer>
+      </form>
+    </field>
+  </record>
+  <record
+    model="ir.actions.act_window"
+    id="service_invoicing_action_wizard_action"
+  >
+      <field name="name">Service invoicing actions</field>
+      <field name="res_model">service.invoicing.action.wizard</field>
+      <field name="view_mode">form</field>
+      <field name="target">new</field>
+  </record>
+
+</odoo>
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
new file mode 100644
index 000000000..033f4986d
--- /dev/null
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
@@ -0,0 +1,43 @@
+from odoo import api, fields, models
+from odoo.exceptions import ValidationError
+from odoo.tools.translate import _
+
+from odoo.addons.energy_communities.utils import (
+    contract_utils,
+    sale_order_utils,
+)
+
+
+class ServiceInvoicingActionCreateWizard(models.TransientModel):
+    _name = "service.invoicing.action.create.wizard"
+    _description = "Create service invoicing for an energy community"
+
+    company_id = fields.Many2one("res.company", string="Coordinator")
+    community_company_id = fields.Many2one("res.company", string="Community")
+    service_id = fields.Many2one("product.product", string="Service")
+
+    def execute_create(self):
+        with sale_order_utils(self.env) as component:
+            so = component.create_service_invoicing_activation_sale_order(
+                company_id=self.company_id,
+                community_company_id=self.community_company_id,
+                service_id=self.service_id,
+            )
+            so.action_confirm()
+            rel_contracts = component.get_related_contracts(so)
+        with contract_utils(self.env) as component:
+            component.set_contract_on_hold(rel_contracts)
+        return {
+            "type": "ir.actions.act_window",
+            "res_model": "contract.contract",
+            "views": [
+                (
+                    self.env.ref(
+                        "energy_communities_service_invoicing.view_contract_contract_customer_form"
+                    ).id,
+                    "form",
+                ),
+            ],
+            "target": "current",
+            "res_id": rel_contracts.id,
+        }
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_create.xml b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
similarity index 72%
rename from energy_communities_service_invoicing/wizards/service_invoicing_create.xml
rename to energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
index feb1ff6bf..ad65a555f 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_create.xml
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
@@ -1,10 +1,10 @@
 <odoo>
   <record
-    id="view_service_invoicing_create_wizard_form"
+    id="view_service_invoicing_action_create_wizard_form"
     model="ir.ui.view"
   >
-    <field name="name">service.invoicing.create.wizard.form</field>
-    <field name="model">service.invoicing.create.wizard</field>
+    <field name="name">service.invoicing.action.create.wizard.form</field>
+    <field name="model">service.invoicing.action.create.wizard</field>
     <field name="arch" type="xml">
       <form string="Service invoicing">
         <sheet>
@@ -32,17 +32,17 @@
   </record>
   <record
     model="ir.actions.act_window"
-    id="service_invoicing_create_wizard_action"
+    id="service_invoicing_action_create_wizard_action"
   >
       <field name="name">Create community service invoicing</field>
-      <field name="res_model">service.invoicing.create.wizard</field>
+      <field name="res_model">service.invoicing.action.create.wizard</field>
       <field name="view_mode">form</field>
       <field name="target">new</field>
   </record>
   <menuitem
-    id="service_invoicing_create_wizard_menu"
+    id="service_invoicing_action_create_wizard_menu"
     name="Create community service invoicing"
-    action="service_invoicing_create_wizard_action"
+    action="service_invoicing_action_create_wizard_action"
     parent="ce_service_invoicing_menu"
     sequence="200"
   />
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_create.py
deleted file mode 100644
index 3d2c0d309..000000000
--- a/energy_communities_service_invoicing/wizards/service_invoicing_create.py
+++ /dev/null
@@ -1,47 +0,0 @@
-from odoo import api, fields, models
-from odoo.exceptions import ValidationError
-from odoo.tools.translate import _
-
-from odoo.addons.energy_communities.utils import sale_order_utils
-
-
-class ServiceInvoicingCreateWizard(models.TransientModel):
-    _name = "service.invoicing.create.wizard"
-    _description = "Create service invoicing for an energy community"
-
-    company_id = fields.Many2one("res.company", string="Coordinator")
-    community_company_id = fields.Many2one("res.company", string="Community")
-    service_id = fields.Many2one("product.product", string="Service")
-
-    def execute_create(self):
-        with sale_order_utils(self.env) as component:
-            so = component.create_service_invoicing_activation_sale_order(
-                company_id=self.company_id,
-                community_company_id=self.community_company_id,
-                service_id=self.service_id,
-            )
-        return True
-        # self._consistency_validation()
-        # voluntary_share_interest_return = self.env[
-        #     "voluntary.share.interest.return"
-        # ].create(
-        #     {
-        #         "name": "{company_name} voluntary share interest return from {start_date_period} to {end_date_period}".format(
-        #             company_name=self.company_id.name,
-        #             start_date_period=self.start_date_period,
-        #             end_date_period=self.end_date_period,
-        #         ),
-        #         "start_date_period": self.start_date_period,
-        #         "end_date_period": self.end_date_period,
-        #         "payment_mode_id": self.payment_mode_id.id,
-        #     }
-        # )
-        # return {
-        #     "type": "ir.actions.act_window",
-        #     "name": _("Return voluntary shares interest"),
-        #     "res_model": "voluntary.share.interest.return",
-        #     "view_type": "form",
-        #     "view_mode": "form",
-        #     "target": "current",
-        #     "res_id": voluntary_share_interest_return.id,
-        # }
-- 
GitLab


From e921f2160e25e055112ad40b4a5aa70931778d82 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Thu, 23 Jan 2025 12:29:37 +0100
Subject: [PATCH 11/85] =?UTF-8?q?[WIP]=20=F0=9F=9A=A7=20Dummy=20contract?=
 =?UTF-8?q?=20activation?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 energy_communities/utils.py                   | 32 +++++------------
 .../components/contract_utils.py              | 34 +++++++++++++------
 .../components/sale_order_utils.py            |  1 -
 .../wizards/service_invoicing_action.py       |  7 ++--
 .../service_invoicing_action_create.py        |  4 +--
 5 files changed, 36 insertions(+), 42 deletions(-)

diff --git a/energy_communities/utils.py b/energy_communities/utils.py
index d0a440e78..fd3dcca18 100644
--- a/energy_communities/utils.py
+++ b/energy_communities/utils.py
@@ -1,17 +1,18 @@
 from contextlib import contextmanager
+from typing import Any
 
 from odoo.api import Environment
 from odoo.tools.translate import code_translations
 
 from odoo.addons.component.core import Component, WorkContext
+from odoo.addons.contract.models.contract import ContractContract
 
 
-def _get_component(env: Environment, model_name: str, usage: str) -> Component:
+def _get_component(
+    env: Environment, model_name: str, usage: str, record: Any = None
+) -> Component:
     backend = env["utils.backend"].browse(1)
-    work = WorkContext(
-        model_name=model_name,
-        collection=backend,
-    )
+    work = WorkContext(model_name=model_name, collection=backend, record=record)
     return work.component(usage=usage)
 
 
@@ -19,38 +20,21 @@ def _get_component(env: Environment, model_name: str, usage: str) -> Component:
 def user_creator(
     env: Environment,
 ) -> Component:
-    # backend = env["utils.backend"].browse(1)
-    # work = WorkContext(
-    #     model_name="res.users",
-    #     collection=backend,
-    # )
-    # yield work.component(usage="user.create")
     yield _get_component(env, "res.users", "user.create")
 
 
 @contextmanager
 def contract_utils(
     env: Environment,
+    contract_id: ContractContract,
 ) -> Component:
-    # backend = env["utils.backend"].browse(1)
-    # work = WorkContext(
-    #     model_name="contract.contract",
-    #     collection=backend,
-    # )
-    # yield work.component(usage="contract.utils")
-    yield _get_component(env, "contract.contract", "contract.utils")
+    yield _get_component(env, "contract.contract", "contract.utils", contract_id)
 
 
 @contextmanager
 def sale_order_utils(
     env: Environment,
 ) -> Component:
-    # backend = env["utils.backend"].browse(1)
-    # work = WorkContext(
-    #     model_name="sale.order",
-    #     collection=backend,
-    # )
-    # yield work.component(usage="sale.order.utils")
     yield _get_component(env, "sale.order", "sale.order.utils")
 
 
diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
index 6ceb7d5fb..a41107240 100644
--- a/energy_communities_service_invoicing/components/contract_utils.py
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -4,16 +4,30 @@ from odoo.addons.component.core import Component
 class ContractUtils(Component):
     _inherit = "contract.utils"
 
-    def set_contract_on_hold(self, contract):
-        for line in contract.contract_line_ids:
+    def set_contract_on_hold(self):
+        for line in self.work.record.contract_line_ids:
             line.cancel()
 
-    def set_contract_active(self, contract_id, activation_date):
-        for line in contract_id.contract_line_ids:
-            line.write(
-                {
-                    "date_start": activation_date,
-                    "next_period_date_start": activation_date,
-                    "recurring_next_date": activation_date,
-                }
+    def set_contract_active(self, activation_date):
+        for line in self.work.record.contract_line_ids:
+            if self._is_service_line(line):
+                line.write(
+                    {
+                        "date_start": activation_date,
+                        "next_period_date_start": activation_date,
+                        "recurring_next_date": activation_date,
+                        "is_canceled": False,
+                    }
+                )
+                # line.is_cancelled = False
+                line._compute_state()
+
+    def _is_service_line(self, contract_line):
+        if self.work.record.contract_template_id:
+            contract_template_services = (
+                self.work.record.contract_template_id.contract_line_ids.mapped(
+                    "product_id"
+                )
             )
+            return contract_line.product_id in contract_template_services
+        return False
diff --git a/energy_communities_service_invoicing/components/sale_order_utils.py b/energy_communities_service_invoicing/components/sale_order_utils.py
index c113003b0..736e9fdf5 100644
--- a/energy_communities_service_invoicing/components/sale_order_utils.py
+++ b/energy_communities_service_invoicing/components/sale_order_utils.py
@@ -26,7 +26,6 @@ class SaleOrderUtils(Component):
             ],
         }
         return self.env["sale.order"].create(so_creation_dict)
-        # print("CREATE SO on component!")
 
     def get_related_contracts(self, sale_order):
         return (
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action.py b/energy_communities_service_invoicing/wizards/service_invoicing_action.py
index 79f86e1dc..40fdca9b1 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action.py
@@ -15,8 +15,5 @@ class ServiceInvoicingActionWizard(models.TransientModel):
     execution_date = fields.Date(string="Execution date")
 
     def execute_activate(self):
-        with contract_utils(self.env) as component:
-            component.set_contract_active(
-                contract_id=self.service_invoicing_id,
-                activation_date="2025-03-01",
-            )
+        with contract_utils(self.env, self.service_invoicing_id) as component:
+            component.set_contract_active(self.execution_date)
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
index 033f4986d..cf41b8853 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
@@ -25,8 +25,8 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
             )
             so.action_confirm()
             rel_contracts = component.get_related_contracts(so)
-        with contract_utils(self.env) as component:
-            component.set_contract_on_hold(rel_contracts)
+        with contract_utils(self.env, rel_contracts) as component:
+            component.set_contract_on_hold()
         return {
             "type": "ir.actions.act_window",
             "res_model": "contract.contract",
-- 
GitLab


From d92878b3815b9c8c7a5905ed7a1f22e2fc46979d Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Thu, 23 Jan 2025 12:59:17 +0100
Subject: [PATCH 12/85] Introduce debug view on contracts

---
 .../views/contract_views.xml                          | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index 805b869a7..63939647e 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -31,6 +31,15 @@
       <xpath expr="//field[@name='partner_id']" position="after">
         <field name="community_company_id" />
       </xpath>
+      <!-- For dev debug purposes -->
+      <xpath expr="//field[@name='user_id']" position="after">
+        <field name="date_start" />
+        <field name="recurring_next_date" />
+        <field name="next_period_date_start" />
+        <field name="next_period_date_end" />
+        <field name="date_end" />
+      </xpath>
+      
     </field>
   </record>
 
@@ -54,7 +63,7 @@
   <record model="ir.actions.act_window.view" id="action_view_contract_contract_customer_form">
     <field name="sequence" eval="2"/>
     <field name="view_mode">form</field>
-    <field name="view_id" ref="view_contract_contract_customer_form"/>
+    <field name="view_id" ref="contract.contract_contract_customer_form_view"/>
     <field name="act_window_id" ref="view_service_invoicing_window"/>
   </record>
 
-- 
GitLab


From fcc1a4e7c6c6f6f9a608f0ade14af3b76592c0de Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Thu, 23 Jan 2025 16:03:27 +0100
Subject: [PATCH 13/85] =?UTF-8?q?type=20<description>=20[IMP]=20=E2=9C=A8?=
 =?UTF-8?q?=20wizard=20actions:=20activate,=20close?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../components/contract_utils.py                  | 15 ++++++++++-----
 .../components/sale_order_utils.py                |  4 ++--
 .../models/contract.py                            | 10 ++++++++--
 .../views/contract_views.xml                      |  7 +++++--
 .../wizards/service_invoicing_action.py           | 12 ++++++++++++
 .../wizards/service_invoicing_action.xml          |  9 +++++++++
 .../wizards/service_invoicing_action_create.py    |  4 ++--
 .../wizards/service_invoicing_action_create.xml   |  2 +-
 8 files changed, 49 insertions(+), 14 deletions(-)

diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
index a41107240..40b567634 100644
--- a/energy_communities_service_invoicing/components/contract_utils.py
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -8,18 +8,23 @@ class ContractUtils(Component):
         for line in self.work.record.contract_line_ids:
             line.cancel()
 
-    def set_contract_active(self, activation_date):
+    def set_contract_active(self, execution_date):
         for line in self.work.record.contract_line_ids:
             if self._is_service_line(line):
                 line.write(
                     {
-                        "date_start": activation_date,
-                        "next_period_date_start": activation_date,
-                        "recurring_next_date": activation_date,
+                        "date_start": execution_date,
+                        "next_period_date_start": execution_date,
+                        "recurring_next_date": execution_date,
                         "is_canceled": False,
                     }
                 )
-                # line.is_cancelled = False
+                line._compute_state()
+
+    def set_contract_closed(self, execution_date):
+        for line in self.work.record.contract_line_ids:
+            if self._is_service_line(line):
+                line.write({"date_end": execution_date})
                 line._compute_state()
 
     def _is_service_line(self, contract_line):
diff --git a/energy_communities_service_invoicing/components/sale_order_utils.py b/energy_communities_service_invoicing/components/sale_order_utils.py
index 736e9fdf5..21e598d09 100644
--- a/energy_communities_service_invoicing/components/sale_order_utils.py
+++ b/energy_communities_service_invoicing/components/sale_order_utils.py
@@ -7,7 +7,7 @@ class SaleOrderUtils(Component):
     _inherit = "sale.order.utils"
 
     def create_service_invoicing_activation_sale_order(
-        self, company_id, community_company_id, service_id
+        self, company_id, community_company_id, service_pack_id
     ):
         so_creation_dict = {
             "partner_id": company_id.partner_id.id,
@@ -17,7 +17,7 @@ class SaleOrderUtils(Component):
                     0,
                     0,
                     {
-                        "product_id": service_id.id,
+                        "product_id": service_pack_id.id,
                         # "product_uom,qty": 1,
                         "date_start": datetime.now(),
                         "date_end": datetime.now(),
diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index 57c9cf48a..05e79e8d4 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -13,13 +13,19 @@ class ContractContract(models.Model):
     )
 
     def action_activate_contract(self):
+        return self._action_contract("activate")
+
+    def action_close_contract(self):
+        return self._action_contract("close")
+
+    def _action_contract(self, action):
         self.ensure_one()
         wizard = self.env["service.invoicing.action.wizard"].create(
-            {"service_invoicing_id": self.id}
+            {"service_invoicing_id": self.id, "executed_action": action}
         )
         return {
             "type": "ir.actions.act_window",
-            "name": _("Activate srvice invoicing"),
+            # "name": _("Activate srvice invoicing"),
             "res_model": "service.invoicing.action.wizard",
             "view_type": "form",
             "view_mode": "form",
diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index 63939647e..4bbefc124 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -20,13 +20,16 @@
     <field name="inherit_id" ref="product_contract.contract_contract_customer_form_view" />
     <field name="arch" type="xml">
       <xpath expr="//button[@name='action_preview']" position="after">
-      <!--<xpath expr="//header" position="inside">-->
         <button
           name="action_activate_contract"
           type="object"
           string="Activate"
         />
-        <!--groups="energy_communities.group_platform_manager"-->
+        <button
+          name="action_close_contract"
+          type="object"
+          string="Close"
+        />
       </xpath>
       <xpath expr="//field[@name='partner_id']" position="after">
         <field name="community_company_id" />
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action.py b/energy_communities_service_invoicing/wizards/service_invoicing_action.py
index 40fdca9b1..f856375c6 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action.py
@@ -13,7 +13,19 @@ class ServiceInvoicingActionWizard(models.TransientModel):
         "contract.contract", string="Selected contract"
     )
     execution_date = fields.Date(string="Execution date")
+    executed_action = fields.Selection(
+        [
+            ("activate", _("Activate")),
+            ("close", _("Close")),
+            ("modify_pack", _("Modify pack")),
+            ("modify_pricelist", _("Modify pricelist")),
+        ]
+    )
 
     def execute_activate(self):
         with contract_utils(self.env, self.service_invoicing_id) as component:
             component.set_contract_active(self.execution_date)
+
+    def execute_close(self):
+        with contract_utils(self.env, self.service_invoicing_id) as component:
+            component.set_contract_closed(self.execution_date)
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action.xml b/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
index d2dba0c29..7d2a37e2a 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
@@ -9,6 +9,7 @@
       <form string="Execute a service invoicing action">
         <sheet>
           <group>
+            <field name="executed_action" invisible="1" />
             <field name="service_invoicing_id" required="1" domain="[('community_company_id','!=',False)]"/>
             <field name="execution_date" required="1"/>
           </group>
@@ -19,6 +20,14 @@
             string="activate contract"
             type="object"
             class="btn-primary"
+            attrs="{'invisible': [('executed_action','!=','activate')]}"
+          />
+          <button
+            name="execute_close"
+            string="close contract"
+            type="object"
+            class="btn-primary"
+            attrs="{'invisible': [('executed_action','!=','close')]}"
           />
           <button
             string="Cancelar"
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
index cf41b8853..5a22d5c55 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
@@ -14,14 +14,14 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
 
     company_id = fields.Many2one("res.company", string="Coordinator")
     community_company_id = fields.Many2one("res.company", string="Community")
-    service_id = fields.Many2one("product.product", string="Service")
+    service_pack_id = fields.Many2one("product.product", string="Service")
 
     def execute_create(self):
         with sale_order_utils(self.env) as component:
             so = component.create_service_invoicing_activation_sale_order(
                 company_id=self.company_id,
                 community_company_id=self.community_company_id,
-                service_id=self.service_id,
+                service_pack_id=self.service_pack_id,
             )
             so.action_confirm()
             rel_contracts = component.get_related_contracts(so)
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
index ad65a555f..78bf4491d 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
@@ -11,7 +11,7 @@
           <group>
             <field name="company_id" required="1" domain="[('hierarchy_level','=','coordinator')]"/>
             <field name="community_company_id" required="1" domain="[('hierarchy_level','=','community')]"/>
-            <field name="service_id" required="1" domain="[('is_contract','=',True)]"/>
+            <field name="service_pack_id" required="1" domain="[('is_contract','=',True)]"/>
           </group>
         </sheet>
         <footer>
-- 
GitLab


From ff43dcc008d0be77249f56408e22bfe820235d58 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Thu, 23 Jan 2025 16:20:08 +0100
Subject: [PATCH 14/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Propagate=20pricelist?=
 =?UTF-8?q?=20from=20SO=20to=20Contract?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../components/sale_order_utils.py                         | 4 ++--
 energy_communities_service_invoicing/models/sale_order.py  | 7 ++++++-
 .../wizards/service_invoicing_action_create.py             | 4 +++-
 .../wizards/service_invoicing_action_create.xml            | 1 +
 4 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/energy_communities_service_invoicing/components/sale_order_utils.py b/energy_communities_service_invoicing/components/sale_order_utils.py
index 21e598d09..49a013451 100644
--- a/energy_communities_service_invoicing/components/sale_order_utils.py
+++ b/energy_communities_service_invoicing/components/sale_order_utils.py
@@ -7,18 +7,18 @@ class SaleOrderUtils(Component):
     _inherit = "sale.order.utils"
 
     def create_service_invoicing_activation_sale_order(
-        self, company_id, community_company_id, service_pack_id
+        self, company_id, community_company_id, service_pack_id, pricelist_id
     ):
         so_creation_dict = {
             "partner_id": company_id.partner_id.id,
             "community_company_id": community_company_id.id,
+            "pricelist_id": pricelist_id.id,
             "order_line": [
                 (
                     0,
                     0,
                     {
                         "product_id": service_pack_id.id,
-                        # "product_uom,qty": 1,
                         "date_start": datetime.now(),
                         "date_end": datetime.now(),
                     },
diff --git a/energy_communities_service_invoicing/models/sale_order.py b/energy_communities_service_invoicing/models/sale_order.py
index 692affc57..b8cbfee41 100644
--- a/energy_communities_service_invoicing/models/sale_order.py
+++ b/energy_communities_service_invoicing/models/sale_order.py
@@ -19,5 +19,10 @@ class SaleOrder(models.Model):
         contracts = super().action_create_contract()
         if self.community_company_id:
             for contract in contracts:
-                contract.write({"community_company_id": self.community_company_id.id})
+                contract.write(
+                    {
+                        "community_company_id": self.community_company_id.id,
+                        "pricelist_id": self.pricelist_id.id,
+                    }
+                )
         return contracts
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
index 5a22d5c55..b5c7bbb6f 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
@@ -14,7 +14,8 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
 
     company_id = fields.Many2one("res.company", string="Coordinator")
     community_company_id = fields.Many2one("res.company", string="Community")
-    service_pack_id = fields.Many2one("product.product", string="Service")
+    service_pack_id = fields.Many2one("product.product", string="Service pack")
+    pricelist_id = fields.Many2one("product.pricelist", string="PriceList")
 
     def execute_create(self):
         with sale_order_utils(self.env) as component:
@@ -22,6 +23,7 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
                 company_id=self.company_id,
                 community_company_id=self.community_company_id,
                 service_pack_id=self.service_pack_id,
+                pricelist_id=self.pricelist_id,
             )
             so.action_confirm()
             rel_contracts = component.get_related_contracts(so)
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
index 78bf4491d..f18a2d2ca 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
@@ -12,6 +12,7 @@
             <field name="company_id" required="1" domain="[('hierarchy_level','=','coordinator')]"/>
             <field name="community_company_id" required="1" domain="[('hierarchy_level','=','community')]"/>
             <field name="service_pack_id" required="1" domain="[('is_contract','=',True)]"/>
+            <field name="pricelist_id" required="1" />
           </group>
         </sheet>
         <footer>
-- 
GitLab


From 646820dcc778de2fdff59071ebb3cd4b68d87787 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Fri, 24 Jan 2025 18:00:53 +0100
Subject: [PATCH 15/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Contract=20modificati?=
 =?UTF-8?q?ons=20and=20Multicompany=20base=20structure?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 energy_communities/models/res_partner.py      | 17 +++++--
 .../__manifest__.py                           |  2 +-
 .../components/contract_utils.py              | 38 ++++++++++++++
 .../components/sale_order_utils.py            | 49 +++++++++++++++++--
 .../models/__init__.py                        |  1 +
 .../models/contract.py                        |  8 ++-
 .../models/product_template.py                |  9 ++++
 .../models/sale_order.py                      |  3 ++
 energy_communities_service_invoicing/utils.py | 20 ++++++++
 .../views/contract_views.xml                  | 37 +++++++++++++-
 .../views/sale_order_views.xml                |  3 ++
 .../wizards/service_invoicing_action.py       | 25 +++++++++-
 .../wizards/service_invoicing_action.xml      | 31 +++++++++++-
 .../service_invoicing_action_create.py        | 33 ++++---------
 .../service_invoicing_action_create.xml       |  3 +-
 15 files changed, 240 insertions(+), 39 deletions(-)
 create mode 100644 energy_communities_service_invoicing/models/product_template.py
 create mode 100644 energy_communities_service_invoicing/utils.py

diff --git a/energy_communities/models/res_partner.py b/energy_communities/models/res_partner.py
index 77e3db740..8b7d36c57 100644
--- a/energy_communities/models/res_partner.py
+++ b/energy_communities/models/res_partner.py
@@ -30,6 +30,12 @@ class ResPartner(models.Model):
         compute="compute_company_hierarchy_level",
         store=True,
     )
+    related_company_id = fields.Many2one(
+        "res.company",
+        string="Related company",
+        compute="compute_related_company_id",
+        store=False,
+    )
     company_ids_info = fields.Many2many(
         string="Companies",
         comodel_name="res.company",
@@ -53,11 +59,16 @@ class ResPartner(models.Model):
 
     def compute_company_hierarchy_level(self):
         for record in self:
-            rel_company = self.env["res.company"].search(
+            if self.related_company_id:
+                record.company_hierarchy_level = self.related_company_id.hierarchy_level
+
+    def compute_related_company_id(self):
+        for record in self:
+            related_company_id = self.env["res.company"].search(
                 [("partner_id", "=", record.id)]
             )
-            if rel_company:
-                record.company_hierarchy_level = rel_company.hierarchy_level
+            if related_company_id:
+                record.related_company_id = related_company_id.id
 
     @api.constrains("company_ids")
     def _constrains_partner_company_ids(self):
diff --git a/energy_communities_service_invoicing/__manifest__.py b/energy_communities_service_invoicing/__manifest__.py
index e0d2a3301..5cdd64fc9 100644
--- a/energy_communities_service_invoicing/__manifest__.py
+++ b/energy_communities_service_invoicing/__manifest__.py
@@ -11,7 +11,7 @@
     "category": "Contract Management",
     "version": "16.0.0.1.1",
     # any module necessary for this one to work correctly
-    "depends": ["base", "product_contract", "energy_communities"],
+    "depends": ["base", "contract", "sale", "product_contract", "energy_communities"],
     # always loaded
     "data": [
         "security/ir.model.access.csv",
diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
index 40b567634..3637fbb21 100644
--- a/energy_communities_service_invoicing/components/contract_utils.py
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -1,3 +1,5 @@
+from datetime import timedelta
+
 from odoo.addons.component.core import Component
 
 
@@ -27,6 +29,36 @@ class ContractUtils(Component):
                 line.write({"date_end": execution_date})
                 line._compute_state()
 
+    def set_start_date(self, date_start):
+        self.work.record.write({"date_start": date_start})
+        for line in self.work.record.contract_line_ids:
+            if self._is_service_line(line):
+                line.write({"date_start": date_start})
+                line._compute_state()
+
+    def modify(
+        self,
+        execution_date,
+        executed_modification_action,
+        pricelist_id=None,
+        service_pack_id=None,
+    ):
+        self.set_contract_closed(execution_date)
+        sale_order_utils = self.component(
+            usage="sale.order.utils", model_name="sale.order"
+        )
+        return sale_order_utils.create_service_invoicing(
+            self.work.record.company_id,
+            self.work.record.community_company_id,
+            self._get_service_pack_id()
+            if executed_modification_action not in ["modify_all", "modify_service_pack"]
+            else service_pack_id,
+            self.work.record.pricelist_id
+            if executed_modification_action not in ["modify_all", "modify_pricelist"]
+            else pricelist_id,
+            execution_date + timedelta(days=1),
+        )
+
     def _is_service_line(self, contract_line):
         if self.work.record.contract_template_id:
             contract_template_services = (
@@ -36,3 +68,9 @@ class ContractUtils(Component):
             )
             return contract_line.product_id in contract_template_services
         return False
+
+    def _get_service_pack_id(self):
+        for line in self.work.record.contract_line_ids:
+            if not self._is_service_line(line):
+                return line.product_id
+        return False
diff --git a/energy_communities_service_invoicing/components/sale_order_utils.py b/energy_communities_service_invoicing/components/sale_order_utils.py
index 49a013451..2e3deacc3 100644
--- a/energy_communities_service_invoicing/components/sale_order_utils.py
+++ b/energy_communities_service_invoicing/components/sale_order_utils.py
@@ -1,16 +1,21 @@
-from datetime import datetime
-
 from odoo.addons.component.core import Component
+from odoo.addons.energy_communities.utils import contract_utils
 
 
 class SaleOrderUtils(Component):
     _inherit = "sale.order.utils"
 
     def create_service_invoicing_activation_sale_order(
-        self, company_id, community_company_id, service_pack_id, pricelist_id
+        self,
+        company_id,
+        community_company_id,
+        service_pack_id,
+        pricelist_id,
+        start_date,
     ):
         so_creation_dict = {
             "partner_id": company_id.partner_id.id,
+            "company_id": company_id.id,
             "community_company_id": community_company_id.id,
             "pricelist_id": pricelist_id.id,
             "order_line": [
@@ -19,14 +24,48 @@ class SaleOrderUtils(Component):
                     0,
                     {
                         "product_id": service_pack_id.id,
-                        "date_start": datetime.now(),
-                        "date_end": datetime.now(),
+                        "date_start": start_date,
+                        "date_end": start_date,
                     },
                 )
             ],
         }
         return self.env["sale.order"].create(so_creation_dict)
 
+    def create_service_invoicing(
+        self,
+        company_id,
+        community_company_id,
+        service_pack_id,
+        pricelist_id,
+        start_date,
+    ):
+        so = self.create_service_invoicing_activation_sale_order(
+            company_id, community_company_id, service_pack_id, pricelist_id, start_date
+        )
+        so.action_confirm()
+        service_invoicing_id = self.get_related_contracts(so)
+        # TODO: We must call contract_utils with a better component and workcontext modification approach
+        with contract_utils(self.env, service_invoicing_id) as component:
+            component.set_start_date(start_date)
+        return service_invoicing_id
+
+    def create_service_invoicing_on_hold(
+        self,
+        company_id,
+        community_company_id,
+        service_pack_id,
+        pricelist_id,
+        start_date,
+    ):
+        service_invoicing_id = self.create_service_invoicing(
+            company_id, community_company_id, service_pack_id, pricelist_id, start_date
+        )
+        # TODO: We must call contract_utils with a better component and workcontext modification approach
+        with contract_utils(self.env, service_invoicing_id) as component:
+            component.set_contract_on_hold()
+        return service_invoicing_id
+
     def get_related_contracts(self, sale_order):
         return (
             self.env["contract.line"]
diff --git a/energy_communities_service_invoicing/models/__init__.py b/energy_communities_service_invoicing/models/__init__.py
index 7b51a0ddc..cdc17d9f6 100644
--- a/energy_communities_service_invoicing/models/__init__.py
+++ b/energy_communities_service_invoicing/models/__init__.py
@@ -1,2 +1,3 @@
 from . import contract
+from . import product_template
 from . import sale_order
diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index 05e79e8d4..cf3e83447 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -11,6 +11,9 @@ class ContractContract(models.Model):
         string="Related community",
         domain="[('hierarchy_level','=','community')]",
     )
+    predecessor_contract_id = fields.Many2one(
+        "contract.contract", string="Predecessor contract"
+    )
 
     def action_activate_contract(self):
         return self._action_contract("activate")
@@ -18,6 +21,9 @@ class ContractContract(models.Model):
     def action_close_contract(self):
         return self._action_contract("close")
 
+    def action_modify_contract(self):
+        return self._action_contract("modification")
+
     def _action_contract(self, action):
         self.ensure_one()
         wizard = self.env["service.invoicing.action.wizard"].create(
@@ -25,7 +31,7 @@ class ContractContract(models.Model):
         )
         return {
             "type": "ir.actions.act_window",
-            # "name": _("Activate srvice invoicing"),
+            "name": _("Executing: {}").format(action),
             "res_model": "service.invoicing.action.wizard",
             "view_type": "form",
             "view_mode": "form",
diff --git a/energy_communities_service_invoicing/models/product_template.py b/energy_communities_service_invoicing/models/product_template.py
new file mode 100644
index 000000000..71dc1cc50
--- /dev/null
+++ b/energy_communities_service_invoicing/models/product_template.py
@@ -0,0 +1,9 @@
+from odoo import fields, models
+
+
+class ProductTemplate(models.Model):
+    _inherit = "product.template"
+
+    property_contract_template_id = fields.Many2one(
+        company_dependent=False,
+    )
diff --git a/energy_communities_service_invoicing/models/sale_order.py b/energy_communities_service_invoicing/models/sale_order.py
index b8cbfee41..2f95a8e20 100644
--- a/energy_communities_service_invoicing/models/sale_order.py
+++ b/energy_communities_service_invoicing/models/sale_order.py
@@ -14,6 +14,9 @@ class SaleOrder(models.Model):
         string="Related community",
         domain="[('hierarchy_level','=','community')]",
     )
+    # company_id = fields.Many2one(
+    #     required=False, index=True
+    # )
 
     def action_create_contract(self):
         contracts = super().action_create_contract()
diff --git a/energy_communities_service_invoicing/utils.py b/energy_communities_service_invoicing/utils.py
new file mode 100644
index 000000000..87a38cffb
--- /dev/null
+++ b/energy_communities_service_invoicing/utils.py
@@ -0,0 +1,20 @@
+from odoo.api import Environment
+
+from odoo.addons.contract.models.contract import ContractContract
+
+
+def service_invoicing_view(env: Environment, service_invoicing_id: ContractContract):
+    return {
+        "type": "ir.actions.act_window",
+        "res_model": "contract.contract",
+        "views": [
+            (
+                env.ref(
+                    "energy_communities_service_invoicing.view_contract_contract_customer_form"
+                ).id,
+                "form",
+            ),
+        ],
+        "target": "current",
+        "res_id": service_invoicing_id.id,
+    }
diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index 4bbefc124..ade969e5c 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -25,6 +25,11 @@
           type="object"
           string="Activate"
         />
+        <button
+          name="action_modify_contract"
+          type="object"
+          string="Modify"
+        />
         <button
           name="action_close_contract"
           type="object"
@@ -46,16 +51,37 @@
     </field>
   </record>
 
+  <record id="contract_template_form_view" model="ir.ui.view">
+    <field name="name">contract.template form view  (in energy_communities service_invoicing)</field>
+    <field name="model">contract.contract</field>
+    <field name="inherit_id" ref="contract.contract_template_form_view" />
+    <field name="arch" type="xml">
+      <xpath expr="//field[@name='company_id']" position="attributes">
+        <attribute name="required">0</attribute>
+      </xpath>
+    </field>
+  </record>
+
   <record
       id="view_service_invoicing_window"
       model="ir.actions.act_window"
   >
-    <field name="name">Communities Services</field>
+    <field name="name">Service Invoicing</field>
     <field name="res_model">contract.contract</field>
     <field name="view_mode">tree,form</field>
     <field name="domain">[('community_company_id','!=',False)]</field>
   </record>
 
+  <record
+      id="view_service_products_window"
+      model="ir.actions.act_window"
+  >
+    <field name="name">Service Products</field>
+    <field name="res_model">product.product</field>
+    <field name="view_mode">tree,form</field>
+    <field name="domain">[('is_contract','=',True)]</field>
+  </record>
+
   <record model="ir.actions.act_window.view" id="action_view_service_invoicing_tree">
     <field name="sequence" eval="1"/>
     <field name="view_mode">tree</field>
@@ -71,10 +97,17 @@
   </record>
 
   <menuitem
-    name="Communities Services"
+    name="Service invoicing"
     id="view_service_invoicing_menu"
     parent="ce_service_invoicing_menu"
     action="view_service_invoicing_window"
     sequence="100"
   />
+  <menuitem
+    name="Service Products"
+    id="view_service_products_menu"
+    parent="ce_service_invoicing_menu"
+    action="view_service_products_window"
+    sequence="200"
+  />
 </odoo>
diff --git a/energy_communities_service_invoicing/views/sale_order_views.xml b/energy_communities_service_invoicing/views/sale_order_views.xml
index 0b330c7aa..6fb974615 100644
--- a/energy_communities_service_invoicing/views/sale_order_views.xml
+++ b/energy_communities_service_invoicing/views/sale_order_views.xml
@@ -7,6 +7,9 @@
         <xpath expr="//field[@name='partner_id']" position="after">
           <field name="community_company_id" />
         </xpath>
+        <xpath expr="//field[@name='company_id']" position="attributes">
+          <attribute name="required">0</attribute>
+        </xpath>
     </field>
   </record>
 </odoo>
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action.py b/energy_communities_service_invoicing/wizards/service_invoicing_action.py
index f856375c6..f6340f4d9 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action.py
@@ -4,6 +4,8 @@ from odoo.tools.translate import _
 
 from odoo.addons.energy_communities.utils import contract_utils
 
+from ..utils import service_invoicing_view
+
 
 class ServiceInvoicingActionWizard(models.TransientModel):
     _name = "service.invoicing.action.wizard"
@@ -17,10 +19,19 @@ class ServiceInvoicingActionWizard(models.TransientModel):
         [
             ("activate", _("Activate")),
             ("close", _("Close")),
-            ("modify_pack", _("Modify pack")),
-            ("modify_pricelist", _("Modify pricelist")),
+            ("modification", _("Modification")),
         ]
     )
+    executed_modification_action = fields.Selection(
+        [
+            ("modify_all", _("Modify prices and service pack")),
+            ("modify_pricelist", _("Modify prices")),
+            ("modify_service_pack", _("Modify service pack")),
+        ],
+        string="Modification action",
+    )
+    pricelist_id = fields.Many2one("product.pricelist", string="Select pricelist")
+    service_pack_id = fields.Many2one("product.product", string="Service pack")
 
     def execute_activate(self):
         with contract_utils(self.env, self.service_invoicing_id) as component:
@@ -29,3 +40,13 @@ class ServiceInvoicingActionWizard(models.TransientModel):
     def execute_close(self):
         with contract_utils(self.env, self.service_invoicing_id) as component:
             component.set_contract_closed(self.execution_date)
+
+    def execute_modify(self):
+        with contract_utils(self.env, self.service_invoicing_id) as component:
+            service_invoicing_id = component.modify(
+                self.execution_date,
+                self.executed_modification_action,
+                self.pricelist_id,
+                self.service_pack_id,
+            )
+        return service_invoicing_view(self.env, service_invoicing_id)
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action.xml b/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
index 7d2a37e2a..3cfe36339 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
@@ -12,6 +12,28 @@
             <field name="executed_action" invisible="1" />
             <field name="service_invoicing_id" required="1" domain="[('community_company_id','!=',False)]"/>
             <field name="execution_date" required="1"/>
+            <field
+              name="executed_modification_action"
+              attrs="{
+               'invisible': [('executed_action','!=','modification')],
+               'required': [('executed_action','==','modification')]
+              }"
+            />
+            <field
+              name="pricelist_id"
+              attrs="{
+               'invisible': [('executed_modification_action','not in',['modify_all','modify_pricelist'])],
+               'required': [('executed_modification_action','in',['modify_all','modify_pricelist'])]
+              }"
+            />
+            <field
+              name="service_pack_id"
+              domain="[('is_contract','=',True)]"
+              attrs="{
+               'invisible': [('executed_modification_action','not in',['modify_all','modify_service_pack'])],
+               'required': [('executed_modification_action','in',['modify_all','modify_service_pack'])]
+              }"
+            />
           </group>
         </sheet>
         <footer>
@@ -22,6 +44,13 @@
             class="btn-primary"
             attrs="{'invisible': [('executed_action','!=','activate')]}"
           />
+          <button
+            name="execute_modify"
+            string="modify"
+            type="object"
+            class="btn-primary"
+            attrs="{'invisible': [('executed_action','!=','modification')]}"
+          />
           <button
             name="execute_close"
             string="close contract"
@@ -30,9 +59,9 @@
             attrs="{'invisible': [('executed_action','!=','close')]}"
           />
           <button
+            special="cancel"
             string="Cancelar"
             class="btn-secondary"
-            special="cancel"
           />
         </footer>
       </form>
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
index b5c7bbb6f..3a0a2ee24 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
@@ -7,6 +7,8 @@ from odoo.addons.energy_communities.utils import (
     sale_order_utils,
 )
 
+from ..utils import service_invoicing_view
+
 
 class ServiceInvoicingActionCreateWizard(models.TransientModel):
     _name = "service.invoicing.action.create.wizard"
@@ -16,30 +18,15 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
     community_company_id = fields.Many2one("res.company", string="Community")
     service_pack_id = fields.Many2one("product.product", string="Service pack")
     pricelist_id = fields.Many2one("product.pricelist", string="PriceList")
+    start_date = fields.Date(string="Start date")
 
     def execute_create(self):
         with sale_order_utils(self.env) as component:
-            so = component.create_service_invoicing_activation_sale_order(
-                company_id=self.company_id,
-                community_company_id=self.community_company_id,
-                service_pack_id=self.service_pack_id,
-                pricelist_id=self.pricelist_id,
+            service_invoicing_id = component.create_service_invoicing_on_hold(
+                self.company_id,
+                self.community_company_id,
+                self.service_pack_id,
+                self.pricelist_id,
+                self.start_date,
             )
-            so.action_confirm()
-            rel_contracts = component.get_related_contracts(so)
-        with contract_utils(self.env, rel_contracts) as component:
-            component.set_contract_on_hold()
-        return {
-            "type": "ir.actions.act_window",
-            "res_model": "contract.contract",
-            "views": [
-                (
-                    self.env.ref(
-                        "energy_communities_service_invoicing.view_contract_contract_customer_form"
-                    ).id,
-                    "form",
-                ),
-            ],
-            "target": "current",
-            "res_id": rel_contracts.id,
-        }
+        return service_invoicing_view(self.env, service_invoicing_id)
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
index f18a2d2ca..82540d43d 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
@@ -11,6 +11,7 @@
           <group>
             <field name="company_id" required="1" domain="[('hierarchy_level','=','coordinator')]"/>
             <field name="community_company_id" required="1" domain="[('hierarchy_level','=','community')]"/>
+            <field name="start_date" required="1"/>
             <field name="service_pack_id" required="1" domain="[('is_contract','=',True)]"/>
             <field name="pricelist_id" required="1" />
           </group>
@@ -45,6 +46,6 @@
     name="Create community service invoicing"
     action="service_invoicing_action_create_wizard_action"
     parent="ce_service_invoicing_menu"
-    sequence="200"
+    sequence="300"
   />
 </odoo>
-- 
GitLab


From b0c2a05fb515acb41c6a22721c641d698f173672 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Tue, 28 Jan 2025 10:21:10 +0100
Subject: [PATCH 16/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20First=20multicompany,?=
 =?UTF-8?q?=20better=20UX,=20modification=20workflow=20improved.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../components/contract_utils.py              |  8 ++-
 .../models/__init__.py                        |  1 +
 .../models/abstract_contract.py               | 11 +++
 .../models/contract.py                        |  3 +
 .../views/contract_views.xml                  | 67 +++++++++++++++----
 .../service_invoicing_action_create.xml       |  2 +-
 6 files changed, 76 insertions(+), 16 deletions(-)
 create mode 100644 energy_communities_service_invoicing/models/abstract_contract.py

diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
index 3637fbb21..fef25c126 100644
--- a/energy_communities_service_invoicing/components/contract_utils.py
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -47,7 +47,7 @@ class ContractUtils(Component):
         sale_order_utils = self.component(
             usage="sale.order.utils", model_name="sale.order"
         )
-        return sale_order_utils.create_service_invoicing(
+        new_service_invoicing_id = sale_order_utils.create_service_invoicing(
             self.work.record.company_id,
             self.work.record.community_company_id,
             self._get_service_pack_id()
@@ -58,6 +58,8 @@ class ContractUtils(Component):
             else pricelist_id,
             execution_date + timedelta(days=1),
         )
+        self._setup_successors_and_predecessors(new_service_invoicing_id)
+        return new_service_invoicing_id
 
     def _is_service_line(self, contract_line):
         if self.work.record.contract_template_id:
@@ -74,3 +76,7 @@ class ContractUtils(Component):
             if not self._is_service_line(line):
                 return line.product_id
         return False
+
+    def _setup_successors_and_predecessors(self, new_service_invoicing_id):
+        self.work.record.write({"successor_contract_id": new_service_invoicing_id.id})
+        new_service_invoicing_id.write({"predecessor_contract_id": self.work.record.id})
diff --git a/energy_communities_service_invoicing/models/__init__.py b/energy_communities_service_invoicing/models/__init__.py
index cdc17d9f6..1877c8565 100644
--- a/energy_communities_service_invoicing/models/__init__.py
+++ b/energy_communities_service_invoicing/models/__init__.py
@@ -1,3 +1,4 @@
+from . import abstract_contract
 from . import contract
 from . import product_template
 from . import sale_order
diff --git a/energy_communities_service_invoicing/models/abstract_contract.py b/energy_communities_service_invoicing/models/abstract_contract.py
new file mode 100644
index 000000000..f790b5dec
--- /dev/null
+++ b/energy_communities_service_invoicing/models/abstract_contract.py
@@ -0,0 +1,11 @@
+from odoo import fields, models
+
+
+class ContractAbstractContract(models.AbstractModel):
+    _inherit = "contract.abstract.contract"
+    _check_company_auto = False
+
+    company_id = fields.Many2one(
+        required=False,
+        default=None,
+    )
diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index cf3e83447..9dba8f354 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -14,6 +14,9 @@ class ContractContract(models.Model):
     predecessor_contract_id = fields.Many2one(
         "contract.contract", string="Predecessor contract"
     )
+    successor_contract_id = fields.Many2one(
+        "contract.contract", string="Successor contract"
+    )
 
     def action_activate_contract(self):
         return self._action_contract("activate")
diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index ade969e5c..48a2dbb9e 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -46,18 +46,8 @@
         <field name="next_period_date_start" />
         <field name="next_period_date_end" />
         <field name="date_end" />
-      </xpath>
-      
-    </field>
-  </record>
-
-  <record id="contract_template_form_view" model="ir.ui.view">
-    <field name="name">contract.template form view  (in energy_communities service_invoicing)</field>
-    <field name="model">contract.contract</field>
-    <field name="inherit_id" ref="contract.contract_template_form_view" />
-    <field name="arch" type="xml">
-      <xpath expr="//field[@name='company_id']" position="attributes">
-        <attribute name="required">0</attribute>
+        <field name="predecessor_contract_id" />
+        <field name="successor_contract_id" />
       </xpath>
     </field>
   </record>
@@ -77,9 +67,36 @@
       model="ir.actions.act_window"
   >
     <field name="name">Service Products</field>
-    <field name="res_model">product.product</field>
+    <field name="res_model">product.template</field>
+    <field name="view_mode">tree,form</field>
+    <!--<field name="domain">[('is_contract','=',True)]</field>-->
+  </record>
+
+  <record
+      id="view_service_contract_templates_window"
+      model="ir.actions.act_window"
+  >
+    <field name="name">Service Contract Types</field>
+    <field name="res_model">contract.template</field>
+    <field name="view_mode">tree,form</field>
+  </record>
+
+  <record
+      id="view_service_sale_orders_window"
+      model="ir.actions.act_window"
+  >
+    <field name="name">Service Sale Orders</field>
+    <field name="res_model">sale.order</field>
+    <field name="view_mode">tree,form</field>
+  </record>
+
+  <record
+      id="view_service_tariffs_window"
+      model="ir.actions.act_window"
+  >
+    <field name="name">Service Tariffs</field>
+    <field name="res_model">sale.order</field>
     <field name="view_mode">tree,form</field>
-    <field name="domain">[('is_contract','=',True)]</field>
   </record>
 
   <record model="ir.actions.act_window.view" id="action_view_service_invoicing_tree">
@@ -110,4 +127,26 @@
     action="view_service_products_window"
     sequence="200"
   />
+  <menuitem
+    name="Service Contract Types"
+    id="view_service_contract_templates_menu"
+    parent="ce_service_invoicing_menu"
+    action="view_service_contract_templates_window"
+    sequence="300"
+  />
+  <menuitem
+    name="Service Sale Orders"
+    id="view_service_sale_orders_menu"
+    parent="ce_service_invoicing_menu"
+    action="view_service_sale_orders_window"
+    sequence="400"
+  />
+  <menuitem
+    name="Service Tariffs"
+    id="view_service_tariffs_menu"
+    parent="ce_service_invoicing_menu"
+    action="view_service_tariffs_window"
+    sequence="500"
+  />
+
 </odoo>
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
index 82540d43d..9b54330fe 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
@@ -45,7 +45,7 @@
     id="service_invoicing_action_create_wizard_menu"
     name="Create community service invoicing"
     action="service_invoicing_action_create_wizard_action"
-    parent="ce_service_invoicing_menu"
+    parent="energy_communities.ce_config_menu"
     sequence="300"
   />
 </odoo>
-- 
GitLab


From 5b51dd37a98c2bdce2bf9dd3b039854c165b3561 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Fri, 31 Jan 2025 16:42:48 +0100
Subject: [PATCH 17/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Community=20members?=
 =?UTF-8?q?=20quantity=20formula=20on=20contract=20line?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../__manifest__.py                              |  1 +
 .../data/contract_line_qty_formula_data.xml      | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)
 create mode 100644 energy_communities_service_invoicing/data/contract_line_qty_formula_data.xml

diff --git a/energy_communities_service_invoicing/__manifest__.py b/energy_communities_service_invoicing/__manifest__.py
index 5cdd64fc9..469e40dcf 100644
--- a/energy_communities_service_invoicing/__manifest__.py
+++ b/energy_communities_service_invoicing/__manifest__.py
@@ -15,6 +15,7 @@
     # always loaded
     "data": [
         "security/ir.model.access.csv",
+        "data/contract_line_qty_formula_data.xml",
         "views/menus.xml",
         "views/contract_views.xml",
         "views/sale_order_views.xml",
diff --git a/energy_communities_service_invoicing/data/contract_line_qty_formula_data.xml b/energy_communities_service_invoicing/data/contract_line_qty_formula_data.xml
new file mode 100644
index 000000000..85565bddd
--- /dev/null
+++ b/energy_communities_service_invoicing/data/contract_line_qty_formula_data.xml
@@ -0,0 +1,16 @@
+<odoo>
+  <data>
+    <record
+      id="community_members_formula"
+      model="contract.line.qty.formula"
+    >
+      <field name="name">Community members</field>
+      <field name="code">
+result = env['res.users.role.line'].search_count([
+('role_id','in',[env.ref("energy_communities.role_ce_admin").id,env.ref("energy_communities.role_ce_member").id]),
+('company_id','=',contract.community_company_id.id)
+])
+      </field>
+    </record>
+  </data>
+</odoo>
-- 
GitLab


From 3b691299fe85748e3ac4b2030fdbc0d78d1067b9 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Fri, 31 Jan 2025 17:24:05 +0100
Subject: [PATCH 18/85] =?UTF-8?q?[FIX]=20=F0=9F=90=9B=20Display=20pricelis?=
 =?UTF-8?q?t=20on=20service=20tariffs?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 energy_communities_service_invoicing/views/contract_views.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index 48a2dbb9e..b9dca2273 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -95,7 +95,7 @@
       model="ir.actions.act_window"
   >
     <field name="name">Service Tariffs</field>
-    <field name="res_model">sale.order</field>
+    <field name="res_model">product.pricelist</field>
     <field name="view_mode">tree,form</field>
   </record>
 
-- 
GitLab


From f866f8565017ff1946b61a7624a72430cf3cb00e Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Mon, 3 Feb 2025 16:45:40 +0100
Subject: [PATCH 19/85] =?UTF-8?q?type=20<description>=20[IMP]=20=E2=9C=A8?=
 =?UTF-8?q?=20Set=20contract=20line=20to=203=20decimal.=20Discount=20apply?=
 =?UTF-8?q?=20on=20wizard=20creation.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../models/abstract_contract.py                    | 14 ++++++++++++++
 .../wizards/service_invoicing_action_create.py     |  7 +++++++
 .../wizards/service_invoicing_action_create.xml    |  1 +
 3 files changed, 22 insertions(+)

diff --git a/energy_communities_service_invoicing/models/abstract_contract.py b/energy_communities_service_invoicing/models/abstract_contract.py
index f790b5dec..22120a175 100644
--- a/energy_communities_service_invoicing/models/abstract_contract.py
+++ b/energy_communities_service_invoicing/models/abstract_contract.py
@@ -9,3 +9,17 @@ class ContractAbstractContract(models.AbstractModel):
         required=False,
         default=None,
     )
+
+
+class ContractAbstractContractLine(models.AbstractModel):
+    _inherit = "contract.abstract.contract.line"
+
+    price_unit = fields.Float(
+        string="Unit Price",
+        compute="_compute_price_unit",
+        inverse="_inverse_price_unit",
+        digits="Product Price",
+    )
+    price_subtotal = fields.Float(
+        compute="_compute_price_subtotal", string="Sub Total", digits="Product Price"
+    )
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
index 3a0a2ee24..e8ed29c34 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
@@ -19,6 +19,12 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
     service_pack_id = fields.Many2one("product.product", string="Service pack")
     pricelist_id = fields.Many2one("product.pricelist", string="PriceList")
     start_date = fields.Date(string="Start date")
+    # TODO: We could implement this to apply discount or in contract basis.
+    # discount = fields.Float(
+    #     string="Discount (%)",
+    #     digits="Discount",
+    #     default=0
+    # )
 
     def execute_create(self):
         with sale_order_utils(self.env) as component:
@@ -28,5 +34,6 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
                 self.service_pack_id,
                 self.pricelist_id,
                 self.start_date,
+                # self.discount
             )
         return service_invoicing_view(self.env, service_invoicing_id)
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
index 9b54330fe..3ea74a200 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
@@ -14,6 +14,7 @@
             <field name="start_date" required="1"/>
             <field name="service_pack_id" required="1" domain="[('is_contract','=',True)]"/>
             <field name="pricelist_id" required="1" />
+            <!--<field name="discount" required="1" />-->
           </group>
         </sheet>
         <footer>
-- 
GitLab


From b8ff114857667a2136136181c1d9647e640ed478 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Mon, 3 Feb 2025 17:17:05 +0100
Subject: [PATCH 20/85] =?UTF-8?q?[FIX]=20=F0=9F=90=9B=20Apply=20contract?=
 =?UTF-8?q?=20company=5Fid=20to=20platform=20company.=20We=20must=20work?=
 =?UTF-8?q?=20on=20record=20rules=20to=20make=20contract=20and=20invoice?=
 =?UTF-8?q?=20available=20to=20coordinator.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 energy_communities/models/res_partner.py      |  2 +-
 .../views/res_partner_views.xml               | 19 ++++++++++---------
 .../components/contract_utils.py              |  2 +-
 .../components/sale_order_utils.py            |  2 +-
 4 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/energy_communities/models/res_partner.py b/energy_communities/models/res_partner.py
index 8b7d36c57..654d8cac5 100644
--- a/energy_communities/models/res_partner.py
+++ b/energy_communities/models/res_partner.py
@@ -32,7 +32,7 @@ class ResPartner(models.Model):
     )
     related_company_id = fields.Many2one(
         "res.company",
-        string="Related company",
+        string="Represented company",
         compute="compute_related_company_id",
         store=False,
     )
diff --git a/energy_communities/views/res_partner_views.xml b/energy_communities/views/res_partner_views.xml
index e0a56e92a..4d95e3659 100644
--- a/energy_communities/views/res_partner_views.xml
+++ b/energy_communities/views/res_partner_views.xml
@@ -46,20 +46,21 @@
                 <xpath expr="//field[@name='vat']" position="after">
                   <field name="company_hierarchy_level" invisible="1" />
                   <field name="user_current_role" />
+                  <field name="related_company_id" attrs="{'invisible': [('company_hierarchy_level', '=', 'none')]}" />
                 </xpath>
                 <xpath expr="//field[@name='name']" position="before">
                   <h4
-            style="color:green;"
-            attrs="{'invisible': [('company_hierarchy_level', '!=', 'instance')]}"
-          >Platform company</h4>
+                    style="color:green;"
+                    attrs="{'invisible': [('company_hierarchy_level', '!=', 'instance')]}"
+                  >Platform company</h4>
                   <h4
-            style="color:green;"
-            attrs="{'invisible': [('company_hierarchy_level', '!=', 'coordinator')]}"
-          >Coordinator company</h4>
+                    style="color:green;"
+                    attrs="{'invisible': [('company_hierarchy_level', '!=', 'coordinator')]}"
+                  >Coordinator company</h4>
                   <h4
-            style="color:green;"
-            attrs="{'invisible': [('company_hierarchy_level', '!=', 'community')]}"
-          >Community company</h4>
+                    style="color:green;"
+                    attrs="{'invisible': [('company_hierarchy_level', '!=', 'community')]}"
+                  >Community company</h4>
                 </xpath>
                 <xpath expr="//field[@name='child_ids']" position="after">
                   <label
diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
index fef25c126..2aa924d29 100644
--- a/energy_communities_service_invoicing/components/contract_utils.py
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -48,7 +48,7 @@ class ContractUtils(Component):
             usage="sale.order.utils", model_name="sale.order"
         )
         new_service_invoicing_id = sale_order_utils.create_service_invoicing(
-            self.work.record.company_id,
+            self.work.record.partner_id.related_company_id,
             self.work.record.community_company_id,
             self._get_service_pack_id()
             if executed_modification_action not in ["modify_all", "modify_service_pack"]
diff --git a/energy_communities_service_invoicing/components/sale_order_utils.py b/energy_communities_service_invoicing/components/sale_order_utils.py
index 2e3deacc3..ea8e5a998 100644
--- a/energy_communities_service_invoicing/components/sale_order_utils.py
+++ b/energy_communities_service_invoicing/components/sale_order_utils.py
@@ -15,7 +15,7 @@ class SaleOrderUtils(Component):
     ):
         so_creation_dict = {
             "partner_id": company_id.partner_id.id,
-            "company_id": company_id.id,
+            # "company_id": company_id.id,
             "community_company_id": community_company_id.id,
             "pricelist_id": pricelist_id.id,
             "order_line": [
-- 
GitLab


From 526389ae4d9ebe57998ce4b95929db0be24898d6 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Tue, 4 Feb 2025 10:33:21 +0100
Subject: [PATCH 21/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Add=20formulas=20to?=
 =?UTF-8?q?=20energy=5Fcommunities=20configuration=20menu?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 energy_communities/views/menus.xml | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/energy_communities/views/menus.xml b/energy_communities/views/menus.xml
index 0c01b523a..1fde3dba6 100644
--- a/energy_communities/views/menus.xml
+++ b/energy_communities/views/menus.xml
@@ -4,6 +4,16 @@
      License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
 -->
 <odoo>
+
+  <record
+      id="view_ec_formulas_window"
+      model="ir.actions.act_window"
+  >
+    <field name="name">Formulas (quantity)</field>
+    <field name="res_model">contract.line.qty.formula</field>
+    <field name="view_mode">tree,form</field>
+  </record>
+
   <menuitem
     id="ce_root_menu"
     name="Energy Communities"
@@ -17,6 +27,7 @@
     name="Source types"
     parent="ce_config_menu"
     action="ce_utm_sources_action"
+    groups="group_platform_manager"
   />
   <menuitem
     id="energy_actions_menu"
@@ -25,6 +36,13 @@
     action="energy_action_views"
     groups="group_platform_manager"
   />
+  <menuitem
+    id="ec_formulas_menu"
+    name="Formulas"
+    parent="ce_config_menu"
+    action="view_ec_formulas_window"
+    groups="group_platform_manager"
+  />
 
   <!-- Hide menu items unless platform manager -->
   <record model="ir.ui.menu" id="community_maps.menu_root">
-- 
GitLab


From d906771e940811abb96ea5e231c68ad393c99005 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Tue, 4 Feb 2025 12:05:09 +0100
Subject: [PATCH 22/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Introduce=20action=20?=
 =?UTF-8?q?categorisation?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../models/sale_order.py                      | 24 +++++++++++++------
 energy_communities_service_invoicing/utils.py | 18 ++++++++++++++
 .../views/sale_order_views.xml                |  9 ++++++-
 .../wizards/service_invoicing_action.py       | 18 ++++++--------
 4 files changed, 50 insertions(+), 19 deletions(-)

diff --git a/energy_communities_service_invoicing/models/sale_order.py b/energy_communities_service_invoicing/models/sale_order.py
index 2f95a8e20..9a9f4014e 100644
--- a/energy_communities_service_invoicing/models/sale_order.py
+++ b/energy_communities_service_invoicing/models/sale_order.py
@@ -1,9 +1,10 @@
-# Copyright 2017 LasLabs Inc.
-# Copyright 2018 ACSONE SA/NV.
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
 from odoo import _, api, fields, models
 
+from ..utils import (
+    _SALE_ORDER_SERVICE_INVOICING_ACTION_VALUES,
+    _SALE_ORDER_SERVICE_INVOICING_MODIFICATION_ACTION_VALUES,
+)
+
 
 class SaleOrder(models.Model):
     _name = "sale.order"
@@ -14,9 +15,18 @@ class SaleOrder(models.Model):
         string="Related community",
         domain="[('hierarchy_level','=','community')]",
     )
-    # company_id = fields.Many2one(
-    #     required=False, index=True
-    # )
+
+    service_invoicing_action = fields.Selection(
+        selection=_SALE_ORDER_SERVICE_INVOICING_ACTION_VALUES,
+        required=True,
+        string="Service invoicing action",
+        default="none",
+    )
+    service_invoicing_modification_action = fields.Selection(
+        selection=_SALE_ORDER_SERVICE_INVOICING_MODIFICATION_ACTION_VALUES,
+        string="Modification action",
+        default="none",
+    )
 
     def action_create_contract(self):
         contracts = super().action_create_contract()
diff --git a/energy_communities_service_invoicing/utils.py b/energy_communities_service_invoicing/utils.py
index 87a38cffb..2a1d67fdf 100644
--- a/energy_communities_service_invoicing/utils.py
+++ b/energy_communities_service_invoicing/utils.py
@@ -1,7 +1,25 @@
+from odoo import _
 from odoo.api import Environment
 
 from odoo.addons.contract.models.contract import ContractContract
 
+_SERVICE_INVOICING_EXECUTED_ACTION_VALUES = [
+    ("activate", _("Activate")),
+    ("close", _("Close")),
+    ("modification", _("Modification")),
+]
+_SERVICE_INVOICING_EXECUTED_MODIFICATION_ACTION_VALUES = [
+    ("modify_all", _("Modify prices and service pack")),
+    ("modify_pricelist", _("Modify prices")),
+    ("modify_service_pack", _("Modify service pack")),
+]
+_SALE_ORDER_SERVICE_INVOICING_ACTION_VALUES = [
+    ("none", _("None"))
+] + _SERVICE_INVOICING_EXECUTED_ACTION_VALUES
+_SALE_ORDER_SERVICE_INVOICING_MODIFICATION_ACTION_VALUES = [
+    ("none", _("None"))
+] + _SERVICE_INVOICING_EXECUTED_MODIFICATION_ACTION_VALUES
+
 
 def service_invoicing_view(env: Environment, service_invoicing_id: ContractContract):
     return {
diff --git a/energy_communities_service_invoicing/views/sale_order_views.xml b/energy_communities_service_invoicing/views/sale_order_views.xml
index 6fb974615..545deb36d 100644
--- a/energy_communities_service_invoicing/views/sale_order_views.xml
+++ b/energy_communities_service_invoicing/views/sale_order_views.xml
@@ -1,9 +1,16 @@
 <odoo>
-  <record id="view_order_form" model="ir.ui.view">
+  <record id="ec_view_order_form" model="ir.ui.view">
     <field name="name">sale.order.form (in energy_communities service_invoicing)</field>
     <field name="model">sale.order</field>
     <field name="inherit_id" ref="sale.view_order_form" />
     <field name="arch" type="xml">
+        <xpath expr="//field[@name='partner_id']" position="before">
+          <field name="service_invoicing_action" readonly="1" />
+          <field
+            name="service_invoicing_modification_action"
+            attrs="{'readonly': 1,'invisible': [('service_invoicing_action','!=', 'modify')]}"
+          />
+        </xpath>
         <xpath expr="//field[@name='partner_id']" position="after">
           <field name="community_company_id" />
         </xpath>
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action.py b/energy_communities_service_invoicing/wizards/service_invoicing_action.py
index f6340f4d9..2f4ee7112 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action.py
@@ -4,7 +4,11 @@ from odoo.tools.translate import _
 
 from odoo.addons.energy_communities.utils import contract_utils
 
-from ..utils import service_invoicing_view
+from ..utils import (
+    _SERVICE_INVOICING_EXECUTED_ACTION_VALUES,
+    _SERVICE_INVOICING_EXECUTED_MODIFICATION_ACTION_VALUES,
+    service_invoicing_view,
+)
 
 
 class ServiceInvoicingActionWizard(models.TransientModel):
@@ -16,18 +20,10 @@ class ServiceInvoicingActionWizard(models.TransientModel):
     )
     execution_date = fields.Date(string="Execution date")
     executed_action = fields.Selection(
-        [
-            ("activate", _("Activate")),
-            ("close", _("Close")),
-            ("modification", _("Modification")),
-        ]
+        selection=_SERVICE_INVOICING_EXECUTED_ACTION_VALUES
     )
     executed_modification_action = fields.Selection(
-        [
-            ("modify_all", _("Modify prices and service pack")),
-            ("modify_pricelist", _("Modify prices")),
-            ("modify_service_pack", _("Modify service pack")),
-        ],
+        selection=_SERVICE_INVOICING_EXECUTED_MODIFICATION_ACTION_VALUES,
         string="Modification action",
     )
     pricelist_id = fields.Many2one("product.pricelist", string="Select pricelist")
-- 
GitLab


From 1149296f56cc124a5a7cbeb448b14f8a3cc928a1 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Tue, 4 Feb 2025 15:26:46 +0100
Subject: [PATCH 23/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Propagate=20service?=
 =?UTF-8?q?=5Finvoicing=20action=20into=20sale=5Forder?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../components/contract_utils.py              |  2 ++
 .../components/sale_order_utils.py            | 27 +++++++++++++++----
 energy_communities_service_invoicing/utils.py |  4 +--
 .../views/sale_order_views.xml                |  2 +-
 .../service_invoicing_action_create.py        |  2 +-
 5 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
index 2aa924d29..f7c8ac71e 100644
--- a/energy_communities_service_invoicing/components/contract_utils.py
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -57,6 +57,8 @@ class ContractUtils(Component):
             if executed_modification_action not in ["modify_all", "modify_pricelist"]
             else pricelist_id,
             execution_date + timedelta(days=1),
+            "modification",
+            executed_modification_action,
         )
         self._setup_successors_and_predecessors(new_service_invoicing_id)
         return new_service_invoicing_id
diff --git a/energy_communities_service_invoicing/components/sale_order_utils.py b/energy_communities_service_invoicing/components/sale_order_utils.py
index ea8e5a998..65416ee62 100644
--- a/energy_communities_service_invoicing/components/sale_order_utils.py
+++ b/energy_communities_service_invoicing/components/sale_order_utils.py
@@ -5,19 +5,23 @@ from odoo.addons.energy_communities.utils import contract_utils
 class SaleOrderUtils(Component):
     _inherit = "sale.order.utils"
 
-    def create_service_invoicing_activation_sale_order(
+    def create_service_invoicing_sale_order(
         self,
         company_id,
         community_company_id,
         service_pack_id,
         pricelist_id,
         start_date,
+        executed_action,
+        executed_modification_action,
     ):
         so_creation_dict = {
             "partner_id": company_id.partner_id.id,
             # "company_id": company_id.id,
             "community_company_id": community_company_id.id,
             "pricelist_id": pricelist_id.id,
+            "service_invoicing_action": executed_action,
+            "service_invoicing_modification_action": executed_modification_action,
             "order_line": [
                 (
                     0,
@@ -39,9 +43,17 @@ class SaleOrderUtils(Component):
         service_pack_id,
         pricelist_id,
         start_date,
+        executed_action,
+        executed_modification_action="none",
     ):
-        so = self.create_service_invoicing_activation_sale_order(
-            company_id, community_company_id, service_pack_id, pricelist_id, start_date
+        so = self.create_service_invoicing_sale_order(
+            company_id,
+            community_company_id,
+            service_pack_id,
+            pricelist_id,
+            start_date,
+            executed_action,
+            executed_modification_action,
         )
         so.action_confirm()
         service_invoicing_id = self.get_related_contracts(so)
@@ -50,7 +62,7 @@ class SaleOrderUtils(Component):
             component.set_start_date(start_date)
         return service_invoicing_id
 
-    def create_service_invoicing_on_hold(
+    def create_service_invoicing_initial(
         self,
         company_id,
         community_company_id,
@@ -59,7 +71,12 @@ class SaleOrderUtils(Component):
         start_date,
     ):
         service_invoicing_id = self.create_service_invoicing(
-            company_id, community_company_id, service_pack_id, pricelist_id, start_date
+            company_id,
+            community_company_id,
+            service_pack_id,
+            pricelist_id,
+            start_date,
+            "activate",
         )
         # TODO: We must call contract_utils with a better component and workcontext modification approach
         with contract_utils(self.env, service_invoicing_id) as component:
diff --git a/energy_communities_service_invoicing/utils.py b/energy_communities_service_invoicing/utils.py
index 2a1d67fdf..9c45be14c 100644
--- a/energy_communities_service_invoicing/utils.py
+++ b/energy_communities_service_invoicing/utils.py
@@ -5,8 +5,8 @@ from odoo.addons.contract.models.contract import ContractContract
 
 _SERVICE_INVOICING_EXECUTED_ACTION_VALUES = [
     ("activate", _("Activate")),
-    ("close", _("Close")),
     ("modification", _("Modification")),
+    ("close", _("Close")),
 ]
 _SERVICE_INVOICING_EXECUTED_MODIFICATION_ACTION_VALUES = [
     ("modify_all", _("Modify prices and service pack")),
@@ -15,7 +15,7 @@ _SERVICE_INVOICING_EXECUTED_MODIFICATION_ACTION_VALUES = [
 ]
 _SALE_ORDER_SERVICE_INVOICING_ACTION_VALUES = [
     ("none", _("None"))
-] + _SERVICE_INVOICING_EXECUTED_ACTION_VALUES
+] + _SERVICE_INVOICING_EXECUTED_ACTION_VALUES[:-1]
 _SALE_ORDER_SERVICE_INVOICING_MODIFICATION_ACTION_VALUES = [
     ("none", _("None"))
 ] + _SERVICE_INVOICING_EXECUTED_MODIFICATION_ACTION_VALUES
diff --git a/energy_communities_service_invoicing/views/sale_order_views.xml b/energy_communities_service_invoicing/views/sale_order_views.xml
index 545deb36d..2da76391e 100644
--- a/energy_communities_service_invoicing/views/sale_order_views.xml
+++ b/energy_communities_service_invoicing/views/sale_order_views.xml
@@ -8,7 +8,7 @@
           <field name="service_invoicing_action" readonly="1" />
           <field
             name="service_invoicing_modification_action"
-            attrs="{'readonly': 1,'invisible': [('service_invoicing_action','!=', 'modify')]}"
+            attrs="{'readonly': 1,'invisible': [('service_invoicing_action','!=', 'modification')]}"
           />
         </xpath>
         <xpath expr="//field[@name='partner_id']" position="after">
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
index e8ed29c34..8b3cdbda8 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
@@ -28,7 +28,7 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
 
     def execute_create(self):
         with sale_order_utils(self.env) as component:
-            service_invoicing_id = component.create_service_invoicing_on_hold(
+            service_invoicing_id = component.create_service_invoicing_initial(
                 self.company_id,
                 self.community_company_id,
                 self.service_pack_id,
-- 
GitLab


From 1410c46325f311c228813e6ca0bf222b2a237aba Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Tue, 4 Feb 2025 18:38:11 +0100
Subject: [PATCH 24/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Improved=20workflow?=
 =?UTF-8?q?=20actions?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../components/contract_utils.py              | 87 +++++++++++++------
 .../components/sale_order_utils.py            | 14 +--
 .../models/contract.py                        | 16 ++++
 energy_communities_service_invoicing/utils.py |  6 ++
 .../views/contract_views.xml                  |  8 +-
 .../service_invoicing_action_create.py        |  8 +-
 .../service_invoicing_action_create.xml       |  1 -
 7 files changed, 102 insertions(+), 38 deletions(-)

diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
index f7c8ac71e..57ec20d1f 100644
--- a/energy_communities_service_invoicing/components/contract_utils.py
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -6,28 +6,23 @@ from odoo.addons.component.core import Component
 class ContractUtils(Component):
     _inherit = "contract.utils"
 
-    def set_contract_on_hold(self):
+    def set_contract_ready_to_start(self):
         for line in self.work.record.contract_line_ids:
             line.cancel()
+        self.work.record.write({"status": "ready_to_start"})
 
     def set_contract_active(self, execution_date):
-        for line in self.work.record.contract_line_ids:
-            if self._is_service_line(line):
-                line.write(
-                    {
-                        "date_start": execution_date,
-                        "next_period_date_start": execution_date,
-                        "recurring_next_date": execution_date,
-                        "is_canceled": False,
-                    }
-                )
-                line._compute_state()
+        self._uncancel_contract_lines(execution_date)
+        self.set_start_date(execution_date)
+        self.work.record.write({"status": "in_progress"})
 
     def set_contract_closed(self, execution_date):
         for line in self.work.record.contract_line_ids:
-            if self._is_service_line(line):
-                line.write({"date_end": execution_date})
-                line._compute_state()
+            if self.work.record.status == "ready_to_start":
+                self._uncancel_contract_lines(execution_date)
+            line.write({"date_end": execution_date})
+            line._compute_state()
+        self.work.record.compute_close_status(execution_date)
 
     def set_start_date(self, date_start):
         self.work.record.write({"date_start": date_start})
@@ -36,6 +31,12 @@ class ContractUtils(Component):
                 line.write({"date_start": date_start})
                 line._compute_state()
 
+    def clean_non_service_lines(self):
+        for line in self.work.record.contract_line_ids:
+            if not self._is_service_line(line):
+                line.cancel()
+                line.unlink()
+
     def modify(
         self,
         execution_date,
@@ -43,23 +44,35 @@ class ContractUtils(Component):
         pricelist_id=None,
         service_pack_id=None,
     ):
+        initial_status = self.work.record.status
         self.set_contract_closed(execution_date)
         sale_order_utils = self.component(
             usage="sale.order.utils", model_name="sale.order"
         )
-        new_service_invoicing_id = sale_order_utils.create_service_invoicing(
-            self.work.record.partner_id.related_company_id,
-            self.work.record.community_company_id,
-            self._get_service_pack_id()
+        service_invoicing_params = {
+            "company_id": self.work.record.partner_id.related_company_id,
+            "community_company_id": self.work.record.community_company_id,
+            "service_pack_id": self._get_service_pack_id()
             if executed_modification_action not in ["modify_all", "modify_service_pack"]
             else service_pack_id,
-            self.work.record.pricelist_id
+            "pricelist_id": self.work.record.pricelist_id
             if executed_modification_action not in ["modify_all", "modify_pricelist"]
             else pricelist_id,
-            execution_date + timedelta(days=1),
-            "modification",
-            executed_modification_action,
-        )
+            "start_date": execution_date + timedelta(days=1),
+            "executed_action": "modification",
+            "executed_modification_action": executed_modification_action,
+        }
+        if initial_status == "ready_to_start":
+            new_service_invoicing_id = (
+                sale_order_utils.create_service_invoicing_ready_to_start(
+                    **service_invoicing_params
+                )
+            )
+        if initial_status == "in_progress":
+            new_service_invoicing_id = sale_order_utils.create_service_invoicing(
+                **service_invoicing_params
+            )
+
         self._setup_successors_and_predecessors(new_service_invoicing_id)
         return new_service_invoicing_id
 
@@ -74,11 +87,31 @@ class ContractUtils(Component):
         return False
 
     def _get_service_pack_id(self):
-        for line in self.work.record.contract_line_ids:
-            if not self._is_service_line(line):
-                return line.product_id
+        if self.work.record.contract_template_id:
+            return self.env["product.product"].search(
+                [
+                    (
+                        "property_contract_template_id",
+                        "=",
+                        self.work.record.contract_template_id.id,
+                    )
+                ],
+                limit=1,
+            )
         return False
 
     def _setup_successors_and_predecessors(self, new_service_invoicing_id):
         self.work.record.write({"successor_contract_id": new_service_invoicing_id.id})
         new_service_invoicing_id.write({"predecessor_contract_id": self.work.record.id})
+
+    def _uncancel_contract_lines(self, execution_date):
+        for line in self.work.record.contract_line_ids:
+            line.write(
+                {
+                    "date_start": execution_date,
+                    "next_period_date_start": execution_date,
+                    "recurring_next_date": execution_date,
+                    "is_canceled": False,
+                }
+            )
+            line._compute_state()
diff --git a/energy_communities_service_invoicing/components/sale_order_utils.py b/energy_communities_service_invoicing/components/sale_order_utils.py
index 65416ee62..3fadaf2ef 100644
--- a/energy_communities_service_invoicing/components/sale_order_utils.py
+++ b/energy_communities_service_invoicing/components/sale_order_utils.py
@@ -56,19 +56,22 @@ class SaleOrderUtils(Component):
             executed_modification_action,
         )
         so.action_confirm()
-        service_invoicing_id = self.get_related_contracts(so)
+        service_invoicing_id = self._get_related_contracts(so)
         # TODO: We must call contract_utils with a better component and workcontext modification approach
         with contract_utils(self.env, service_invoicing_id) as component:
+            component.clean_non_service_lines()
             component.set_start_date(start_date)
         return service_invoicing_id
 
-    def create_service_invoicing_initial(
+    def create_service_invoicing_ready_to_start(
         self,
         company_id,
         community_company_id,
         service_pack_id,
         pricelist_id,
         start_date,
+        executed_action,
+        executed_modification_action="none",
     ):
         service_invoicing_id = self.create_service_invoicing(
             company_id,
@@ -76,14 +79,15 @@ class SaleOrderUtils(Component):
             service_pack_id,
             pricelist_id,
             start_date,
-            "activate",
+            executed_action,
+            executed_modification_action,
         )
         # TODO: We must call contract_utils with a better component and workcontext modification approach
         with contract_utils(self.env, service_invoicing_id) as component:
-            component.set_contract_on_hold()
+            component.set_contract_ready_to_start()
         return service_invoicing_id
 
-    def get_related_contracts(self, sale_order):
+    def _get_related_contracts(self, sale_order):
         return (
             self.env["contract.line"]
             .search([("sale_order_line_id", "in", sale_order.order_line.ids)])
diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index 9dba8f354..a47344dd0 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -1,7 +1,11 @@
+from datetime import datetime
+
 from odoo import api, fields, models
 from odoo.exceptions import AccessError
 from odoo.tools.translate import _
 
+from ..utils import _CONTRACT_STATUS_VALUES
+
 
 class ContractContract(models.Model):
     _inherit = "contract.contract"
@@ -17,6 +21,18 @@ class ContractContract(models.Model):
     successor_contract_id = fields.Many2one(
         "contract.contract", string="Successor contract"
     )
+    status = fields.Selection(
+        selection=_CONTRACT_STATUS_VALUES,
+        required=True,
+        string="Status",
+        default="in_progress",
+    )
+
+    def compute_close_status(self, execution_date):
+        if execution_date.strftime("%Y-%m-%d") == datetime.now().strftime("%Y-%m-%d"):
+            self.write({"status": "closed"})
+        else:
+            self.write({"status": "closed_planned"})
 
     def action_activate_contract(self):
         return self._action_contract("activate")
diff --git a/energy_communities_service_invoicing/utils.py b/energy_communities_service_invoicing/utils.py
index 9c45be14c..2e78e27f7 100644
--- a/energy_communities_service_invoicing/utils.py
+++ b/energy_communities_service_invoicing/utils.py
@@ -3,6 +3,12 @@ from odoo.api import Environment
 
 from odoo.addons.contract.models.contract import ContractContract
 
+_CONTRACT_STATUS_VALUES = [
+    ("ready_to_start", _("Ready to start")),
+    ("in_progress", _("In progress")),
+    ("closed_planned", _("Planned closure")),
+    ("closed", _("Closed")),
+]
 _SERVICE_INVOICING_EXECUTED_ACTION_VALUES = [
     ("activate", _("Activate")),
     ("modification", _("Modification")),
diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index b9dca2273..b562b0ccb 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -19,21 +19,27 @@
     <field name="model">contract.contract</field>
     <field name="inherit_id" ref="product_contract.contract_contract_customer_form_view" />
     <field name="arch" type="xml">
+      <xpath expr="//header" position="inside">
+        <field name="status" widget="statusbar" />
+      </xpath>
       <xpath expr="//button[@name='action_preview']" position="after">
         <button
           name="action_activate_contract"
           type="object"
           string="Activate"
+          attrs="{'invisible':[('status','not in',['ready_to_start'])]}"
         />
         <button
           name="action_modify_contract"
           type="object"
           string="Modify"
+          attrs="{'invisible':[('status','not in',['ready_to_start','in_progress'])]}"
         />
         <button
           name="action_close_contract"
           type="object"
           string="Close"
+          attrs="{'invisible':[('status','not in',['ready_to_start','in_progress'])]}"
         />
       </xpath>
       <xpath expr="//field[@name='partner_id']" position="after">
@@ -43,8 +49,6 @@
       <xpath expr="//field[@name='user_id']" position="after">
         <field name="date_start" />
         <field name="recurring_next_date" />
-        <field name="next_period_date_start" />
-        <field name="next_period_date_end" />
         <field name="date_end" />
         <field name="predecessor_contract_id" />
         <field name="successor_contract_id" />
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
index 8b3cdbda8..03fad5031 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
@@ -1,3 +1,5 @@
+from datetime import datetime
+
 from odoo import api, fields, models
 from odoo.exceptions import ValidationError
 from odoo.tools.translate import _
@@ -18,7 +20,6 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
     community_company_id = fields.Many2one("res.company", string="Community")
     service_pack_id = fields.Many2one("product.product", string="Service pack")
     pricelist_id = fields.Many2one("product.pricelist", string="PriceList")
-    start_date = fields.Date(string="Start date")
     # TODO: We could implement this to apply discount or in contract basis.
     # discount = fields.Float(
     #     string="Discount (%)",
@@ -28,12 +29,13 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
 
     def execute_create(self):
         with sale_order_utils(self.env) as component:
-            service_invoicing_id = component.create_service_invoicing_initial(
+            service_invoicing_id = component.create_service_invoicing_ready_to_start(
                 self.company_id,
                 self.community_company_id,
                 self.service_pack_id,
                 self.pricelist_id,
-                self.start_date,
+                datetime.now(),
+                "activate",
                 # self.discount
             )
         return service_invoicing_view(self.env, service_invoicing_id)
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
index 3ea74a200..e7217982a 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
@@ -11,7 +11,6 @@
           <group>
             <field name="company_id" required="1" domain="[('hierarchy_level','=','coordinator')]"/>
             <field name="community_company_id" required="1" domain="[('hierarchy_level','=','community')]"/>
-            <field name="start_date" required="1"/>
             <field name="service_pack_id" required="1" domain="[('is_contract','=',True)]"/>
             <field name="pricelist_id" required="1" />
             <!--<field name="discount" required="1" />-->
-- 
GitLab


From 1733462ab3feec71517765a50fe95e7ce71d453f Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Thu, 6 Feb 2025 10:31:52 +0100
Subject: [PATCH 25/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Implement=20discount?=
 =?UTF-8?q?=20on=20contract=20creation?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../components/contract_utils.py              | 20 +++++++++------
 .../components/sale_order_utils.py            |  6 ++++-
 .../models/contract.py                        | 25 ++++++++++++++++++-
 .../views/contract_views.xml                  |  2 ++
 .../wizards/service_invoicing_action.py       |  4 +--
 .../service_invoicing_action_create.py        |  9 ++-----
 .../service_invoicing_action_create.xml       |  2 +-
 7 files changed, 48 insertions(+), 20 deletions(-)

diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
index 57ec20d1f..f87d21652 100644
--- a/energy_communities_service_invoicing/components/contract_utils.py
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -6,30 +6,33 @@ from odoo.addons.component.core import Component
 class ContractUtils(Component):
     _inherit = "contract.utils"
 
-    def set_contract_ready_to_start(self):
+    def set_contract_status_ready_to_start(self):
         for line in self.work.record.contract_line_ids:
             line.cancel()
         self.work.record.write({"status": "ready_to_start"})
 
-    def set_contract_active(self, execution_date):
+    def set_contract_status_active(self, execution_date):
         self._uncancel_contract_lines(execution_date)
         self.set_start_date(execution_date)
         self.work.record.write({"status": "in_progress"})
 
-    def set_contract_closed(self, execution_date):
+    def set_contract_status_closed(self, execution_date):
         for line in self.work.record.contract_line_ids:
             if self.work.record.status == "ready_to_start":
                 self._uncancel_contract_lines(execution_date)
             line.write({"date_end": execution_date})
             line._compute_state()
-        self.work.record.compute_close_status(execution_date)
+        self.work.record.set_close_status_type_by_date(execution_date)
 
     def set_start_date(self, date_start):
         self.work.record.write({"date_start": date_start})
         for line in self.work.record.contract_line_ids:
-            if self._is_service_line(line):
-                line.write({"date_start": date_start})
-                line._compute_state()
+            line.write({"date_start": date_start})
+            line._compute_state()
+
+    def set_discount(self, discount):
+        for line in self.work.record.contract_line_ids:
+            line.write({"discount": discount})
 
     def clean_non_service_lines(self):
         for line in self.work.record.contract_line_ids:
@@ -45,7 +48,7 @@ class ContractUtils(Component):
         service_pack_id=None,
     ):
         initial_status = self.work.record.status
-        self.set_contract_closed(execution_date)
+        self.set_contract_status_closed(execution_date)
         sale_order_utils = self.component(
             usage="sale.order.utils", model_name="sale.order"
         )
@@ -61,6 +64,7 @@ class ContractUtils(Component):
             "start_date": execution_date + timedelta(days=1),
             "executed_action": "modification",
             "executed_modification_action": executed_modification_action,
+            "discount": self.work.record.discount,
         }
         if initial_status == "ready_to_start":
             new_service_invoicing_id = (
diff --git a/energy_communities_service_invoicing/components/sale_order_utils.py b/energy_communities_service_invoicing/components/sale_order_utils.py
index 3fadaf2ef..ad8431ed6 100644
--- a/energy_communities_service_invoicing/components/sale_order_utils.py
+++ b/energy_communities_service_invoicing/components/sale_order_utils.py
@@ -43,6 +43,7 @@ class SaleOrderUtils(Component):
         service_pack_id,
         pricelist_id,
         start_date,
+        discount,
         executed_action,
         executed_modification_action="none",
     ):
@@ -61,6 +62,7 @@ class SaleOrderUtils(Component):
         with contract_utils(self.env, service_invoicing_id) as component:
             component.clean_non_service_lines()
             component.set_start_date(start_date)
+            component.set_discount(discount)
         return service_invoicing_id
 
     def create_service_invoicing_ready_to_start(
@@ -70,6 +72,7 @@ class SaleOrderUtils(Component):
         service_pack_id,
         pricelist_id,
         start_date,
+        discount,
         executed_action,
         executed_modification_action="none",
     ):
@@ -79,12 +82,13 @@ class SaleOrderUtils(Component):
             service_pack_id,
             pricelist_id,
             start_date,
+            discount,
             executed_action,
             executed_modification_action,
         )
         # TODO: We must call contract_utils with a better component and workcontext modification approach
         with contract_utils(self.env, service_invoicing_id) as component:
-            component.set_contract_ready_to_start()
+            component.set_contract_status_ready_to_start()
         return service_invoicing_id
 
     def _get_related_contracts(self, sale_order):
diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index a47344dd0..e2aad8454 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -27,8 +27,31 @@ class ContractContract(models.Model):
         string="Status",
         default="in_progress",
     )
+    discount = fields.Float(
+        string="Discount (%)",
+        digits="Discount",
+        compute="_compute_discount",
+        store=False,
+    )
+    last_date_invoiced = fields.Date(
+        string="Last Date Invoiced", compute="_compute_last_date_invoiced", store=False
+    )
+
+    @api.depends("contract_line_ids")
+    def _compute_discount(self):
+        for record in self:
+            if record.contract_line_ids:
+                record.discount = record.contract_line_ids[0].discount
+
+    @api.depends("contract_line_ids")
+    def _compute_last_date_invoiced(self):
+        for record in self:
+            if record.contract_line_ids:
+                record.last_date_invoiced = record.contract_line_ids[
+                    0
+                ].last_date_invoiced
 
-    def compute_close_status(self, execution_date):
+    def set_close_status_type_by_date(self, execution_date):
         if execution_date.strftime("%Y-%m-%d") == datetime.now().strftime("%Y-%m-%d"):
             self.write({"status": "closed"})
         else:
diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index b562b0ccb..42863db7c 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -48,8 +48,10 @@
       <!-- For dev debug purposes -->
       <xpath expr="//field[@name='user_id']" position="after">
         <field name="date_start" />
+        <field name="last_date_invoiced" />
         <field name="recurring_next_date" />
         <field name="date_end" />
+        <field name="discount" />
         <field name="predecessor_contract_id" />
         <field name="successor_contract_id" />
       </xpath>
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action.py b/energy_communities_service_invoicing/wizards/service_invoicing_action.py
index 2f4ee7112..5fe32e7a8 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action.py
@@ -31,11 +31,11 @@ class ServiceInvoicingActionWizard(models.TransientModel):
 
     def execute_activate(self):
         with contract_utils(self.env, self.service_invoicing_id) as component:
-            component.set_contract_active(self.execution_date)
+            component.set_contract_status_active(self.execution_date)
 
     def execute_close(self):
         with contract_utils(self.env, self.service_invoicing_id) as component:
-            component.set_contract_closed(self.execution_date)
+            component.set_contract_status_closed(self.execution_date)
 
     def execute_modify(self):
         with contract_utils(self.env, self.service_invoicing_id) as component:
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
index 03fad5031..739d42c9a 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
@@ -20,12 +20,7 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
     community_company_id = fields.Many2one("res.company", string="Community")
     service_pack_id = fields.Many2one("product.product", string="Service pack")
     pricelist_id = fields.Many2one("product.pricelist", string="PriceList")
-    # TODO: We could implement this to apply discount or in contract basis.
-    # discount = fields.Float(
-    #     string="Discount (%)",
-    #     digits="Discount",
-    #     default=0
-    # )
+    discount = fields.Float(string="Discount (%)", digits="Discount", default=0)
 
     def execute_create(self):
         with sale_order_utils(self.env) as component:
@@ -35,7 +30,7 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
                 self.service_pack_id,
                 self.pricelist_id,
                 datetime.now(),
+                self.discount,
                 "activate",
-                # self.discount
             )
         return service_invoicing_view(self.env, service_invoicing_id)
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
index e7217982a..81aafab85 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
@@ -13,7 +13,7 @@
             <field name="community_company_id" required="1" domain="[('hierarchy_level','=','community')]"/>
             <field name="service_pack_id" required="1" domain="[('is_contract','=',True)]"/>
             <field name="pricelist_id" required="1" />
-            <!--<field name="discount" required="1" />-->
+            <field name="discount" required="1" />
           </group>
         </sheet>
         <footer>
-- 
GitLab


From 528d05c1a5954b89fd250d3536f025fc1acf575a Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Thu, 6 Feb 2025 14:40:24 +0100
Subject: [PATCH 26/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Dynamic=20modificatio?=
 =?UTF-8?q?n=20on=20contract?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../components/contract_utils.py              | 27 +++++--------------
 .../models/contract.py                        | 23 ++++++++++++++++
 .../models/sale_order.py                      |  8 ++----
 energy_communities_service_invoicing/utils.py |  8 ------
 .../views/contract_views.xml                  |  2 +-
 .../wizards/service_invoicing_action.py       | 23 +++++++++++-----
 .../wizards/service_invoicing_action.xml      | 24 ++---------------
 7 files changed, 52 insertions(+), 63 deletions(-)

diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
index f87d21652..9adeb4a05 100644
--- a/energy_communities_service_invoicing/components/contract_utils.py
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -48,6 +48,7 @@ class ContractUtils(Component):
         service_pack_id=None,
     ):
         initial_status = self.work.record.status
+        executed_modification_action_list = executed_modification_action.split(",")
         self.set_contract_status_closed(execution_date)
         sale_order_utils = self.component(
             usage="sale.order.utils", model_name="sale.order"
@@ -55,12 +56,12 @@ class ContractUtils(Component):
         service_invoicing_params = {
             "company_id": self.work.record.partner_id.related_company_id,
             "community_company_id": self.work.record.community_company_id,
-            "service_pack_id": self._get_service_pack_id()
-            if executed_modification_action not in ["modify_all", "modify_service_pack"]
-            else service_pack_id,
-            "pricelist_id": self.work.record.pricelist_id
-            if executed_modification_action not in ["modify_all", "modify_pricelist"]
-            else pricelist_id,
+            "service_pack_id": service_pack_id
+            if "modify_service_pack" in executed_modification_action_list
+            else self.work.record.service_activation_product_id,
+            "pricelist_id": pricelist_id
+            if "modify_pricelist" in executed_modification_action_list
+            else self.work.record.pricelist_id,
             "start_date": execution_date + timedelta(days=1),
             "executed_action": "modification",
             "executed_modification_action": executed_modification_action,
@@ -90,20 +91,6 @@ class ContractUtils(Component):
             return contract_line.product_id in contract_template_services
         return False
 
-    def _get_service_pack_id(self):
-        if self.work.record.contract_template_id:
-            return self.env["product.product"].search(
-                [
-                    (
-                        "property_contract_template_id",
-                        "=",
-                        self.work.record.contract_template_id.id,
-                    )
-                ],
-                limit=1,
-            )
-        return False
-
     def _setup_successors_and_predecessors(self, new_service_invoicing_id):
         self.work.record.write({"successor_contract_id": new_service_invoicing_id.id})
         new_service_invoicing_id.write({"predecessor_contract_id": self.work.record.id})
diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index e2aad8454..75e42cd0b 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -36,6 +36,12 @@ class ContractContract(models.Model):
     last_date_invoiced = fields.Date(
         string="Last Date Invoiced", compute="_compute_last_date_invoiced", store=False
     )
+    service_activation_product_id = fields.Many2one(
+        "product.product",
+        string="Service Activation Product",
+        compute="_compute_service_activation_product_id",
+        store=False,
+    )
 
     @api.depends("contract_line_ids")
     def _compute_discount(self):
@@ -51,6 +57,23 @@ class ContractContract(models.Model):
                     0
                 ].last_date_invoiced
 
+    @api.depends("contract_template_id")
+    def _compute_service_activation_product_id(self):
+        for record in self:
+            if record.contract_template_id:
+                record.service_activation_product_id = self.env[
+                    "product.product"
+                ].search(
+                    [
+                        (
+                            "property_contract_template_id",
+                            "=",
+                            record.contract_template_id.id,
+                        )
+                    ],
+                    limit=1,
+                )
+
     def set_close_status_type_by_date(self, execution_date):
         if execution_date.strftime("%Y-%m-%d") == datetime.now().strftime("%Y-%m-%d"):
             self.write({"status": "closed"})
diff --git a/energy_communities_service_invoicing/models/sale_order.py b/energy_communities_service_invoicing/models/sale_order.py
index 9a9f4014e..7a429af6c 100644
--- a/energy_communities_service_invoicing/models/sale_order.py
+++ b/energy_communities_service_invoicing/models/sale_order.py
@@ -1,9 +1,6 @@
 from odoo import _, api, fields, models
 
-from ..utils import (
-    _SALE_ORDER_SERVICE_INVOICING_ACTION_VALUES,
-    _SALE_ORDER_SERVICE_INVOICING_MODIFICATION_ACTION_VALUES,
-)
+from ..utils import _SALE_ORDER_SERVICE_INVOICING_ACTION_VALUES
 
 
 class SaleOrder(models.Model):
@@ -22,8 +19,7 @@ class SaleOrder(models.Model):
         string="Service invoicing action",
         default="none",
     )
-    service_invoicing_modification_action = fields.Selection(
-        selection=_SALE_ORDER_SERVICE_INVOICING_MODIFICATION_ACTION_VALUES,
+    service_invoicing_modification_action = fields.Char(
         string="Modification action",
         default="none",
     )
diff --git a/energy_communities_service_invoicing/utils.py b/energy_communities_service_invoicing/utils.py
index 2e78e27f7..dd363efeb 100644
--- a/energy_communities_service_invoicing/utils.py
+++ b/energy_communities_service_invoicing/utils.py
@@ -14,17 +14,9 @@ _SERVICE_INVOICING_EXECUTED_ACTION_VALUES = [
     ("modification", _("Modification")),
     ("close", _("Close")),
 ]
-_SERVICE_INVOICING_EXECUTED_MODIFICATION_ACTION_VALUES = [
-    ("modify_all", _("Modify prices and service pack")),
-    ("modify_pricelist", _("Modify prices")),
-    ("modify_service_pack", _("Modify service pack")),
-]
 _SALE_ORDER_SERVICE_INVOICING_ACTION_VALUES = [
     ("none", _("None"))
 ] + _SERVICE_INVOICING_EXECUTED_ACTION_VALUES[:-1]
-_SALE_ORDER_SERVICE_INVOICING_MODIFICATION_ACTION_VALUES = [
-    ("none", _("None"))
-] + _SERVICE_INVOICING_EXECUTED_MODIFICATION_ACTION_VALUES
 
 
 def service_invoicing_view(env: Environment, service_invoicing_id: ContractContract):
diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index 42863db7c..d2d5b3573 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -82,7 +82,7 @@
       id="view_service_contract_templates_window"
       model="ir.actions.act_window"
   >
-    <field name="name">Service Contract Types</field>
+    <field name="name">Service Packs</field>
     <field name="res_model">contract.template</field>
     <field name="view_mode">tree,form</field>
   </record>
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action.py b/energy_communities_service_invoicing/wizards/service_invoicing_action.py
index 5fe32e7a8..48ecdc641 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action.py
@@ -6,7 +6,6 @@ from odoo.addons.energy_communities.utils import contract_utils
 
 from ..utils import (
     _SERVICE_INVOICING_EXECUTED_ACTION_VALUES,
-    _SERVICE_INVOICING_EXECUTED_MODIFICATION_ACTION_VALUES,
     service_invoicing_view,
 )
 
@@ -22,10 +21,6 @@ class ServiceInvoicingActionWizard(models.TransientModel):
     executed_action = fields.Selection(
         selection=_SERVICE_INVOICING_EXECUTED_ACTION_VALUES
     )
-    executed_modification_action = fields.Selection(
-        selection=_SERVICE_INVOICING_EXECUTED_MODIFICATION_ACTION_VALUES,
-        string="Modification action",
-    )
     pricelist_id = fields.Many2one("product.pricelist", string="Select pricelist")
     service_pack_id = fields.Many2one("product.product", string="Service pack")
 
@@ -38,11 +33,27 @@ class ServiceInvoicingActionWizard(models.TransientModel):
             component.set_contract_status_closed(self.execution_date)
 
     def execute_modify(self):
+        self._validate_execute_modify()
+        executed_modification_action = self._build_executed_modification_action()
         with contract_utils(self.env, self.service_invoicing_id) as component:
             service_invoicing_id = component.modify(
                 self.execution_date,
-                self.executed_modification_action,
+                executed_modification_action,
                 self.pricelist_id,
                 self.service_pack_id,
             )
         return service_invoicing_view(self.env, service_invoicing_id)
+
+    def _validate_execute_modify(self):
+        if not self.pricelist_id and not self.service_pack_id:
+            raise ValidationError(_("Select at least one value to modify"))
+
+    def _build_executed_modification_action(self):
+        executed_modification_action = ""
+        if self.pricelist_id:
+            executed_modification_action += "modify_pricelist"
+        if self.service_pack_id:
+            if bool(executed_modification_action):
+                executed_modification_action += ","
+            executed_modification_action += "modify_service_pack"
+        return executed_modification_action
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action.xml b/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
index 3cfe36339..631bee84a 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
@@ -12,28 +12,8 @@
             <field name="executed_action" invisible="1" />
             <field name="service_invoicing_id" required="1" domain="[('community_company_id','!=',False)]"/>
             <field name="execution_date" required="1"/>
-            <field
-              name="executed_modification_action"
-              attrs="{
-               'invisible': [('executed_action','!=','modification')],
-               'required': [('executed_action','==','modification')]
-              }"
-            />
-            <field
-              name="pricelist_id"
-              attrs="{
-               'invisible': [('executed_modification_action','not in',['modify_all','modify_pricelist'])],
-               'required': [('executed_modification_action','in',['modify_all','modify_pricelist'])]
-              }"
-            />
-            <field
-              name="service_pack_id"
-              domain="[('is_contract','=',True)]"
-              attrs="{
-               'invisible': [('executed_modification_action','not in',['modify_all','modify_service_pack'])],
-               'required': [('executed_modification_action','in',['modify_all','modify_service_pack'])]
-              }"
-            />
+            <field name="pricelist_id" />
+            <field name="service_pack_id" domain="[('is_contract','=',True)]"/>
           </group>
         </sheet>
         <footer>
-- 
GitLab


From de22ad8a47a878feebe546d529b6679f6f56905c Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Thu, 6 Feb 2025 17:30:19 +0100
Subject: [PATCH 27/85] =?UTF-8?q?[FIX]=20=F0=9F=90=9B=20On=20action=20wiza?=
 =?UTF-8?q?rd=20show=20modification=20fields=20only=20if=20action=20is=20m?=
 =?UTF-8?q?odification?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../wizards/service_invoicing_action.xml          | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action.xml b/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
index 631bee84a..f491b9829 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
@@ -12,8 +12,19 @@
             <field name="executed_action" invisible="1" />
             <field name="service_invoicing_id" required="1" domain="[('community_company_id','!=',False)]"/>
             <field name="execution_date" required="1"/>
-            <field name="pricelist_id" />
-            <field name="service_pack_id" domain="[('is_contract','=',True)]"/>
+            <field
+              name="pricelist_id"
+              attrs="{
+               'invisible': [('executed_action','!=','modification')],
+              }"
+            />
+            <field
+              name="service_pack_id"
+              domain="[('is_contract','=',True)]"
+              attrs="{
+               'invisible': [('executed_action','!=','modification')],
+              }"
+            />
           </group>
         </sheet>
         <footer>
-- 
GitLab


From dcff378d76ba44d5dcc64eb05b464df1c76e464c Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Fri, 7 Feb 2025 10:00:00 +0100
Subject: [PATCH 28/85] =?UTF-8?q?[REF]=20=E2=99=BB=EF=B8=8F=20is=5Fcontrac?=
 =?UTF-8?q?t=20product=20finally=20named=20pack?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../components/contract_utils.py                     |  2 +-
 .../models/contract.py                               | 12 +++++-------
 .../views/contract_views.xml                         |  9 ++++++---
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
index 9adeb4a05..1f980df47 100644
--- a/energy_communities_service_invoicing/components/contract_utils.py
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -58,7 +58,7 @@ class ContractUtils(Component):
             "community_company_id": self.work.record.community_company_id,
             "service_pack_id": service_pack_id
             if "modify_service_pack" in executed_modification_action_list
-            else self.work.record.service_activation_product_id,
+            else self.work.record.service_pack_id,
             "pricelist_id": pricelist_id
             if "modify_pricelist" in executed_modification_action_list
             else self.work.record.pricelist_id,
diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index 75e42cd0b..450e8e03e 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -36,10 +36,10 @@ class ContractContract(models.Model):
     last_date_invoiced = fields.Date(
         string="Last Date Invoiced", compute="_compute_last_date_invoiced", store=False
     )
-    service_activation_product_id = fields.Many2one(
+    service_pack_id = fields.Many2one(
         "product.product",
-        string="Service Activation Product",
-        compute="_compute_service_activation_product_id",
+        string="Service Pack",
+        compute="_compute_service_pack_id",
         store=False,
     )
 
@@ -58,12 +58,10 @@ class ContractContract(models.Model):
                 ].last_date_invoiced
 
     @api.depends("contract_template_id")
-    def _compute_service_activation_product_id(self):
+    def _compute_service_pack_id(self):
         for record in self:
             if record.contract_template_id:
-                record.service_activation_product_id = self.env[
-                    "product.product"
-                ].search(
+                record.service_pack_id = self.env["product.product"].search(
                     [
                         (
                             "property_contract_template_id",
diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index d2d5b3573..89dd3d1d8 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -45,7 +45,9 @@
       <xpath expr="//field[@name='partner_id']" position="after">
         <field name="community_company_id" />
       </xpath>
-      <!-- For dev debug purposes -->
+      <xpath expr="//field[@name='pricelist_id']" position="after">
+        <field name="service_pack_id" />
+      </xpath>
       <xpath expr="//field[@name='user_id']" position="after">
         <field name="date_start" />
         <field name="last_date_invoiced" />
@@ -127,14 +129,15 @@
     sequence="100"
   />
   <menuitem
-    name="Service Products"
+    name="Service Packs"
     id="view_service_products_menu"
     parent="ce_service_invoicing_menu"
     action="view_service_products_window"
     sequence="200"
   />
+  <!-- TODO: Create Services entry point -->
   <menuitem
-    name="Service Contract Types"
+    name="Service Packs Services"
     id="view_service_contract_templates_menu"
     parent="ce_service_invoicing_menu"
     action="view_service_contract_templates_window"
-- 
GitLab


From 1805e6328cc610b454b87d855ca86799050002e9 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Fri, 7 Feb 2025 10:16:56 +0100
Subject: [PATCH 29/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Introducing=20payment?=
 =?UTF-8?q?=5Fmode=20in=20workflow?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../components/contract_utils.py                            | 1 +
 .../components/sale_order_utils.py                          | 6 ++++++
 energy_communities_service_invoicing/models/sale_order.py   | 1 +
 .../wizards/service_invoicing_action_create.py              | 2 ++
 .../wizards/service_invoicing_action_create.xml             | 1 +
 5 files changed, 11 insertions(+)

diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
index 1f980df47..ce69d516b 100644
--- a/energy_communities_service_invoicing/components/contract_utils.py
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -62,6 +62,7 @@ class ContractUtils(Component):
             "pricelist_id": pricelist_id
             if "modify_pricelist" in executed_modification_action_list
             else self.work.record.pricelist_id,
+            "payment_mode_id": self.work.record.payment_mode_id,
             "start_date": execution_date + timedelta(days=1),
             "executed_action": "modification",
             "executed_modification_action": executed_modification_action,
diff --git a/energy_communities_service_invoicing/components/sale_order_utils.py b/energy_communities_service_invoicing/components/sale_order_utils.py
index ad8431ed6..3ced8f48d 100644
--- a/energy_communities_service_invoicing/components/sale_order_utils.py
+++ b/energy_communities_service_invoicing/components/sale_order_utils.py
@@ -11,6 +11,7 @@ class SaleOrderUtils(Component):
         community_company_id,
         service_pack_id,
         pricelist_id,
+        payment_mode_id,
         start_date,
         executed_action,
         executed_modification_action,
@@ -22,6 +23,7 @@ class SaleOrderUtils(Component):
             "pricelist_id": pricelist_id.id,
             "service_invoicing_action": executed_action,
             "service_invoicing_modification_action": executed_modification_action,
+            "payment_mode_id": payment_mode_id.id,
             "order_line": [
                 (
                     0,
@@ -42,6 +44,7 @@ class SaleOrderUtils(Component):
         community_company_id,
         service_pack_id,
         pricelist_id,
+        payment_mode_id,
         start_date,
         discount,
         executed_action,
@@ -52,6 +55,7 @@ class SaleOrderUtils(Component):
             community_company_id,
             service_pack_id,
             pricelist_id,
+            payment_mode_id,
             start_date,
             executed_action,
             executed_modification_action,
@@ -71,6 +75,7 @@ class SaleOrderUtils(Component):
         community_company_id,
         service_pack_id,
         pricelist_id,
+        payment_mode_id,
         start_date,
         discount,
         executed_action,
@@ -81,6 +86,7 @@ class SaleOrderUtils(Component):
             community_company_id,
             service_pack_id,
             pricelist_id,
+            payment_mode_id,
             start_date,
             discount,
             executed_action,
diff --git a/energy_communities_service_invoicing/models/sale_order.py b/energy_communities_service_invoicing/models/sale_order.py
index 7a429af6c..380d77e9c 100644
--- a/energy_communities_service_invoicing/models/sale_order.py
+++ b/energy_communities_service_invoicing/models/sale_order.py
@@ -32,6 +32,7 @@ class SaleOrder(models.Model):
                     {
                         "community_company_id": self.community_company_id.id,
                         "pricelist_id": self.pricelist_id.id,
+                        "payment_mode_id": self.payment_mode_id.id,
                     }
                 )
         return contracts
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
index 739d42c9a..bec1db94a 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
@@ -20,6 +20,7 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
     community_company_id = fields.Many2one("res.company", string="Community")
     service_pack_id = fields.Many2one("product.product", string="Service pack")
     pricelist_id = fields.Many2one("product.pricelist", string="PriceList")
+    payment_mode_id = fields.Many2one("account.payment.mode", string="Payment mode")
     discount = fields.Float(string="Discount (%)", digits="Discount", default=0)
 
     def execute_create(self):
@@ -29,6 +30,7 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
                 self.community_company_id,
                 self.service_pack_id,
                 self.pricelist_id,
+                self.payment_mode_id,
                 datetime.now(),
                 self.discount,
                 "activate",
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
index 81aafab85..1901a0f98 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
@@ -13,6 +13,7 @@
             <field name="community_company_id" required="1" domain="[('hierarchy_level','=','community')]"/>
             <field name="service_pack_id" required="1" domain="[('is_contract','=',True)]"/>
             <field name="pricelist_id" required="1" />
+            <field name="payment_mode_id" required="1" />
             <field name="discount" required="1" />
           </group>
         </sheet>
-- 
GitLab


From c65bf4b33d9b25742c0b8217e06202418a442d5c Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Fri, 7 Feb 2025 10:31:21 +0100
Subject: [PATCH 30/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20On=20energy=5Fcommuni?=
 =?UTF-8?q?ties=20all=20contracts=20have=20skip=5Fzero=5Fqty=20marked=20by?=
 =?UTF-8?q?=20default?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 energy_communities_service_invoicing/__manifest__.py    | 9 ++++++++-
 energy_communities_service_invoicing/models/contract.py | 2 ++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/energy_communities_service_invoicing/__manifest__.py b/energy_communities_service_invoicing/__manifest__.py
index 469e40dcf..82a7f7aa3 100644
--- a/energy_communities_service_invoicing/__manifest__.py
+++ b/energy_communities_service_invoicing/__manifest__.py
@@ -11,7 +11,14 @@
     "category": "Contract Management",
     "version": "16.0.0.1.1",
     # any module necessary for this one to work correctly
-    "depends": ["base", "contract", "sale", "product_contract", "energy_communities"],
+    "depends": [
+        "base",
+        "contract",
+        "sale",
+        "product_contract",
+        "contract_variable_quantity",
+        "energy_communities",
+    ],
     # always loaded
     "data": [
         "security/ir.model.access.csv",
diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index 450e8e03e..b54916b83 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -42,6 +42,8 @@ class ContractContract(models.Model):
         compute="_compute_service_pack_id",
         store=False,
     )
+    # On energy_communities all contracts have skip_zero_qty marked by default
+    skip_zero_qty = fields.Boolean(default=True)
 
     @api.depends("contract_line_ids")
     def _compute_discount(self):
-- 
GitLab


From 5d134d0661885ef9edfe07c0df54e1c64a022c97 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Fri, 7 Feb 2025 10:44:16 +0100
Subject: [PATCH 31/85] =?UTF-8?q?[FIX]=20=F0=9F=90=9B=20Community=20member?=
 =?UTF-8?q?s=20formula=20looks=20for=20members=20not=20for=20active=20plat?=
 =?UTF-8?q?form=20users?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../data/contract_line_qty_formula_data.xml                 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/energy_communities_service_invoicing/data/contract_line_qty_formula_data.xml b/energy_communities_service_invoicing/data/contract_line_qty_formula_data.xml
index 85565bddd..d4988f8b8 100644
--- a/energy_communities_service_invoicing/data/contract_line_qty_formula_data.xml
+++ b/energy_communities_service_invoicing/data/contract_line_qty_formula_data.xml
@@ -6,9 +6,9 @@
     >
       <field name="name">Community members</field>
       <field name="code">
-result = env['res.users.role.line'].search_count([
-('role_id','in',[env.ref("energy_communities.role_ce_admin").id,env.ref("energy_communities.role_ce_member").id]),
-('company_id','=',contract.community_company_id.id)
+result = env['cooperative.membership'].search_count([
+('company_id','=',contract.community_company_id.id),
+('member','=',True)
 ])
       </field>
     </record>
-- 
GitLab


From dbda787a4d0bfd672fe34e88fede8589fe1786e3 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Fri, 7 Feb 2025 11:12:01 +0100
Subject: [PATCH 32/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Cron=20to=20close=20c?=
 =?UTF-8?q?losed=5Fplanned=20contracts?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../__manifest__.py                                 |  1 +
 .../components/contract_utils.py                    |  2 +-
 .../data/contract_cron.xml                          | 13 +++++++++++++
 .../models/contract.py                              | 13 +++++++++++--
 4 files changed, 26 insertions(+), 3 deletions(-)
 create mode 100644 energy_communities_service_invoicing/data/contract_cron.xml

diff --git a/energy_communities_service_invoicing/__manifest__.py b/energy_communities_service_invoicing/__manifest__.py
index 82a7f7aa3..8585cd9c8 100644
--- a/energy_communities_service_invoicing/__manifest__.py
+++ b/energy_communities_service_invoicing/__manifest__.py
@@ -22,6 +22,7 @@
     # always loaded
     "data": [
         "security/ir.model.access.csv",
+        "data/contract_cron.xml",
         "data/contract_line_qty_formula_data.xml",
         "views/menus.xml",
         "views/contract_views.xml",
diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
index ce69d516b..3acd60084 100644
--- a/energy_communities_service_invoicing/components/contract_utils.py
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -22,7 +22,7 @@ class ContractUtils(Component):
                 self._uncancel_contract_lines(execution_date)
             line.write({"date_end": execution_date})
             line._compute_state()
-        self.work.record.set_close_status_type_by_date(execution_date)
+        self.work.record.set_close_status_type_by_date()
 
     def set_start_date(self, date_start):
         self.work.record.write({"date_start": date_start})
diff --git a/energy_communities_service_invoicing/data/contract_cron.xml b/energy_communities_service_invoicing/data/contract_cron.xml
new file mode 100644
index 000000000..876cfdfc3
--- /dev/null
+++ b/energy_communities_service_invoicing/data/contract_cron.xml
@@ -0,0 +1,13 @@
+<odoo noupdate="1">
+    <record model="ir.cron" id="contract_cron_for_invoice_closure">
+        <field name="name">Close today's (closed planned) Contracts </field>
+        <field name="model_id" ref="model_contract_contract" />
+        <field name="state">code</field>
+        <field name="code">model.cron_close_todays_closed_planned_contacts()</field>
+        <field name="user_id" ref="base.user_root" />
+        <field name="interval_number">1</field>
+        <field name="interval_type">days</field>
+        <field name="numbercall">-1</field>
+        <field eval="False" name="doall" />
+    </record>
+</odoo>
diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index b54916b83..68a5d0b35 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -74,8 +74,8 @@ class ContractContract(models.Model):
                     limit=1,
                 )
 
-    def set_close_status_type_by_date(self, execution_date):
-        if execution_date.strftime("%Y-%m-%d") == datetime.now().strftime("%Y-%m-%d"):
+    def set_close_status_type_by_date(self):
+        if self.date_end.strftime("%Y-%m-%d") == datetime.now().strftime("%Y-%m-%d"):
             self.write({"status": "closed"})
         else:
             self.write({"status": "closed_planned"})
@@ -103,3 +103,12 @@ class ContractContract(models.Model):
             "target": "new",
             "res_id": wizard.id,
         }
+
+    @api.model
+    def cron_close_todays_closed_planned_contacts(self):
+        impacted_contracts = self.env["contract.contract"].search(
+            [("status", "closed_planned")]
+        )
+        for contract in impacted_contracts:
+            contract.set_close_status_type_by_date()
+        return True
-- 
GitLab


From 36e2ec7c1e386dcdaf218742ce66e6c8e777b2c6 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Fri, 7 Feb 2025 15:36:13 +0100
Subject: [PATCH 33/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Better=20UI=20UX?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../__manifest__.py                           |   4 +-
 .../data/product_data.xml                     |   8 +
 .../models/__init__.py                        |   1 +
 .../models/contract_template.py               |  25 ++++
 .../models/product_template.py                |   9 +-
 .../views/contract_views.xml                  | 140 +++++-------------
 .../views/menus.xml                           |  43 ++++++
 .../views/service_invoicing_views.xml         |  83 +++++++++++
 8 files changed, 211 insertions(+), 102 deletions(-)
 create mode 100644 energy_communities_service_invoicing/data/product_data.xml
 create mode 100644 energy_communities_service_invoicing/models/contract_template.py
 create mode 100644 energy_communities_service_invoicing/views/service_invoicing_views.xml

diff --git a/energy_communities_service_invoicing/__manifest__.py b/energy_communities_service_invoicing/__manifest__.py
index 8585cd9c8..bdf18da58 100644
--- a/energy_communities_service_invoicing/__manifest__.py
+++ b/energy_communities_service_invoicing/__manifest__.py
@@ -24,9 +24,11 @@
         "security/ir.model.access.csv",
         "data/contract_cron.xml",
         "data/contract_line_qty_formula_data.xml",
-        "views/menus.xml",
+        "data/product_data.xml",
         "views/contract_views.xml",
         "views/sale_order_views.xml",
+        "views/service_invoicing_views.xml",
+        "views/menus.xml",
         "wizards/service_invoicing_action.xml",
         "wizards/service_invoicing_action_create.xml",
     ],
diff --git a/energy_communities_service_invoicing/data/product_data.xml b/energy_communities_service_invoicing/data/product_data.xml
new file mode 100644
index 000000000..b3248d09a
--- /dev/null
+++ b/energy_communities_service_invoicing/data/product_data.xml
@@ -0,0 +1,8 @@
+<odoo>
+  <record id="product_category_pack" model="product.category">
+    <field name="name">Service Pack</field>
+  </record>
+  <record id="product_category_service" model="product.category">
+    <field name="name">Service</field>
+  </record>
+</odoo>
diff --git a/energy_communities_service_invoicing/models/__init__.py b/energy_communities_service_invoicing/models/__init__.py
index 1877c8565..0ecf355b2 100644
--- a/energy_communities_service_invoicing/models/__init__.py
+++ b/energy_communities_service_invoicing/models/__init__.py
@@ -1,4 +1,5 @@
 from . import abstract_contract
 from . import contract
+from . import contract_template
 from . import product_template
 from . import sale_order
diff --git a/energy_communities_service_invoicing/models/contract_template.py b/energy_communities_service_invoicing/models/contract_template.py
new file mode 100644
index 000000000..c27d13e3f
--- /dev/null
+++ b/energy_communities_service_invoicing/models/contract_template.py
@@ -0,0 +1,25 @@
+from odoo import api, fields, models
+
+
+class ContractTemplate(models.Model):
+    _name = "contract.template"
+    _inherit = "contract.template"
+
+    is_pack = fields.Boolean(compute="_compute_is_pack", store=True)
+
+    def compute_is_pack(self):
+        for record in self:
+            record.is_pack = bool(
+                self.env["product.template"].search(
+                    [
+                        ("property_contract_template_id", "=", record.id),
+                        (
+                            "categ_id",
+                            "=",
+                            self.env.ref(
+                                "energy_communities_service_invoicing.product_category_pack"
+                            ).id,
+                        ),
+                    ]
+                )
+            )
diff --git a/energy_communities_service_invoicing/models/product_template.py b/energy_communities_service_invoicing/models/product_template.py
index 71dc1cc50..d6ee536cc 100644
--- a/energy_communities_service_invoicing/models/product_template.py
+++ b/energy_communities_service_invoicing/models/product_template.py
@@ -1,4 +1,4 @@
-from odoo import fields, models
+from odoo import api, fields, models
 
 
 class ProductTemplate(models.Model):
@@ -7,3 +7,10 @@ class ProductTemplate(models.Model):
     property_contract_template_id = fields.Many2one(
         company_dependent=False,
     )
+
+    @api.constrains("property_contract_template_id")
+    def compute_contract_template_is_pack(self):
+        for record in self:
+            ctemplates = self.env["contract.template"].search([])
+            for ctemplate in ctemplates:
+                ctemplate.compute_is_pack()
diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index 89dd3d1d8..21f434de4 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -1,5 +1,36 @@
 <odoo>
 
+  <record id="contract_contract_search_view" model="ir.ui.view">
+    <field name="name">contract.contract search view (in service invoicing)</field>
+    <field name="model">contract.contract</field>
+    <field name="inherit_id" ref="contract.contract_contract_search_view" />
+    <field name="arch" type="xml">
+      <filter name="not_finished" position="before">
+        <filter
+          name="ready_to_start"
+          string="Ready to start"
+          domain="[('status','=','ready_to_start')]"
+        />
+        <!--<separator />-->
+      </filter>
+      <filter name="not_finished" position="attributes">
+        <attribute name="domain">[('status','=','in_progress')]</attribute>
+      </filter>
+      <filter name="finished" position="before">
+        <filter
+          name="closed_planned"
+          string="Planned closure"
+          domain="[('status','=','closed_planned')]"
+        />
+        <!--<separator />-->
+      </filter>
+      <filter name="finished" position="attributes">
+        <attribute name="string">Closed</attribute>
+        <attribute name="domain">[('status','=','closed')]</attribute>
+      </filter>
+    </field>
+  </record>
+
   <record id="view_service_invoicing_tree" model="ir.ui.view">
     <field name="name">service.invoicing.tree</field>
     <field name="model">contract.contract</field>
@@ -7,9 +38,17 @@
     <field name="arch" type="xml">
       <tree>
         <field name="name" />
+        <field 
+          name="status"
+          widget="badge"
+          decoration-info="status == 'ready_to_start'"
+          decoration-danger="status == 'closed'"
+          decoration-warning="status == 'closed_planned'"
+          decoration-success="status == 'in_progress'"
+        />
         <field name="partner_id" />
         <field name="community_company_id" />
-        <field name="contract_template_id" />
+        <field name="service_pack_id" />
       </tree>
     </field>
   </record>
@@ -59,103 +98,4 @@
       </xpath>
     </field>
   </record>
-
-  <record
-      id="view_service_invoicing_window"
-      model="ir.actions.act_window"
-  >
-    <field name="name">Service Invoicing</field>
-    <field name="res_model">contract.contract</field>
-    <field name="view_mode">tree,form</field>
-    <field name="domain">[('community_company_id','!=',False)]</field>
-  </record>
-
-  <record
-      id="view_service_products_window"
-      model="ir.actions.act_window"
-  >
-    <field name="name">Service Products</field>
-    <field name="res_model">product.template</field>
-    <field name="view_mode">tree,form</field>
-    <!--<field name="domain">[('is_contract','=',True)]</field>-->
-  </record>
-
-  <record
-      id="view_service_contract_templates_window"
-      model="ir.actions.act_window"
-  >
-    <field name="name">Service Packs</field>
-    <field name="res_model">contract.template</field>
-    <field name="view_mode">tree,form</field>
-  </record>
-
-  <record
-      id="view_service_sale_orders_window"
-      model="ir.actions.act_window"
-  >
-    <field name="name">Service Sale Orders</field>
-    <field name="res_model">sale.order</field>
-    <field name="view_mode">tree,form</field>
-  </record>
-
-  <record
-      id="view_service_tariffs_window"
-      model="ir.actions.act_window"
-  >
-    <field name="name">Service Tariffs</field>
-    <field name="res_model">product.pricelist</field>
-    <field name="view_mode">tree,form</field>
-  </record>
-
-  <record model="ir.actions.act_window.view" id="action_view_service_invoicing_tree">
-    <field name="sequence" eval="1"/>
-    <field name="view_mode">tree</field>
-    <field name="view_id" ref="view_service_invoicing_tree"/>
-    <field name="act_window_id" ref="view_service_invoicing_window"/>
-  </record>
-
-  <record model="ir.actions.act_window.view" id="action_view_contract_contract_customer_form">
-    <field name="sequence" eval="2"/>
-    <field name="view_mode">form</field>
-    <field name="view_id" ref="contract.contract_contract_customer_form_view"/>
-    <field name="act_window_id" ref="view_service_invoicing_window"/>
-  </record>
-
-  <menuitem
-    name="Service invoicing"
-    id="view_service_invoicing_menu"
-    parent="ce_service_invoicing_menu"
-    action="view_service_invoicing_window"
-    sequence="100"
-  />
-  <menuitem
-    name="Service Packs"
-    id="view_service_products_menu"
-    parent="ce_service_invoicing_menu"
-    action="view_service_products_window"
-    sequence="200"
-  />
-  <!-- TODO: Create Services entry point -->
-  <menuitem
-    name="Service Packs Services"
-    id="view_service_contract_templates_menu"
-    parent="ce_service_invoicing_menu"
-    action="view_service_contract_templates_window"
-    sequence="300"
-  />
-  <menuitem
-    name="Service Sale Orders"
-    id="view_service_sale_orders_menu"
-    parent="ce_service_invoicing_menu"
-    action="view_service_sale_orders_window"
-    sequence="400"
-  />
-  <menuitem
-    name="Service Tariffs"
-    id="view_service_tariffs_menu"
-    parent="ce_service_invoicing_menu"
-    action="view_service_tariffs_window"
-    sequence="500"
-  />
-
 </odoo>
diff --git a/energy_communities_service_invoicing/views/menus.xml b/energy_communities_service_invoicing/views/menus.xml
index ae9428640..8ab3410f9 100644
--- a/energy_communities_service_invoicing/views/menus.xml
+++ b/energy_communities_service_invoicing/views/menus.xml
@@ -1,3 +1,46 @@
 <odoo>
   <menuitem id="ce_service_invoicing_menu" name="Services" parent="energy_communities.ce_root_menu" sequence="1" />
+  <menuitem
+    name="Service invoicing"
+    id="view_service_invoicing_menu"
+    parent="ce_service_invoicing_menu"
+    action="view_service_invoicing_window"
+    sequence="100"
+  />
+  <menuitem
+    name="Packs"
+    id="view_service_packs_menu"
+    parent="ce_service_invoicing_menu"
+    action="view_service_packs_window"
+    sequence="200"
+  />
+  <menuitem
+    name="Services"
+    id="view_services_menu"
+    parent="ce_service_invoicing_menu"
+    action="view_services_window"
+    sequence="300"
+  />
+  <!-- TODO: Create Services entry point -->
+  <menuitem
+    name="Packs contract templates"
+    id="view_service_contract_templates_menu"
+    parent="ce_service_invoicing_menu"
+    action="view_service_contract_templates_window"
+    sequence="400"
+  />
+  <menuitem
+    name="Service actions (sale orders)"
+    id="view_service_sale_orders_menu"
+    parent="ce_service_invoicing_menu"
+    action="view_service_sale_orders_window"
+    sequence="500"
+  />
+  <menuitem
+    name="Tariffs"
+    id="view_service_tariffs_menu"
+    parent="ce_service_invoicing_menu"
+    action="view_service_tariffs_window"
+    sequence="600"
+  />
 </odoo>
diff --git a/energy_communities_service_invoicing/views/service_invoicing_views.xml b/energy_communities_service_invoicing/views/service_invoicing_views.xml
new file mode 100644
index 000000000..8068f83f2
--- /dev/null
+++ b/energy_communities_service_invoicing/views/service_invoicing_views.xml
@@ -0,0 +1,83 @@
+<odoo>
+  <record
+      id="view_service_invoicing_window"
+      model="ir.actions.act_window"
+  >
+    <field name="name">Service Invoicing</field>
+    <field name="res_model">contract.contract</field>
+    <field name="view_mode">tree,form</field>
+    <field name="domain">
+[('community_company_id','!=',False)]
+    </field>
+  </record>
+
+  <record
+      id="view_service_packs_window"
+      model="ir.actions.act_window"
+  >
+    <field name="name">Packs</field>
+    <field name="res_model">product.template</field>
+    <field name="view_mode">tree,form</field>
+    <field name="domain" eval="[('categ_id','=',ref('product_category_pack'))]" />
+  </record>
+
+  <record
+      id="view_services_window"
+      model="ir.actions.act_window"
+  >
+    <field name="name">Services</field>
+    <field name="res_model">product.template</field>
+    <field name="view_mode">tree,form</field>
+    <field name="domain" eval="[('categ_id','=',ref('product_category_service'))]" />
+  </record>
+
+  <record
+      id="view_service_contract_templates_window"
+      model="ir.actions.act_window"
+  >
+    <field name="name">Packs contract templates</field>
+    <field name="res_model">contract.template</field>
+    <field name="view_mode">tree,form</field>
+    <field name="domain">[('is_pack','=',True)]</field>
+  </record>
+
+  <record
+      id="view_service_sale_orders_window"
+      model="ir.actions.act_window"
+  >
+    <field name="name">Service actions (sale orders)</field>
+    <field name="res_model">sale.order</field>
+    <field name="view_mode">tree,form</field>
+    <field name="domain">[('service_invoicing_action','!=','none')]</field>
+  </record>
+
+  <record
+      id="view_service_tariffs_window"
+      model="ir.actions.act_window"
+  >
+    <field name="name">Tariffs</field>
+    <field name="res_model">product.pricelist</field>
+    <field name="view_mode">tree,form</field>
+  </record>
+
+  <record
+    id="action_view_service_invoicing_tree"
+    model="ir.actions.act_window.view"
+  >
+    <field name="sequence" eval="1"/>
+    <field name="view_mode">tree</field>
+    <field name="view_id" ref="view_service_invoicing_tree"/>
+    <field name="act_window_id" ref="view_service_invoicing_window"/>
+  </record>
+
+  <record
+    id="action_view_contract_contract_customer_form"
+    model="ir.actions.act_window.view"
+  >
+    <field name="sequence" eval="2"/>
+    <field name="view_mode">form</field>
+    <field name="view_id" ref="contract.contract_contract_customer_form_view"/>
+    <field name="act_window_id" ref="view_service_invoicing_window"/>
+    </record>
+  
+</odoo>
-- 
GitLab


From 22290dfa105d2d5dcfeaf2eb3d81b0fccb29fc40 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Fri, 7 Feb 2025 15:53:28 +0100
Subject: [PATCH 34/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Relationship=20betwee?=
 =?UTF-8?q?n=20contract=20and=20it's=20activation=20sale=20order?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 energy_communities_service_invoicing/models/contract.py       | 4 ++++
 energy_communities_service_invoicing/models/sale_order.py     | 1 +
 energy_communities_service_invoicing/views/contract_views.xml | 1 +
 3 files changed, 6 insertions(+)

diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index 68a5d0b35..38cf73fc1 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -42,6 +42,10 @@ class ContractContract(models.Model):
         compute="_compute_service_pack_id",
         store=False,
     )
+    sale_order_id = fields.Many2one(
+        "sale.order",
+        string="Sale Order (activation)",
+    )
     # On energy_communities all contracts have skip_zero_qty marked by default
     skip_zero_qty = fields.Boolean(default=True)
 
diff --git a/energy_communities_service_invoicing/models/sale_order.py b/energy_communities_service_invoicing/models/sale_order.py
index 380d77e9c..5f8680751 100644
--- a/energy_communities_service_invoicing/models/sale_order.py
+++ b/energy_communities_service_invoicing/models/sale_order.py
@@ -33,6 +33,7 @@ class SaleOrder(models.Model):
                         "community_company_id": self.community_company_id.id,
                         "pricelist_id": self.pricelist_id.id,
                         "payment_mode_id": self.payment_mode_id.id,
+                        "sale_order_id": self.id,
                     }
                 )
         return contracts
diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index 21f434de4..69b214591 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -95,6 +95,7 @@
         <field name="discount" />
         <field name="predecessor_contract_id" />
         <field name="successor_contract_id" />
+        <field name="sale_order_id" />
       </xpath>
     </field>
   </record>
-- 
GitLab


From 52b732c6c6214e13bb8c43f2f3cff541100eaece Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Fri, 7 Feb 2025 16:01:06 +0100
Subject: [PATCH 35/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Relationship=20betwee?=
 =?UTF-8?q?n=20sale=20order=20and=20contract=20(UI)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../models/sale_order.py                      | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/energy_communities_service_invoicing/models/sale_order.py b/energy_communities_service_invoicing/models/sale_order.py
index 5f8680751..f2c61ea09 100644
--- a/energy_communities_service_invoicing/models/sale_order.py
+++ b/energy_communities_service_invoicing/models/sale_order.py
@@ -37,3 +37,23 @@ class SaleOrder(models.Model):
                     }
                 )
         return contracts
+
+    def action_show_contracts(self):
+        self.ensure_one()
+        action = self.env["ir.actions.act_window"]._for_xml_id(
+            "contract.action_customer_contract"
+        )
+
+        contracts = self.env["contract.contract"].search(
+            [("sale_order_id", "=", self.id)]
+        )
+        if len(contracts) == 1:
+            # If there is only one contract, open it directly
+            action.update(
+                {
+                    "res_id": contracts.id,
+                    "view_mode": "form",
+                    "views": filter(lambda view: view[1] == "form", action["views"]),
+                }
+            )
+        return action
-- 
GitLab


From 9d63cb281180b87faf9cdd3d87bcae3c03ca7e46 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Mon, 10 Feb 2025 15:25:46 +0100
Subject: [PATCH 36/85] =?UTF-8?q?[FIX]=20=F0=9F=90=9B=20compute=5Fis=5Fpac?=
 =?UTF-8?q?k=20is=20a=20public=20method?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../models/contract_template.py                                 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/energy_communities_service_invoicing/models/contract_template.py b/energy_communities_service_invoicing/models/contract_template.py
index c27d13e3f..11e4847d8 100644
--- a/energy_communities_service_invoicing/models/contract_template.py
+++ b/energy_communities_service_invoicing/models/contract_template.py
@@ -5,7 +5,7 @@ class ContractTemplate(models.Model):
     _name = "contract.template"
     _inherit = "contract.template"
 
-    is_pack = fields.Boolean(compute="_compute_is_pack", store=True)
+    is_pack = fields.Boolean(compute="compute_is_pack", store=True)
 
     def compute_is_pack(self):
         for record in self:
-- 
GitLab


From 3f5f7c38388981ed2869e457e150ed486be18fa4 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Tue, 11 Feb 2025 10:57:30 +0100
Subject: [PATCH 37/85] =?UTF-8?q?[FIX]=20=F0=9F=90=9B=20Allow=20energy=20m?=
 =?UTF-8?q?odules=20installation?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 energy_communities/models/res_partner.py      | 14 +++++---
 .../__manifest__.py                           |  1 +
 .../models/contract_template.py               | 33 +++++++++++--------
 3 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/energy_communities/models/res_partner.py b/energy_communities/models/res_partner.py
index 654d8cac5..a2ad9155f 100644
--- a/energy_communities/models/res_partner.py
+++ b/energy_communities/models/res_partner.py
@@ -59,16 +59,22 @@ class ResPartner(models.Model):
 
     def compute_company_hierarchy_level(self):
         for record in self:
-            if self.related_company_id:
-                record.company_hierarchy_level = self.related_company_id.hierarchy_level
+            try:
+                related_company_id = record.related_company_id
+            except:
+                related_company_id = False
+            if related_company_id:
+                record.company_hierarchy_level = (
+                    record.related_company_id.hierarchy_level
+                )
 
     def compute_related_company_id(self):
         for record in self:
             related_company_id = self.env["res.company"].search(
-                [("partner_id", "=", record.id)]
+                [("partner_id", "=", record.id)], limit=1
             )
             if related_company_id:
-                record.related_company_id = related_company_id.id
+                record.related_company_id = related_company_id[0].id
 
     @api.constrains("company_ids")
     def _constrains_partner_company_ids(self):
diff --git a/energy_communities_service_invoicing/__manifest__.py b/energy_communities_service_invoicing/__manifest__.py
index bdf18da58..8039519b4 100644
--- a/energy_communities_service_invoicing/__manifest__.py
+++ b/energy_communities_service_invoicing/__manifest__.py
@@ -18,6 +18,7 @@
         "product_contract",
         "contract_variable_quantity",
         "energy_communities",
+        "energy_communities_cooperator",  # TODO: This dependency is needed for active members formula. Need to refactor this.
     ],
     # always loaded
     "data": [
diff --git a/energy_communities_service_invoicing/models/contract_template.py b/energy_communities_service_invoicing/models/contract_template.py
index 11e4847d8..80fd7506e 100644
--- a/energy_communities_service_invoicing/models/contract_template.py
+++ b/energy_communities_service_invoicing/models/contract_template.py
@@ -8,18 +8,23 @@ class ContractTemplate(models.Model):
     is_pack = fields.Boolean(compute="compute_is_pack", store=True)
 
     def compute_is_pack(self):
-        for record in self:
-            record.is_pack = bool(
-                self.env["product.template"].search(
-                    [
-                        ("property_contract_template_id", "=", record.id),
-                        (
-                            "categ_id",
-                            "=",
-                            self.env.ref(
-                                "energy_communities_service_invoicing.product_category_pack"
-                            ).id,
-                        ),
-                    ]
+        try:
+            categ_id = self.env.ref(
+                "energy_communities_service_invoicing.product_category_pack"
+            ).id
+        except:
+            categ_id = False
+        if categ_id:
+            for record in self:
+                record.is_pack = bool(
+                    self.env["product.template"].search(
+                        [
+                            ("property_contract_template_id", "=", record.id),
+                            (
+                                "categ_id",
+                                "=",
+                                categ_id,
+                            ),
+                        ]
+                    )
                 )
-            )
-- 
GitLab


From 584740089e56579cdf3d18e6be412a56049c37e4 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Tue, 11 Feb 2025 12:28:34 +0100
Subject: [PATCH 38/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Global=20menus=20visi?=
 =?UTF-8?q?bility?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 energy_communities/__manifest__.py |  1 +
 energy_communities/views/menus.xml | 14 +++++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/energy_communities/__manifest__.py b/energy_communities/__manifest__.py
index d5099e94e..f0066cbbb 100644
--- a/energy_communities/__manifest__.py
+++ b/energy_communities/__manifest__.py
@@ -16,6 +16,7 @@
         "base_technical_features",
         "base_user_role",
         "base_user_role_company",
+        "calendar",
         "community_maps",
         "contacts",
         "event",
diff --git a/energy_communities/views/menus.xml b/energy_communities/views/menus.xml
index 1fde3dba6..e49e773a4 100644
--- a/energy_communities/views/menus.xml
+++ b/energy_communities/views/menus.xml
@@ -18,7 +18,7 @@
     id="ce_root_menu"
     name="Energy Communities"
     sequence="10"
-    groups="group_platform_manager"
+    groups="group_platform_manager,group_admin,group_user"
     web_icon="energy_communities,static/description/icon.png"
   />
   <menuitem id="ce_config_menu" name="Configuration" parent="ce_root_menu" sequence="99" />
@@ -45,6 +45,18 @@
   />
 
   <!-- Hide menu items unless platform manager -->
+  <record model="ir.ui.menu" id="mail.menu_root_discuss">
+    <field name="groups_id" eval="[(6,0,[ref('group_platform_manager')])]" />
+  </record>
+  <record model="ir.ui.menu" id="calendar.mail_menu_calendar">
+    <field name="groups_id" eval="[(6,0,[ref('group_platform_manager')])]" />
+  </record>
+  <record model="ir.ui.menu" id="base.menu_board_root">
+    <field name="groups_id" eval="[(6,0,[ref('group_platform_manager')])]" />
+  </record>
+  <record model="ir.ui.menu" id="spreadsheet_dashboard.spreadsheet_dashboard_menu_root">
+    <field name="groups_id" eval="[(6,0,[ref('group_platform_manager')])]" />
+  </record>
   <record model="ir.ui.menu" id="community_maps.menu_root">
     <field name="groups_id" eval="[(6,0,[ref('group_platform_manager')])]" />
   </record>
-- 
GitLab


From 42771d18650a71020a5c75833c22795038822e10 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Thu, 13 Feb 2025 13:25:37 +0100
Subject: [PATCH 39/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Base=20menu=20structu?=
 =?UTF-8?q?re=20for=20service-invoicing?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 energy_communities/security/ir_rule_data.xml  | 89 ++++++++++++-------
 energy_communities/views/menus.xml            | 23 ++++-
 .../__manifest__.py                           |  1 +
 .../data/contract_line_qty_formula_data.xml   |  2 +-
 .../models/__init__.py                        |  1 +
 .../models/account_move.py                    | 33 +++++++
 .../models/contract.py                        |  1 +
 .../security/ir_rule_data.xml                 | 32 +++++++
 .../views/contract_views.xml                  |  1 +
 .../views/menus.xml                           | 37 +++++---
 .../views/service_invoicing_views.xml         | 20 +++++
 .../service_invoicing_action_create.xml       |  8 +-
 12 files changed, 196 insertions(+), 52 deletions(-)
 create mode 100644 energy_communities_service_invoicing/models/account_move.py
 create mode 100644 energy_communities_service_invoicing/security/ir_rule_data.xml

diff --git a/energy_communities/security/ir_rule_data.xml b/energy_communities/security/ir_rule_data.xml
index 461acbedc..6557e2c65 100644
--- a/energy_communities/security/ir_rule_data.xml
+++ b/energy_communities/security/ir_rule_data.xml
@@ -1,36 +1,37 @@
-<?xml version="1.0" ?>
 <odoo>
     <record model="ir.rule" id="landing_page_company_rule">
         <field name="name">Landing Page multi-company</field>
         <field name="model_id" ref="energy_communities.model_landing_page" />
         <field name="global" eval="True" />
-        <field
-      name="domain_force"
-    >['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]</field>
+        <field name="domain_force">
+['|',('company_id', '=', False),('company_id', 'in', company_ids)]
+        </field>
     </record>
 
     <record model="ir.rule" id="mail_message_company_rule">
         <field name="name">mail.message multi-company</field>
         <field name="model_id" ref="mail.model_mail_message" />
         <field name="global" eval="True" />
-        <field name="domain_force">['|', ('author_id.company_ids', '=', False),
-                                    ('author_id.company_ids', 'in', company_ids)]</field>
+        <field name="domain_force">
+['|',('author_id.company_ids', '=', False),('author_id.company_ids', 'in', company_ids)]
+        </field>
     </record>
 
     <record model="ir.rule" id="mail_followers_company_rule">
         <field name="name">mail.followers multi-company</field>
         <field name="model_id" ref="mail.model_mail_followers" />
         <field name="global" eval="True" />
-        <field name="domain_force">['|', ('partner_id.company_ids', '=', False),
-                                    ('partner_id.company_ids', 'in', company_ids)]</field>
+        <field name="domain_force">
+['|',('partner_id.company_ids', '=', False),('partner_id.company_ids', 'in', company_ids)]
+        </field>
     </record>
 
     <record model="ir.rule" id="mail_activity_company_rule">
         <field name="name">mail.activity multi-company</field>
         <field name="model_id" ref="mail.model_mail_activity" />
         <field name="global" eval="True" />
-        <field name="domain_force">['|', ('user_id.partner_id.company_ids', '=', False),
-                                    ('user_id.partner_id.company_ids', 'in', company_ids)]
+        <field name="domain_force">
+['|',('user_id.partner_id.company_ids', '=', False),('user_id.partner_id.company_ids', 'in', company_ids)]
         </field>
     </record>
 
@@ -45,9 +46,9 @@
       <field name="perm_write" eval="False" />
       <field name="perm_create" eval="False" />
       <field name="perm_unlink" eval="False" />
-        <field
-      name="domain_force"
-    >['|', ('company_ids', '=', False), ('company_ids', 'in', company_ids)]</field>
+        <field name="domain_force">
+['|',('company_ids', '=', False),('company_ids', 'in', company_ids)]
+        </field>
     </record>
     <function name="write" model="ir.model.data">
         <function name="search" model="ir.model.data">
@@ -58,9 +59,7 @@
 
     <function name="write" model="ir.model.data">
         <function name="search" model="ir.model.data">
-            <value
-        eval="[('module', '=', 'base'),('name', '=', 'res_partner_rule_private_employee')]"
-      />
+            <value eval="[('module', '=', 'base'),('name', '=', 'res_partner_rule_private_employee')]"/>
         </function>
         <value eval="{'noupdate': False}" />
     </function>
@@ -69,9 +68,7 @@
     </record>
     <function name="write" model="ir.model.data">
         <function name="search" model="ir.model.data">
-            <value
-        eval="[('module', '=', 'base'),('name', '=', 'res_partner_rule_private_employee')]"
-      />
+          <value eval="[('module', '=', 'base'),('name', '=', 'res_partner_rule_private_employee')]"/>
         </function>
         <value eval="{'noupdate': True}" />
     </function>
@@ -80,9 +77,16 @@
       <field name="name">res.partner multi-company</field>
       <field name="model_id" ref="base.model_res_partner" />
       <field name="groups" eval="[(4, ref('base.group_user'))]" />
-      <field
-      name="domain_force"
-    >["&amp;","|",('company_ids', '=', False),('company_ids', 'in', company_ids),"|",('type', '!=', 'private'), ('type', '=', False)]</field>
+      <field name="domain_force">
+[
+'&amp;','|',
+('company_ids', '=', False),
+('company_ids', 'in', company_ids),
+'|',
+('type', '!=', 'private'),
+('type', '=', False)
+]
+      </field>
       <field name="perm_read" eval="True" />
       <field name="perm_write" eval="False" />
       <field name="perm_create" eval="False" />
@@ -93,9 +97,15 @@
       <field name="name">res.partner Platform-admin multi-company</field>
       <field name="model_id" ref="base.model_res_partner" />
       <field name="groups" eval="[(4, ref('base.group_user'))]" />
-      <field
-      name="domain_force"
-    >['&amp;',('user_current_role', '=', 'role_platform_admin'),'|', ('type', '!=', 'private'), ('type', '=', False)]</field>
+      <field name="domain_force">
+[
+'&amp;',
+('user_current_role', '=', 'role_platform_admin'),
+'|',
+('type', '!=', 'private'),
+('type', '=', False)
+]
+      </field>
       <field name="perm_read" eval="False" />
       <field name="perm_write" eval="True" />
       <field name="perm_create" eval="True" />
@@ -106,9 +116,16 @@
       <field name="name">res.partner Coordinator-admin-worker multi-company</field>
       <field name="model_id" ref="base.model_res_partner" />
       <field name="groups" eval="[(4, ref('base.group_user'))]" />
-      <field
-      name="domain_force"
-    >['&amp;','&amp;',('user_current_role', 'in', ['role_coord_admin','role_coord_worker']),('company_hierarchy_level','!=','instance'),'|', ('type', '!=', 'private'), ('type', '=', False)]</field>
+      <field name="domain_force">
+[
+'&amp;','&amp;',
+('user_current_role', 'in', ['role_coord_admin','role_coord_worker']),
+('company_hierarchy_level','!=','instance'),
+'|',
+('type', '!=', 'private'),
+('type', '=', False)
+]
+      </field>
       <field name="perm_read" eval="False" />
       <field name="perm_write" eval="True" />
       <field name="perm_create" eval="True" />
@@ -119,9 +136,16 @@
       <field name="name">res.partner Community-manager-admin multi-company</field>
       <field name="model_id" ref="base.model_res_partner" />
       <field name="groups" eval="[(4, ref('base.group_user'))]" />
-      <field
-      name="domain_force"
-    >['&amp;','&amp;',('user_current_role', 'in', ['role_ce_manager','role_ce_admin']),('company_hierarchy_level','not in',['instance','coordinator']),'|', ('type', '!=', 'private'), ('type', '=', False)]</field>
+      <field name="domain_force">
+[
+'&amp;','&amp;',
+('user_current_role', 'in', ['role_ce_manager','role_ce_admin']),
+('company_hierarchy_level','not in',['instance','coordinator']),
+'|',
+('type', '!=', 'private'),
+('type', '=', False)
+]
+      </field>
       <field name="perm_read" eval="False" />
       <field name="perm_write" eval="True" />
       <field name="perm_create" eval="True" />
@@ -133,11 +157,12 @@
         <field name="model_id" ref="account_reconcile_oca.model_account_account_reconcile"/>
         <field name="groups" eval="[(4, ref('base.group_user'))]" />
         <field name="domain_force">
-            [('company_id', 'in', company_ids)]
+[('company_id', 'in', company_ids)]
         </field>
         <field name="perm_read" eval="True" />
         <field name="perm_write" eval="True" />
         <field name="perm_create" eval="True" />
         <field name="perm_unlink" eval="False" />
     </record>
+
 </odoo>
diff --git a/energy_communities/views/menus.xml b/energy_communities/views/menus.xml
index e49e773a4..d9a4d72dd 100644
--- a/energy_communities/views/menus.xml
+++ b/energy_communities/views/menus.xml
@@ -15,13 +15,28 @@
   </record>
 
   <menuitem
-    id="ce_root_menu"
-    name="Energy Communities"
+    id="ce_root_menu_platform_manager"
+    name="Instance Management"
     sequence="10"
-    groups="group_platform_manager,group_admin,group_user"
+    groups="role_platform_admin_res_groups,role_coord_admin_res_groups,role_coord_worker_res_groups"
     web_icon="energy_communities,static/description/icon.png"
   />
-  <menuitem id="ce_config_menu" name="Configuration" parent="ce_root_menu" sequence="99" />
+  <menuitem
+    id="ce_root_menu_coord_admin"
+    name="Coordinator management"
+    sequence="10"
+    groups="role_coord_admin_res_groups,role_coord_worker_res_groups"
+    web_icon="energy_communities,static/description/icon.png"
+  />
+  <menuitem
+    id="ce_root_menu_community_admin"
+    name="Community management"
+    sequence="10"
+    groups="role_ce_admin,role_ce_manager"
+    web_icon="energy_communities,static/description/icon.png"
+  />
+  <menuitem id="ce_assistants_menu" name="Assistants" parent="ce_root_menu_platform_manager" sequence="99" />
+  <menuitem id="ce_config_menu" name="Configuration" parent="ce_root_menu_platform_manager" sequence="999" />
   <menuitem
     id="ce_config_sources_menu"
     name="Source types"
diff --git a/energy_communities_service_invoicing/__manifest__.py b/energy_communities_service_invoicing/__manifest__.py
index 8039519b4..a09779105 100644
--- a/energy_communities_service_invoicing/__manifest__.py
+++ b/energy_communities_service_invoicing/__manifest__.py
@@ -23,6 +23,7 @@
     # always loaded
     "data": [
         "security/ir.model.access.csv",
+        "security/ir_rule_data.xml",
         "data/contract_cron.xml",
         "data/contract_line_qty_formula_data.xml",
         "data/product_data.xml",
diff --git a/energy_communities_service_invoicing/data/contract_line_qty_formula_data.xml b/energy_communities_service_invoicing/data/contract_line_qty_formula_data.xml
index d4988f8b8..2a58d0c02 100644
--- a/energy_communities_service_invoicing/data/contract_line_qty_formula_data.xml
+++ b/energy_communities_service_invoicing/data/contract_line_qty_formula_data.xml
@@ -6,7 +6,7 @@
     >
       <field name="name">Community members</field>
       <field name="code">
-result = env['cooperative.membership'].search_count([
+result = env['cooperative.membership'].sudo().search_count([
 ('company_id','=',contract.community_company_id.id),
 ('member','=',True)
 ])
diff --git a/energy_communities_service_invoicing/models/__init__.py b/energy_communities_service_invoicing/models/__init__.py
index 0ecf355b2..3beedf2f4 100644
--- a/energy_communities_service_invoicing/models/__init__.py
+++ b/energy_communities_service_invoicing/models/__init__.py
@@ -1,4 +1,5 @@
 from . import abstract_contract
+from . import account_move
 from . import contract
 from . import contract_template
 from . import product_template
diff --git a/energy_communities_service_invoicing/models/account_move.py b/energy_communities_service_invoicing/models/account_move.py
new file mode 100644
index 000000000..4add5cb7a
--- /dev/null
+++ b/energy_communities_service_invoicing/models/account_move.py
@@ -0,0 +1,33 @@
+from odoo import api, fields, models
+
+
+class AccountMove(models.Model):
+    _inherit = "account.move"
+
+    ref_invoice_id = fields.Many2one(
+        compute="_compute_ref_invoice_id_and_is_pack", store=False
+    )
+    is_pack = fields.Boolean(compute="_compute_ref_invoice_id_and_is_pack", store=True)
+
+    @api.depends("invoice_line_ids", "ref")
+    def _compute_ref_invoice_id_and_is_pack(self):
+        for record in self:
+            record.ref_invoice_id = False
+            record.is_pack = False
+            rel_inv = False
+            if record.ref:
+                rel_inv = (
+                    self.env["account.move"]
+                    .sudo()
+                    .search([("name", "=", record.ref)], limit=1)
+                )
+                if rel_inv:
+                    record.ref_invoice_id = rel_inv.id
+                    record.is_pack = rel_inv.is_pack
+            else:
+                if record.invoice_line_ids:
+                    first_move_line = record.invoice_line_ids[0]
+                    if first_move_line.contract_line_id:
+                        record.is_pack = (
+                            first_move_line.contract_line_id.contract_id.is_pack
+                        )
diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index 38cf73fc1..87e0c92c2 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -36,6 +36,7 @@ class ContractContract(models.Model):
     last_date_invoiced = fields.Date(
         string="Last Date Invoiced", compute="_compute_last_date_invoiced", store=False
     )
+    is_pack = fields.Boolean(related="contract_template_id.is_pack")
     service_pack_id = fields.Many2one(
         "product.product",
         string="Service Pack",
diff --git a/energy_communities_service_invoicing/security/ir_rule_data.xml b/energy_communities_service_invoicing/security/ir_rule_data.xml
new file mode 100644
index 000000000..b9e6dd228
--- /dev/null
+++ b/energy_communities_service_invoicing/security/ir_rule_data.xml
@@ -0,0 +1,32 @@
+<odoo>
+  <function name="write" model="ir.model.data">
+      <function name="search" model="ir.model.data">
+          <value eval="[('module', '=', 'account'),('name', '=', 'account_move_comp_rule')]"/>
+      </function>
+      <value eval="{'noupdate': False}" />
+  </function>
+  <record model="ir.rule" id="account.account_move_comp_rule">
+    <field name="domain_force">
+[
+'|',
+('company_id','=',False),
+('company_id', 'in', company_ids),
+]
+    </field>
+  </record>
+  <function name="write" model="ir.model.data">
+    <function name="search" model="ir.model.data">
+        <value eval="[('module', '=', 'account'),('name', '=', 'account_move_comp_rule')]"/>
+    </function>
+    <value eval="{'noupdate': True}" />
+  </function>
+</odoo>
+
+<!--    <field name="domain_force">-->
+<!--[-->
+<!--'|','|',-->
+<!--('company_id','=',False),-->
+<!--('company_id', 'in', company_ids),-->
+<!--('partner_id','=',user.user_current_company.partner_id.id)-->
+<!--]-->
+<!--    </field>-->
diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index 69b214591..47942f73f 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -49,6 +49,7 @@
         <field name="partner_id" />
         <field name="community_company_id" />
         <field name="service_pack_id" />
+        <field name="is_pack" />
       </tree>
     </field>
   </record>
diff --git a/energy_communities_service_invoicing/views/menus.xml b/energy_communities_service_invoicing/views/menus.xml
index 8ab3410f9..f2508ac4e 100644
--- a/energy_communities_service_invoicing/views/menus.xml
+++ b/energy_communities_service_invoicing/views/menus.xml
@@ -1,40 +1,55 @@
 <odoo>
-  <menuitem id="ce_service_invoicing_menu" name="Services" parent="energy_communities.ce_root_menu" sequence="1" />
+  <menuitem id="ce_service_invoicing_menu" name="Services" parent="energy_communities.ce_root_menu_platform_manager" sequence="1" />
   <menuitem
-    name="Service invoicing"
+    name="Service Contracts"
     id="view_service_invoicing_menu"
     parent="ce_service_invoicing_menu"
     action="view_service_invoicing_window"
     sequence="100"
   />
   <menuitem
-    name="Packs"
-    id="view_service_packs_menu"
+    name="Platform Services"
+    id="view_services_menu"
     parent="ce_service_invoicing_menu"
-    action="view_service_packs_window"
+    action="view_services_window"
     sequence="200"
   />
   <menuitem
-    name="Services"
-    id="view_services_menu"
+    name="Service Packs"
+    id="view_service_packs_menu"
     parent="ce_service_invoicing_menu"
-    action="view_services_window"
+    action="view_service_packs_window"
     sequence="300"
   />
-  <!-- TODO: Create Services entry point -->
   <menuitem
-    name="Packs contract templates"
+    name="Service Packs templates"
     id="view_service_contract_templates_menu"
     parent="ce_service_invoicing_menu"
     action="view_service_contract_templates_window"
     sequence="400"
   />
+  <menuitem
+    name="Service invoices issued"
+    id="view_service_invoices_issued_menu"
+    parent="ce_service_invoicing_menu"
+    action="view_service_invoices_issued_window"
+    groups="energy_communities.role_platform_admin_res_groups"
+    sequence="500"
+  />
+  <menuitem
+    name="Service invoices received"
+    id="view_service_invoices_received_menu"
+    parent="ce_service_invoicing_menu"
+    action="view_service_invoices_received_window"
+    groups="energy_communities.role_coord_admin_res_groups,energy_communities.role_coord_worker_res_groups"
+    sequence="500"
+  />
   <menuitem
     name="Service actions (sale orders)"
     id="view_service_sale_orders_menu"
     parent="ce_service_invoicing_menu"
     action="view_service_sale_orders_window"
-    sequence="500"
+    sequence="550"
   />
   <menuitem
     name="Tariffs"
diff --git a/energy_communities_service_invoicing/views/service_invoicing_views.xml b/energy_communities_service_invoicing/views/service_invoicing_views.xml
index 8068f83f2..87ac98852 100644
--- a/energy_communities_service_invoicing/views/service_invoicing_views.xml
+++ b/energy_communities_service_invoicing/views/service_invoicing_views.xml
@@ -41,6 +41,26 @@
     <field name="domain">[('is_pack','=',True)]</field>
   </record>
 
+  <record
+      id="view_service_invoices_issued_window"
+      model="ir.actions.act_window"
+  >
+    <field name="name">Service invoices (issued)</field>
+    <field name="res_model">account.move</field>
+    <field name="view_mode">tree,form</field>
+    <field name="domain" eval="[('move_type', 'in', ['out_invoice', 'out_refund']),('is_pack','=',True)]"/>
+  </record>
+
+  <record
+      id="view_service_invoices_received_window"
+      model="ir.actions.act_window"
+  >
+    <field name="name">Service invoices (received)</field>
+    <field name="res_model">account.move</field>
+    <field name="view_mode">tree,form</field>
+    <field name="domain" eval="[('move_type', 'in', ['in_invoice', 'in_refund']),('is_pack','=',True)]"/>
+  </record>
+
   <record
       id="view_service_sale_orders_window"
       model="ir.actions.act_window"
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
index 1901a0f98..7ddea48f0 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
@@ -37,16 +37,16 @@
     model="ir.actions.act_window"
     id="service_invoicing_action_create_wizard_action"
   >
-      <field name="name">Create community service invoicing</field>
+      <field name="name">Assign pack to community</field>
       <field name="res_model">service.invoicing.action.create.wizard</field>
       <field name="view_mode">form</field>
       <field name="target">new</field>
   </record>
   <menuitem
     id="service_invoicing_action_create_wizard_menu"
-    name="Create community service invoicing"
+    name="Assign pack to community"
     action="service_invoicing_action_create_wizard_action"
-    parent="energy_communities.ce_config_menu"
-    sequence="300"
+    parent="energy_communities.ce_assistants_menu"
+    sequence="100"
   />
 </odoo>
-- 
GitLab


From 88b1474ab0ec26e5e850f50a85b3f096b227ed26 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Mon, 17 Feb 2025 15:13:44 +0100
Subject: [PATCH 40/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Contract=20model=20AC?=
 =?UTF-8?q?L=20and=20record=20rules?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../models/contract.py                        |  7 +-
 .../security/ir.model.access.csv              |  3 +
 .../security/ir_rule_data.xml                 | 70 +++++++++++++++----
 .../views/contract_views.xml                  | 46 +++++++++++-
 .../views/menus.xml                           | 30 +++++---
 .../views/service_invoicing_views.xml         | 48 ++++++++++---
 6 files changed, 168 insertions(+), 36 deletions(-)

diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index 87e0c92c2..4652c7487 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -53,12 +53,14 @@ class ContractContract(models.Model):
     @api.depends("contract_line_ids")
     def _compute_discount(self):
         for record in self:
+            record.discount = 0
             if record.contract_line_ids:
                 record.discount = record.contract_line_ids[0].discount
 
     @api.depends("contract_line_ids")
     def _compute_last_date_invoiced(self):
         for record in self:
+            record.last_date_invoiced = None
             if record.contract_line_ids:
                 record.last_date_invoiced = record.contract_line_ids[
                     0
@@ -67,8 +69,9 @@ class ContractContract(models.Model):
     @api.depends("contract_template_id")
     def _compute_service_pack_id(self):
         for record in self:
+            record.service_pack_id = False
             if record.contract_template_id:
-                record.service_pack_id = self.env["product.product"].search(
+                rel_product = self.env["product.product"].search(
                     [
                         (
                             "property_contract_template_id",
@@ -78,6 +81,8 @@ class ContractContract(models.Model):
                     ],
                     limit=1,
                 )
+                if rel_product:
+                    record.service_pack_id = rel_product.id
 
     def set_close_status_type_by_date(self):
         if self.date_end.strftime("%Y-%m-%d") == datetime.now().strftime("%Y-%m-%d"):
diff --git a/energy_communities_service_invoicing/security/ir.model.access.csv b/energy_communities_service_invoicing/security/ir.model.access.csv
index 2d0b824de..b7866d028 100644
--- a/energy_communities_service_invoicing/security/ir.model.access.csv
+++ b/energy_communities_service_invoicing/security/ir.model.access.csv
@@ -1,3 +1,6 @@
 id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
 access_service_invoicing_action_wizard,service_invoicing_action_wizard,model_service_invoicing_action_wizard,base.group_user,1,1,1,1
 access_service_invoicing_action_create_wizard,service_invoicing_action_create_wizard,model_service_invoicing_action_create_wizard,base.group_user,1,1,1,1
+contract.contract_manager,contract_manager,model_contract_contract,account.group_account_manager,1,0,0,0
+contract_platform_admin,contract_platform_admin,model_contract_contract,energy_communities.role_platform_admin_res_groups,1,1,1,1
+contract_coord_admin,contract_coord_admin,model_contract_contract,energy_communities.role_coord_admin_res_groups,1,1,0,0
diff --git a/energy_communities_service_invoicing/security/ir_rule_data.xml b/energy_communities_service_invoicing/security/ir_rule_data.xml
index b9e6dd228..95056d3f6 100644
--- a/energy_communities_service_invoicing/security/ir_rule_data.xml
+++ b/energy_communities_service_invoicing/security/ir_rule_data.xml
@@ -1,32 +1,74 @@
 <odoo>
+
+  <record model="ir.rule" id="energy_communities_service_invoicing.rule_contract_contract_admin">
+    <field name="name">Contract admins</field>
+    <field name="model_id" ref="model_contract_contract"/>
+    <field name="groups" eval="[(4, ref('energy_communities.role_platform_admin_res_groups')),(4, ref('energy_communities.role_coord_admin_res_groups'))]"/>
+    <field name="domain_force">[('company_id', 'in', company_ids)]</field>
+    <field name="perm_read" eval="False" />
+    <field name="perm_write" eval="True" />
+    <field name="perm_create" eval="True" />
+    <field name="perm_unlink" eval="True" />
+  </record>
+
   <function name="write" model="ir.model.data">
       <function name="search" model="ir.model.data">
-          <value eval="[('module', '=', 'account'),('name', '=', 'account_move_comp_rule')]"/>
+          <value eval="[('module', '=', 'contract'),('name', '=', 'rule_contract_contract_multi_company')]"/>
       </function>
       <value eval="{'noupdate': False}" />
   </function>
-  <record model="ir.rule" id="account.account_move_comp_rule">
+  <record model="ir.rule" id="contract.rule_contract_contract_multi_company">
+
     <field name="domain_force">
 [
-'|',
+'|','|',
+('partner_id','=',user.user_current_company.partner_id.id),
 ('company_id','=',False),
-('company_id', 'in', company_ids),
+('company_id','in',company_ids)
 ]
     </field>
+    <field name="perm_read" eval="True"/>
+    <field name="perm_write" eval="False"/>
+    <field name="perm_create" eval="False"/>
+    <field name="perm_unlink" eval="False"/>
   </record>
   <function name="write" model="ir.model.data">
     <function name="search" model="ir.model.data">
-        <value eval="[('module', '=', 'account'),('name', '=', 'account_move_comp_rule')]"/>
+        <value eval="[('module', '=', 'contract'),('name', '=', 'rule_contract_contract_multi_company')]"/>
+    </function>
+    <value eval="{'noupdate': True}" />
+  </function>
+
+  <function name="write" model="ir.model.data">
+      <function name="search" model="ir.model.data">
+          <value eval="[('module', '=', 'contract'),('name', '=', 'contract_contract_see_all')]"/>
+      </function>
+      <value eval="{'noupdate': False}" />
+  </function>
+  <record model="ir.rule" id="contract.contract_contract_see_all">
+    <field name="active">False</field>
+  </record>
+  <function name="write" model="ir.model.data">
+    <function name="search" model="ir.model.data">
+        <value eval="[('module', '=', 'contract'),('name', '=', 'contract_contract_see_all')]"/>
     </function>
     <value eval="{'noupdate': True}" />
   </function>
-</odoo>
 
-<!--    <field name="domain_force">-->
-<!--[-->
-<!--'|','|',-->
-<!--('company_id','=',False),-->
-<!--('company_id', 'in', company_ids),-->
-<!--('partner_id','=',user.user_current_company.partner_id.id)-->
-<!--]-->
-<!--    </field>-->
+  <function name="write" model="ir.model.data">
+      <function name="search" model="ir.model.data">
+          <value eval="[('module', '=', 'contract'),('name', '=', 'rule_contract_contract_portal')]"/>
+      </function>
+      <value eval="{'noupdate': False}" />
+  </function>
+  <record model="ir.rule" id="contract.rule_contract_contract_portal">
+    <field name="active">False</field>
+  </record>
+  <function name="write" model="ir.model.data">
+    <function name="search" model="ir.model.data">
+        <value eval="[('module', '=', 'contract'),('name', '=', 'rule_contract_contract_portal')]"/>
+    </function>
+    <value eval="{'noupdate': True}" />
+  </function>
+
+</odoo>
diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index 47942f73f..26de8ad93 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -54,8 +54,50 @@
     </field>
   </record>
 
-  <record id="view_contract_contract_customer_form" model="ir.ui.view">
-    <field name="name">contract.contract.form (in energy_communities service_invoicing)</field>
+  <record id="view_contract_contract_customer_form_coord_admin" model="ir.ui.view">
+    <field name="name">contract.contract.form (in energy_communities service_invoicing coordinator)</field>
+    <field name="model">contract.contract</field>
+    <field name="arch" type="xml">
+      <form edit="false" create="false" delete="false">
+        <header>
+          <field name="status" widget="statusbar" />
+        </header>
+        <sheet>
+          <div class="oe_button_box" name="button_box">
+            <button
+              name="action_show_invoices"
+              type="object"
+              icon="fa-list"
+              class="oe_stat_button"
+            >
+              <field
+                string="Invoices"
+                name="invoice_count"
+                widget="statinfo"
+              />
+            </button>
+          </div>
+          <group>
+            <field name="name" />
+            <field name="service_pack_id" />
+            <field name="pricelist_id" />
+            <field name="service_pack_id" />
+            <field name="discount" />
+            <!--TODO: Instead of contract template id we must show related service products -->
+          </group>
+          <group>
+            <field name="date_start" />
+            <field name="last_date_invoiced" />
+            <field name="recurring_next_date" />
+            <field name="date_end" attrs="{'invisible': [('status','!=','closed')]}" />
+          </group>
+        </sheet>
+      </form>
+    </field>
+  </record>
+
+  <record id="view_contract_contract_customer_form_platform_admin" model="ir.ui.view">
+    <field name="name">contract.contract.form (in energy_communities service_invoicing platform admin)</field>
     <field name="model">contract.contract</field>
     <field name="inherit_id" ref="product_contract.contract_contract_customer_form_view" />
     <field name="arch" type="xml">
diff --git a/energy_communities_service_invoicing/views/menus.xml b/energy_communities_service_invoicing/views/menus.xml
index f2508ac4e..df0946281 100644
--- a/energy_communities_service_invoicing/views/menus.xml
+++ b/energy_communities_service_invoicing/views/menus.xml
@@ -1,37 +1,45 @@
 <odoo>
-  <menuitem id="ce_service_invoicing_menu" name="Services" parent="energy_communities.ce_root_menu_platform_manager" sequence="1" />
+  <menuitem id="ce_service_invoicing_menu_platform_manager" name="Services" parent="energy_communities.ce_root_menu_platform_manager" sequence="1" />
+  <menuitem id="ce_service_invoicing_menu_coord_admin" name="Services Coord" parent="energy_communities.ce_root_menu_platform_manager" sequence="1" />
   <menuitem
     name="Service Contracts"
-    id="view_service_invoicing_menu"
-    parent="ce_service_invoicing_menu"
-    action="view_service_invoicing_window"
+    id="view_service_invoicing_menu_platform_manager"
+    parent="ce_service_invoicing_menu_platform_manager"
+    action="view_service_invoicing_window_platform_manager"
+    sequence="100"
+  />
+  <menuitem
+    name="Service Contracts"
+    id="view_service_invoicing_menu_coord_admin"
+    parent="ce_service_invoicing_menu_coord_admin"
+    action="view_service_invoicing_window_coord_admin"
     sequence="100"
   />
   <menuitem
     name="Platform Services"
     id="view_services_menu"
-    parent="ce_service_invoicing_menu"
+    parent="ce_service_invoicing_menu_platform_manager"
     action="view_services_window"
     sequence="200"
   />
   <menuitem
     name="Service Packs"
     id="view_service_packs_menu"
-    parent="ce_service_invoicing_menu"
+    parent="ce_service_invoicing_menu_platform_manager"
     action="view_service_packs_window"
     sequence="300"
   />
   <menuitem
     name="Service Packs templates"
     id="view_service_contract_templates_menu"
-    parent="ce_service_invoicing_menu"
+    parent="ce_service_invoicing_menu_platform_manager"
     action="view_service_contract_templates_window"
     sequence="400"
   />
   <menuitem
     name="Service invoices issued"
     id="view_service_invoices_issued_menu"
-    parent="ce_service_invoicing_menu"
+    parent="ce_service_invoicing_menu_platform_manager"
     action="view_service_invoices_issued_window"
     groups="energy_communities.role_platform_admin_res_groups"
     sequence="500"
@@ -39,7 +47,7 @@
   <menuitem
     name="Service invoices received"
     id="view_service_invoices_received_menu"
-    parent="ce_service_invoicing_menu"
+    parent="ce_service_invoicing_menu_platform_manager"
     action="view_service_invoices_received_window"
     groups="energy_communities.role_coord_admin_res_groups,energy_communities.role_coord_worker_res_groups"
     sequence="500"
@@ -47,14 +55,14 @@
   <menuitem
     name="Service actions (sale orders)"
     id="view_service_sale_orders_menu"
-    parent="ce_service_invoicing_menu"
+    parent="ce_service_invoicing_menu_platform_manager"
     action="view_service_sale_orders_window"
     sequence="550"
   />
   <menuitem
     name="Tariffs"
     id="view_service_tariffs_menu"
-    parent="ce_service_invoicing_menu"
+    parent="ce_service_invoicing_menu_platform_manager"
     action="view_service_tariffs_window"
     sequence="600"
   />
diff --git a/energy_communities_service_invoicing/views/service_invoicing_views.xml b/energy_communities_service_invoicing/views/service_invoicing_views.xml
index 87ac98852..d88715f79 100644
--- a/energy_communities_service_invoicing/views/service_invoicing_views.xml
+++ b/energy_communities_service_invoicing/views/service_invoicing_views.xml
@@ -1,6 +1,18 @@
 <odoo>
   <record
-      id="view_service_invoicing_window"
+      id="view_service_invoicing_window_platform_manager"
+      model="ir.actions.act_window"
+  >
+    <field name="name">Service Invoicing</field>
+    <field name="res_model">contract.contract</field>
+    <field name="view_mode">tree,form</field>
+    <field name="domain">
+[('community_company_id','!=',False)]
+    </field>
+  </record>
+
+  <record
+      id="view_service_invoicing_window_coord_admin"
       model="ir.actions.act_window"
   >
     <field name="name">Service Invoicing</field>
@@ -81,23 +93,43 @@
   </record>
 
   <record
-    id="action_view_service_invoicing_tree"
+    id="action_view_service_invoicing_tree_platform_manager"
+    model="ir.actions.act_window.view"
+  >
+    <field name="sequence" eval="1"/>
+    <field name="view_mode">tree</field>
+    <field name="view_id" ref="view_service_invoicing_tree"/>
+    <field name="act_window_id" ref="view_service_invoicing_window_platform_manager"/>
+  </record>
+
+  <record
+    id="action_view_service_invoicing_tree_coord_admin"
     model="ir.actions.act_window.view"
   >
     <field name="sequence" eval="1"/>
     <field name="view_mode">tree</field>
     <field name="view_id" ref="view_service_invoicing_tree"/>
-    <field name="act_window_id" ref="view_service_invoicing_window"/>
+    <field name="act_window_id" ref="view_service_invoicing_window_coord_admin"/>
+  </record>
+
+  <record
+    id="action_view_contract_contract_customer_form_platform_manager"
+    model="ir.actions.act_window.view"
+  >
+    <field name="sequence" eval="2"/>
+    <field name="view_mode">form</field>
+    <field name="view_id" ref="view_contract_contract_customer_form_platform_admin"/>
+    <field name="act_window_id" ref="view_service_invoicing_window_platform_manager"/>
   </record>
 
   <record
-    id="action_view_contract_contract_customer_form"
+    id="action_view_contract_contract_customer_form_coord_admin"
     model="ir.actions.act_window.view"
   >
     <field name="sequence" eval="2"/>
     <field name="view_mode">form</field>
-    <field name="view_id" ref="contract.contract_contract_customer_form_view"/>
-    <field name="act_window_id" ref="view_service_invoicing_window"/>
-    </record>
-  
+    <field name="view_id" ref="view_contract_contract_customer_form_coord_admin"/>
+    <field name="act_window_id" ref="view_service_invoicing_window_coord_admin"/>
+  </record>
+
 </odoo>
-- 
GitLab


From 49da66aee2afcd37ed64ad67e58cacb704c13d3d Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Mon, 17 Feb 2025 16:04:47 +0100
Subject: [PATCH 41/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Product=20model=20acl?=
 =?UTF-8?q?s=20and=20record=20rules?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../security/ir.model.access.csv              |  2 +
 .../security/ir_rule_data.xml                 | 43 ++++++++++++++++++-
 2 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/energy_communities_service_invoicing/security/ir.model.access.csv b/energy_communities_service_invoicing/security/ir.model.access.csv
index b7866d028..087389c37 100644
--- a/energy_communities_service_invoicing/security/ir.model.access.csv
+++ b/energy_communities_service_invoicing/security/ir.model.access.csv
@@ -4,3 +4,5 @@ access_service_invoicing_action_create_wizard,service_invoicing_action_create_wi
 contract.contract_manager,contract_manager,model_contract_contract,account.group_account_manager,1,0,0,0
 contract_platform_admin,contract_platform_admin,model_contract_contract,energy_communities.role_platform_admin_res_groups,1,1,1,1
 contract_coord_admin,contract_coord_admin,model_contract_contract,energy_communities.role_coord_admin_res_groups,1,1,0,0
+sale.access_product_category_sale_manager,product.category salemanager,product.model_product_category,sales_team.group_sale_manager,1,0,0,0
+purchase.access_product_category_purchase_manager,product.category purchase_manager,product.model_product_category,purchase.group_purchase_manager,1,0,0,0
diff --git a/energy_communities_service_invoicing/security/ir_rule_data.xml b/energy_communities_service_invoicing/security/ir_rule_data.xml
index 95056d3f6..ea94cd91a 100644
--- a/energy_communities_service_invoicing/security/ir_rule_data.xml
+++ b/energy_communities_service_invoicing/security/ir_rule_data.xml
@@ -1,5 +1,5 @@
 <odoo>
-
+  <!-- CONTRACT -->
   <record model="ir.rule" id="energy_communities_service_invoicing.rule_contract_contract_admin">
     <field name="name">Contract admins</field>
     <field name="model_id" ref="model_contract_contract"/>
@@ -69,6 +69,47 @@
         <value eval="[('module', '=', 'contract'),('name', '=', 'rule_contract_contract_portal')]"/>
     </function>
     <value eval="{'noupdate': True}" />
+    </function>
+
+  <!-- PRODUCT TEMPLATE -->
+  <function name="write" model="ir.model.data">
+      <function name="search" model="ir.model.data">
+          <value eval="[('module', '=', 'product'),('name', '=', 'product_comp_rule')]"/>
+      </function>
+      <value eval="{'noupdate': False}" />
+  </function>
+  <record model="ir.rule" id="product.product_comp_rule">
+    <field name="perm_read" eval="True"/>
+    <field name="perm_write" eval="False"/>
+    <field name="perm_create" eval="False"/>
+    <field name="perm_unlink" eval="False"/>
+  </record>
+  <function name="write" model="ir.model.data">
+    <function name="search" model="ir.model.data">
+        <value eval="[('module', '=', 'product'),('name', '=', 'product_comp_rule')]"/>
+    </function>
+    <value eval="{'noupdate': True}" />
   </function>
 
+  <record model="ir.rule" id="energy_communities_service_invoicing.rule_product_template_coord_admin">
+    <field name="name">Product - Coordinator admin</field>
+    <field name="model_id" ref="model_product_template"/>
+    <field name="groups" eval="[(4, ref('energy_communities.role_coord_admin_res_groups'))]"/>
+    <field name="domain_force">[('company_id', 'in', company_ids)]</field>
+    <field name="perm_read" eval="False" />
+    <field name="perm_write" eval="True" />
+    <field name="perm_create" eval="False" />
+    <field name="perm_unlink" eval="False" />
+  </record>
+
+  <record model="ir.rule" id="energy_communities_service_invoicing.rule_product_template_platform_admin">
+    <field name="name">Product - Platform admin</field>
+    <field name="model_id" ref="model_product_template"/>
+    <field name="groups" eval="[(4, ref('energy_communities.role_platform_admin_res_groups'))]"/>
+    <field name="domain_force">[(1, '=', 1)]</field>
+    <field name="perm_read" eval="False" />
+    <field name="perm_write" eval="True" />
+    <field name="perm_create" eval="True" />
+    <field name="perm_unlink" eval="True" />
+  </record>
 </odoo>
-- 
GitLab


From 705708565fc119bf465bfb0ae8eaa505ef2d501e Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Mon, 17 Feb 2025 16:40:46 +0100
Subject: [PATCH 42/85] =?UTF-8?q?[FIX]=20=F0=9F=90=9B=20Contract=20creatio?=
 =?UTF-8?q?n=20wizard=20return=20view?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 energy_communities_service_invoicing/utils.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/energy_communities_service_invoicing/utils.py b/energy_communities_service_invoicing/utils.py
index dd363efeb..d7c96fccc 100644
--- a/energy_communities_service_invoicing/utils.py
+++ b/energy_communities_service_invoicing/utils.py
@@ -26,7 +26,7 @@ def service_invoicing_view(env: Environment, service_invoicing_id: ContractContr
         "views": [
             (
                 env.ref(
-                    "energy_communities_service_invoicing.view_contract_contract_customer_form"
+                    "energy_communities_service_invoicing.view_contract_contract_customer_form_platform_admin"
                 ).id,
                 "form",
             ),
-- 
GitLab


From de960743b7104e69da7aa4f7bfa7e1ede04c9d60 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Mon, 17 Feb 2025 17:11:06 +0100
Subject: [PATCH 43/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Group=20permissions?=
 =?UTF-8?q?=20applied=20on=20menu=20items?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 energy_communities/views/menus.xml            | 42 ++++++++++++-------
 .../views/menus.xml                           | 35 +++++++++++-----
 .../service_invoicing_action_create.xml       |  1 +
 3 files changed, 52 insertions(+), 26 deletions(-)

diff --git a/energy_communities/views/menus.xml b/energy_communities/views/menus.xml
index d9a4d72dd..c4a37ce02 100644
--- a/energy_communities/views/menus.xml
+++ b/energy_communities/views/menus.xml
@@ -15,28 +15,40 @@
   </record>
 
   <menuitem
-    id="ce_root_menu_platform_manager"
-    name="Instance Management"
+    id="ce_root_menu"
+    name="Community Management"
     sequence="10"
-    groups="role_platform_admin_res_groups,role_coord_admin_res_groups,role_coord_worker_res_groups"
+    groups="role_platform_admin_res_groups,role_coord_admin_res_groups,role_coord_worker_res_groups,role_ce_admin,role_ce_manager"
     web_icon="energy_communities,static/description/icon.png"
   />
+  <!--<menuitem-->
+  <!--  id="ce_root_menu_coord_admin"-->
+  <!--  name="Coordinator management"-->
+  <!--  sequence="10"-->
+  <!--  groups="role_coord_admin_res_groups,role_coord_worker_res_groups"-->
+  <!--  web_icon="energy_communities,static/description/icon.png"-->
+  <!--/>-->
+  <!--<menuitem-->
+  <!--  id="ce_root_menu_community_admin"-->
+  <!--  name="Community management"-->
+  <!--  sequence="10"-->
+  <!--  groups="role_ce_admin,role_ce_manager"-->
+  <!--  web_icon="energy_communities,static/description/icon.png"-->
+  <!--/>-->
   <menuitem
-    id="ce_root_menu_coord_admin"
-    name="Coordinator management"
-    sequence="10"
-    groups="role_coord_admin_res_groups,role_coord_worker_res_groups"
-    web_icon="energy_communities,static/description/icon.png"
+    id="ce_assistants_menu"
+    name="Assistants"
+    parent="ce_root_menu"
+    groups="role_platform_admin_res_groups"
+    sequence="99"
   />
   <menuitem
-    id="ce_root_menu_community_admin"
-    name="Community management"
-    sequence="10"
-    groups="role_ce_admin,role_ce_manager"
-    web_icon="energy_communities,static/description/icon.png"
+    id="ce_config_menu"
+    name="Configuration"
+    parent="ce_root_menu"
+    groups="role_platform_admin_res_groups"
+    sequence="999"
   />
-  <menuitem id="ce_assistants_menu" name="Assistants" parent="ce_root_menu_platform_manager" sequence="99" />
-  <menuitem id="ce_config_menu" name="Configuration" parent="ce_root_menu_platform_manager" sequence="999" />
   <menuitem
     id="ce_config_sources_menu"
     name="Source types"
diff --git a/energy_communities_service_invoicing/views/menus.xml b/energy_communities_service_invoicing/views/menus.xml
index df0946281..9c615fc6f 100644
--- a/energy_communities_service_invoicing/views/menus.xml
+++ b/energy_communities_service_invoicing/views/menus.xml
@@ -1,45 +1,56 @@
 <odoo>
-  <menuitem id="ce_service_invoicing_menu_platform_manager" name="Services" parent="energy_communities.ce_root_menu_platform_manager" sequence="1" />
-  <menuitem id="ce_service_invoicing_menu_coord_admin" name="Services Coord" parent="energy_communities.ce_root_menu_platform_manager" sequence="1" />
+  <menuitem
+    id="ce_service_invoicing_menu"
+    name="Services"
+    parent="energy_communities.ce_root_menu"
+    sequence="1"
+    groups="energy_communities.role_platform_admin_res_groups,energy_communities.role_coord_admin_res_groups"
+  />
+  <!--<menuitem id="ce_service_invoicing_menu_coord_admin" name="Services Coord" parent="energy_communities.ce_root_menu_platform_manager" sequence="1" />-->
   <menuitem
     name="Service Contracts"
     id="view_service_invoicing_menu_platform_manager"
-    parent="ce_service_invoicing_menu_platform_manager"
+    parent="ce_service_invoicing_menu"
     action="view_service_invoicing_window_platform_manager"
+    groups="energy_communities.role_platform_admin_res_groups"
     sequence="100"
   />
   <menuitem
     name="Service Contracts"
     id="view_service_invoicing_menu_coord_admin"
-    parent="ce_service_invoicing_menu_coord_admin"
+    parent="ce_service_invoicing_menu"
     action="view_service_invoicing_window_coord_admin"
+    groups="energy_communities.role_coord_admin_res_groups"
     sequence="100"
   />
   <menuitem
     name="Platform Services"
     id="view_services_menu"
-    parent="ce_service_invoicing_menu_platform_manager"
+    parent="ce_service_invoicing_menu"
     action="view_services_window"
+    groups="energy_communities.role_platform_admin_res_groups,energy_communities.role_coord_admin_res_groups"
     sequence="200"
   />
   <menuitem
     name="Service Packs"
     id="view_service_packs_menu"
-    parent="ce_service_invoicing_menu_platform_manager"
+    parent="ce_service_invoicing_menu"
     action="view_service_packs_window"
+    groups="energy_communities.role_platform_admin_res_groups,energy_communities.role_coord_admin_res_groups"
     sequence="300"
   />
   <menuitem
     name="Service Packs templates"
     id="view_service_contract_templates_menu"
-    parent="ce_service_invoicing_menu_platform_manager"
+    parent="ce_service_invoicing_menu"
     action="view_service_contract_templates_window"
+    groups="energy_communities.role_platform_admin_res_groups"
     sequence="400"
   />
   <menuitem
     name="Service invoices issued"
     id="view_service_invoices_issued_menu"
-    parent="ce_service_invoicing_menu_platform_manager"
+    parent="ce_service_invoicing_menu"
     action="view_service_invoices_issued_window"
     groups="energy_communities.role_platform_admin_res_groups"
     sequence="500"
@@ -47,7 +58,7 @@
   <menuitem
     name="Service invoices received"
     id="view_service_invoices_received_menu"
-    parent="ce_service_invoicing_menu_platform_manager"
+    parent="ce_service_invoicing_menu"
     action="view_service_invoices_received_window"
     groups="energy_communities.role_coord_admin_res_groups,energy_communities.role_coord_worker_res_groups"
     sequence="500"
@@ -55,15 +66,17 @@
   <menuitem
     name="Service actions (sale orders)"
     id="view_service_sale_orders_menu"
-    parent="ce_service_invoicing_menu_platform_manager"
+    parent="ce_service_invoicing_menu"
     action="view_service_sale_orders_window"
+    groups="energy_communities.role_platform_admin_res_groups"
     sequence="550"
   />
   <menuitem
     name="Tariffs"
     id="view_service_tariffs_menu"
-    parent="ce_service_invoicing_menu_platform_manager"
+    parent="ce_service_invoicing_menu"
     action="view_service_tariffs_window"
+    groups="energy_communities.role_platform_admin_res_groups"
     sequence="600"
   />
 </odoo>
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
index 7ddea48f0..32582e7e5 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
@@ -47,6 +47,7 @@
     name="Assign pack to community"
     action="service_invoicing_action_create_wizard_action"
     parent="energy_communities.ce_assistants_menu"
+    groups="energy_communities.role_platform_admin_res_groups"
     sequence="100"
   />
 </odoo>
-- 
GitLab


From 1b1bd6828f310da148b1766070faede34cc935cf Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Tue, 18 Feb 2025 10:56:43 +0100
Subject: [PATCH 44/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20ACLs=20and=20Record?=
 =?UTF-8?q?=20rules=20for=20some=20needed=20models=20on=20service=20invoic?=
 =?UTF-8?q?ing?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../__manifest__.py                           |  3 +
 .../data/contract_line_qty_formula_data.xml   |  1 +
 .../models/__init__.py                        |  1 +
 .../models/contract_line_formula.py           | 10 +++
 .../security/ir_rule_data.xml                 | 79 +++++++++++++++++++
 .../views/contract_line_formula_views.xml     | 12 +++
 .../views/contract_views.xml                  |  4 +-
 .../data/contract_line_qty_formula_data.xml   |  3 +
 8 files changed, 111 insertions(+), 2 deletions(-)
 create mode 100644 energy_communities_service_invoicing/models/contract_line_formula.py
 create mode 100644 energy_communities_service_invoicing/views/contract_line_formula_views.xml

diff --git a/energy_communities_service_invoicing/__manifest__.py b/energy_communities_service_invoicing/__manifest__.py
index a09779105..6eb803fab 100644
--- a/energy_communities_service_invoicing/__manifest__.py
+++ b/energy_communities_service_invoicing/__manifest__.py
@@ -15,6 +15,8 @@
         "base",
         "contract",
         "sale",
+        "purchase",
+        "product",
         "product_contract",
         "contract_variable_quantity",
         "energy_communities",
@@ -27,6 +29,7 @@
         "data/contract_cron.xml",
         "data/contract_line_qty_formula_data.xml",
         "data/product_data.xml",
+        "views/contract_line_formula_views.xml",
         "views/contract_views.xml",
         "views/sale_order_views.xml",
         "views/service_invoicing_views.xml",
diff --git a/energy_communities_service_invoicing/data/contract_line_qty_formula_data.xml b/energy_communities_service_invoicing/data/contract_line_qty_formula_data.xml
index 2a58d0c02..c65eae7e2 100644
--- a/energy_communities_service_invoicing/data/contract_line_qty_formula_data.xml
+++ b/energy_communities_service_invoicing/data/contract_line_qty_formula_data.xml
@@ -11,6 +11,7 @@ result = env['cooperative.membership'].sudo().search_count([
 ('member','=',True)
 ])
       </field>
+      <field name="company_id" eval="ref('base.main_company')" />
     </record>
   </data>
 </odoo>
diff --git a/energy_communities_service_invoicing/models/__init__.py b/energy_communities_service_invoicing/models/__init__.py
index 3beedf2f4..55018fd03 100644
--- a/energy_communities_service_invoicing/models/__init__.py
+++ b/energy_communities_service_invoicing/models/__init__.py
@@ -1,6 +1,7 @@
 from . import abstract_contract
 from . import account_move
 from . import contract
+from . import contract_line_formula
 from . import contract_template
 from . import product_template
 from . import sale_order
diff --git a/energy_communities_service_invoicing/models/contract_line_formula.py b/energy_communities_service_invoicing/models/contract_line_formula.py
new file mode 100644
index 000000000..f39384a85
--- /dev/null
+++ b/energy_communities_service_invoicing/models/contract_line_formula.py
@@ -0,0 +1,10 @@
+from odoo import api, fields, models
+
+
+class ContractLineFormula(models.Model):
+    _name = "contract.line.qty.formula"
+    _inherit = "contract.line.qty.formula"
+
+    company_id = fields.Many2one(
+        "res.company", default=lambda self: self.env.company, required=True
+    )
diff --git a/energy_communities_service_invoicing/security/ir_rule_data.xml b/energy_communities_service_invoicing/security/ir_rule_data.xml
index ea94cd91a..74272a276 100644
--- a/energy_communities_service_invoicing/security/ir_rule_data.xml
+++ b/energy_communities_service_invoicing/security/ir_rule_data.xml
@@ -71,6 +71,31 @@
     <value eval="{'noupdate': True}" />
     </function>
 
+  <!-- CONTRACT LINE -->
+  <function name="write" model="ir.model.data">
+      <function name="search" model="ir.model.data">
+          <value eval="[('module', '=', 'contract'),('name', '=', 'rule_contract_line_multi_company')]"/>
+      </function>
+      <value eval="{'noupdate': False}" />
+  </function>
+  <record model="ir.rule" id="contract.rule_contract_line_multi_company">
+
+    <field name="domain_force">
+[
+'|','|',
+('partner_id','=',user.user_current_company.partner_id.id),
+('company_id','=',False),
+('company_id','in',company_ids)
+]
+    </field>
+  </record>
+  <function name="write" model="ir.model.data">
+    <function name="search" model="ir.model.data">
+        <value eval="[('module', '=', 'contract'),('name', '=', 'rule_contract_line_multi_company')]"/>
+    </function>
+    <value eval="{'noupdate': True}" />
+  </function>
+
   <!-- PRODUCT TEMPLATE -->
   <function name="write" model="ir.model.data">
       <function name="search" model="ir.model.data">
@@ -112,4 +137,58 @@
     <field name="perm_create" eval="True" />
     <field name="perm_unlink" eval="True" />
   </record>
+
+  <!-- CONTRACT LINE QUANTITY FORMULA -->
+  <record model="ir.rule" id="energy_communities_service_invoicing.rule_contract_line_qty_formula_multi_company">
+    <field name="name">Contract Line Formula Multicompany</field>
+    <field name="model_id" ref="model_contract_line_qty_formula"/>
+    <field name="domain_force">[('company_id', 'in', company_ids)]</field>
+    <field name="perm_read" eval="True" />
+    <field name="perm_write" eval="True" />
+    <field name="perm_create" eval="True" />
+    <field name="perm_unlink" eval="True" />
+  </record>
+
+  <!-- PRODUCT PRICELIST -->
+  <function name="write" model="ir.model.data">
+      <function name="search" model="ir.model.data">
+          <value eval="[('module', '=', 'product'),('name', '=', 'product_pricelist_comp_rule')]"/>
+      </function>
+      <value eval="{'noupdate': False}" />
+  </function>
+  <record model="ir.rule" id="product.product_pricelist_comp_rule">
+    <field name="perm_read" eval="True"/>
+    <field name="perm_write" eval="False"/>
+    <field name="perm_create" eval="False"/>
+    <field name="perm_unlink" eval="False"/>
+  </record>
+  <function name="write" model="ir.model.data">
+    <function name="search" model="ir.model.data">
+        <value eval="[('module', '=', 'product'),('name', '=', 'product_pricelist_comp_rule')]"/>
+    </function>
+    <value eval="{'noupdate': True}" />
+  </function>
+
+  <record model="ir.rule" id="energy_communities_service_invoicing.rule_product_pricelist_coord_admin">
+    <field name="name">Pricelist - Coordinator admin</field>
+    <field name="model_id" ref="product.model_product_pricelist"/>
+    <field name="groups" eval="[(4, ref('energy_communities.role_coord_admin_res_groups'))]"/>
+    <field name="domain_force">[('company_id', 'in', company_ids)]</field>
+    <field name="perm_read" eval="False" />
+    <field name="perm_write" eval="True" />
+    <field name="perm_create" eval="False" />
+    <field name="perm_unlink" eval="True" />
+  </record>
+
+  <record model="ir.rule" id="energy_communities_service_invoicing.rule_product_pricelist_platform_admin">
+    <field name="name">Pricelist - Platform admin</field>
+    <field name="model_id" ref="product.model_product_pricelist"/>
+    <field name="groups" eval="[(4, ref('energy_communities.role_platform_admin_res_groups'))]"/>
+    <field name="domain_force">[(1, '=', 1)]</field>
+    <field name="perm_read" eval="False" />
+    <field name="perm_write" eval="True" />
+    <field name="perm_create" eval="True" />
+    <field name="perm_unlink" eval="True" />
+  </record>
+
 </odoo>
diff --git a/energy_communities_service_invoicing/views/contract_line_formula_views.xml b/energy_communities_service_invoicing/views/contract_line_formula_views.xml
new file mode 100644
index 000000000..10fcf10c7
--- /dev/null
+++ b/energy_communities_service_invoicing/views/contract_line_formula_views.xml
@@ -0,0 +1,12 @@
+<odoo>
+  <record id="view_contract_line_qty_formula_form" model="ir.ui.view">
+    <field name="name">contract.line.qty.formula form(in energy_communities service_invoicing)</field>
+    <field name="model">contract.line.qty.formula</field>
+    <field name="inherit_id" ref="contract_variable_quantity.view_contract_line_qty_formula_form" />
+    <field name="arch" type="xml">
+      <xpath expr="//field[@name='code']" position="before">
+        <field name="company_id" />
+      </xpath>
+    </field>
+  </record>
+</odoo>
diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index 26de8ad93..ddb3c0d30 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -63,6 +63,7 @@
           <field name="status" widget="statusbar" />
         </header>
         <sheet>
+          <!--TODO: Not working: redirect to invoices issued menu -->
           <div class="oe_button_box" name="button_box">
             <button
               name="action_show_invoices"
@@ -79,9 +80,8 @@
           </div>
           <group>
             <field name="name" />
-            <field name="service_pack_id" />
+            <field name="service_pack_id" readonly="1" />
             <field name="pricelist_id" />
-            <field name="service_pack_id" />
             <field name="discount" />
             <!--TODO: Instead of contract template id we must show related service products -->
           </group>
diff --git a/energy_selfconsumption/data/contract_line_qty_formula_data.xml b/energy_selfconsumption/data/contract_line_qty_formula_data.xml
index b5f974949..289add01c 100644
--- a/energy_selfconsumption/data/contract_line_qty_formula_data.xml
+++ b/energy_selfconsumption/data/contract_line_qty_formula_data.xml
@@ -12,6 +12,7 @@ else:
   days_between = 0
 result = contract.supply_point_assignation_id.distribution_table_id.selfconsumption_project_id.power * contract.supply_point_assignation_id.coefficient *  days_between
             </field>
+            <field name="company_id" eval="ref('base.main_company')" />
         </record>
         <record id="energy_delivered_formula" model="contract.line.qty.formula">
             <field name="name">Energy Delivered Formula</field>
@@ -21,6 +22,7 @@ if 'energy_delivered' in context:
   energy_delivered = context['energy_delivered']
 result = energy_delivered * contract.supply_point_assignation_id.coefficient
             </field>
+            <field name="company_id" eval="ref('base.main_company')" />
         </record>
         <record
       id="energy_delivered_variable_formula"
@@ -30,6 +32,7 @@ result = energy_delivered * contract.supply_point_assignation_id.coefficient
             <field name="code">
 result = 0
             </field>
+            <field name="company_id" eval="ref('base.main_company')" />
         </record>
     </data>
 </odoo>
-- 
GitLab


From fb1a361900b8d9bf29273f8f8ee9df476915c9e6 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Tue, 18 Feb 2025 11:30:05 +0100
Subject: [PATCH 45/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Contract=20template?=
 =?UTF-8?q?=20record=20rules?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../security/ir_rule_data.xml                 | 88 ++++++++++++++++++-
 .../views/contract_views.xml                  |  2 +-
 2 files changed, 86 insertions(+), 4 deletions(-)

diff --git a/energy_communities_service_invoicing/security/ir_rule_data.xml b/energy_communities_service_invoicing/security/ir_rule_data.xml
index 74272a276..b0580adc4 100644
--- a/energy_communities_service_invoicing/security/ir_rule_data.xml
+++ b/energy_communities_service_invoicing/security/ir_rule_data.xml
@@ -2,7 +2,7 @@
   <!-- CONTRACT -->
   <record model="ir.rule" id="energy_communities_service_invoicing.rule_contract_contract_admin">
     <field name="name">Contract admins</field>
-    <field name="model_id" ref="model_contract_contract"/>
+    <field name="model_id" ref="contract.model_contract_contract"/>
     <field name="groups" eval="[(4, ref('energy_communities.role_platform_admin_res_groups')),(4, ref('energy_communities.role_coord_admin_res_groups'))]"/>
     <field name="domain_force">[('company_id', 'in', company_ids)]</field>
     <field name="perm_read" eval="False" />
@@ -118,7 +118,7 @@
 
   <record model="ir.rule" id="energy_communities_service_invoicing.rule_product_template_coord_admin">
     <field name="name">Product - Coordinator admin</field>
-    <field name="model_id" ref="model_product_template"/>
+    <field name="model_id" ref="product.model_product_template"/>
     <field name="groups" eval="[(4, ref('energy_communities.role_coord_admin_res_groups'))]"/>
     <field name="domain_force">[('company_id', 'in', company_ids)]</field>
     <field name="perm_read" eval="False" />
@@ -129,7 +129,7 @@
 
   <record model="ir.rule" id="energy_communities_service_invoicing.rule_product_template_platform_admin">
     <field name="name">Product - Platform admin</field>
-    <field name="model_id" ref="model_product_template"/>
+    <field name="model_id" ref="product.model_product_template"/>
     <field name="groups" eval="[(4, ref('energy_communities.role_platform_admin_res_groups'))]"/>
     <field name="domain_force">[(1, '=', 1)]</field>
     <field name="perm_read" eval="False" />
@@ -138,6 +138,88 @@
     <field name="perm_unlink" eval="True" />
   </record>
 
+  <!-- CONTRACT TEMPLATE -->
+  <function name="write" model="ir.model.data">
+      <function name="search" model="ir.model.data">
+          <value eval="[('module', '=', 'contract'),('name', '=', 'rule_contract_template_line_multi_company')]"/>
+      </function>
+      <value eval="{'noupdate': False}" />
+  </function>
+  <record model="ir.rule" id="contract.rule_contract_template_line_multi_company">
+    <field name="perm_read" eval="True"/>
+    <field name="perm_write" eval="False"/>
+    <field name="perm_create" eval="False"/>
+    <field name="perm_unlink" eval="False"/>
+  </record>
+  <function name="write" model="ir.model.data">
+    <function name="search" model="ir.model.data">
+        <value eval="[('module', '=', 'contract'),('name', '=', 'rule_contract_template_line_multi_company')]"/>
+    </function>
+    <value eval="{'noupdate': True}" />
+  </function>
+  <function name="write" model="ir.model.data">
+      <function name="search" model="ir.model.data">
+          <value eval="[('module', '=', 'contract'),('name', '=', 'rule_contract_template_multi_company')]"/>
+      </function>
+      <value eval="{'noupdate': False}" />
+  </function>
+  <record model="ir.rule" id="contract.rule_contract_template_multi_company">
+    <field name="perm_read" eval="True"/>
+    <field name="perm_write" eval="False"/>
+    <field name="perm_create" eval="False"/>
+    <field name="perm_unlink" eval="False"/>
+  </record>
+  <function name="write" model="ir.model.data">
+    <function name="search" model="ir.model.data">
+        <value eval="[('module', '=', 'contract'),('name', '=', 'rule_contract_template_multi_company')]"/>
+    </function>
+    <value eval="{'noupdate': True}" />
+  </function>
+
+  <record model="ir.rule" id="energy_communities_service_invoicing.rule_contract_template_platform_admin">
+    <field name="name">Contract template platform admins</field>
+    <field name="model_id" ref="contract.model_contract_template"/>
+    <field name="groups" eval="[(4, ref('energy_communities.role_platform_admin_res_groups'))]"/>
+    <field name="domain_force">[(1, '=', 1)]</field>
+    <field name="perm_read" eval="False" />
+    <field name="perm_write" eval="True" />
+    <field name="perm_create" eval="True" />
+    <field name="perm_unlink" eval="True" />
+  </record>
+
+  <record model="ir.rule" id="energy_communities_service_invoicing.rule_contract_template_coord_admin">
+    <field name="name">Contract template coordinator admins</field>
+    <field name="model_id" ref="contract.model_contract_template"/>
+    <field name="groups" eval="[(4, ref('energy_communities.role_coord_admin_res_groups'))]"/>
+    <field name="domain_force">[('company_id', 'in', company_ids)]</field>
+    <field name="perm_read" eval="False" />
+    <field name="perm_write" eval="True" />
+    <field name="perm_create" eval="True" />
+    <field name="perm_unlink" eval="True" />
+  </record>
+
+  <record model="ir.rule" id="energy_communities_service_invoicing.rule_contract_template_line_platform_admin">
+    <field name="name">Contract template line platform admins</field>
+    <field name="model_id" ref="contract.model_contract_template_line"/>
+    <field name="groups" eval="[(4, ref('energy_communities.role_platform_admin_res_groups'))]"/>
+    <field name="domain_force">[(1, '=', 1)]</field>
+    <field name="perm_read" eval="False" />
+    <field name="perm_write" eval="True" />
+    <field name="perm_create" eval="True" />
+    <field name="perm_unlink" eval="True" />
+  </record>
+
+  <record model="ir.rule" id="energy_communities_service_invoicing.rule_contract_template_line_coord_admin">
+    <field name="name">Contract template line coordinator admins</field>
+    <field name="model_id" ref="contract.model_contract_template_line"/>
+    <field name="groups" eval="[(4, ref('energy_communities.role_coord_admin_res_groups'))]"/>
+    <field name="domain_force">[('company_id', 'in', company_ids)]</field>
+    <field name="perm_read" eval="False" />
+    <field name="perm_write" eval="True" />
+    <field name="perm_create" eval="True" />
+    <field name="perm_unlink" eval="True" />
+  </record>
+
   <!-- CONTRACT LINE QUANTITY FORMULA -->
   <record model="ir.rule" id="energy_communities_service_invoicing.rule_contract_line_qty_formula_multi_company">
     <field name="name">Contract Line Formula Multicompany</field>
diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index ddb3c0d30..f3522117c 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -80,7 +80,7 @@
           </div>
           <group>
             <field name="name" />
-            <field name="service_pack_id" readonly="1" />
+            <field name="service_pack_id" options="{'no_open': True}" />
             <field name="pricelist_id" />
             <field name="discount" />
             <!--TODO: Instead of contract template id we must show related service products -->
-- 
GitLab


From 08e3bac45fbf1bcb107b461a0cb6304f72afb341 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Tue, 18 Feb 2025 12:14:37 +0100
Subject: [PATCH 46/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Contract=20related=20?=
 =?UTF-8?q?services?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../models/contract.py                           | 16 ++++++++++++++++
 .../models/product_template.py                   | 16 ++++++++++++++++
 .../views/contract_views.xml                     |  8 ++++++++
 3 files changed, 40 insertions(+)

diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index 4652c7487..4728a8215 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -37,6 +37,12 @@ class ContractContract(models.Model):
         string="Last Date Invoiced", compute="_compute_last_date_invoiced", store=False
     )
     is_pack = fields.Boolean(related="contract_template_id.is_pack")
+    related_contract_product_ids = fields.One2many(
+        "product.product",
+        string="Related services",
+        compute="_compute_related_contract_product_ids",
+        store=False,
+    )
     service_pack_id = fields.Many2one(
         "product.product",
         string="Service Pack",
@@ -50,6 +56,16 @@ class ContractContract(models.Model):
     # On energy_communities all contracts have skip_zero_qty marked by default
     skip_zero_qty = fields.Boolean(default=True)
 
+    @api.depends("contract_template_id")
+    def _compute_related_contract_product_ids(self):
+        for record in self:
+            rel_products = [(5, 0, 0)]
+            record.related_contract_product_ids = rel_products
+            if record.contract_template_id:
+                for line in record.contract_template_id.contract_line_ids:
+                    rel_products.append((4, line.product_id.id))
+                record.related_contract_product_ids = rel_products
+
     @api.depends("contract_line_ids")
     def _compute_discount(self):
         for record in self:
diff --git a/energy_communities_service_invoicing/models/product_template.py b/energy_communities_service_invoicing/models/product_template.py
index d6ee536cc..662106d75 100644
--- a/energy_communities_service_invoicing/models/product_template.py
+++ b/energy_communities_service_invoicing/models/product_template.py
@@ -7,6 +7,22 @@ class ProductTemplate(models.Model):
     property_contract_template_id = fields.Many2one(
         company_dependent=False,
     )
+    related_contract_product_ids = fields.One2many(
+        "product.product",
+        string="Related services",
+        compute="_compute_related_contract_product_ids",
+        store=False,
+    )
+
+    @api.depends("property_contract_template_id")
+    def _compute_related_contract_product_ids(self):
+        for record in self:
+            rel_products = [(5, 0, 0)]
+            record.related_contract_product_ids = rel_products
+            if record.property_contract_template_id:
+                for line in record.property_contract_template_id.contract_line_ids:
+                    rel_products.append((4, line.product_id.id))
+                record.related_contract_product_ids = rel_products
 
     @api.constrains("property_contract_template_id")
     def compute_contract_template_is_pack(self):
diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index f3522117c..772d73dda 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -81,6 +81,14 @@
           <group>
             <field name="name" />
             <field name="service_pack_id" options="{'no_open': True}" />
+            <field name="related_contract_product_ids" widget="one2many" >
+              <tree editable="bottom">
+                <field name="name" readonly="1"/>
+              </tree>
+              <form>
+                <field name="name" readonly="1"/>
+              </form>
+            </field>
             <field name="pricelist_id" />
             <field name="discount" />
             <!--TODO: Instead of contract template id we must show related service products -->
-- 
GitLab


From a9b94dd641f2ed951d102e4b3426bfe5ba150e99 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Tue, 18 Feb 2025 15:25:01 +0100
Subject: [PATCH 47/85] =?UTF-8?q?[WIP]=20=F0=9F=9A=A7=20Show=20received=20?=
 =?UTF-8?q?invoices=20from=20a=20contract?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../models/contract.py                        | 40 +++++++++++++++++++
 .../views/contract_views.xml                  | 28 ++++++-------
 2 files changed, 54 insertions(+), 14 deletions(-)

diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index 4728a8215..3daf0896f 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -55,6 +55,11 @@ class ContractContract(models.Model):
     )
     # On energy_communities all contracts have skip_zero_qty marked by default
     skip_zero_qty = fields.Boolean(default=True)
+    received_invoices_count = fields.Integer(compute="_compute_received_invoices_count")
+
+    def _compute_received_invoices_count(self):
+        for record in self:
+            record.received_invoices_count = len(record._get_received_invoices_ids())
 
     @api.depends("contract_template_id")
     def _compute_related_contract_product_ids(self):
@@ -130,6 +135,41 @@ class ContractContract(models.Model):
             "res_id": wizard.id,
         }
 
+    def action_show_received_invoices(self):
+        self.ensure_one()
+        tree_view = self.env.ref("account.view_invoice_tree", raise_if_not_found=False)
+        form_view = self.env.ref("account.view_move_form", raise_if_not_found=False)
+        ctx = dict(self.env.context)
+        ctx["default_move_type"] = "in_invoice"
+        action = {
+            "type": "ir.actions.act_window",
+            "name": "Invoices",
+            "res_model": "account.move",
+            "view_mode": "tree,form",
+            "domain": [("id", "in", self._get_received_invoices_ids())],
+            "context": ctx,
+        }
+        if tree_view and form_view:
+            action["views"] = [(tree_view.id, "tree"), (form_view.id, "form")]
+        return action
+
+    # TODO: Not working. Lack of access rules
+    def _get_received_invoices_ids(self):
+        received_invoices = []
+        issued_invoices = self.sudo()._get_related_invoices().ids
+        # related_partner = self.env["res.partner"].sudo.
+        all_received_invoices = self.env["account.move"].search(
+            [
+                ("partner_id", "=", self.sudo().company_id.partner_id.id),
+                ("move_type", "=", "in_invoice"),
+            ]
+        )
+        for invoice in all_received_invoices:
+            if invoice.sudo().ref_invoice_id:
+                if invoice.sudo().ref_invoice_id.id in issued_invoices:
+                    received_invoices.append(invoice.id)
+        return received_invoices
+
     @api.model
     def cron_close_todays_closed_planned_contacts(self):
         impacted_contracts = self.env["contract.contract"].search(
diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index 772d73dda..225cb4423 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -64,20 +64,20 @@
         </header>
         <sheet>
           <!--TODO: Not working: redirect to invoices issued menu -->
-          <div class="oe_button_box" name="button_box">
-            <button
-              name="action_show_invoices"
-              type="object"
-              icon="fa-list"
-              class="oe_stat_button"
-            >
-              <field
-                string="Invoices"
-                name="invoice_count"
-                widget="statinfo"
-              />
-            </button>
-          </div>
+          <!--<div class="oe_button_box" name="button_box">-->
+          <!--  <button-->
+          <!--    name="action_show_received_invoices"-->
+          <!--    type="object"-->
+          <!--    icon="fa-list"-->
+          <!--    class="oe_stat_button"-->
+          <!--  >-->
+          <!--    <field-->
+          <!--      string="Invoices"-->
+          <!--      name="received_invoices_count"-->
+          <!--      widget="statinfo"-->
+          <!--    />-->
+          <!--  </button>-->
+          <!--</div>-->
           <group>
             <field name="name" />
             <field name="service_pack_id" options="{'no_open': True}" />
-- 
GitLab


From 5b1df4dd91f2d41a60c08d9be0038d7b58479298 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Tue, 18 Feb 2025 17:13:37 +0100
Subject: [PATCH 48/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Display=20Active=20se?=
 =?UTF-8?q?rvice=20pack=20on=20community=20partner=20view?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 energy_communities/models/res_partner.py      | 14 +++---
 .../views/res_partner_views.xml               |  2 +-
 .../__manifest__.py                           |  1 +
 .../models/__init__.py                        |  1 +
 .../models/res_partner.py                     | 47 +++++++++++++++++++
 .../views/res_partner_views.xml               | 14 ++++++
 6 files changed, 71 insertions(+), 8 deletions(-)
 create mode 100644 energy_communities_service_invoicing/models/res_partner.py
 create mode 100644 energy_communities_service_invoicing/views/res_partner_views.xml

diff --git a/energy_communities/models/res_partner.py b/energy_communities/models/res_partner.py
index a2ad9155f..d83b6bad6 100644
--- a/energy_communities/models/res_partner.py
+++ b/energy_communities/models/res_partner.py
@@ -59,19 +59,19 @@ class ResPartner(models.Model):
 
     def compute_company_hierarchy_level(self):
         for record in self:
-            try:
-                related_company_id = record.related_company_id
-            except:
-                related_company_id = False
-            if related_company_id:
+            record.company_hierarchy_level = "none"
+            if record.related_company_id:
                 record.company_hierarchy_level = (
                     record.related_company_id.hierarchy_level
                 )
 
     def compute_related_company_id(self):
         for record in self:
-            related_company_id = self.env["res.company"].search(
-                [("partner_id", "=", record.id)], limit=1
+            record.related_company_id = False
+            related_company_id = (
+                self.env["res.company"]
+                .sudo()
+                .search([("partner_id", "=", record.id)], limit=1)
             )
             if related_company_id:
                 record.related_company_id = related_company_id[0].id
diff --git a/energy_communities/views/res_partner_views.xml b/energy_communities/views/res_partner_views.xml
index 4d95e3659..ccc795602 100644
--- a/energy_communities/views/res_partner_views.xml
+++ b/energy_communities/views/res_partner_views.xml
@@ -46,7 +46,7 @@
                 <xpath expr="//field[@name='vat']" position="after">
                   <field name="company_hierarchy_level" invisible="1" />
                   <field name="user_current_role" />
-                  <field name="related_company_id" attrs="{'invisible': [('company_hierarchy_level', '=', 'none')]}" />
+                  <field name="related_company_id" options="{'no_open': True}" readonly="1" attrs="{'invisible': [('company_hierarchy_level', '=', 'none')]}" />
                 </xpath>
                 <xpath expr="//field[@name='name']" position="before">
                   <h4
diff --git a/energy_communities_service_invoicing/__manifest__.py b/energy_communities_service_invoicing/__manifest__.py
index 6eb803fab..37ce926fc 100644
--- a/energy_communities_service_invoicing/__manifest__.py
+++ b/energy_communities_service_invoicing/__manifest__.py
@@ -31,6 +31,7 @@
         "data/product_data.xml",
         "views/contract_line_formula_views.xml",
         "views/contract_views.xml",
+        "views/res_partner_views.xml",
         "views/sale_order_views.xml",
         "views/service_invoicing_views.xml",
         "views/menus.xml",
diff --git a/energy_communities_service_invoicing/models/__init__.py b/energy_communities_service_invoicing/models/__init__.py
index 55018fd03..2deeec9c8 100644
--- a/energy_communities_service_invoicing/models/__init__.py
+++ b/energy_communities_service_invoicing/models/__init__.py
@@ -4,4 +4,5 @@ from . import contract
 from . import contract_line_formula
 from . import contract_template
 from . import product_template
+from . import res_partner
 from . import sale_order
diff --git a/energy_communities_service_invoicing/models/res_partner.py b/energy_communities_service_invoicing/models/res_partner.py
new file mode 100644
index 000000000..02db8bb7b
--- /dev/null
+++ b/energy_communities_service_invoicing/models/res_partner.py
@@ -0,0 +1,47 @@
+from odoo import _, api, fields, models
+
+from ..utils import _CONTRACT_STATUS_VALUES
+
+_PACK_CONTRACT_STATUS_VALUES = _CONTRACT_STATUS_VALUES + [("none", _("None"))]
+
+
+class ResPartner(models.Model):
+    _name = "res.partner"
+    _inherit = ["res.partner"]
+
+    service_pack_id = fields.Many2one(
+        "product.product",
+        string="Service Pack",
+        compute="_compute_service_pack_id",
+        store=False,
+    )
+    pack_contract_status = fields.Selection(
+        selection=_PACK_CONTRACT_STATUS_VALUES,
+        string="Service Pack Status",
+        compute="_compute_service_pack_status",
+        store=False,
+    )
+
+    def _compute_service_pack_status(self):
+        for record in self:
+            record.pack_contract_status = "none"
+            rel_contract = record._get_related_service_contract()
+            if rel_contract:
+                record.pack_contract_status = rel_contract.status
+
+    def _compute_service_pack_id(self):
+        for record in self:
+            record.service_pack_id = False
+            rel_contract = record._get_related_service_contract()
+            if rel_contract:
+                if rel_contract.service_pack_id:
+                    record.service_pack_id = rel_contract.service_pack_id.id
+
+    def _get_related_service_contract(self):
+        return self.env["contract.contract"].search(
+            [
+                ("community_company_id", "=", self.related_company_id.id),
+                ("is_pack", "=", True),
+            ],
+            limit=1,
+        )
diff --git a/energy_communities_service_invoicing/views/res_partner_views.xml b/energy_communities_service_invoicing/views/res_partner_views.xml
new file mode 100644
index 000000000..87850b0f4
--- /dev/null
+++ b/energy_communities_service_invoicing/views/res_partner_views.xml
@@ -0,0 +1,14 @@
+<odoo>
+  <record id="view_partner_form" model="ir.ui.view">
+    <field name="name">view_partner_form</field>
+    <field name="model">res.partner</field>
+    <field name="inherit_id" ref="base.view_partner_form" />
+    <field name="arch" type="xml">
+      <xpath expr="//field[@name='vat']" position="after">
+        <field name="company_hierarchy_level" invisible="1" />
+        <field name="service_pack_id" attrs="{'invisible': [('company_hierarchy_level', '!=', 'community')]}" options="{'no_open': True}" />
+        <field name="pack_contract_status" attrs="{'invisible': [('company_hierarchy_level', '!=', 'community')]}" />
+      </xpath>
+    </field>
+  </record>
+</odoo>
-- 
GitLab


From ea817df20adfc7fd8e963f9e815b571533fd754a Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Tue, 18 Feb 2025 18:27:37 +0100
Subject: [PATCH 49/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Contract=20reopen=20w?=
 =?UTF-8?q?orkflow?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../components/contract_utils.py              | 69 ++++++++++++++-----
 .../models/contract.py                        |  3 +
 energy_communities_service_invoicing/utils.py |  1 +
 .../views/contract_views.xml                  |  6 ++
 .../wizards/service_invoicing_action.py       |  9 +++
 .../wizards/service_invoicing_action.xml      | 13 +++-
 6 files changed, 83 insertions(+), 18 deletions(-)

diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
index 3acd60084..9315b97c0 100644
--- a/energy_communities_service_invoicing/components/contract_utils.py
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -48,26 +48,17 @@ class ContractUtils(Component):
         service_pack_id=None,
     ):
         initial_status = self.work.record.status
-        executed_modification_action_list = executed_modification_action.split(",")
         self.set_contract_status_closed(execution_date)
         sale_order_utils = self.component(
             usage="sale.order.utils", model_name="sale.order"
         )
-        service_invoicing_params = {
-            "company_id": self.work.record.partner_id.related_company_id,
-            "community_company_id": self.work.record.community_company_id,
-            "service_pack_id": service_pack_id
-            if "modify_service_pack" in executed_modification_action_list
-            else self.work.record.service_pack_id,
-            "pricelist_id": pricelist_id
-            if "modify_pricelist" in executed_modification_action_list
-            else self.work.record.pricelist_id,
-            "payment_mode_id": self.work.record.payment_mode_id,
-            "start_date": execution_date + timedelta(days=1),
-            "executed_action": "modification",
-            "executed_modification_action": executed_modification_action,
-            "discount": self.work.record.discount,
-        }
+        service_invoicing_params = self._build_service_invoicing_params(
+            "modification",
+            executed_modification_action,
+            execution_date,
+            pricelist_id,
+            service_pack_id,
+        )
         if initial_status == "ready_to_start":
             new_service_invoicing_id = (
                 sale_order_utils.create_service_invoicing_ready_to_start(
@@ -82,6 +73,52 @@ class ContractUtils(Component):
         self._setup_successors_and_predecessors(new_service_invoicing_id)
         return new_service_invoicing_id
 
+    def reopen(
+        self,
+        execution_date,
+        pricelist_id=None,
+        service_pack_id=None,
+    ):
+        self.set_contract_status_closed(execution_date)
+        new_service_invoicing_id = self.component(
+            usage="sale.order.utils", model_name="sale.order"
+        ).create_service_invoicing_ready_to_start(
+            **self._build_service_invoicing_params(
+                "reopen",
+                "modify_service_pack,modify_pricelist",
+                execution_date,
+                pricelist_id,
+                service_pack_id,
+            )
+        )
+        self._setup_successors_and_predecessors(new_service_invoicing_id)
+        return new_service_invoicing_id
+
+    def _build_service_invoicing_params(
+        self,
+        executed_action,
+        executed_modification_action,
+        execution_date,
+        pricelist_id=None,
+        service_pack_id=None,
+    ):
+        executed_modification_action_list = executed_modification_action.split(",")
+        return {
+            "company_id": self.work.record.partner_id.related_company_id,
+            "community_company_id": self.work.record.community_company_id,
+            "service_pack_id": service_pack_id
+            if "modify_service_pack" in executed_modification_action_list
+            else self.work.record.service_pack_id,
+            "pricelist_id": pricelist_id
+            if "modify_pricelist" in executed_modification_action_list
+            else self.work.record.pricelist_id,
+            "payment_mode_id": self.work.record.payment_mode_id,
+            "start_date": execution_date + timedelta(days=1),
+            "executed_action": executed_action,
+            "executed_modification_action": executed_modification_action,
+            "discount": self.work.record.discount,
+        }
+
     def _is_service_line(self, contract_line):
         if self.work.record.contract_template_id:
             contract_template_services = (
diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index 3daf0896f..32407f1e4 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -120,6 +120,9 @@ class ContractContract(models.Model):
     def action_modify_contract(self):
         return self._action_contract("modification")
 
+    def action_reopen_contract(self):
+        return self._action_contract("reopen")
+
     def _action_contract(self, action):
         self.ensure_one()
         wizard = self.env["service.invoicing.action.wizard"].create(
diff --git a/energy_communities_service_invoicing/utils.py b/energy_communities_service_invoicing/utils.py
index d7c96fccc..0297abeed 100644
--- a/energy_communities_service_invoicing/utils.py
+++ b/energy_communities_service_invoicing/utils.py
@@ -12,6 +12,7 @@ _CONTRACT_STATUS_VALUES = [
 _SERVICE_INVOICING_EXECUTED_ACTION_VALUES = [
     ("activate", _("Activate")),
     ("modification", _("Modification")),
+    ("reopen", _("Reopen")),
     ("close", _("Close")),
 ]
 _SALE_ORDER_SERVICE_INVOICING_ACTION_VALUES = [
diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index 225cb4423..ad9ff43a1 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -131,6 +131,12 @@
           string="Close"
           attrs="{'invisible':[('status','not in',['ready_to_start','in_progress'])]}"
         />
+        <button
+          name="action_reopen_contract"
+          type="object"
+          string="Reopen"
+          attrs="{'invisible':[('status','not in',['closed','closed_planned'])]}"
+        />
       </xpath>
       <xpath expr="//field[@name='partner_id']" position="after">
         <field name="community_company_id" />
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action.py b/energy_communities_service_invoicing/wizards/service_invoicing_action.py
index 48ecdc641..a3cdf4aef 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action.py
@@ -44,6 +44,15 @@ class ServiceInvoicingActionWizard(models.TransientModel):
             )
         return service_invoicing_view(self.env, service_invoicing_id)
 
+    def execute_reopen(self):
+        with contract_utils(self.env, self.service_invoicing_id) as component:
+            service_invoicing_id = component.reopen(
+                self.execution_date,
+                self.pricelist_id,
+                self.service_pack_id,
+            )
+        return service_invoicing_view(self.env, service_invoicing_id)
+
     def _validate_execute_modify(self):
         if not self.pricelist_id and not self.service_pack_id:
             raise ValidationError(_("Select at least one value to modify"))
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action.xml b/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
index f491b9829..5e48bef40 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
@@ -15,14 +15,16 @@
             <field
               name="pricelist_id"
               attrs="{
-               'invisible': [('executed_action','!=','modification')],
+               'invisible': [('executed_action','not in',['modification','reopen'])],
+               'required': [('executed_action','=','reopen')]
               }"
             />
             <field
               name="service_pack_id"
               domain="[('is_contract','=',True)]"
               attrs="{
-               'invisible': [('executed_action','!=','modification')],
+                'invisible': [('executed_action','not in',['modification','reopen'])],
+                'required': [('executed_action','=','reopen')]
               }"
             />
           </group>
@@ -49,6 +51,13 @@
             class="btn-primary"
             attrs="{'invisible': [('executed_action','!=','close')]}"
           />
+          <button
+            name="execute_reopen"
+            string="reopen contract"
+            type="object"
+            class="btn-primary"
+            attrs="{'invisible': [('executed_action','!=','reopen')]}"
+          />
           <button
             special="cancel"
             string="Cancelar"
-- 
GitLab


From 3289beaefdcd90da0e1bedace3dfa35bfb1c6374 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Tue, 18 Feb 2025 18:45:58 +0100
Subject: [PATCH 50/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Only=20one=20service?=
 =?UTF-8?q?=20pack=20per=20coordinator=20and=20community?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../models/contract.py                        | 21 ++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index 32407f1e4..d2bb113e5 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -1,7 +1,7 @@
 from datetime import datetime
 
 from odoo import api, fields, models
-from odoo.exceptions import AccessError
+from odoo.exceptions import AccessError, ValidationError
 from odoo.tools.translate import _
 
 from ..utils import _CONTRACT_STATUS_VALUES
@@ -57,6 +57,25 @@ class ContractContract(models.Model):
     skip_zero_qty = fields.Boolean(default=True)
     received_invoices_count = fields.Integer(compute="_compute_received_invoices_count")
 
+    @api.constrains("partner_id", "community_company_id")
+    def _constrain_unique_contract(self):
+        for record in self:
+            if record.community_company_id:
+                existing_contract = self.env["contract.contract"].search(
+                    [
+                        ("partner_id", "=", record.partner_id.id),
+                        ("community_company_id", "=", record.community_company_id.id),
+                        ("id", "!=", record.id),
+                        ("is_pack", "=", True),
+                    ]
+                )
+                if existing_contract:
+                    raise ValidationError(
+                        _(
+                            "It can only exists one service contract per Customer and related community."
+                        )
+                    )
+
     def _compute_received_invoices_count(self):
         for record in self:
             record.received_invoices_count = len(record._get_received_invoices_ids())
-- 
GitLab


From 2f759bbf60534f6e10ef2d69b46cbe3acbe8bec0 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Wed, 19 Feb 2025 09:09:25 +0100
Subject: [PATCH 51/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Avoid=20more=20than?=
 =?UTF-8?q?=20one=20open=20project=20per=20coordinator=20and=20community?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../components/contract_utils.py                              | 4 +++-
 energy_communities_service_invoicing/models/contract.py       | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
index 9315b97c0..457444ea8 100644
--- a/energy_communities_service_invoicing/components/contract_utils.py
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -113,7 +113,9 @@ class ContractUtils(Component):
             if "modify_pricelist" in executed_modification_action_list
             else self.work.record.pricelist_id,
             "payment_mode_id": self.work.record.payment_mode_id,
-            "start_date": execution_date + timedelta(days=1),
+            "start_date": execution_date + timedelta(days=1)
+            if executed_action == "modification"
+            else execution_date,
             "executed_action": executed_action,
             "executed_modification_action": executed_modification_action,
             "discount": self.work.record.discount,
diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index d2bb113e5..09b4302d1 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -67,6 +67,7 @@ class ContractContract(models.Model):
                         ("community_company_id", "=", record.community_company_id.id),
                         ("id", "!=", record.id),
                         ("is_pack", "=", True),
+                        ("status", "in", ["ready_to_start", "in_progress"]),
                     ]
                 )
                 if existing_contract:
-- 
GitLab


From 7dd0c5e77a864f4ca9bff6f25d276565595dc2cf Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Wed, 19 Feb 2025 14:09:50 +0100
Subject: [PATCH 52/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Reopen=20contract=20w?=
 =?UTF-8?q?orkflow.=20On=20contract=20creation.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../models/contract.py                        | 54 +++++++++----------
 energy_communities_service_invoicing/utils.py | 37 +++++++++++++
 .../service_invoicing_action_create.py        | 48 ++++++++++++-----
 3 files changed, 98 insertions(+), 41 deletions(-)

diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index 09b4302d1..1ef9fe56f 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -1,10 +1,13 @@
 from datetime import datetime
 
 from odoo import api, fields, models
-from odoo.exceptions import AccessError, ValidationError
 from odoo.tools.translate import _
 
-from ..utils import _CONTRACT_STATUS_VALUES
+from ..utils import (
+    _CONTRACT_STATUS_VALUES,
+    get_existing_open_contract,
+    raise_existing_same_open_contract_error,
+)
 
 
 class ContractContract(models.Model):
@@ -61,21 +64,9 @@ class ContractContract(models.Model):
     def _constrain_unique_contract(self):
         for record in self:
             if record.community_company_id:
-                existing_contract = self.env["contract.contract"].search(
-                    [
-                        ("partner_id", "=", record.partner_id.id),
-                        ("community_company_id", "=", record.community_company_id.id),
-                        ("id", "!=", record.id),
-                        ("is_pack", "=", True),
-                        ("status", "in", ["ready_to_start", "in_progress"]),
-                    ]
-                )
+                existing_contract = record._get_existing_same_open_contract()
                 if existing_contract:
-                    raise ValidationError(
-                        _(
-                            "It can only exists one service contract per Customer and related community."
-                        )
-                    )
+                    raise_existing_same_open_contract_error()
 
     def _compute_received_invoices_count(self):
         for record in self:
@@ -125,12 +116,6 @@ class ContractContract(models.Model):
                 if rel_product:
                     record.service_pack_id = rel_product.id
 
-    def set_close_status_type_by_date(self):
-        if self.date_end.strftime("%Y-%m-%d") == datetime.now().strftime("%Y-%m-%d"):
-            self.write({"status": "closed"})
-        else:
-            self.write({"status": "closed_planned"})
-
     def action_activate_contract(self):
         return self._action_contract("activate")
 
@@ -176,6 +161,15 @@ class ContractContract(models.Model):
             action["views"] = [(tree_view.id, "tree"), (form_view.id, "form")]
         return action
 
+    @api.model
+    def cron_close_todays_closed_planned_contacts(self):
+        impacted_contracts = self.env["contract.contract"].search(
+            [("status", "closed_planned")]
+        )
+        for contract in impacted_contracts:
+            contract.set_close_status_type_by_date()
+        return True
+
     # TODO: Not working. Lack of access rules
     def _get_received_invoices_ids(self):
         received_invoices = []
@@ -193,11 +187,13 @@ class ContractContract(models.Model):
                     received_invoices.append(invoice.id)
         return received_invoices
 
-    @api.model
-    def cron_close_todays_closed_planned_contacts(self):
-        impacted_contracts = self.env["contract.contract"].search(
-            [("status", "closed_planned")]
+    def _get_existing_same_open_contract(self):
+        return get_existing_open_contract(
+            self.env, self.partner_id, self.community_company_id, self
         )
-        for contract in impacted_contracts:
-            contract.set_close_status_type_by_date()
-        return True
+
+    def set_close_status_type_by_date(self):
+        if self.date_end.strftime("%Y-%m-%d") == datetime.now().strftime("%Y-%m-%d"):
+            self.write({"status": "closed"})
+        else:
+            self.write({"status": "closed_planned"})
diff --git a/energy_communities_service_invoicing/utils.py b/energy_communities_service_invoicing/utils.py
index 0297abeed..47feda5bc 100644
--- a/energy_communities_service_invoicing/utils.py
+++ b/energy_communities_service_invoicing/utils.py
@@ -1,5 +1,6 @@
 from odoo import _
 from odoo.api import Environment
+from odoo.exceptions import ValidationError
 
 from odoo.addons.contract.models.contract import ContractContract
 
@@ -35,3 +36,39 @@ def service_invoicing_view(env: Environment, service_invoicing_id: ContractContr
         "target": "current",
         "res_id": service_invoicing_id.id,
     }
+
+
+# TODO: Think a bit more about more about if this 3 methods must go to contract utils component
+def raise_existing_same_open_contract_error():
+    raise ValidationError(
+        _("It can only exists one service contract per Customer and related community.")
+    )
+
+
+def get_existing_open_contract(
+    env, partner_id, community_company_id, contract_id=False
+):
+    query = [
+        ("partner_id", "=", partner_id.id),
+        ("community_company_id", "=", community_company_id.id),
+        ("is_pack", "=", True),
+        ("status", "in", ["ready_to_start", "in_progress"]),
+    ]
+    if contract_id:
+        query.append(("id", "!=", contract_id.id))
+    return env["contract.contract"].search(query, limit=1)
+
+
+def get_existing_last_closed_contract(
+    env, partner_id, community_company_id, contract_id=False
+):
+    query = [
+        ("partner_id", "=", partner_id.id),
+        ("community_company_id", "=", community_company_id.id),
+        ("is_pack", "=", True),
+        ("status", "in", ["closed_planned", "closed"]),
+        ("successor_contract_id", "=", False),
+    ]
+    if contract_id:
+        query.append(("id", "!=", contract_id.id))
+    return env["contract.contract"].search(query, limit=1)
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
index bec1db94a..8c4be8d4e 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
@@ -9,7 +9,12 @@ from odoo.addons.energy_communities.utils import (
     sale_order_utils,
 )
 
-from ..utils import service_invoicing_view
+from ..utils import (
+    get_existing_last_closed_contract,
+    get_existing_open_contract,
+    raise_existing_same_open_contract_error,
+    service_invoicing_view,
+)
 
 
 class ServiceInvoicingActionCreateWizard(models.TransientModel):
@@ -24,15 +29,34 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
     discount = fields.Float(string="Discount (%)", digits="Discount", default=0)
 
     def execute_create(self):
-        with sale_order_utils(self.env) as component:
-            service_invoicing_id = component.create_service_invoicing_ready_to_start(
-                self.company_id,
-                self.community_company_id,
-                self.service_pack_id,
-                self.pricelist_id,
-                self.payment_mode_id,
-                datetime.now(),
-                self.discount,
-                "activate",
-            )
+        # Check if already open one and raise error
+        existing_contract = get_existing_open_contract(
+            self.env, self.company_id.partner_id, self.community_company_id
+        )
+        if existing_contract:
+            raise_existing_same_open_contract_error()
+        existing_closed_contract = get_existing_last_closed_contract(
+            self.env, self.company_id.partner_id, self.community_company_id
+        )
+        # If existing closed contract reopen it
+        if existing_closed_contract:
+            with contract_utils(self.env, existing_closed_contract) as component:
+                service_invoicing_id = component.reopen(
+                    datetime.now(), self.pricelist_id, self.service_pack_id
+                )
+        # If none of previous create a new contract
+        else:
+            with sale_order_utils(self.env) as component:
+                service_invoicing_id = (
+                    component.create_service_invoicing_ready_to_start(
+                        self.company_id,
+                        self.community_company_id,
+                        self.service_pack_id,
+                        self.pricelist_id,
+                        self.payment_mode_id,
+                        datetime.now(),
+                        self.discount,
+                        "activate",
+                    )
+                )
         return service_invoicing_view(self.env, service_invoicing_id)
-- 
GitLab


From 9eae74e6d6953c3be5805041697d1b2e88765c3c Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Wed, 19 Feb 2025 15:01:21 +0100
Subject: [PATCH 53/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Being=20able=20to=20r?=
 =?UTF-8?q?eopen=20and=20modify=20with=20discount?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../components/contract_utils.py                | 15 +++++++++------
 .../models/contract.py                          | 17 ++++++++++++-----
 .../views/contract_views.xml                    |  2 +-
 .../wizards/service_invoicing_action.py         | 17 +++++++++++------
 .../wizards/service_invoicing_action.xml        |  7 +++++++
 .../wizards/service_invoicing_action_create.py  |  5 ++++-
 6 files changed, 44 insertions(+), 19 deletions(-)

diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
index 457444ea8..73cb4008d 100644
--- a/energy_communities_service_invoicing/components/contract_utils.py
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -46,6 +46,7 @@ class ContractUtils(Component):
         executed_modification_action,
         pricelist_id=None,
         service_pack_id=None,
+        discount=None,
     ):
         initial_status = self.work.record.status
         self.set_contract_status_closed(execution_date)
@@ -58,6 +59,7 @@ class ContractUtils(Component):
             execution_date,
             pricelist_id,
             service_pack_id,
+            discount,
         )
         if initial_status == "ready_to_start":
             new_service_invoicing_id = (
@@ -74,10 +76,7 @@ class ContractUtils(Component):
         return new_service_invoicing_id
 
     def reopen(
-        self,
-        execution_date,
-        pricelist_id=None,
-        service_pack_id=None,
+        self, execution_date, pricelist_id=None, service_pack_id=None, discount=None
     ):
         self.set_contract_status_closed(execution_date)
         new_service_invoicing_id = self.component(
@@ -85,10 +84,11 @@ class ContractUtils(Component):
         ).create_service_invoicing_ready_to_start(
             **self._build_service_invoicing_params(
                 "reopen",
-                "modify_service_pack,modify_pricelist",
+                "modify_service_pack,modify_pricelist,modify_discount",
                 execution_date,
                 pricelist_id,
                 service_pack_id,
+                discount,
             )
         )
         self._setup_successors_and_predecessors(new_service_invoicing_id)
@@ -101,6 +101,7 @@ class ContractUtils(Component):
         execution_date,
         pricelist_id=None,
         service_pack_id=None,
+        discount=None,
     ):
         executed_modification_action_list = executed_modification_action.split(",")
         return {
@@ -118,7 +119,9 @@ class ContractUtils(Component):
             else execution_date,
             "executed_action": executed_action,
             "executed_modification_action": executed_modification_action,
-            "discount": self.work.record.discount,
+            "discount": discount
+            if "modify_discount" in executed_modification_action_list
+            else self.work.record.discount,
         }
 
     def _is_service_line(self, contract_line):
diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index 1ef9fe56f..3ebc9c3ba 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -126,13 +126,20 @@ class ContractContract(models.Model):
         return self._action_contract("modification")
 
     def action_reopen_contract(self):
-        return self._action_contract("reopen")
+        return self._action_contract("reopen", self.service_pack_id, self.pricelist_id)
 
-    def _action_contract(self, action):
+    def _action_contract(self, action, service_pack_id=False, pricelist_id=False):
         self.ensure_one()
-        wizard = self.env["service.invoicing.action.wizard"].create(
-            {"service_invoicing_id": self.id, "executed_action": action}
-        )
+        create_dict = {
+            "service_invoicing_id": self.id,
+            "executed_action": action,
+            "discount": self.discount,
+        }
+        if service_pack_id:
+            create_dict["service_pack_id"] = service_pack_id.id
+        if pricelist_id:
+            create_dict["pricelist_id"] = pricelist_id.id
+        wizard = self.env["service.invoicing.action.wizard"].create(create_dict)
         return {
             "type": "ir.actions.act_window",
             "name": _("Executing: {}").format(action),
diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index ad9ff43a1..14da3acba 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -135,7 +135,7 @@
           name="action_reopen_contract"
           type="object"
           string="Reopen"
-          attrs="{'invisible':[('status','not in',['closed','closed_planned'])]}"
+          attrs="{'invisible':['|',('status','not in',['closed','closed_planned']),('successor_contract_id','!=',False)]}"
         />
       </xpath>
       <xpath expr="//field[@name='partner_id']" position="after">
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action.py b/energy_communities_service_invoicing/wizards/service_invoicing_action.py
index a3cdf4aef..81328dd69 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action.py
@@ -23,6 +23,7 @@ class ServiceInvoicingActionWizard(models.TransientModel):
     )
     pricelist_id = fields.Many2one("product.pricelist", string="Select pricelist")
     service_pack_id = fields.Many2one("product.product", string="Service pack")
+    discount = fields.Float(string="Discount (%)", digits="Discount")
 
     def execute_activate(self):
         with contract_utils(self.env, self.service_invoicing_id) as component:
@@ -41,6 +42,7 @@ class ServiceInvoicingActionWizard(models.TransientModel):
                 executed_modification_action,
                 self.pricelist_id,
                 self.service_pack_id,
+                self.discount,
             )
         return service_invoicing_view(self.env, service_invoicing_id)
 
@@ -50,19 +52,22 @@ class ServiceInvoicingActionWizard(models.TransientModel):
                 self.execution_date,
                 self.pricelist_id,
                 self.service_pack_id,
+                self.discount,
             )
         return service_invoicing_view(self.env, service_invoicing_id)
 
     def _validate_execute_modify(self):
-        if not self.pricelist_id and not self.service_pack_id:
+        if (
+            not self.pricelist_id
+            and not self.service_pack_id
+            and self.discount == self.service_invoicing_id.discount
+        ):
             raise ValidationError(_("Select at least one value to modify"))
 
     def _build_executed_modification_action(self):
-        executed_modification_action = ""
+        executed_modification_action = "modify_discount"
         if self.pricelist_id:
-            executed_modification_action += "modify_pricelist"
+            executed_modification_action += ",modify_pricelist"
         if self.service_pack_id:
-            if bool(executed_modification_action):
-                executed_modification_action += ","
-            executed_modification_action += "modify_service_pack"
+            executed_modification_action += ",modify_service_pack"
         return executed_modification_action
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action.xml b/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
index 5e48bef40..edafd5cd3 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
@@ -27,6 +27,13 @@
                 'required': [('executed_action','=','reopen')]
               }"
             />
+            <field
+              name="discount"
+              attrs="{
+                'invisible': [('executed_action','not in',['modification','reopen'])],
+                'required': [('executed_action','=','reopen')]
+              }"
+            />
           </group>
         </sheet>
         <footer>
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
index 8c4be8d4e..ca2afd128 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
@@ -42,7 +42,10 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
         if existing_closed_contract:
             with contract_utils(self.env, existing_closed_contract) as component:
                 service_invoicing_id = component.reopen(
-                    datetime.now(), self.pricelist_id, self.service_pack_id
+                    datetime.now(),
+                    self.pricelist_id,
+                    self.service_pack_id,
+                    self.discount,
                 )
         # If none of previous create a new contract
         else:
-- 
GitLab


From b9cdc4d3dc9111875118605167208d6bc583d55b Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Wed, 19 Feb 2025 15:28:49 +0100
Subject: [PATCH 54/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Introduce=20payment?=
 =?UTF-8?q?=5Fmode=20as=20selectable=20on=20workflow?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../components/contract_utils.py              | 17 +++++++++++++---
 .../models/contract.py                        | 10 ++++++++--
 .../wizards/service_invoicing_action.py       | 20 ++++++++++++++++---
 .../wizards/service_invoicing_action.xml      | 15 ++++++++++----
 .../service_invoicing_action_create.py        |  1 +
 5 files changed, 51 insertions(+), 12 deletions(-)

diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
index 73cb4008d..4a07a45e6 100644
--- a/energy_communities_service_invoicing/components/contract_utils.py
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -47,6 +47,7 @@ class ContractUtils(Component):
         pricelist_id=None,
         service_pack_id=None,
         discount=None,
+        payment_mode_id=None,
     ):
         initial_status = self.work.record.status
         self.set_contract_status_closed(execution_date)
@@ -60,6 +61,7 @@ class ContractUtils(Component):
             pricelist_id,
             service_pack_id,
             discount,
+            payment_mode_id,
         )
         if initial_status == "ready_to_start":
             new_service_invoicing_id = (
@@ -76,7 +78,12 @@ class ContractUtils(Component):
         return new_service_invoicing_id
 
     def reopen(
-        self, execution_date, pricelist_id=None, service_pack_id=None, discount=None
+        self,
+        execution_date,
+        pricelist_id=None,
+        service_pack_id=None,
+        discount=None,
+        payment_mode_id=None,
     ):
         self.set_contract_status_closed(execution_date)
         new_service_invoicing_id = self.component(
@@ -84,11 +91,12 @@ class ContractUtils(Component):
         ).create_service_invoicing_ready_to_start(
             **self._build_service_invoicing_params(
                 "reopen",
-                "modify_service_pack,modify_pricelist,modify_discount",
+                "modify_service_pack,modify_pricelist,modify_discount,modify_payment_mode",
                 execution_date,
                 pricelist_id,
                 service_pack_id,
                 discount,
+                payment_mode_id,
             )
         )
         self._setup_successors_and_predecessors(new_service_invoicing_id)
@@ -102,6 +110,7 @@ class ContractUtils(Component):
         pricelist_id=None,
         service_pack_id=None,
         discount=None,
+        payment_mode_id=None,
     ):
         executed_modification_action_list = executed_modification_action.split(",")
         return {
@@ -113,7 +122,9 @@ class ContractUtils(Component):
             "pricelist_id": pricelist_id
             if "modify_pricelist" in executed_modification_action_list
             else self.work.record.pricelist_id,
-            "payment_mode_id": self.work.record.payment_mode_id,
+            "payment_mode_id": payment_mode_id
+            if "modify_payment_mode" in executed_modification_action_list
+            else self.work.record.payment_mode_id,
             "start_date": execution_date + timedelta(days=1)
             if executed_action == "modification"
             else execution_date,
diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index 3ebc9c3ba..9047ab13a 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -126,9 +126,13 @@ class ContractContract(models.Model):
         return self._action_contract("modification")
 
     def action_reopen_contract(self):
-        return self._action_contract("reopen", self.service_pack_id, self.pricelist_id)
+        return self._action_contract(
+            "reopen", self.service_pack_id, self.pricelist_id, self.payment_mode_id
+        )
 
-    def _action_contract(self, action, service_pack_id=False, pricelist_id=False):
+    def _action_contract(
+        self, action, service_pack_id=False, pricelist_id=False, payment_mode_id=False
+    ):
         self.ensure_one()
         create_dict = {
             "service_invoicing_id": self.id,
@@ -139,6 +143,8 @@ class ContractContract(models.Model):
             create_dict["service_pack_id"] = service_pack_id.id
         if pricelist_id:
             create_dict["pricelist_id"] = pricelist_id.id
+        if payment_mode_id:
+            create_dict["payment_mode_id"] = payment_mode_id.id
         wizard = self.env["service.invoicing.action.wizard"].create(create_dict)
         return {
             "type": "ir.actions.act_window",
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action.py b/energy_communities_service_invoicing/wizards/service_invoicing_action.py
index 81328dd69..49c7ed275 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action.py
@@ -24,6 +24,7 @@ class ServiceInvoicingActionWizard(models.TransientModel):
     pricelist_id = fields.Many2one("product.pricelist", string="Select pricelist")
     service_pack_id = fields.Many2one("product.product", string="Service pack")
     discount = fields.Float(string="Discount (%)", digits="Discount")
+    payment_mode_id = fields.Many2one("account.payment.mode", string="Payment mode")
 
     def execute_activate(self):
         with contract_utils(self.env, self.service_invoicing_id) as component:
@@ -43,6 +44,7 @@ class ServiceInvoicingActionWizard(models.TransientModel):
                 self.pricelist_id,
                 self.service_pack_id,
                 self.discount,
+                self.payment_mode_id,
             )
         return service_invoicing_view(self.env, service_invoicing_id)
 
@@ -53,6 +55,7 @@ class ServiceInvoicingActionWizard(models.TransientModel):
                 self.pricelist_id,
                 self.service_pack_id,
                 self.discount,
+                self.payment_mode_id,
             )
         return service_invoicing_view(self.env, service_invoicing_id)
 
@@ -60,14 +63,25 @@ class ServiceInvoicingActionWizard(models.TransientModel):
         if (
             not self.pricelist_id
             and not self.service_pack_id
+            and not self.payment_mode_id
             and self.discount == self.service_invoicing_id.discount
         ):
             raise ValidationError(_("Select at least one value to modify"))
 
     def _build_executed_modification_action(self):
-        executed_modification_action = "modify_discount"
+        executed_modification_action = ""
         if self.pricelist_id:
-            executed_modification_action += ",modify_pricelist"
+            executed_modification_action += "modify_pricelist"
         if self.service_pack_id:
-            executed_modification_action += ",modify_service_pack"
+            if bool(executed_modification_action):
+                executed_modification_action += ","
+            executed_modification_action += "modify_service_pack"
+        if self.payment_mode_id:
+            if bool(executed_modification_action):
+                executed_modification_action += ","
+            executed_modification_action += "modify_payment_mode"
+        if self.discount != self.service_invoicing_id.discount:
+            if bool(executed_modification_action):
+                executed_modification_action += ","
+            executed_action += "modify_discount"
         return executed_modification_action
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action.xml b/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
index edafd5cd3..dc16b29be 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
@@ -12,6 +12,14 @@
             <field name="executed_action" invisible="1" />
             <field name="service_invoicing_id" required="1" domain="[('community_company_id','!=',False)]"/>
             <field name="execution_date" required="1"/>
+            <field
+              name="service_pack_id"
+              domain="[('is_contract','=',True)]"
+              attrs="{
+                'invisible': [('executed_action','not in',['modification','reopen'])],
+                'required': [('executed_action','=','reopen')]
+              }"
+            />
             <field
               name="pricelist_id"
               attrs="{
@@ -20,11 +28,10 @@
               }"
             />
             <field
-              name="service_pack_id"
-              domain="[('is_contract','=',True)]"
+              name="payment_mode_id"
               attrs="{
-                'invisible': [('executed_action','not in',['modification','reopen'])],
-                'required': [('executed_action','=','reopen')]
+               'invisible': [('executed_action','not in',['modification','reopen'])],
+               'required': [('executed_action','=','reopen')]
               }"
             />
             <field
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
index ca2afd128..7f36c9ae4 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
@@ -46,6 +46,7 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
                     self.pricelist_id,
                     self.service_pack_id,
                     self.discount,
+                    self.payment_mode_id,
                 )
         # If none of previous create a new contract
         else:
-- 
GitLab


From cb014ac607cd9001a6e6a8df57af1c1c9d53f875 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Wed, 19 Feb 2025 16:02:57 +0100
Subject: [PATCH 55/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Avoid=20creating=20co?=
 =?UTF-8?q?ntract=20and=20modify=20dates=20when=20contract=20invoice=20has?=
 =?UTF-8?q?=20no=20lines.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../models/contract.py                                | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index 9047ab13a..cb8312737 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -116,6 +116,17 @@ class ContractContract(models.Model):
                 if rel_product:
                     record.service_pack_id = rel_product.id
 
+    def _recurring_create_invoice(self, date_ref=False):
+        previous_last_date_invoiced = self.last_date_invoiced
+        moves = super()._recurring_create_invoice(date_ref)
+        for move in moves:
+            if not move.line_ids:
+                for line in self.contract_line_ids:
+                    line.write({"last_date_invoiced": previous_last_date_invoiced})
+                move.unlink()
+
+        return moves
+
     def action_activate_contract(self):
         return self._action_contract("activate")
 
-- 
GitLab


From 1aa1db1bd72b93cc85c3264b1002d8ed28280f43 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Thu, 20 Feb 2025 17:26:06 +0100
Subject: [PATCH 56/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Change=20ready=20to?=
 =?UTF-8?q?=20start=20strategy=20to=20lines=20with=200=20quantity?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../components/contract_utils.py              | 41 ++++++++++++-------
 .../models/__init__.py                        |  1 +
 .../models/contract.py                        |  4 --
 .../models/contract_line.py                   | 14 +++++++
 4 files changed, 41 insertions(+), 19 deletions(-)
 create mode 100644 energy_communities_service_invoicing/models/contract_line.py

diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
index 4a07a45e6..368bb8e37 100644
--- a/energy_communities_service_invoicing/components/contract_utils.py
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -8,18 +8,41 @@ class ContractUtils(Component):
 
     def set_contract_status_ready_to_start(self):
         for line in self.work.record.contract_line_ids:
-            line.cancel()
+            line.write(
+                {
+                    "ordered_qty_type": line.qty_type,
+                    "ordered_quantity": line.quantity,
+                    "ordered_qty_formula_id": line.qty_formula_id.id,
+                    "qty_type": "fixed",
+                    "quantity": 0,
+                }
+            )
         self.work.record.write({"status": "ready_to_start"})
 
+    def _activate_contract_lines(self, execution_date):
+        for line in self.work.record.contract_line_ids:
+            line.write(
+                {
+                    "date_start": execution_date,
+                    "next_period_date_start": execution_date,
+                    "recurring_next_date": execution_date,
+                    "last_date_invoiced": None,
+                    "qty_type": line.ordered_qty_type,
+                    "quantity": line.ordered_quantity,
+                    "qty_formula_id": line.ordered_qty_formula_id.id,
+                }
+            )
+            line._compute_state()
+
     def set_contract_status_active(self, execution_date):
-        self._uncancel_contract_lines(execution_date)
+        self._activate_contract_lines(execution_date)
         self.set_start_date(execution_date)
         self.work.record.write({"status": "in_progress"})
 
     def set_contract_status_closed(self, execution_date):
         for line in self.work.record.contract_line_ids:
             if self.work.record.status == "ready_to_start":
-                self._uncancel_contract_lines(execution_date)
+                self._activate_contract_lines(execution_date)
             line.write({"date_end": execution_date})
             line._compute_state()
         self.work.record.set_close_status_type_by_date()
@@ -148,15 +171,3 @@ class ContractUtils(Component):
     def _setup_successors_and_predecessors(self, new_service_invoicing_id):
         self.work.record.write({"successor_contract_id": new_service_invoicing_id.id})
         new_service_invoicing_id.write({"predecessor_contract_id": self.work.record.id})
-
-    def _uncancel_contract_lines(self, execution_date):
-        for line in self.work.record.contract_line_ids:
-            line.write(
-                {
-                    "date_start": execution_date,
-                    "next_period_date_start": execution_date,
-                    "recurring_next_date": execution_date,
-                    "is_canceled": False,
-                }
-            )
-            line._compute_state()
diff --git a/energy_communities_service_invoicing/models/__init__.py b/energy_communities_service_invoicing/models/__init__.py
index 2deeec9c8..a7c4f8dc5 100644
--- a/energy_communities_service_invoicing/models/__init__.py
+++ b/energy_communities_service_invoicing/models/__init__.py
@@ -1,6 +1,7 @@
 from . import abstract_contract
 from . import account_move
 from . import contract
+from . import contract_line
 from . import contract_line_formula
 from . import contract_template
 from . import product_template
diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index cb8312737..2188aead8 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -117,14 +117,10 @@ class ContractContract(models.Model):
                     record.service_pack_id = rel_product.id
 
     def _recurring_create_invoice(self, date_ref=False):
-        previous_last_date_invoiced = self.last_date_invoiced
         moves = super()._recurring_create_invoice(date_ref)
         for move in moves:
             if not move.line_ids:
-                for line in self.contract_line_ids:
-                    line.write({"last_date_invoiced": previous_last_date_invoiced})
                 move.unlink()
-
         return moves
 
     def action_activate_contract(self):
diff --git a/energy_communities_service_invoicing/models/contract_line.py b/energy_communities_service_invoicing/models/contract_line.py
new file mode 100644
index 000000000..fef87be5f
--- /dev/null
+++ b/energy_communities_service_invoicing/models/contract_line.py
@@ -0,0 +1,14 @@
+from odoo import api, fields, models
+
+
+class ContractLine(models.Model):
+    _inherit = "contract.line"
+
+    ordered_qty_type = fields.Char()
+    ordered_quantity = fields.Float()
+    ordered_qty_formula_id = fields.Many2one("contract.line.qty.formula")
+
+    def _compute_allowed(self):
+        super()._compute_allowed()
+        for record in self:
+            record.is_cancel_allowed = True
-- 
GitLab


From 0d46730881d539951712d613fb5d00daccbb0381 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Fri, 21 Feb 2025 10:58:07 +0100
Subject: [PATCH 57/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Wizard=20creation=20c?=
 =?UTF-8?q?ompany=20selection=20domain=20based=20fields?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../components/contract_utils.py              |  9 ++-
 .../models/contract_line.py                   |  4 ++
 energy_communities_service_invoicing/utils.py | 15 +++++
 .../service_invoicing_action_create.py        | 63 ++++++++++++++++++-
 .../service_invoicing_action_create.xml       |  9 ++-
 5 files changed, 89 insertions(+), 11 deletions(-)

diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
index 368bb8e37..b75d584c9 100644
--- a/energy_communities_service_invoicing/components/contract_utils.py
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -1,5 +1,3 @@
-from datetime import timedelta
-
 from odoo.addons.component.core import Component
 
 
@@ -73,6 +71,9 @@ class ContractUtils(Component):
         payment_mode_id=None,
     ):
         initial_status = self.work.record.status
+        # TODO: control closing date in order to being able modify contract with previous date.
+        # on contract line:
+        # skip last_date_invoice validation for modification action if contract is ready to start or active on free plan.
         self.set_contract_status_closed(execution_date)
         sale_order_utils = self.component(
             usage="sale.order.utils", model_name="sale.order"
@@ -148,9 +149,7 @@ class ContractUtils(Component):
             "payment_mode_id": payment_mode_id
             if "modify_payment_mode" in executed_modification_action_list
             else self.work.record.payment_mode_id,
-            "start_date": execution_date + timedelta(days=1)
-            if executed_action == "modification"
-            else execution_date,
+            "start_date": execution_date,
             "executed_action": executed_action,
             "executed_modification_action": executed_modification_action,
             "discount": discount
diff --git a/energy_communities_service_invoicing/models/contract_line.py b/energy_communities_service_invoicing/models/contract_line.py
index fef87be5f..ab5763ec7 100644
--- a/energy_communities_service_invoicing/models/contract_line.py
+++ b/energy_communities_service_invoicing/models/contract_line.py
@@ -12,3 +12,7 @@ class ContractLine(models.Model):
         super()._compute_allowed()
         for record in self:
             record.is_cancel_allowed = True
+
+    # TODO:
+    # skip last_date_invoice validation for modification action if contract is ready to start or active on free plan.
+    # def _check_last_date_invoiced(self):
diff --git a/energy_communities_service_invoicing/utils.py b/energy_communities_service_invoicing/utils.py
index 47feda5bc..f64fd894c 100644
--- a/energy_communities_service_invoicing/utils.py
+++ b/energy_communities_service_invoicing/utils.py
@@ -45,6 +45,21 @@ def raise_existing_same_open_contract_error():
     )
 
 
+def get_pack_product_product_ids(env):
+    ret = env["product.product"].search(
+        [
+            (
+                "categ_id",
+                "=",
+                env.ref(
+                    "energy_communities_service_invoicing.product_category_pack"
+                ).id,
+            )
+        ]
+    )
+    return ret
+
+
 def get_existing_open_contract(
     env, partner_id, community_company_id, contract_id=False
 ):
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
index 7f36c9ae4..6370bd5d4 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
@@ -12,6 +12,7 @@ from odoo.addons.energy_communities.utils import (
 from ..utils import (
     get_existing_last_closed_contract,
     get_existing_open_contract,
+    get_pack_product_product_ids,
     raise_existing_same_open_contract_error,
     service_invoicing_view,
 )
@@ -20,14 +21,70 @@ from ..utils import (
 class ServiceInvoicingActionCreateWizard(models.TransientModel):
     _name = "service.invoicing.action.create.wizard"
     _description = "Create service invoicing for an energy community"
+    _inherit = ["user.currentcompany.mixin"]
 
     company_id = fields.Many2one("res.company", string="Coordinator")
-    community_company_id = fields.Many2one("res.company", string="Community")
-    service_pack_id = fields.Many2one("product.product", string="Service pack")
+    community_company_id = fields.Many2one(
+        "res.company",
+        string="Community",
+        domain="[('id', 'in', allowed_community_company_ids)]",
+    )
+    service_pack_id = fields.Many2one(
+        "product.product",
+        string="Service pack",
+        domain="[('id', 'in', pack_product_product_ids)]",
+    )
+    payment_mode_id = fields.Many2one(
+        "account.payment.mode",
+        string="Payment mode",
+        domain="[('id', 'in', allowed_payment_mode_ids)]",
+    )
     pricelist_id = fields.Many2one("product.pricelist", string="PriceList")
-    payment_mode_id = fields.Many2one("account.payment.mode", string="Payment mode")
     discount = fields.Float(string="Discount (%)", digits="Discount", default=0)
 
+    allowed_community_company_ids = fields.Many2many(
+        comodel_name="res.company",
+        _compute="_compute_allowed_community_company_ids",
+        store=False,
+    )
+    allowed_payment_mode_ids = fields.Many2many(
+        comodel_name="account.payment.mode",
+        _compute="_compute_ allowed_payment_mode_ids",
+        store=False,
+    )
+    pack_product_product_ids = fields.Many2many(
+        comodel_name="product.product",
+        _compute="_compute_pack_product_product_ids",
+        store=False,
+    )
+
+    @api.depends("company_id")
+    def _compute_allowed_community_company_ids(self):
+        for record in self:
+            record.allowed_community_company_ids = self.env["res.company"].search(
+                [
+                    ("hierarchy_level", "=", "community"),
+                    ("parent_id", "=", record.company_id.id),
+                ]
+            )
+
+    def _compute_allowed_payment_mode_ids(self):
+        for record in self:
+            record.allowed_payment_mode_ids = self.env["account.payment.mode"].search(
+                [("company_id", "=", self.user_current_company.id)]
+            )
+
+    def _compute_pack_product_product_ids(self):
+        for record in self:
+            record.pack_product_product_ids = get_pack_product_product_ids(self.env)
+
+    @api.onchange("company_id")
+    def _on_change_company_id(self):
+        for record in self:
+            record._compute_allowed_community_company_ids()
+            record._compute_allowed_payment_mode_ids()
+            record._compute_pack_product_product_ids()
+
     def execute_create(self):
         # Check if already open one and raise error
         existing_contract = get_existing_open_contract(
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
index 32582e7e5..147f07487 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
@@ -9,10 +9,13 @@
       <form string="Service invoicing">
         <sheet>
           <group>
+            <field name="allowed_community_company_ids" invisible="1" />
+            <field name="allowed_payment_mode_ids" invisible="1" />
+            <field name="pack_product_product_ids" invisible="1" />
             <field name="company_id" required="1" domain="[('hierarchy_level','=','coordinator')]"/>
-            <field name="community_company_id" required="1" domain="[('hierarchy_level','=','community')]"/>
-            <field name="service_pack_id" required="1" domain="[('is_contract','=',True)]"/>
-            <field name="pricelist_id" required="1" />
+            <field name="community_company_id" required="1" />
+            <field name="service_pack_id" required="1"/>
+            <field name="pricelist_id" required="1" domain="[('company_id','=',False)]"/>
             <field name="payment_mode_id" required="1" />
             <field name="discount" required="1" />
           </group>
-- 
GitLab


From b17afbf7f833122406516447cb31d6ac7caf36cd Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Fri, 21 Feb 2025 11:04:13 +0100
Subject: [PATCH 58/85] =?UTF-8?q?[FIX]=20=F0=9F=90=9B=20Wrong=20search=20d?=
 =?UTF-8?q?omain=20for=20clsed=5Fplanned=20contracts?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 energy_communities_service_invoicing/models/contract.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index 2188aead8..af300d13e 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -184,7 +184,7 @@ class ContractContract(models.Model):
     @api.model
     def cron_close_todays_closed_planned_contacts(self):
         impacted_contracts = self.env["contract.contract"].search(
-            [("status", "closed_planned")]
+            [("status", "=", "closed_planned")]
         )
         for contract in impacted_contracts:
             contract.set_close_status_type_by_date()
-- 
GitLab


From d74e86ff078b0d792dc50f36764583f5c6a417c0 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Fri, 21 Feb 2025 12:08:34 +0100
Subject: [PATCH 59/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Propagate=20company?=
 =?UTF-8?q?=20configuration=20service=20invocing=20journal=20to=20contract?=
 =?UTF-8?q?=20journal?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../__manifest__.py                             |  1 +
 .../components/contract_utils.py                |  5 +++++
 .../components/sale_order_utils.py              |  1 +
 .../models/__init__.py                          |  1 +
 .../models/contract.py                          |  4 +++-
 .../models/res_company.py                       | 12 ++++++++++++
 .../views/res_company_views.xml                 | 17 +++++++++++++++++
 7 files changed, 40 insertions(+), 1 deletion(-)
 create mode 100644 energy_communities_service_invoicing/models/res_company.py
 create mode 100644 energy_communities_service_invoicing/views/res_company_views.xml

diff --git a/energy_communities_service_invoicing/__manifest__.py b/energy_communities_service_invoicing/__manifest__.py
index 37ce926fc..5a979d294 100644
--- a/energy_communities_service_invoicing/__manifest__.py
+++ b/energy_communities_service_invoicing/__manifest__.py
@@ -31,6 +31,7 @@
         "data/product_data.xml",
         "views/contract_line_formula_views.xml",
         "views/contract_views.xml",
+        "views/res_company_views.xml",
         "views/res_partner_views.xml",
         "views/sale_order_views.xml",
         "views/service_invoicing_views.xml",
diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
index b75d584c9..54432117b 100644
--- a/energy_communities_service_invoicing/components/contract_utils.py
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -55,6 +55,11 @@ class ContractUtils(Component):
         for line in self.work.record.contract_line_ids:
             line.write({"discount": discount})
 
+    def set_configuration_journal_if_defined(self):
+        journal_id = self.work.record.company_id.service_invoicing_journal_id
+        if journal_id:
+            self.work.record.write({"journal_id": journal_id.id})
+
     def clean_non_service_lines(self):
         for line in self.work.record.contract_line_ids:
             if not self._is_service_line(line):
diff --git a/energy_communities_service_invoicing/components/sale_order_utils.py b/energy_communities_service_invoicing/components/sale_order_utils.py
index 3ced8f48d..0cd51e2e7 100644
--- a/energy_communities_service_invoicing/components/sale_order_utils.py
+++ b/energy_communities_service_invoicing/components/sale_order_utils.py
@@ -65,6 +65,7 @@ class SaleOrderUtils(Component):
         # TODO: We must call contract_utils with a better component and workcontext modification approach
         with contract_utils(self.env, service_invoicing_id) as component:
             component.clean_non_service_lines()
+            component.set_configuration_journal_if_defined()
             component.set_start_date(start_date)
             component.set_discount(discount)
         return service_invoicing_id
diff --git a/energy_communities_service_invoicing/models/__init__.py b/energy_communities_service_invoicing/models/__init__.py
index a7c4f8dc5..7ba9edcc6 100644
--- a/energy_communities_service_invoicing/models/__init__.py
+++ b/energy_communities_service_invoicing/models/__init__.py
@@ -5,5 +5,6 @@ from . import contract_line
 from . import contract_line_formula
 from . import contract_template
 from . import product_template
+from . import res_company
 from . import res_partner
 from . import sale_order
diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index af300d13e..77f98faf3 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -56,9 +56,11 @@ class ContractContract(models.Model):
         "sale.order",
         string="Sale Order (activation)",
     )
+    received_invoices_count = fields.Integer(compute="_compute_received_invoices_count")
     # On energy_communities all contracts have skip_zero_qty marked by default
     skip_zero_qty = fields.Boolean(default=True)
-    received_invoices_count = fields.Integer(compute="_compute_received_invoices_count")
+    # On energy communities all contracts have company_id
+    company_id = fields.Many2one(required=True)
 
     @api.constrains("partner_id", "community_company_id")
     def _constrain_unique_contract(self):
diff --git a/energy_communities_service_invoicing/models/res_company.py b/energy_communities_service_invoicing/models/res_company.py
new file mode 100644
index 000000000..6d8d8bf50
--- /dev/null
+++ b/energy_communities_service_invoicing/models/res_company.py
@@ -0,0 +1,12 @@
+from odoo import fields, models
+from odoo.tools.translate import _
+
+
+class ResCompany(models.Model):
+    _name = "res.company"
+    _inherit = "res.company"
+
+    service_invoicing_journal_id = fields.Many2one(
+        comodel_name="account.journal",
+        string="Service invoicing journal",
+    )
diff --git a/energy_communities_service_invoicing/views/res_company_views.xml b/energy_communities_service_invoicing/views/res_company_views.xml
new file mode 100644
index 000000000..a907bb966
--- /dev/null
+++ b/energy_communities_service_invoicing/views/res_company_views.xml
@@ -0,0 +1,17 @@
+<odoo>
+  <record id="view_service_invocing_company_form" model="ir.ui.view">
+    <field name="name">service.invoicing.res.company.form.inherit</field>
+    <field name="model">res.company</field>
+    <field name="inherit_id" ref="base.view_company_form" />
+    <field name="arch" type="xml">
+      <xpath expr="//notebook" position="inside">
+        <page string="Services Invoicing">
+          <group>
+            <field name="id" invisible="1"/>
+            <field name="service_invoicing_journal_id" domain="[('company_id', '=', id)]" />
+          </group>
+        </page>
+      </xpath>
+    </field>
+  </record>
+</odoo>
-- 
GitLab


From 4a7795be761b1a698ea106ab036cba5b03ece89c Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Fri, 21 Feb 2025 12:39:58 +0100
Subject: [PATCH 60/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Setup=20journal=5Fid?=
 =?UTF-8?q?=20only=20if=20we're=20activating=20platform=5Fservice=5Finvoic?=
 =?UTF-8?q?ing=20contracts?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../components/contract_utils.py                 | 16 ++++++++--------
 .../components/sale_order_utils.py               | 15 ++++++++-------
 .../models/sale_order.py                         |  4 ++--
 .../views/sale_order_views.xml                   |  4 ++--
 .../wizards/service_invoicing_action_create.py   |  1 +
 5 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
index 54432117b..101bee90a 100644
--- a/energy_communities_service_invoicing/components/contract_utils.py
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -55,7 +55,7 @@ class ContractUtils(Component):
         for line in self.work.record.contract_line_ids:
             line.write({"discount": discount})
 
-    def set_configuration_journal_if_defined(self):
+    def set_configuration_service_invoicing_journal_if_defined(self):
         journal_id = self.work.record.company_id.service_invoicing_journal_id
         if journal_id:
             self.work.record.write({"journal_id": journal_id.id})
@@ -134,31 +134,31 @@ class ContractUtils(Component):
     def _build_service_invoicing_params(
         self,
         executed_action,
-        executed_modification_action,
+        executed_action_description,
         execution_date,
         pricelist_id=None,
         service_pack_id=None,
         discount=None,
         payment_mode_id=None,
     ):
-        executed_modification_action_list = executed_modification_action.split(",")
+        executed_action_description_list = executed_action_description.split(",")
         return {
             "company_id": self.work.record.partner_id.related_company_id,
             "community_company_id": self.work.record.community_company_id,
             "service_pack_id": service_pack_id
-            if "modify_service_pack" in executed_modification_action_list
+            if "modify_service_pack" in executed_action_description_list
             else self.work.record.service_pack_id,
             "pricelist_id": pricelist_id
-            if "modify_pricelist" in executed_modification_action_list
+            if "modify_pricelist" in executed_action_description_list
             else self.work.record.pricelist_id,
             "payment_mode_id": payment_mode_id
-            if "modify_payment_mode" in executed_modification_action_list
+            if "modify_payment_mode" in executed_action_description_list
             else self.work.record.payment_mode_id,
             "start_date": execution_date,
             "executed_action": executed_action,
-            "executed_modification_action": executed_modification_action,
+            "executed_action_description": executed_action_description,
             "discount": discount
-            if "modify_discount" in executed_modification_action_list
+            if "modify_discount" in executed_action_description_list
             else self.work.record.discount,
         }
 
diff --git a/energy_communities_service_invoicing/components/sale_order_utils.py b/energy_communities_service_invoicing/components/sale_order_utils.py
index 0cd51e2e7..58025debf 100644
--- a/energy_communities_service_invoicing/components/sale_order_utils.py
+++ b/energy_communities_service_invoicing/components/sale_order_utils.py
@@ -14,7 +14,7 @@ class SaleOrderUtils(Component):
         payment_mode_id,
         start_date,
         executed_action,
-        executed_modification_action,
+        executed_action_description,
     ):
         so_creation_dict = {
             "partner_id": company_id.partner_id.id,
@@ -22,7 +22,7 @@ class SaleOrderUtils(Component):
             "community_company_id": community_company_id.id,
             "pricelist_id": pricelist_id.id,
             "service_invoicing_action": executed_action,
-            "service_invoicing_modification_action": executed_modification_action,
+            "service_invoicing_action_description": executed_action_description,
             "payment_mode_id": payment_mode_id.id,
             "order_line": [
                 (
@@ -48,7 +48,7 @@ class SaleOrderUtils(Component):
         start_date,
         discount,
         executed_action,
-        executed_modification_action="none",
+        executed_action_description="none",
     ):
         so = self.create_service_invoicing_sale_order(
             company_id,
@@ -58,16 +58,17 @@ class SaleOrderUtils(Component):
             payment_mode_id,
             start_date,
             executed_action,
-            executed_modification_action,
+            executed_action_description,
         )
         so.action_confirm()
         service_invoicing_id = self._get_related_contracts(so)
         # TODO: We must call contract_utils with a better component and workcontext modification approach
         with contract_utils(self.env, service_invoicing_id) as component:
             component.clean_non_service_lines()
-            component.set_configuration_journal_if_defined()
             component.set_start_date(start_date)
             component.set_discount(discount)
+            if executed_action_description == "active_platform_service_invocing":
+                component.set_configuration_service_invoicing_journal_if_defined()
         return service_invoicing_id
 
     def create_service_invoicing_ready_to_start(
@@ -80,7 +81,7 @@ class SaleOrderUtils(Component):
         start_date,
         discount,
         executed_action,
-        executed_modification_action="none",
+        executed_action_description="none",
     ):
         service_invoicing_id = self.create_service_invoicing(
             company_id,
@@ -91,7 +92,7 @@ class SaleOrderUtils(Component):
             start_date,
             discount,
             executed_action,
-            executed_modification_action,
+            executed_action_description,
         )
         # TODO: We must call contract_utils with a better component and workcontext modification approach
         with contract_utils(self.env, service_invoicing_id) as component:
diff --git a/energy_communities_service_invoicing/models/sale_order.py b/energy_communities_service_invoicing/models/sale_order.py
index f2c61ea09..ad4b23c5a 100644
--- a/energy_communities_service_invoicing/models/sale_order.py
+++ b/energy_communities_service_invoicing/models/sale_order.py
@@ -19,8 +19,8 @@ class SaleOrder(models.Model):
         string="Service invoicing action",
         default="none",
     )
-    service_invoicing_modification_action = fields.Char(
-        string="Modification action",
+    service_invoicing_action_description = fields.Char(
+        string="Service invoicing action description",
         default="none",
     )
 
diff --git a/energy_communities_service_invoicing/views/sale_order_views.xml b/energy_communities_service_invoicing/views/sale_order_views.xml
index 2da76391e..72c636d92 100644
--- a/energy_communities_service_invoicing/views/sale_order_views.xml
+++ b/energy_communities_service_invoicing/views/sale_order_views.xml
@@ -7,8 +7,8 @@
         <xpath expr="//field[@name='partner_id']" position="before">
           <field name="service_invoicing_action" readonly="1" />
           <field
-            name="service_invoicing_modification_action"
-            attrs="{'readonly': 1,'invisible': [('service_invoicing_action','!=', 'modification')]}"
+            name="service_invoicing_action_description"
+            attrs="{'readonly': 1,'invisible': [('service_invoicing_action','not in', ['modification','activate'])]}"
           />
         </xpath>
         <xpath expr="//field[@name='partner_id']" position="after">
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
index 6370bd5d4..290ddba4a 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
@@ -118,6 +118,7 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
                         datetime.now(),
                         self.discount,
                         "activate",
+                        "active_platform_service_invocing",
                     )
                 )
         return service_invoicing_view(self.env, service_invoicing_id)
-- 
GitLab


From 05ec4031fe3bf6908bffa84b3242b5efda789a12 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Fri, 21 Feb 2025 16:06:25 +0100
Subject: [PATCH 61/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Propagate=20sale=5Fde?=
 =?UTF-8?q?scription=20on=20service=20invoicing=20related=20models?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../components/sale_order_utils.py                            | 4 ++++
 energy_communities_service_invoicing/models/contract.py       | 1 +
 2 files changed, 5 insertions(+)

diff --git a/energy_communities_service_invoicing/components/sale_order_utils.py b/energy_communities_service_invoicing/components/sale_order_utils.py
index 58025debf..2dc8013c9 100644
--- a/energy_communities_service_invoicing/components/sale_order_utils.py
+++ b/energy_communities_service_invoicing/components/sale_order_utils.py
@@ -36,6 +36,10 @@ class SaleOrderUtils(Component):
                 )
             ],
         }
+        sale_order = self.env["sale.order"].create(so_creation_dict)
+        # Trigger name computattion in oder to include product's description_sale
+        for order_line in sale_order.order_line:
+            order_line._compute_name()
         return self.env["sale.order"].create(so_creation_dict)
 
     def create_service_invoicing(
diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index 77f98faf3..b06d5d759 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -12,6 +12,7 @@ from ..utils import (
 
 class ContractContract(models.Model):
     _inherit = "contract.contract"
+    _order = "id desc"
 
     community_company_id = fields.Many2one(
         "res.company",
-- 
GitLab


From 389b188827de6659879712adf1d400f39103e6d8 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Fri, 21 Feb 2025 18:23:55 +0100
Subject: [PATCH 62/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20More=20permissive=20w?=
 =?UTF-8?q?ays=20of=20modifying=20and=20reopening=20contracts?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../__manifest__.py                           |  1 +
 .../components/contract_utils.py              |  5 +++-
 .../models/__init__.py                        |  1 +
 .../models/contract.py                        |  3 +-
 .../models/contract_line.py                   | 15 ++++++++--
 .../models/contract_template.py               |  5 ++--
 .../models/res_company.py                     |  2 +-
 .../models/service_invoicing_info_mixin.py    | 28 +++++++++++++++++++
 energy_communities_service_invoicing/utils.py | 15 ----------
 .../views/contract_template_views.xml         | 12 ++++++++
 .../service_invoicing_action_create.py        | 14 ++--------
 11 files changed, 67 insertions(+), 34 deletions(-)
 create mode 100644 energy_communities_service_invoicing/models/service_invoicing_info_mixin.py
 create mode 100644 energy_communities_service_invoicing/views/contract_template_views.xml

diff --git a/energy_communities_service_invoicing/__manifest__.py b/energy_communities_service_invoicing/__manifest__.py
index 5a979d294..a3ec60b9e 100644
--- a/energy_communities_service_invoicing/__manifest__.py
+++ b/energy_communities_service_invoicing/__manifest__.py
@@ -30,6 +30,7 @@
         "data/contract_line_qty_formula_data.xml",
         "data/product_data.xml",
         "views/contract_line_formula_views.xml",
+        "views/contract_template_views.xml",
         "views/contract_views.xml",
         "views/res_company_views.xml",
         "views/res_partner_views.xml",
diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
index 101bee90a..c0cd319e4 100644
--- a/energy_communities_service_invoicing/components/contract_utils.py
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -39,7 +39,10 @@ class ContractUtils(Component):
 
     def set_contract_status_closed(self, execution_date):
         for line in self.work.record.contract_line_ids:
-            if self.work.record.status == "ready_to_start":
+            if (
+                self.work.record.status == "ready_to_start"
+                or self.work.record.is_free_pack
+            ):
                 self._activate_contract_lines(execution_date)
             line.write({"date_end": execution_date})
             line._compute_state()
diff --git a/energy_communities_service_invoicing/models/__init__.py b/energy_communities_service_invoicing/models/__init__.py
index 7ba9edcc6..4c3afbbec 100644
--- a/energy_communities_service_invoicing/models/__init__.py
+++ b/energy_communities_service_invoicing/models/__init__.py
@@ -1,3 +1,4 @@
+from . import service_invoicing_info_mixin
 from . import abstract_contract
 from . import account_move
 from . import contract
diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index b06d5d759..acadcae8f 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -41,6 +41,7 @@ class ContractContract(models.Model):
         string="Last Date Invoiced", compute="_compute_last_date_invoiced", store=False
     )
     is_pack = fields.Boolean(related="contract_template_id.is_pack")
+    is_free_pack = fields.Boolean(related="contract_template_id.is_free_pack")
     related_contract_product_ids = fields.One2many(
         "product.product",
         string="Related services",
@@ -216,7 +217,7 @@ class ContractContract(models.Model):
         )
 
     def set_close_status_type_by_date(self):
-        if self.date_end.strftime("%Y-%m-%d") == datetime.now().strftime("%Y-%m-%d"):
+        if self.date_end.strftime("%Y-%m-%d") <= datetime.now().strftime("%Y-%m-%d"):
             self.write({"status": "closed"})
         else:
             self.write({"status": "closed_planned"})
diff --git a/energy_communities_service_invoicing/models/contract_line.py b/energy_communities_service_invoicing/models/contract_line.py
index ab5763ec7..3bed75255 100644
--- a/energy_communities_service_invoicing/models/contract_line.py
+++ b/energy_communities_service_invoicing/models/contract_line.py
@@ -13,6 +13,15 @@ class ContractLine(models.Model):
         for record in self:
             record.is_cancel_allowed = True
 
-    # TODO:
-    # skip last_date_invoice validation for modification action if contract is ready to start or active on free plan.
-    # def _check_last_date_invoiced(self):
+    # skip last_date_invoice update for modification action if contract is ready to start or on free plan.
+    def _update_recurring_next_date(self):
+        # TODO: Pay attention to original code in order to detect if method has been renamed:
+        # FIXME: Change method name according to real updated field
+        # e.g.: _update_last_date_invoiced()
+        for record in self:
+            if (
+                record.contract_id.status != "ready_to_start"
+                or record.contract_id.is_free_pack
+            ):
+                return
+        super()._update_recurring_next_date()
diff --git a/energy_communities_service_invoicing/models/contract_template.py b/energy_communities_service_invoicing/models/contract_template.py
index 80fd7506e..c4008db80 100644
--- a/energy_communities_service_invoicing/models/contract_template.py
+++ b/energy_communities_service_invoicing/models/contract_template.py
@@ -6,6 +6,7 @@ class ContractTemplate(models.Model):
     _inherit = "contract.template"
 
     is_pack = fields.Boolean(compute="compute_is_pack", store=True)
+    is_free_pack = fields.Boolean(string="Is a free pack")
 
     def compute_is_pack(self):
         try:
@@ -14,8 +15,8 @@ class ContractTemplate(models.Model):
             ).id
         except:
             categ_id = False
-        if categ_id:
-            for record in self:
+        for record in self:
+            if categ_id:
                 record.is_pack = bool(
                     self.env["product.template"].search(
                         [
diff --git a/energy_communities_service_invoicing/models/res_company.py b/energy_communities_service_invoicing/models/res_company.py
index 6d8d8bf50..11701aaea 100644
--- a/energy_communities_service_invoicing/models/res_company.py
+++ b/energy_communities_service_invoicing/models/res_company.py
@@ -4,7 +4,7 @@ from odoo.tools.translate import _
 
 class ResCompany(models.Model):
     _name = "res.company"
-    _inherit = "res.company"
+    _inherit = ["res.company"]
 
     service_invoicing_journal_id = fields.Many2one(
         comodel_name="account.journal",
diff --git a/energy_communities_service_invoicing/models/service_invoicing_info_mixin.py b/energy_communities_service_invoicing/models/service_invoicing_info_mixin.py
new file mode 100644
index 000000000..a1bb3b721
--- /dev/null
+++ b/energy_communities_service_invoicing/models/service_invoicing_info_mixin.py
@@ -0,0 +1,28 @@
+from odoo import api, fields, models
+
+
+class ServiceInvoicingInfoMixin(models.AbstractModel):
+    _name = "service.invoicing.info.mixin"
+    _description = "Get info about current service invoicing configuration"
+
+    pack_product_product_ids = fields.Many2many(
+        comodel_name="product.product",
+        _compute="_compute_pack_product_product_ids",
+        store=False,
+    )
+
+    @api.depends("name")
+    def _compute_pack_product_product_ids(self):
+        for record in self:
+            pack_product_product_ids = []
+            record.pack_product_product_ids = self.env["product.product"].search(
+                [
+                    (
+                        "categ_id",
+                        "=",
+                        self.env.ref(
+                            "energy_communities_service_invoicing.product_category_pack"
+                        ).id,
+                    )
+                ]
+            )
diff --git a/energy_communities_service_invoicing/utils.py b/energy_communities_service_invoicing/utils.py
index f64fd894c..47feda5bc 100644
--- a/energy_communities_service_invoicing/utils.py
+++ b/energy_communities_service_invoicing/utils.py
@@ -45,21 +45,6 @@ def raise_existing_same_open_contract_error():
     )
 
 
-def get_pack_product_product_ids(env):
-    ret = env["product.product"].search(
-        [
-            (
-                "categ_id",
-                "=",
-                env.ref(
-                    "energy_communities_service_invoicing.product_category_pack"
-                ).id,
-            )
-        ]
-    )
-    return ret
-
-
 def get_existing_open_contract(
     env, partner_id, community_company_id, contract_id=False
 ):
diff --git a/energy_communities_service_invoicing/views/contract_template_views.xml b/energy_communities_service_invoicing/views/contract_template_views.xml
new file mode 100644
index 000000000..dfb1bece1
--- /dev/null
+++ b/energy_communities_service_invoicing/views/contract_template_views.xml
@@ -0,0 +1,12 @@
+<odoo>
+<record id="contract_template_form_view" model="ir.ui.view">
+  <field name="name">contract.template form view (in energy_communities service_invoicing)</field>
+  <field name="model">contract.template</field>
+  <field name="inherit_id" ref="contract.contract_template_form_view" />
+  <field name="arch" type="xml">
+    <xpath expr="//field[@name='contract_type']" position="after">
+      <field name="is_free_pack" />
+    </xpath>
+  </field>
+</record>
+</odoo>
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
index 290ddba4a..3dfce8f31 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
@@ -12,7 +12,6 @@ from odoo.addons.energy_communities.utils import (
 from ..utils import (
     get_existing_last_closed_contract,
     get_existing_open_contract,
-    get_pack_product_product_ids,
     raise_existing_same_open_contract_error,
     service_invoicing_view,
 )
@@ -21,7 +20,7 @@ from ..utils import (
 class ServiceInvoicingActionCreateWizard(models.TransientModel):
     _name = "service.invoicing.action.create.wizard"
     _description = "Create service invoicing for an energy community"
-    _inherit = ["user.currentcompany.mixin"]
+    _inherit = ["user.currentcompany.mixin", "service.invoicing.info.mixin"]
 
     company_id = fields.Many2one("res.company", string="Coordinator")
     community_company_id = fields.Many2one(
@@ -33,6 +32,7 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
         "product.product",
         string="Service pack",
         domain="[('id', 'in', pack_product_product_ids)]",
+        precompute=True,
     )
     payment_mode_id = fields.Many2one(
         "account.payment.mode",
@@ -52,11 +52,6 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
         _compute="_compute_ allowed_payment_mode_ids",
         store=False,
     )
-    pack_product_product_ids = fields.Many2many(
-        comodel_name="product.product",
-        _compute="_compute_pack_product_product_ids",
-        store=False,
-    )
 
     @api.depends("company_id")
     def _compute_allowed_community_company_ids(self):
@@ -74,15 +69,12 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
                 [("company_id", "=", self.user_current_company.id)]
             )
 
-    def _compute_pack_product_product_ids(self):
-        for record in self:
-            record.pack_product_product_ids = get_pack_product_product_ids(self.env)
-
     @api.onchange("company_id")
     def _on_change_company_id(self):
         for record in self:
             record._compute_allowed_community_company_ids()
             record._compute_allowed_payment_mode_ids()
+            # TODO: This should be necessary if pack_product_product_ids gets properly auto computed
             record._compute_pack_product_product_ids()
 
     def execute_create(self):
-- 
GitLab


From 70afb81d3dbd3cbb7295f1c283ced8340e6be198 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Fri, 21 Feb 2025 19:27:03 +0100
Subject: [PATCH 63/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Service=20Invoicing?=
 =?UTF-8?q?=20MVP?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../components/contract_utils.py              | 28 +++++++------------
 .../components/sale_order_utils.py            | 10 ++++---
 .../models/contract_line.py                   |  5 +---
 energy_communities_service_invoicing/utils.py |  4 +--
 .../views/contract_views.xml                  | 14 +++++-----
 .../service_invoicing_action_create.py        | 22 +++++++--------
 6 files changed, 36 insertions(+), 47 deletions(-)

diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
index c0cd319e4..cc36474cf 100644
--- a/energy_communities_service_invoicing/components/contract_utils.py
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -4,7 +4,7 @@ from odoo.addons.component.core import Component
 class ContractUtils(Component):
     _inherit = "contract.utils"
 
-    def set_contract_status_ready_to_start(self):
+    def setup_initial_data(self):
         for line in self.work.record.contract_line_ids:
             line.write(
                 {
@@ -15,7 +15,7 @@ class ContractUtils(Component):
                     "quantity": 0,
                 }
             )
-        self.work.record.write({"status": "ready_to_start"})
+        self.work.record.write({"status": "paused"})
 
     def _activate_contract_lines(self, execution_date):
         for line in self.work.record.contract_line_ids:
@@ -39,10 +39,7 @@ class ContractUtils(Component):
 
     def set_contract_status_closed(self, execution_date):
         for line in self.work.record.contract_line_ids:
-            if (
-                self.work.record.status == "ready_to_start"
-                or self.work.record.is_free_pack
-            ):
+            if self.work.record.status == "paused" or self.work.record.is_free_pack:
                 self._activate_contract_lines(execution_date)
             line.write({"date_end": execution_date})
             line._compute_state()
@@ -95,17 +92,12 @@ class ContractUtils(Component):
             discount,
             payment_mode_id,
         )
-        if initial_status == "ready_to_start":
-            new_service_invoicing_id = (
-                sale_order_utils.create_service_invoicing_ready_to_start(
-                    **service_invoicing_params
-                )
-            )
-        if initial_status == "in_progress":
-            new_service_invoicing_id = sale_order_utils.create_service_invoicing(
-                **service_invoicing_params
-            )
-
+        new_service_invoicing_id = sale_order_utils.create_service_invoicing_initial(
+            **service_invoicing_params
+        )
+        # Do we really want new contract to be in_progress on a modification??
+        if initial_status == "in_progress" and not self.work.record.is_free_pack:
+            self.set_contract_status_active()
         self._setup_successors_and_predecessors(new_service_invoicing_id)
         return new_service_invoicing_id
 
@@ -120,7 +112,7 @@ class ContractUtils(Component):
         self.set_contract_status_closed(execution_date)
         new_service_invoicing_id = self.component(
             usage="sale.order.utils", model_name="sale.order"
-        ).create_service_invoicing_ready_to_start(
+        ).create_service_invoicing_initial(
             **self._build_service_invoicing_params(
                 "reopen",
                 "modify_service_pack,modify_pricelist,modify_discount,modify_payment_mode",
diff --git a/energy_communities_service_invoicing/components/sale_order_utils.py b/energy_communities_service_invoicing/components/sale_order_utils.py
index 2dc8013c9..5375602fb 100644
--- a/energy_communities_service_invoicing/components/sale_order_utils.py
+++ b/energy_communities_service_invoicing/components/sale_order_utils.py
@@ -42,7 +42,7 @@ class SaleOrderUtils(Component):
             order_line._compute_name()
         return self.env["sale.order"].create(so_creation_dict)
 
-    def create_service_invoicing(
+    def _create_service_invoicing(
         self,
         company_id,
         community_company_id,
@@ -75,7 +75,7 @@ class SaleOrderUtils(Component):
                 component.set_configuration_service_invoicing_journal_if_defined()
         return service_invoicing_id
 
-    def create_service_invoicing_ready_to_start(
+    def create_service_invoicing_initial(
         self,
         company_id,
         community_company_id,
@@ -87,7 +87,7 @@ class SaleOrderUtils(Component):
         executed_action,
         executed_action_description="none",
     ):
-        service_invoicing_id = self.create_service_invoicing(
+        service_invoicing_id = self._create_service_invoicing(
             company_id,
             community_company_id,
             service_pack_id,
@@ -100,7 +100,9 @@ class SaleOrderUtils(Component):
         )
         # TODO: We must call contract_utils with a better component and workcontext modification approach
         with contract_utils(self.env, service_invoicing_id) as component:
-            component.set_contract_status_ready_to_start()
+            component.setup_initial_data()
+            if service_invoicing_id.is_free_pack:
+                component.set_contract_status_active(start_date)
         return service_invoicing_id
 
     def _get_related_contracts(self, sale_order):
diff --git a/energy_communities_service_invoicing/models/contract_line.py b/energy_communities_service_invoicing/models/contract_line.py
index 3bed75255..3ec81ca6a 100644
--- a/energy_communities_service_invoicing/models/contract_line.py
+++ b/energy_communities_service_invoicing/models/contract_line.py
@@ -19,9 +19,6 @@ class ContractLine(models.Model):
         # FIXME: Change method name according to real updated field
         # e.g.: _update_last_date_invoiced()
         for record in self:
-            if (
-                record.contract_id.status != "ready_to_start"
-                or record.contract_id.is_free_pack
-            ):
+            if record.contract_id.status == "paused" or record.contract_id.is_free_pack:
                 return
         super()._update_recurring_next_date()
diff --git a/energy_communities_service_invoicing/utils.py b/energy_communities_service_invoicing/utils.py
index 47feda5bc..3da795640 100644
--- a/energy_communities_service_invoicing/utils.py
+++ b/energy_communities_service_invoicing/utils.py
@@ -5,7 +5,7 @@ from odoo.exceptions import ValidationError
 from odoo.addons.contract.models.contract import ContractContract
 
 _CONTRACT_STATUS_VALUES = [
-    ("ready_to_start", _("Ready to start")),
+    ("paused", _("Paused")),
     ("in_progress", _("In progress")),
     ("closed_planned", _("Planned closure")),
     ("closed", _("Closed")),
@@ -52,7 +52,7 @@ def get_existing_open_contract(
         ("partner_id", "=", partner_id.id),
         ("community_company_id", "=", community_company_id.id),
         ("is_pack", "=", True),
-        ("status", "in", ["ready_to_start", "in_progress"]),
+        ("status", "in", ["paused", "in_progress"]),
     ]
     if contract_id:
         query.append(("id", "!=", contract_id.id))
diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index 14da3acba..9f7dd5a4b 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -7,9 +7,9 @@
     <field name="arch" type="xml">
       <filter name="not_finished" position="before">
         <filter
-          name="ready_to_start"
-          string="Ready to start"
-          domain="[('status','=','ready_to_start')]"
+          name="paused"
+          string="Paused"
+          domain="[('status','=','paused')]"
         />
         <!--<separator />-->
       </filter>
@@ -41,7 +41,7 @@
         <field 
           name="status"
           widget="badge"
-          decoration-info="status == 'ready_to_start'"
+          decoration-info="status == 'paused'"
           decoration-danger="status == 'closed'"
           decoration-warning="status == 'closed_planned'"
           decoration-success="status == 'in_progress'"
@@ -117,19 +117,19 @@
           name="action_activate_contract"
           type="object"
           string="Activate"
-          attrs="{'invisible':[('status','not in',['ready_to_start'])]}"
+          attrs="{'invisible':[('status','not in',['paused'])]}"
         />
         <button
           name="action_modify_contract"
           type="object"
           string="Modify"
-          attrs="{'invisible':[('status','not in',['ready_to_start','in_progress'])]}"
+          attrs="{'invisible':[('status','not in',['paused','in_progress'])]}"
         />
         <button
           name="action_close_contract"
           type="object"
           string="Close"
-          attrs="{'invisible':[('status','not in',['ready_to_start','in_progress'])]}"
+          attrs="{'invisible':[('status','not in',['paused','in_progress'])]}"
         />
         <button
           name="action_reopen_contract"
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
index 3dfce8f31..a68cfef60 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
@@ -100,17 +100,15 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
         # If none of previous create a new contract
         else:
             with sale_order_utils(self.env) as component:
-                service_invoicing_id = (
-                    component.create_service_invoicing_ready_to_start(
-                        self.company_id,
-                        self.community_company_id,
-                        self.service_pack_id,
-                        self.pricelist_id,
-                        self.payment_mode_id,
-                        datetime.now(),
-                        self.discount,
-                        "activate",
-                        "active_platform_service_invocing",
-                    )
+                service_invoicing_id = component.create_service_invoicing_initial(
+                    self.company_id,
+                    self.community_company_id,
+                    self.service_pack_id,
+                    self.pricelist_id,
+                    self.payment_mode_id,
+                    datetime.now(),
+                    self.discount,
+                    "activate",
+                    "active_platform_service_invocing",
                 )
         return service_invoicing_view(self.env, service_invoicing_id)
-- 
GitLab


From 1d2da73b28839872546e0b4f85a682ce19714482 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Mon, 24 Feb 2025 09:29:09 +0100
Subject: [PATCH 64/85] =?UTF-8?q?[WIP]=20=F0=9F=9A=A7=20For=20now=20all=20?=
 =?UTF-8?q?modifications=20stay=20paused.=20Must=20manually=20activate.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../components/contract_utils.py                             | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
index cc36474cf..4b45e99f2 100644
--- a/energy_communities_service_invoicing/components/contract_utils.py
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -95,9 +95,10 @@ class ContractUtils(Component):
         new_service_invoicing_id = sale_order_utils.create_service_invoicing_initial(
             **service_invoicing_params
         )
+        # TODO:
         # Do we really want new contract to be in_progress on a modification??
-        if initial_status == "in_progress" and not self.work.record.is_free_pack:
-            self.set_contract_status_active()
+        # if initial_status == "in_progress" and not self.work.record.is_free_pack:
+        #     self.set_contract_status_active()
         self._setup_successors_and_predecessors(new_service_invoicing_id)
         return new_service_invoicing_id
 
-- 
GitLab


From b428cab34fac7a7afae038183d25b7011b23beb0 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Tue, 25 Feb 2025 10:25:34 +0100
Subject: [PATCH 65/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Introducing=20closing?=
 =?UTF-8?q?=20reason=20on=20contract?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../models/contract.py                        | 42 ++++++++++++++++++-
 .../views/contract_views.xml                  |  8 ++++
 2 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index acadcae8f..392880e0a 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -1,14 +1,18 @@
 from datetime import datetime
 
-from odoo import api, fields, models
-from odoo.tools.translate import _
+from odoo import _, api, fields, models
 
 from ..utils import (
     _CONTRACT_STATUS_VALUES,
+    _SALE_ORDER_SERVICE_INVOICING_ACTION_VALUES,
     get_existing_open_contract,
     raise_existing_same_open_contract_error,
 )
 
+_CLOSING_ACTION_VALUES = _SALE_ORDER_SERVICE_INVOICING_ACTION_VALUES + [
+    ("close", _("Close"))
+]
+
 
 class ContractContract(models.Model):
     _inherit = "contract.contract"
@@ -42,6 +46,18 @@ class ContractContract(models.Model):
     )
     is_pack = fields.Boolean(related="contract_template_id.is_pack")
     is_free_pack = fields.Boolean(related="contract_template_id.is_free_pack")
+    closing_action = fields.Selection(
+        selection=_CLOSING_ACTION_VALUES,
+        compute="_compute_closing_action",
+        string="Closing reason",
+        default="none",
+        store=True,
+    )
+    closing_action_description = fields.Char(
+        string="Closing reason description",
+        compute="_compute_closing_action_description",
+        store=True,
+    )
     related_contract_product_ids = fields.One2many(
         "product.product",
         string="Related services",
@@ -64,6 +80,28 @@ class ContractContract(models.Model):
     # On energy communities all contracts have company_id
     company_id = fields.Many2one(required=True)
 
+    @api.depends("status", "successor_contract_id")
+    def _compute_closing_action(self):
+        for record in self:
+            record.closing_action = "none"
+            if record.status in ["closed", "closed_planned"]:
+                if record.successor_contract_id:
+                    record.closing_action = (
+                        record.successor_contract_id.sale_order_id.service_invoicing_action
+                    )
+                else:
+                    record.closing_action = "close"
+
+    @api.depends("status", "successor_contract_id")
+    def _compute_closing_action_description(self):
+        for record in self:
+            record.closing_action_description = ""
+            if record.status in ["closed", "closed_planned"]:
+                if record.successor_contract_id:
+                    record.closing_action_description = (
+                        record.successor_contract_id.sale_order_id.service_invoicing_action_description
+                    )
+
     @api.constrains("partner_id", "community_company_id")
     def _constrain_unique_contract(self):
         for record in self:
diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index 9f7dd5a4b..924884b58 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -99,6 +99,12 @@
             <field name="recurring_next_date" />
             <field name="date_end" attrs="{'invisible': [('status','!=','closed')]}" />
           </group>
+          <group>
+            <field name="predecessor_contract_id" />
+            <field name="successor_contract_id" attrs="{'invisible':['|',('status','not in',['closed','closed_planned']),('successor_contract_id','!=',False)]}" />
+            <field name="closing_action" attrs="{'invisible':[('status','not in',['closed','closed_planned'])]}" />
+            <field name="closing_action_description" attrs="{'invisible':[('status','not in',['closed','closed_planned'])]}" />
+          </group>
         </sheet>
       </form>
     </field>
@@ -152,6 +158,8 @@
         <field name="discount" />
         <field name="predecessor_contract_id" />
         <field name="successor_contract_id" />
+        <field name="closing_action" attrs="{'invisible':[('status','not in',['closed','closed_planned'])]}" />
+        <field name="closing_action_description" attrs="{'invisible':[('status','not in',['closed','closed_planned'])]}" />
         <field name="sale_order_id" />
       </xpath>
     </field>
-- 
GitLab


From 954cabc77bd4e7be4dc74e4ef9dd7fd3432353cf Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Tue, 25 Feb 2025 11:40:21 +0100
Subject: [PATCH 66/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Propagate=20sale=20de?=
 =?UTF-8?q?scription=20from=20product=20to=20contract=20template=20line?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../models/product_template.py                      | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/energy_communities_service_invoicing/models/product_template.py b/energy_communities_service_invoicing/models/product_template.py
index 662106d75..d9b8d3eef 100644
--- a/energy_communities_service_invoicing/models/product_template.py
+++ b/energy_communities_service_invoicing/models/product_template.py
@@ -30,3 +30,16 @@ class ProductTemplate(models.Model):
             ctemplates = self.env["contract.template"].search([])
             for ctemplate in ctemplates:
                 ctemplate.compute_is_pack()
+
+    @api.constrains("description_sale")
+    def compute_contract_template_line_name(self):
+        for record in self:
+            ctemplatelines = self.env["contract.template.line"].search(
+                [("product_id", "=", record.product_variant_id.id)]
+            )
+            for ctemplateline in ctemplatelines:
+                ctemplateline.write(
+                    {
+                        "name": ctemplateline.product_id.get_product_multiline_description_sale()
+                    }
+                )
-- 
GitLab


From ce558fff6c034d7c0807d2984627ccb5cb80f01e Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Tue, 25 Feb 2025 11:46:07 +0100
Subject: [PATCH 67/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Create=20contracts=20?=
 =?UTF-8?q?always=20with=20defined=20journal?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../components/sale_order_utils.py                             | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/energy_communities_service_invoicing/components/sale_order_utils.py b/energy_communities_service_invoicing/components/sale_order_utils.py
index 5375602fb..fca1c7d84 100644
--- a/energy_communities_service_invoicing/components/sale_order_utils.py
+++ b/energy_communities_service_invoicing/components/sale_order_utils.py
@@ -71,8 +71,7 @@ class SaleOrderUtils(Component):
             component.clean_non_service_lines()
             component.set_start_date(start_date)
             component.set_discount(discount)
-            if executed_action_description == "active_platform_service_invocing":
-                component.set_configuration_service_invoicing_journal_if_defined()
+            component.set_configuration_service_invoicing_journal_if_defined()
         return service_invoicing_id
 
     def create_service_invoicing_initial(
-- 
GitLab


From 0781b1c5f41b790a3dc8fd6b0d8995c9c1cd1a4f Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Tue, 25 Feb 2025 11:53:52 +0100
Subject: [PATCH 68/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Show=20only=20active?=
 =?UTF-8?q?=20and=20paused=20contrats=20by=20default?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../views/service_invoicing_views.xml                           | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/energy_communities_service_invoicing/views/service_invoicing_views.xml b/energy_communities_service_invoicing/views/service_invoicing_views.xml
index d88715f79..d8d507be2 100644
--- a/energy_communities_service_invoicing/views/service_invoicing_views.xml
+++ b/energy_communities_service_invoicing/views/service_invoicing_views.xml
@@ -9,6 +9,7 @@
     <field name="domain">
 [('community_company_id','!=',False)]
     </field>
+    <field name="context">{"search_default_not_finished":1,"search_default_paused":1}</field>
   </record>
 
   <record
@@ -21,6 +22,7 @@
     <field name="domain">
 [('community_company_id','!=',False)]
     </field>
+    <field name="context">{"search_default_not_finished":1,"search_default_paused":1}</field>
   </record>
 
   <record
-- 
GitLab


From de302ad8c40ef0c58a44db5ec07ad32a4a1af19e Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Wed, 26 Feb 2025 14:45:03 +0100
Subject: [PATCH 69/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Batch=20create=20serv?=
 =?UTF-8?q?ice=20invoicings?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 energy_communities/views/res_users_view.xml   |  50 +++---
 .../__manifest__.py                           |   1 +
 .../components/sale_order_utils.py            |   3 +
 .../models/__init__.py                        |   1 -
 .../models/contract.py                        |   2 +-
 .../models/res_company.py                     |   8 +
 .../models/service_invoicing_info_mixin.py    |  28 ----
 energy_communities_service_invoicing/utils.py |  26 +++-
 .../views/res_company_views.xml               |  13 ++
 .../wizards/service_invoicing_action.py       |  10 +-
 .../service_invoicing_action_create.py        | 146 ++++++++++++++----
 .../service_invoicing_action_create.xml       |  24 ++-
 12 files changed, 212 insertions(+), 100 deletions(-)
 delete mode 100644 energy_communities_service_invoicing/models/service_invoicing_info_mixin.py

diff --git a/energy_communities/views/res_users_view.xml b/energy_communities/views/res_users_view.xml
index 9eaba37a8..7cb910ae9 100644
--- a/energy_communities/views/res_users_view.xml
+++ b/energy_communities/views/res_users_view.xml
@@ -1,40 +1,28 @@
 <?xml version="1.0" encoding="utf-8" ?>
 <odoo>
     <data noupdate="1">
-        <record model="ir.actions.server" id="print_instance">
-            <field name="name">Push user to Keycloak</field>
-            <field name="model_id" ref="model_res_users" />
-            <field name="binding_model_id" ref="model_res_users" />
-            <field name="binding_type">action</field>
-            <field name="groups_id" eval="[(4,ref('group_platform_manager'))]" />
-            <field name="state">code</field>
-            <field name="code">
-                record.create_users_on_keycloak()
-            </field>
-        </record>
-
-    <record id="view_res_users_form_inherit" model="ir.ui.view">
-        <field name="name">res.users.form.inherit</field>
-        <field name="model">res.users</field>
-        <field name="inherit_id" ref="base.view_users_form" />
-        <field name="arch" type="xml">
+      <record id="view_res_users_form_inherit" model="ir.ui.view">
+          <field name="name">res.users.form.inherit</field>
+          <field name="model">res.users</field>
+          <field name="inherit_id" ref="base.view_users_form" />
+          <field name="arch" type="xml">
             <xpath
-          expr="//notebook//field[@name='role_line_ids']/tree//field[@name='role_id']"
-          position="attributes"
-        >
-                <attribute name="domain" />
+              expr="//notebook//field[@name='role_line_ids']/tree//field[@name='role_id']"
+              position="attributes"
+            >
+              <attribute name="domain" />
             </xpath>
-        </field>
-    </record>
-    <record id="view_res_users_form_inherit_oauth" model="ir.ui.view">
-        <field name="name">res.users.form.inherit.oauth</field>
-        <field name="model">res.users</field>
-        <field name="inherit_id" ref="auth_oauth.view_users_form" />
-        <field name="arch" type="xml">
+          </field>
+      </record>
+      <record id="view_res_users_form_inherit_oauth" model="ir.ui.view">
+          <field name="name">res.users.form.inherit.oauth</field>
+          <field name="model">res.users</field>
+          <field name="inherit_id" ref="auth_oauth.view_users_form" />
+          <field name="arch" type="xml">
             <field name="oauth_access_token" position="after">
-                <field name="last_user_invitation_through_kc" />
+              <field name="last_user_invitation_through_kc" />
             </field>
-        </field>
-    </record>
+          </field>
+      </record>
     </data>
 </odoo>
diff --git a/energy_communities_service_invoicing/__manifest__.py b/energy_communities_service_invoicing/__manifest__.py
index a3ec60b9e..f525cf563 100644
--- a/energy_communities_service_invoicing/__manifest__.py
+++ b/energy_communities_service_invoicing/__manifest__.py
@@ -15,6 +15,7 @@
         "base",
         "contract",
         "sale",
+        "sales_team",
         "purchase",
         "product",
         "product_contract",
diff --git a/energy_communities_service_invoicing/components/sale_order_utils.py b/energy_communities_service_invoicing/components/sale_order_utils.py
index fca1c7d84..5cfeeccaa 100644
--- a/energy_communities_service_invoicing/components/sale_order_utils.py
+++ b/energy_communities_service_invoicing/components/sale_order_utils.py
@@ -36,6 +36,9 @@ class SaleOrderUtils(Component):
                 )
             ],
         }
+        # Apply configuration sales team to service invoicing sales order
+        if company_id.service_invoicing_sale_team_id:
+            so_creation_dict["team_id"] = company_id.service_invoicing_sale_team_id.id
         sale_order = self.env["sale.order"].create(so_creation_dict)
         # Trigger name computattion in oder to include product's description_sale
         for order_line in sale_order.order_line:
diff --git a/energy_communities_service_invoicing/models/__init__.py b/energy_communities_service_invoicing/models/__init__.py
index 4c3afbbec..7ba9edcc6 100644
--- a/energy_communities_service_invoicing/models/__init__.py
+++ b/energy_communities_service_invoicing/models/__init__.py
@@ -1,4 +1,3 @@
-from . import service_invoicing_info_mixin
 from . import abstract_contract
 from . import account_move
 from . import contract
diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index 392880e0a..14932d2aa 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -108,7 +108,7 @@ class ContractContract(models.Model):
             if record.community_company_id:
                 existing_contract = record._get_existing_same_open_contract()
                 if existing_contract:
-                    raise_existing_same_open_contract_error()
+                    raise_existing_same_open_contract_error(existing_contract)
 
     def _compute_received_invoices_count(self):
         for record in self:
diff --git a/energy_communities_service_invoicing/models/res_company.py b/energy_communities_service_invoicing/models/res_company.py
index 11701aaea..1c74ab3bd 100644
--- a/energy_communities_service_invoicing/models/res_company.py
+++ b/energy_communities_service_invoicing/models/res_company.py
@@ -10,3 +10,11 @@ class ResCompany(models.Model):
         comodel_name="account.journal",
         string="Service invoicing journal",
     )
+    service_invoicing_payment_mode_id = fields.Many2one(
+        comodel_name="account.payment.mode",
+        string="Service invoicing payment mode",
+    )
+    service_invoicing_sale_team_id = fields.Many2one(
+        comodel_name="crm.team",
+        string="Service invoicing sales team",
+    )
diff --git a/energy_communities_service_invoicing/models/service_invoicing_info_mixin.py b/energy_communities_service_invoicing/models/service_invoicing_info_mixin.py
deleted file mode 100644
index a1bb3b721..000000000
--- a/energy_communities_service_invoicing/models/service_invoicing_info_mixin.py
+++ /dev/null
@@ -1,28 +0,0 @@
-from odoo import api, fields, models
-
-
-class ServiceInvoicingInfoMixin(models.AbstractModel):
-    _name = "service.invoicing.info.mixin"
-    _description = "Get info about current service invoicing configuration"
-
-    pack_product_product_ids = fields.Many2many(
-        comodel_name="product.product",
-        _compute="_compute_pack_product_product_ids",
-        store=False,
-    )
-
-    @api.depends("name")
-    def _compute_pack_product_product_ids(self):
-        for record in self:
-            pack_product_product_ids = []
-            record.pack_product_product_ids = self.env["product.product"].search(
-                [
-                    (
-                        "categ_id",
-                        "=",
-                        self.env.ref(
-                            "energy_communities_service_invoicing.product_category_pack"
-                        ).id,
-                    )
-                ]
-            )
diff --git a/energy_communities_service_invoicing/utils.py b/energy_communities_service_invoicing/utils.py
index 3da795640..e9d5e6d38 100644
--- a/energy_communities_service_invoicing/utils.py
+++ b/energy_communities_service_invoicing/utils.py
@@ -21,7 +21,25 @@ _SALE_ORDER_SERVICE_INVOICING_ACTION_VALUES = [
 ] + _SERVICE_INVOICING_EXECUTED_ACTION_VALUES[:-1]
 
 
-def service_invoicing_view(env: Environment, service_invoicing_id: ContractContract):
+def service_invoicing_tree_view(env: Environment):
+    return {
+        "type": "ir.actions.act_window",
+        "res_model": "contract.contract",
+        "views": [
+            (
+                env.ref(
+                    "energy_communities_service_invoicing.view_service_invoicing_tree"
+                ).id,
+                "form",
+            ),
+        ],
+        "target": "current",
+    }
+
+
+def service_invoicing_form_view_for_platform_admins(
+    env: Environment, service_invoicing_id: ContractContract
+):
     return {
         "type": "ir.actions.act_window",
         "res_model": "contract.contract",
@@ -39,9 +57,11 @@ def service_invoicing_view(env: Environment, service_invoicing_id: ContractContr
 
 
 # TODO: Think a bit more about more about if this 3 methods must go to contract utils component
-def raise_existing_same_open_contract_error():
+def raise_existing_same_open_contract_error(existing_contract):
     raise ValidationError(
-        _("It can only exists one service contract per Customer and related community.")
+        _(
+            "It already exists an open contract ({}) with same company and community."
+        ).format(existing_contract.name)
     )
 
 
diff --git a/energy_communities_service_invoicing/views/res_company_views.xml b/energy_communities_service_invoicing/views/res_company_views.xml
index a907bb966..3b5673954 100644
--- a/energy_communities_service_invoicing/views/res_company_views.xml
+++ b/energy_communities_service_invoicing/views/res_company_views.xml
@@ -1,4 +1,15 @@
 <odoo>
+  <record id="service_invoicing_action_create_wizard_from_company_action" model="ir.actions.server">
+    <field name="name">Assign pack to community</field>
+    <field name="binding_model_id" ref="model_res_company" />
+    <field name="model_id" ref="model_service_invoicing_action_create_wizard" />
+    <field name="binding_type">action</field>
+    <field name="state">code</field>
+    <field name="groups_id" eval="[(4,ref('energy_communities.group_platform_manager'))]" />
+    <field name="code">
+        action = model.get_service_invoicing_action_create_wizard_form_view()
+    </field>
+  </record>
   <record id="view_service_invocing_company_form" model="ir.ui.view">
     <field name="name">service.invoicing.res.company.form.inherit</field>
     <field name="model">res.company</field>
@@ -9,6 +20,8 @@
           <group>
             <field name="id" invisible="1"/>
             <field name="service_invoicing_journal_id" domain="[('company_id', '=', id)]" />
+            <field name="service_invoicing_payment_mode_id" domain="[('company_id', '=', id)]" />
+            <field name="service_invoicing_sale_team_id" domain="[('company_id', '=', id)]" />
           </group>
         </page>
       </xpath>
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action.py b/energy_communities_service_invoicing/wizards/service_invoicing_action.py
index 49c7ed275..ec3423774 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action.py
@@ -6,7 +6,7 @@ from odoo.addons.energy_communities.utils import contract_utils
 
 from ..utils import (
     _SERVICE_INVOICING_EXECUTED_ACTION_VALUES,
-    service_invoicing_view,
+    service_invoicing_form_view_for_platform_admins,
 )
 
 
@@ -46,7 +46,9 @@ class ServiceInvoicingActionWizard(models.TransientModel):
                 self.discount,
                 self.payment_mode_id,
             )
-        return service_invoicing_view(self.env, service_invoicing_id)
+        return service_invoicing_form_view_for_platform_admins(
+            self.env, service_invoicing_id
+        )
 
     def execute_reopen(self):
         with contract_utils(self.env, self.service_invoicing_id) as component:
@@ -57,7 +59,9 @@ class ServiceInvoicingActionWizard(models.TransientModel):
                 self.discount,
                 self.payment_mode_id,
             )
-        return service_invoicing_view(self.env, service_invoicing_id)
+        return service_invoicing_form_view_for_platform_admins(
+            self.env, service_invoicing_id
+        )
 
     def _validate_execute_modify(self):
         if (
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
index a68cfef60..33a67f2a1 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
@@ -13,14 +13,15 @@ from ..utils import (
     get_existing_last_closed_contract,
     get_existing_open_contract,
     raise_existing_same_open_contract_error,
-    service_invoicing_view,
+    service_invoicing_form_view_for_platform_admins,
+    service_invoicing_tree_view,
 )
 
 
 class ServiceInvoicingActionCreateWizard(models.TransientModel):
     _name = "service.invoicing.action.create.wizard"
     _description = "Create service invoicing for an energy community"
-    _inherit = ["user.currentcompany.mixin", "service.invoicing.info.mixin"]
+    _inherit = ["user.currentcompany.mixin"]
 
     company_id = fields.Many2one("res.company", string="Coordinator")
     community_company_id = fields.Many2one(
@@ -28,11 +29,12 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
         string="Community",
         domain="[('id', 'in', allowed_community_company_ids)]",
     )
+    community_company_mids = fields.Many2many(
+        comodel_name="res.company",
+    )
     service_pack_id = fields.Many2one(
         "product.product",
         string="Service pack",
-        domain="[('id', 'in', pack_product_product_ids)]",
-        precompute=True,
     )
     payment_mode_id = fields.Many2one(
         "account.payment.mode",
@@ -49,43 +51,67 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
     )
     allowed_payment_mode_ids = fields.Many2many(
         comodel_name="account.payment.mode",
-        _compute="_compute_ allowed_payment_mode_ids",
+        _compute="_compute_allowed_payment_mode_ids",
         store=False,
     )
+    pack_product_categ_id = fields.Many2one(
+        "product.category", compute="_compute_pack_product_categ_id", store=False
+    )
 
-    @api.depends("company_id")
+    def _compute_pack_product_categ_id(self):
+        for record in self:
+            record.pack_product_categ_id = self.env.ref(
+                "energy_communities_service_invoicing.product_category_pack"
+            ).id
+
+    @api.depends("company_id", "community_company_mids")
     def _compute_allowed_community_company_ids(self):
         for record in self:
-            record.allowed_community_company_ids = self.env["res.company"].search(
-                [
-                    ("hierarchy_level", "=", "community"),
-                    ("parent_id", "=", record.company_id.id),
-                ]
-            )
+            query = [("hierarchy_level", "=", "community")]
+            if record.community_company_mids:
+                query.append(("parent_id", "=", self.user_current_company.id))
+            else:
+                query.append(("parent_id", "=", record.company_id.id))
+            record.allowed_community_company_ids = self.env["res.company"].search(query)
 
+    @api.depends("company_id", "community_company_mids")
     def _compute_allowed_payment_mode_ids(self):
         for record in self:
+            if record.community_company_mids:
+                query = [("company_id", "=", self.user_current_company.id)]
+            else:
+                query = [("company_id", "=", record.company_id.id)]
             record.allowed_payment_mode_ids = self.env["account.payment.mode"].search(
-                [("company_id", "=", self.user_current_company.id)]
+                query
             )
 
     @api.onchange("company_id")
-    def _on_change_company_id(self):
+    def _compute_service_invoicing_action_create_wizard_allowed_values(self):
         for record in self:
             record._compute_allowed_community_company_ids()
             record._compute_allowed_payment_mode_ids()
-            # TODO: This should be necessary if pack_product_product_ids gets properly auto computed
-            record._compute_pack_product_product_ids()
 
     def execute_create(self):
-        # Check if already open one and raise error
-        existing_contract = get_existing_open_contract(
-            self.env, self.company_id.partner_id, self.community_company_id
-        )
-        if existing_contract:
-            raise_existing_same_open_contract_error()
+        if self.community_company_mids:
+            for community in self.community_company_mids:
+                self._execute_create_one(
+                    community,
+                    community.parent_id,
+                    self.env.company.service_invoicing_payment_mode_id,
+                )
+            return service_invoicing_tree_view(self.env)
+        else:
+            service_invoicing_id = self._execute_create_one(
+                self.community_company_id, self.company_id, self.payment_mode_id
+            )
+            return service_invoicing_form_view_for_platform_admins(
+                self.env, service_invoicing_id
+            )
+
+    def execute_create_one(self, community_company_id, company_id, payment_mode_id):
+        self._validate_service_invoicing_action_create([community_company_id.id])
         existing_closed_contract = get_existing_last_closed_contract(
-            self.env, self.company_id.partner_id, self.community_company_id
+            self.env, company_id.partner_id, community_company_id
         )
         # If existing closed contract reopen it
         if existing_closed_contract:
@@ -95,20 +121,84 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
                     self.pricelist_id,
                     self.service_pack_id,
                     self.discount,
-                    self.payment_mode_id,
+                    payment_mode_id,
                 )
         # If none of previous create a new contract
         else:
             with sale_order_utils(self.env) as component:
                 service_invoicing_id = component.create_service_invoicing_initial(
-                    self.company_id,
-                    self.community_company_id,
+                    company_id,
+                    community_company_id,
                     self.service_pack_id,
                     self.pricelist_id,
-                    self.payment_mode_id,
+                    payment_mode_id,
                     datetime.now(),
                     self.discount,
                     "activate",
                     "active_platform_service_invocing",
                 )
-        return service_invoicing_view(self.env, service_invoicing_id)
+        return service_invoicing_id
+
+    def get_service_invoicing_action_create_wizard_form_view(self):
+        if "active_ids" in self.env.context.keys():
+            self._validate_service_invoicing_action_create(
+                self.env.context["active_ids"]
+            )
+            self._validate_service_invoicing_action_create_multicommunity(
+                self.env.context["active_ids"]
+            )
+            wizard = self.env["service.invoicing.action.create.wizard"].create(
+                {
+                    "community_company_mids": self.env.context["active_ids"],
+                }
+            )
+            return {
+                "type": "ir.actions.act_window",
+                "res_model": "service.invoicing.action.create.wizard",
+                "views": [
+                    (
+                        self.env.ref(
+                            "energy_communities_service_invoicing.view_service_invoicing_action_create_wizard_form"
+                        ).id,
+                        "form",
+                    ),
+                ],
+                "target": "new",
+                "res_id": wizard.id,
+            }
+        return False
+
+    def _validate_service_invoicing_action_create(self, company_id_list):
+        impacted_records = self.env["res.company"].browse(company_id_list)
+        # Check all selected companies are communities
+        hierarchy_levels = list(set(impacted_records.mapped("hierarchy_level")))
+        if len(hierarchy_levels) > 1 or hierarchy_levels[0] != "community":
+            raise ValidationError(_("You can only assign pack to communities"))
+        # Check if already open one and raise error
+        for record in impacted_records:
+            existing_contract = get_existing_open_contract(
+                self.env, record.parent_id.partner_id, record
+            )
+            if existing_contract:
+                raise_existing_same_open_contract_error(existing_contract)
+
+    def _validate_service_invoicing_action_create_multicommunity(self, company_id_list):
+        impacted_records = self.env["res.company"].browse(company_id_list)
+        # check all communities have coordinator defined
+        for record in impacted_records:
+            if not record.parent_id:
+                raise ValidationError(
+                    _("Community {} must have a parent coordinator defined").format(
+                        record.name
+                    )
+                )
+        # Check current company has configuration payment mode for multicompany creation
+        if (
+            self.community_company_mids
+            and not self.env.company.service_invoicing_payment_mode_id
+        ):
+            raise ValidationError(
+                _(
+                    "Platform {} must have a service invoicing payment mode defined"
+                ).format(self.env.company.name)
+            )
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
index 147f07487..776c34b6e 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
@@ -11,12 +11,26 @@
           <group>
             <field name="allowed_community_company_ids" invisible="1" />
             <field name="allowed_payment_mode_ids" invisible="1" />
-            <field name="pack_product_product_ids" invisible="1" />
-            <field name="company_id" required="1" domain="[('hierarchy_level','=','coordinator')]"/>
-            <field name="community_company_id" required="1" />
-            <field name="service_pack_id" required="1"/>
+            <field name="pack_product_categ_id" invisible="1" />
+            <field
+              name="company_id"
+              domain="[('hierarchy_level','=','coordinator')]"
+              attrs="{'invisible':[('community_company_mids','!=',[])],'required':[('community_company_mids','=',[])]}"
+            />
+            <field
+              name="community_company_id"
+              attrs="{'invisible':[('community_company_mids','!=',[])],'required':[('community_company_mids','=',[])]}"
+            />
+            <field name="community_company_mids" />
+            <field name="service_pack_id"
+              required="1"
+              domain="[('categ_id','=',pack_product_categ_id)]"
+            />
             <field name="pricelist_id" required="1" domain="[('company_id','=',False)]"/>
-            <field name="payment_mode_id" required="1" />
+            <field
+              name="payment_mode_id"
+              attrs="{'invisible':[('community_company_mids','!=',[])],'required':[('community_company_mids','=',[])]}"
+            />
             <field name="discount" required="1" />
           </group>
         </sheet>
-- 
GitLab


From a38a87fa3c462a3ea9080828fcdef61d82b1879b Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Thu, 27 Feb 2025 10:36:17 +0100
Subject: [PATCH 70/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20get=5Fsuccessful=5Fpo?=
 =?UTF-8?q?pup=5Fmessage=20utils=20method=20and=20introduce=20execution=5F?=
 =?UTF-8?q?date=20on=20contract=20creation?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 energy_communities/models/landing_page.py     | 17 +++-------
 energy_communities/utils.py                   | 13 ++++++++
 .../wizards/change_coordinator_wizard.py      | 17 ++++------
 .../wizards/create_users_wizard.py            | 15 +++------
 .../wizards/multicompany_easy_creation.py     | 16 +++-------
 .../models/voluntary_share_interest_return.py | 14 ++-------
 energy_communities_service_invoicing/utils.py | 31 +++++++++++++------
 .../service_invoicing_action_create.py        | 16 +++++-----
 .../service_invoicing_action_create.xml       |  1 +
 9 files changed, 68 insertions(+), 72 deletions(-)

diff --git a/energy_communities/models/landing_page.py b/energy_communities/models/landing_page.py
index 74a01ebba..784428d8c 100644
--- a/energy_communities/models/landing_page.py
+++ b/energy_communities/models/landing_page.py
@@ -12,6 +12,7 @@ from ..pywordpress_client.resources.authenticate import Authenticate
 from ..pywordpress_client.resources.landing_page import (
     LandingPage as LandingPageResource,
 )
+from ..utils import get_successful_popup_message
 from .res_company import _CE_MEMBER_STATUS_VALUES, _CE_TYPE, _LEGAL_FORM_VALUES
 
 
@@ -270,18 +271,10 @@ class LandingPage(models.Model):
                 else:
                     self.sudo().remove_coordinator_filter_to_existing_communities()
             self.write({"publicdata_lastupdate_datetime": datetime.now()})
-            return {
-                "type": "ir.actions.client",
-                "tag": "display_notification",
-                "params": {
-                    "type": "success",
-                    "title": _("Public data update successful"),
-                    "message": _(
-                        "Wordpress landing and map place has been successfully updated."
-                    ),
-                    "sticky": False,
-                },
-            }
+            return get_successful_popup_message(
+                _("Public data update successful"),
+                _("Wordpress landing and map place has been successfully updated."),
+            )
 
     def _update_wordpress(self):
         instance_company = self.env["res.company"].search(
diff --git a/energy_communities/utils.py b/energy_communities/utils.py
index fd3dcca18..f430ddd23 100644
--- a/energy_communities/utils.py
+++ b/energy_communities/utils.py
@@ -42,3 +42,16 @@ def get_translation(source, lang, mods):
     translation = code_translations.get_web_translations(mods, lang)
     translation.update(code_translations.get_python_translations(mods, lang))
     return translation.get(source, source)
+
+
+def get_successful_popup_message(title, message):
+    return {
+        "type": "ir.actions.client",
+        "tag": "display_notification",
+        "params": {
+            "type": "success",
+            "title": title,
+            "message": message,
+            "sticky": False,
+        },
+    }
diff --git a/energy_communities/wizards/change_coordinator_wizard.py b/energy_communities/wizards/change_coordinator_wizard.py
index ffbfff40c..c6cd88dd8 100644
--- a/energy_communities/wizards/change_coordinator_wizard.py
+++ b/energy_communities/wizards/change_coordinator_wizard.py
@@ -2,6 +2,8 @@ from odoo import api, fields, models
 from odoo.exceptions import ValidationError
 from odoo.tools.translate import _
 
+from ..utils import get_successful_popup_message
+
 
 class ChangeCoordinatorWizard(models.TransientModel):
     _name = "change.coordinator.wizard"
@@ -19,14 +21,7 @@ class ChangeCoordinatorWizard(models.TransientModel):
                 company.with_delay().change_coordinator(
                     self.incoming_coordinator, self.change_reason
                 )
-            return {
-                "type": "ir.actions.client",
-                "tag": "display_notification",
-                "params": {
-                    "type": "success",
-                    "title": _("Coordinator change successful"),
-                    "message": _("This community has been moved to a new coordinator"),
-                    "sticky": False,
-                    "next": {"type": "ir.actions.act_window_close"},
-                },
-            }
+            return get_successful_popup_message(
+                _("Coordinator change successful"),
+                _("This community has been moved to a new coordinator"),
+            )
diff --git a/energy_communities/wizards/create_users_wizard.py b/energy_communities/wizards/create_users_wizard.py
index ce2824d6e..6d743f4df 100644
--- a/energy_communities/wizards/create_users_wizard.py
+++ b/energy_communities/wizards/create_users_wizard.py
@@ -1,7 +1,7 @@
 from odoo import fields, models
 from odoo.tools.translate import _
 
-from ..utils import user_creator
+from ..utils import get_successful_popup_message, user_creator
 
 
 class CreateUsersWizard(models.TransientModel):
@@ -38,13 +38,6 @@ class CreateUsersWizard(models.TransientModel):
                 component.create_users_from_communities_cooperator_partners(
                     impacted_records, role_id, self.action, self.force_invite
                 )
-        return {
-            "type": "ir.actions.client",
-            "tag": "display_notification",
-            "params": {
-                "type": "success",
-                "message": _("Process has been started."),
-                "sticky": False,
-                "next": {"type": "ir.actions.act_window_close"},
-            },
-        }
+        return get_successful_popup_message(
+            _("User creation"), _("Process has been started.")
+        )
diff --git a/energy_communities/wizards/multicompany_easy_creation.py b/energy_communities/wizards/multicompany_easy_creation.py
index 58262113d..cf9e019e8 100644
--- a/energy_communities/wizards/multicompany_easy_creation.py
+++ b/energy_communities/wizards/multicompany_easy_creation.py
@@ -9,6 +9,7 @@ from ..models.res_company import (
     _HIERARCHY_LEVEL_BASE_VALUES,
     _LEGAL_FORM_VALUES,
 )
+from ..utils import get_successful_popup_message
 
 _logger = logging.getLogger(__name__)
 
@@ -175,17 +176,10 @@ class AccountMulticompanyEasyCreationWiz(models.TransientModel):
             self.with_delay().thread_action_accept()
         else:
             self.thread_action_accept()
-        return {
-            "type": "ir.actions.client",
-            "tag": "display_notification",
-            "params": {
-                "type": "success",
-                "title": _("Company creation successful"),
-                "message": _("Community creation process has been started."),
-                "sticky": False,
-                "next": {"type": "ir.actions.act_window_close"},
-            },
-        }
+        return get_successful_popup_message(
+            _("Company creation successful"),
+            _("Community creation process has been started."),
+        )
 
     def create_company(self):
         allow_new_members = False
diff --git a/energy_communities_cooperator/models/voluntary_share_interest_return.py b/energy_communities_cooperator/models/voluntary_share_interest_return.py
index d73b436a0..1da0cfa99 100644
--- a/energy_communities_cooperator/models/voluntary_share_interest_return.py
+++ b/energy_communities_cooperator/models/voluntary_share_interest_return.py
@@ -2,6 +2,8 @@ from odoo import api, fields, models
 from odoo.exceptions import ValidationError
 from odoo.tools.translate import _
 
+from odoo.addons.energy_communities.utils import get_successful_popup_message
+
 
 class VoluntaryShareInterestReturn(models.Model):
     _name = "voluntary.share.interest.return"
@@ -90,14 +92,4 @@ class VoluntaryShareInterestReturn(models.Model):
             subject=subject,
             body=body,
         )
-        return {
-            "type": "ir.actions.client",
-            "tag": "display_notification",
-            "params": {
-                "type": "success",
-                "title": subject,
-                "message": body,
-                "sticky": False,
-                "next": {"type": "ir.actions.act_window_close"},
-            },
-        }
+        return get_successful_popup_message(subject, body)
diff --git a/energy_communities_service_invoicing/utils.py b/energy_communities_service_invoicing/utils.py
index e9d5e6d38..15ba8b89a 100644
--- a/energy_communities_service_invoicing/utils.py
+++ b/energy_communities_service_invoicing/utils.py
@@ -22,17 +22,30 @@ _SALE_ORDER_SERVICE_INVOICING_ACTION_VALUES = [
 
 
 def service_invoicing_tree_view(env: Environment):
+    # return {
+    #     "type": "ir.actions.act_window",
+    #     "res_model": "contract.contract",
+    #     "views": [
+    #         (
+    #             env.ref(
+    #                 "energy_communities_service_invoicing.view_service_invoicing_tree"
+    #             ).id,
+    #             "tree",
+    #         ),
+    #     ],
+    #     "target": "current",
+    # }
+
     return {
-        "type": "ir.actions.act_window",
+        # 'name': _('test'),
+        "view_type": "tree",
+        "view_mode": "tree",
+        "view_id": env.ref(
+            "energy_communities_service_invoicing.view_service_invoicing_window_platform_manager"
+        ).id,
         "res_model": "contract.contract",
-        "views": [
-            (
-                env.ref(
-                    "energy_communities_service_invoicing.view_service_invoicing_tree"
-                ).id,
-                "form",
-            ),
-        ],
+        # 'context': "{'type':'out_invoice'}",
+        "type": "ir.actions.act_window",
         "target": "current",
     }
 
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
index 33a67f2a1..92e08d406 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
@@ -1,11 +1,10 @@
-from datetime import datetime
-
 from odoo import api, fields, models
 from odoo.exceptions import ValidationError
 from odoo.tools.translate import _
 
 from odoo.addons.energy_communities.utils import (
     contract_utils,
+    get_successful_popup_message,
     sale_order_utils,
 )
 
@@ -14,7 +13,6 @@ from ..utils import (
     get_existing_open_contract,
     raise_existing_same_open_contract_error,
     service_invoicing_form_view_for_platform_admins,
-    service_invoicing_tree_view,
 )
 
 
@@ -23,6 +21,7 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
     _description = "Create service invoicing for an energy community"
     _inherit = ["user.currentcompany.mixin"]
 
+    execution_date = fields.Date(string="Execution date")
     company_id = fields.Many2one("res.company", string="Coordinator")
     community_company_id = fields.Many2one(
         "res.company",
@@ -99,7 +98,10 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
                     community.parent_id,
                     self.env.company.service_invoicing_payment_mode_id,
                 )
-            return service_invoicing_tree_view(self.env)
+            return get_successful_popup_message(
+                _("Service invoicing contracts successfully created"),
+                _("Visit Community Management section to manage them"),
+            )
         else:
             service_invoicing_id = self._execute_create_one(
                 self.community_company_id, self.company_id, self.payment_mode_id
@@ -108,7 +110,7 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
                 self.env, service_invoicing_id
             )
 
-    def execute_create_one(self, community_company_id, company_id, payment_mode_id):
+    def _execute_create_one(self, community_company_id, company_id, payment_mode_id):
         self._validate_service_invoicing_action_create([community_company_id.id])
         existing_closed_contract = get_existing_last_closed_contract(
             self.env, company_id.partner_id, community_company_id
@@ -117,7 +119,7 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
         if existing_closed_contract:
             with contract_utils(self.env, existing_closed_contract) as component:
                 service_invoicing_id = component.reopen(
-                    datetime.now(),
+                    self.execution_date,
                     self.pricelist_id,
                     self.service_pack_id,
                     self.discount,
@@ -132,7 +134,7 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
                     self.service_pack_id,
                     self.pricelist_id,
                     payment_mode_id,
-                    datetime.now(),
+                    self.execution_date,
                     self.discount,
                     "activate",
                     "active_platform_service_invocing",
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
index 776c34b6e..0a285562d 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
@@ -12,6 +12,7 @@
             <field name="allowed_community_company_ids" invisible="1" />
             <field name="allowed_payment_mode_ids" invisible="1" />
             <field name="pack_product_categ_id" invisible="1" />
+            <field name="execution_date" required="1"/>
             <field
               name="company_id"
               domain="[('hierarchy_level','=','coordinator')]"
-- 
GitLab


From 329830bcf8a8acbbcb2faac6d8adf3b09f7614d1 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Thu, 27 Feb 2025 11:27:01 +0100
Subject: [PATCH 71/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Service=20invoicing?=
 =?UTF-8?q?=20batch=20creation=20redirects=20to=20contracts=20tree=20view?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../models/contract.py                        |   9 ++
 energy_communities_service_invoicing/utils.py |  38 +++---
 .../views/contract_views.xml                  | 110 +++++++++---------
 .../views/service_invoicing_views.xml         |  12 +-
 .../service_invoicing_action_create.py        |   7 +-
 5 files changed, 89 insertions(+), 87 deletions(-)

diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index 14932d2aa..b10170d78 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -232,6 +232,15 @@ class ContractContract(models.Model):
             contract.set_close_status_type_by_date()
         return True
 
+    # TODO: It would be very cool being able to use this methods on service_invoicing xml act_window definition
+    @api.model
+    def get_service_invoicing_views_domain(self):
+        return [("community_company_id", "!=", False)]
+
+    @api.model
+    def get_service_invoicing_views_context(self):
+        return {"search_default_not_finished": 1, "search_default_paused": 1}
+
     # TODO: Not working. Lack of access rules
     def _get_received_invoices_ids(self):
         received_invoices = []
diff --git a/energy_communities_service_invoicing/utils.py b/energy_communities_service_invoicing/utils.py
index 15ba8b89a..f24348955 100644
--- a/energy_communities_service_invoicing/utils.py
+++ b/energy_communities_service_invoicing/utils.py
@@ -22,29 +22,27 @@ _SALE_ORDER_SERVICE_INVOICING_ACTION_VALUES = [
 
 
 def service_invoicing_tree_view(env: Environment):
-    # return {
-    #     "type": "ir.actions.act_window",
-    #     "res_model": "contract.contract",
-    #     "views": [
-    #         (
-    #             env.ref(
-    #                 "energy_communities_service_invoicing.view_service_invoicing_tree"
-    #             ).id,
-    #             "tree",
-    #         ),
-    #     ],
-    #     "target": "current",
-    # }
-
     return {
-        # 'name': _('test'),
+        "name": _("Service Contracts"),
         "view_type": "tree",
-        "view_mode": "tree",
-        "view_id": env.ref(
-            "energy_communities_service_invoicing.view_service_invoicing_window_platform_manager"
-        ).id,
+        "view_mode": "tree,form",
+        "views": [
+            (
+                env.ref(
+                    "energy_communities_service_invoicing.view_service_invoicing_tree"
+                ).id,
+                "tree",
+            ),
+            (
+                env.ref(
+                    "energy_communities_service_invoicing.view_contract_contract_customer_form_platform_admin"
+                ).id,
+                "form",
+            ),
+        ],
         "res_model": "contract.contract",
-        # 'context': "{'type':'out_invoice'}",
+        "context": env["contract.contract"].get_service_invoicing_views_context(),
+        "domain": env["contract.contract"].get_service_invoicing_views_domain(),
         "type": "ir.actions.act_window",
         "target": "current",
     }
diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index 924884b58..b19994cca 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -54,6 +54,61 @@
     </field>
   </record>
 
+  <record id="view_contract_contract_customer_form_platform_admin" model="ir.ui.view">
+    <field name="name">contract.contract.form (in energy_communities service_invoicing platform admin)</field>
+    <field name="model">contract.contract</field>
+    <field name="inherit_id" ref="product_contract.contract_contract_customer_form_view" />
+    <field name="arch" type="xml">
+      <xpath expr="//header" position="inside">
+        <field name="status" widget="statusbar" />
+      </xpath>
+      <xpath expr="//button[@name='action_preview']" position="after">
+        <button
+          name="action_activate_contract"
+          type="object"
+          string="Activate"
+          attrs="{'invisible':[('status','not in',['paused'])]}"
+        />
+        <button
+          name="action_modify_contract"
+          type="object"
+          string="Modify"
+          attrs="{'invisible':[('status','not in',['paused','in_progress'])]}"
+        />
+        <button
+          name="action_close_contract"
+          type="object"
+          string="Close"
+          attrs="{'invisible':[('status','not in',['paused','in_progress'])]}"
+        />
+        <button
+          name="action_reopen_contract"
+          type="object"
+          string="Reopen"
+          attrs="{'invisible':['|',('status','not in',['closed','closed_planned']),('successor_contract_id','!=',False)]}"
+        />
+      </xpath>
+      <xpath expr="//field[@name='partner_id']" position="after">
+        <field name="community_company_id" />
+      </xpath>
+      <xpath expr="//field[@name='pricelist_id']" position="after">
+        <field name="service_pack_id" />
+      </xpath>
+      <xpath expr="//field[@name='user_id']" position="after">
+        <field name="date_start" />
+        <field name="last_date_invoiced" />
+        <field name="recurring_next_date" />
+        <field name="date_end" />
+        <field name="discount" />
+        <field name="predecessor_contract_id" />
+        <field name="successor_contract_id" />
+        <field name="closing_action" attrs="{'invisible':[('status','not in',['closed','closed_planned'])]}" />
+        <field name="closing_action_description" attrs="{'invisible':[('status','not in',['closed','closed_planned'])]}" />
+        <field name="sale_order_id" />
+      </xpath>
+    </field>
+  </record>
+
   <record id="view_contract_contract_customer_form_coord_admin" model="ir.ui.view">
     <field name="name">contract.contract.form (in energy_communities service_invoicing coordinator)</field>
     <field name="model">contract.contract</field>
@@ -110,58 +165,5 @@
     </field>
   </record>
 
-  <record id="view_contract_contract_customer_form_platform_admin" model="ir.ui.view">
-    <field name="name">contract.contract.form (in energy_communities service_invoicing platform admin)</field>
-    <field name="model">contract.contract</field>
-    <field name="inherit_id" ref="product_contract.contract_contract_customer_form_view" />
-    <field name="arch" type="xml">
-      <xpath expr="//header" position="inside">
-        <field name="status" widget="statusbar" />
-      </xpath>
-      <xpath expr="//button[@name='action_preview']" position="after">
-        <button
-          name="action_activate_contract"
-          type="object"
-          string="Activate"
-          attrs="{'invisible':[('status','not in',['paused'])]}"
-        />
-        <button
-          name="action_modify_contract"
-          type="object"
-          string="Modify"
-          attrs="{'invisible':[('status','not in',['paused','in_progress'])]}"
-        />
-        <button
-          name="action_close_contract"
-          type="object"
-          string="Close"
-          attrs="{'invisible':[('status','not in',['paused','in_progress'])]}"
-        />
-        <button
-          name="action_reopen_contract"
-          type="object"
-          string="Reopen"
-          attrs="{'invisible':['|',('status','not in',['closed','closed_planned']),('successor_contract_id','!=',False)]}"
-        />
-      </xpath>
-      <xpath expr="//field[@name='partner_id']" position="after">
-        <field name="community_company_id" />
-      </xpath>
-      <xpath expr="//field[@name='pricelist_id']" position="after">
-        <field name="service_pack_id" />
-      </xpath>
-      <xpath expr="//field[@name='user_id']" position="after">
-        <field name="date_start" />
-        <field name="last_date_invoiced" />
-        <field name="recurring_next_date" />
-        <field name="date_end" />
-        <field name="discount" />
-        <field name="predecessor_contract_id" />
-        <field name="successor_contract_id" />
-        <field name="closing_action" attrs="{'invisible':[('status','not in',['closed','closed_planned'])]}" />
-        <field name="closing_action_description" attrs="{'invisible':[('status','not in',['closed','closed_planned'])]}" />
-        <field name="sale_order_id" />
-      </xpath>
-    </field>
-  </record>
+  
 </odoo>
diff --git a/energy_communities_service_invoicing/views/service_invoicing_views.xml b/energy_communities_service_invoicing/views/service_invoicing_views.xml
index d8d507be2..683cdfda0 100644
--- a/energy_communities_service_invoicing/views/service_invoicing_views.xml
+++ b/energy_communities_service_invoicing/views/service_invoicing_views.xml
@@ -3,12 +3,10 @@
       id="view_service_invoicing_window_platform_manager"
       model="ir.actions.act_window"
   >
-    <field name="name">Service Invoicing</field>
+    <field name="name">Service Contracts</field>
     <field name="res_model">contract.contract</field>
     <field name="view_mode">tree,form</field>
-    <field name="domain">
-[('community_company_id','!=',False)]
-    </field>
+    <field name="domain">[('community_company_id','!=',False)]</field>
     <field name="context">{"search_default_not_finished":1,"search_default_paused":1}</field>
   </record>
 
@@ -16,12 +14,10 @@
       id="view_service_invoicing_window_coord_admin"
       model="ir.actions.act_window"
   >
-    <field name="name">Service Invoicing</field>
+    <field name="name">Service Contracts</field>
     <field name="res_model">contract.contract</field>
     <field name="view_mode">tree,form</field>
-    <field name="domain">
-[('community_company_id','!=',False)]
-    </field>
+    <field name="domain">[('community_company_id','!=',False)]</field>
     <field name="context">{"search_default_not_finished":1,"search_default_paused":1}</field>
   </record>
 
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
index 92e08d406..0f99cc40d 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
@@ -4,7 +4,6 @@ from odoo.tools.translate import _
 
 from odoo.addons.energy_communities.utils import (
     contract_utils,
-    get_successful_popup_message,
     sale_order_utils,
 )
 
@@ -13,6 +12,7 @@ from ..utils import (
     get_existing_open_contract,
     raise_existing_same_open_contract_error,
     service_invoicing_form_view_for_platform_admins,
+    service_invoicing_tree_view,
 )
 
 
@@ -98,10 +98,7 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
                     community.parent_id,
                     self.env.company.service_invoicing_payment_mode_id,
                 )
-            return get_successful_popup_message(
-                _("Service invoicing contracts successfully created"),
-                _("Visit Community Management section to manage them"),
-            )
+            return service_invoicing_tree_view(self.env)
         else:
             service_invoicing_id = self._execute_create_one(
                 self.community_company_id, self.company_id, self.payment_mode_id
-- 
GitLab


From e638d0098aa5cf495dd400bde82c5196539cc7b0 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Thu, 27 Feb 2025 11:54:51 +0100
Subject: [PATCH 72/85] =?UTF-8?q?[FIX]=20=F0=9F=90=9B=20Validate=20platfor?=
 =?UTF-8?q?m=20company=20has=20payment=20mode=20defined?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../wizards/service_invoicing_action_create.py  | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
index 0f99cc40d..f13cb08ca 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
@@ -191,13 +191,10 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
                         record.name
                     )
                 )
-        # Check current company has configuration payment mode for multicompany creation
-        if (
-            self.community_company_mids
-            and not self.env.company.service_invoicing_payment_mode_id
-        ):
-            raise ValidationError(
-                _(
-                    "Platform {} must have a service invoicing payment mode defined"
-                ).format(self.env.company.name)
-            )
+            # Check current company has configuration payment mode for multicompany creation
+            if not self.env.company.service_invoicing_payment_mode_id:
+                raise ValidationError(
+                    _(
+                        "Platform {} must have a service invoicing payment mode defined"
+                    ).format(self.env.company.name)
+                )
-- 
GitLab


From 7da5c4c17ef1c604e2cbb3affaface28719b455a Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Thu, 27 Feb 2025 13:12:50 +0100
Subject: [PATCH 73/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Avoid=20payment=20mod?=
 =?UTF-8?q?e=20required=20on=20service=20contract=20creation?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../components/contract_utils.py              | 19 +++++------
 .../components/sale_order_utils.py            |  5 +--
 .../models/res_company.py                     |  8 ++---
 .../views/res_company_views.xml               |  3 +-
 .../wizards/service_invoicing_action.xml      |  8 ++++-
 .../service_invoicing_action_create.py        | 33 +++++++++----------
 .../service_invoicing_action_create.xml       | 22 +++++++++----
 7 files changed, 56 insertions(+), 42 deletions(-)

diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
index 4b45e99f2..00541918e 100644
--- a/energy_communities_service_invoicing/components/contract_utils.py
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -83,17 +83,16 @@ class ContractUtils(Component):
         sale_order_utils = self.component(
             usage="sale.order.utils", model_name="sale.order"
         )
-        service_invoicing_params = self._build_service_invoicing_params(
-            "modification",
-            executed_modification_action,
-            execution_date,
-            pricelist_id,
-            service_pack_id,
-            discount,
-            payment_mode_id,
-        )
         new_service_invoicing_id = sale_order_utils.create_service_invoicing_initial(
-            **service_invoicing_params
+            **self._build_service_invoicing_params(
+                "modification",
+                executed_modification_action,
+                execution_date,
+                pricelist_id,
+                service_pack_id,
+                discount,
+                payment_mode_id,
+            )
         )
         # TODO:
         # Do we really want new contract to be in_progress on a modification??
diff --git a/energy_communities_service_invoicing/components/sale_order_utils.py b/energy_communities_service_invoicing/components/sale_order_utils.py
index 5cfeeccaa..86ab78a50 100644
--- a/energy_communities_service_invoicing/components/sale_order_utils.py
+++ b/energy_communities_service_invoicing/components/sale_order_utils.py
@@ -23,7 +23,6 @@ class SaleOrderUtils(Component):
             "pricelist_id": pricelist_id.id,
             "service_invoicing_action": executed_action,
             "service_invoicing_action_description": executed_action_description,
-            "payment_mode_id": payment_mode_id.id,
             "order_line": [
                 (
                     0,
@@ -36,6 +35,8 @@ class SaleOrderUtils(Component):
                 )
             ],
         }
+        if payment_mode_id:
+            so_creation_dict["payment_mode_id"] = payment_mode_id.id
         # Apply configuration sales team to service invoicing sales order
         if company_id.service_invoicing_sale_team_id:
             so_creation_dict["team_id"] = company_id.service_invoicing_sale_team_id.id
@@ -83,11 +84,11 @@ class SaleOrderUtils(Component):
         community_company_id,
         service_pack_id,
         pricelist_id,
-        payment_mode_id,
         start_date,
         discount,
         executed_action,
         executed_action_description="none",
+        payment_mode_id=False,
     ):
         service_invoicing_id = self._create_service_invoicing(
             company_id,
diff --git a/energy_communities_service_invoicing/models/res_company.py b/energy_communities_service_invoicing/models/res_company.py
index 1c74ab3bd..0264c69bb 100644
--- a/energy_communities_service_invoicing/models/res_company.py
+++ b/energy_communities_service_invoicing/models/res_company.py
@@ -10,10 +10,10 @@ class ResCompany(models.Model):
         comodel_name="account.journal",
         string="Service invoicing journal",
     )
-    service_invoicing_payment_mode_id = fields.Many2one(
-        comodel_name="account.payment.mode",
-        string="Service invoicing payment mode",
-    )
+    # service_invoicing_payment_mode_id = fields.Many2one(
+    #     comodel_name="account.payment.mode",
+    #     string="Service invoicing payment mode",
+    # )
     service_invoicing_sale_team_id = fields.Many2one(
         comodel_name="crm.team",
         string="Service invoicing sales team",
diff --git a/energy_communities_service_invoicing/views/res_company_views.xml b/energy_communities_service_invoicing/views/res_company_views.xml
index 3b5673954..7c49d6fa3 100644
--- a/energy_communities_service_invoicing/views/res_company_views.xml
+++ b/energy_communities_service_invoicing/views/res_company_views.xml
@@ -7,7 +7,7 @@
     <field name="state">code</field>
     <field name="groups_id" eval="[(4,ref('energy_communities.group_platform_manager'))]" />
     <field name="code">
-        action = model.get_service_invoicing_action_create_wizard_form_view()
+        action = model.get_multiple_service_invoicing_action_create_wizard_form_view()
     </field>
   </record>
   <record id="view_service_invocing_company_form" model="ir.ui.view">
@@ -20,7 +20,6 @@
           <group>
             <field name="id" invisible="1"/>
             <field name="service_invoicing_journal_id" domain="[('company_id', '=', id)]" />
-            <field name="service_invoicing_payment_mode_id" domain="[('company_id', '=', id)]" />
             <field name="service_invoicing_sale_team_id" domain="[('company_id', '=', id)]" />
           </group>
         </page>
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action.xml b/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
index dc16b29be..f66cf95e0 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
@@ -10,7 +10,13 @@
         <sheet>
           <group>
             <field name="executed_action" invisible="1" />
-            <field name="service_invoicing_id" required="1" domain="[('community_company_id','!=',False)]"/>
+            <field
+              name="service_invoicing_id"
+              required="1"
+              readonly="1"
+              domain="[('community_company_id','!=',False)]"
+              options="{'no_open': True}"
+            />
             <field name="execution_date" required="1"/>
             <field
               name="service_pack_id"
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
index f13cb08ca..82768993b 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
@@ -21,6 +21,9 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
     _description = "Create service invoicing for an energy community"
     _inherit = ["user.currentcompany.mixin"]
 
+    creation_type = fields.Selection(
+        [("single", "Single"), ("multiple", "Multiple")], default="single"
+    )
     execution_date = fields.Date(string="Execution date")
     company_id = fields.Many2one("res.company", string="Coordinator")
     community_company_id = fields.Many2one(
@@ -76,27 +79,23 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
     @api.depends("company_id", "community_company_mids")
     def _compute_allowed_payment_mode_ids(self):
         for record in self:
-            if record.community_company_mids:
-                query = [("company_id", "=", self.user_current_company.id)]
-            else:
-                query = [("company_id", "=", record.company_id.id)]
             record.allowed_payment_mode_ids = self.env["account.payment.mode"].search(
-                query
+                [("company_id", "=", self.user_current_company.id)]
             )
 
     @api.onchange("company_id")
     def _compute_service_invoicing_action_create_wizard_allowed_values(self):
         for record in self:
+            record._compute_pack_product_categ_id()
             record._compute_allowed_community_company_ids()
             record._compute_allowed_payment_mode_ids()
 
     def execute_create(self):
-        if self.community_company_mids:
+        if self.creation_type == "multiple":
             for community in self.community_company_mids:
                 self._execute_create_one(
                     community,
                     community.parent_id,
-                    self.env.company.service_invoicing_payment_mode_id,
                 )
             return service_invoicing_tree_view(self.env)
         else:
@@ -107,7 +106,9 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
                 self.env, service_invoicing_id
             )
 
-    def _execute_create_one(self, community_company_id, company_id, payment_mode_id):
+    def _execute_create_one(
+        self, community_company_id, company_id, payment_mode_id=False
+    ):
         self._validate_service_invoicing_action_create([community_company_id.id])
         existing_closed_contract = get_existing_last_closed_contract(
             self.env, company_id.partner_id, community_company_id
@@ -130,15 +131,15 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
                     community_company_id,
                     self.service_pack_id,
                     self.pricelist_id,
-                    payment_mode_id,
                     self.execution_date,
                     self.discount,
                     "activate",
                     "active_platform_service_invocing",
+                    payment_mode_id,
                 )
         return service_invoicing_id
 
-    def get_service_invoicing_action_create_wizard_form_view(self):
+    def get_multiple_service_invoicing_action_create_wizard_form_view(self):
         if "active_ids" in self.env.context.keys():
             self._validate_service_invoicing_action_create(
                 self.env.context["active_ids"]
@@ -148,6 +149,7 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
             )
             wizard = self.env["service.invoicing.action.create.wizard"].create(
                 {
+                    "creation_type": "multiple",
                     "community_company_mids": self.env.context["active_ids"],
                 }
             )
@@ -168,6 +170,10 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
         return False
 
     def _validate_service_invoicing_action_create(self, company_id_list):
+        if self.env.company.hierarchy_level != "instance":
+            raise ValidationError(
+                _("This action is only allowed when you're on instance level.")
+            )
         impacted_records = self.env["res.company"].browse(company_id_list)
         # Check all selected companies are communities
         hierarchy_levels = list(set(impacted_records.mapped("hierarchy_level")))
@@ -191,10 +197,3 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
                         record.name
                     )
                 )
-            # Check current company has configuration payment mode for multicompany creation
-            if not self.env.company.service_invoicing_payment_mode_id:
-                raise ValidationError(
-                    _(
-                        "Platform {} must have a service invoicing payment mode defined"
-                    ).format(self.env.company.name)
-                )
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
index 0a285562d..309c02e08 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
@@ -6,9 +6,10 @@
     <field name="name">service.invoicing.action.create.wizard.form</field>
     <field name="model">service.invoicing.action.create.wizard</field>
     <field name="arch" type="xml">
-      <form string="Service invoicing">
+      <form string="Service Contract">
         <sheet>
           <group>
+            <field name="creation_type" invisible="1" />
             <field name="allowed_community_company_ids" invisible="1" />
             <field name="allowed_payment_mode_ids" invisible="1" />
             <field name="pack_product_categ_id" invisible="1" />
@@ -16,21 +17,30 @@
             <field
               name="company_id"
               domain="[('hierarchy_level','=','coordinator')]"
-              attrs="{'invisible':[('community_company_mids','!=',[])],'required':[('community_company_mids','=',[])]}"
+              attrs="{'invisible':[('creation_type','=','multiple')],'required':[('creation_type','=','single')]}"
             />
             <field
               name="community_company_id"
-              attrs="{'invisible':[('community_company_mids','!=',[])],'required':[('community_company_mids','=',[])]}"
+              attrs="{'invisible':[('creation_type','=','multiple')],'required':[('creation_type','=','single')]}"
             />
-            <field name="community_company_mids" />
+            <field 
+              name="community_company_mids"
+              attrs="{'invisible':[('creation_type','=','single')],'required':[('creation_type','=','multiple')]}"
+              widget="many2many"
+            >
+             <tree>
+                <field name="name"/>
+                <field name="parent_id"/>
+             </tree>
+            </field>
             <field name="service_pack_id"
-              required="1"
               domain="[('categ_id','=',pack_product_categ_id)]"
+              required="1"
             />
             <field name="pricelist_id" required="1" domain="[('company_id','=',False)]"/>
             <field
               name="payment_mode_id"
-              attrs="{'invisible':[('community_company_mids','!=',[])],'required':[('community_company_mids','=',[])]}"
+              attrs="{'invisible':[('creation_type','=','multiple')]}"
             />
             <field name="discount" required="1" />
           </group>
-- 
GitLab


From e06b477700b55311cc13bfe032285c63f67937f8 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Thu, 27 Feb 2025 16:47:26 +0100
Subject: [PATCH 74/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Propagate=20contract?=
 =?UTF-8?q?=20and=20community=20from=20pack=20contract=20to=20invoice?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../views/account_move_views.xml              | 30 ++++++---------
 .../__manifest__.py                           |  2 +
 .../data/product_data.xml                     |  4 +-
 .../models/account_move.py                    | 38 ++++++++++++++++---
 .../models/contract.py                        | 12 +++---
 .../report/report_invoice.xml                 | 31 +++++++++++++++
 energy_communities_service_invoicing/utils.py |  6 +--
 .../views/account_move_views.xml              | 16 ++++++++
 .../wizards/service_invoicing_action.py       |  2 +-
 .../service_invoicing_action_create.py        | 12 +++---
 10 files changed, 111 insertions(+), 42 deletions(-)
 create mode 100644 energy_communities_service_invoicing/report/report_invoice.xml
 create mode 100644 energy_communities_service_invoicing/views/account_move_views.xml

diff --git a/energy_communities_cooperator/views/account_move_views.xml b/energy_communities_cooperator/views/account_move_views.xml
index de9feb1fd..eedd053f7 100644
--- a/energy_communities_cooperator/views/account_move_views.xml
+++ b/energy_communities_cooperator/views/account_move_views.xml
@@ -1,22 +1,16 @@
 <odoo>
   <record id="account_move_form" model="ir.ui.view">
-      <field name="name">account.move.form.inherit</field>
-      <field name="model">account.move</field>
-      <field name="inherit_id" ref="account.view_move_form" />
-      <field name="arch" type="xml">
-        <xpath expr="//notebook" position="before">
-          <group>
-            <field name="user_current_role" invisible="True" />
-            <field
-            name="membership_id"
-            attrs="{'invisible': [('user_current_role', '!=', 'role_platform_admin')],'readonly': 0}"
-          />
-            <field
-            name="voluntary_share_total_contribution"
-            attrs="{'invisible': [('user_current_role', '!=', 'role_platform_admin')]}"
-          />
-          </group>
-        </xpath>
-      </field>
+    <field name="name">account.move.form.inherit</field>
+    <field name="model">account.move</field>
+    <field name="inherit_id" ref="account.view_move_form" />
+    <field name="arch" type="xml">
+      <xpath expr="//notebook" position="before">
+        <field name="user_current_role" invisible="True" />
+        <group attrs="{'invisible': [('user_current_role', '!=', 'role_platform_admin')]}">
+          <field name="membership_id" readonly="False" />
+          <field name="voluntary_share_total_contribution" />
+        </group>
+      </xpath>
+    </field>
   </record>
 </odoo>
diff --git a/energy_communities_service_invoicing/__manifest__.py b/energy_communities_service_invoicing/__manifest__.py
index f525cf563..38cac035e 100644
--- a/energy_communities_service_invoicing/__manifest__.py
+++ b/energy_communities_service_invoicing/__manifest__.py
@@ -30,6 +30,8 @@
         "data/contract_cron.xml",
         "data/contract_line_qty_formula_data.xml",
         "data/product_data.xml",
+        "report/report_invoice.xml",
+        "views/account_move_views.xml",
         "views/contract_line_formula_views.xml",
         "views/contract_template_views.xml",
         "views/contract_views.xml",
diff --git a/energy_communities_service_invoicing/data/product_data.xml b/energy_communities_service_invoicing/data/product_data.xml
index b3248d09a..89e2a323c 100644
--- a/energy_communities_service_invoicing/data/product_data.xml
+++ b/energy_communities_service_invoicing/data/product_data.xml
@@ -1,8 +1,8 @@
 <odoo>
   <record id="product_category_pack" model="product.category">
-    <field name="name">Service Pack</field>
+    <field name="name">Platform Service Pack</field>
   </record>
   <record id="product_category_service" model="product.category">
-    <field name="name">Service</field>
+    <field name="name">Platform Service</field>
   </record>
 </odoo>
diff --git a/energy_communities_service_invoicing/models/account_move.py b/energy_communities_service_invoicing/models/account_move.py
index 4add5cb7a..378c9bd62 100644
--- a/energy_communities_service_invoicing/models/account_move.py
+++ b/energy_communities_service_invoicing/models/account_move.py
@@ -5,15 +5,37 @@ class AccountMove(models.Model):
     _inherit = "account.move"
 
     ref_invoice_id = fields.Many2one(
-        compute="_compute_ref_invoice_id_and_is_pack", store=False
+        comodel_name="account.move",
+        compute="_compute_ref_invoice_id_related_contract_id_is_pack_is_contract",
+        store=False,
+    )
+    related_contract_id = fields.Many2one(
+        comodel_name="contract.contract",
+        compute="_compute_ref_invoice_id_related_contract_id_is_pack_is_contract",
+        store=False,
+    )
+    is_pack = fields.Boolean(
+        compute="_compute_ref_invoice_id_related_contract_id_is_pack_is_contract",
+        store=True,
+    )
+    is_contract = fields.Boolean(
+        compute="_compute_ref_invoice_id_related_contract_id_is_pack_is_contract",
+        store=True,
+    )
+    related_community_company_id = fields.Many2one(
+        comodel_name="res.company",
+        string="Related community",
+        related="related_contract_id.community_company_id",
+        domain="[('hierarchy_level','=','community')]",
     )
-    is_pack = fields.Boolean(compute="_compute_ref_invoice_id_and_is_pack", store=True)
 
     @api.depends("invoice_line_ids", "ref")
-    def _compute_ref_invoice_id_and_is_pack(self):
+    def _compute_ref_invoice_id_related_contract_id_is_pack_is_contract(self):
         for record in self:
             record.ref_invoice_id = False
+            record.related_contract_id = False
             record.is_pack = False
+            record.is_contract = False
             rel_inv = False
             if record.ref:
                 rel_inv = (
@@ -24,10 +46,14 @@ class AccountMove(models.Model):
                 if rel_inv:
                     record.ref_invoice_id = rel_inv.id
                     record.is_pack = rel_inv.is_pack
+                    record.is_contract = rel_inv.is_contract
+                    if rel_inv.related_contract_id:
+                        record.related_contract_id = rel_inv.related_contract_id.id
             else:
                 if record.invoice_line_ids:
                     first_move_line = record.invoice_line_ids[0]
                     if first_move_line.contract_line_id:
-                        record.is_pack = (
-                            first_move_line.contract_line_id.contract_id.is_pack
-                        )
+                        rel_contract = first_move_line.contract_line_id.contract_id
+                        record.is_pack = rel_contract.is_pack
+                        record.related_contract_id = rel_contract.id
+                        record.is_contract = True
diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index b10170d78..12ac6b4a1 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -5,8 +5,8 @@ from odoo import _, api, fields, models
 from ..utils import (
     _CONTRACT_STATUS_VALUES,
     _SALE_ORDER_SERVICE_INVOICING_ACTION_VALUES,
-    get_existing_open_contract,
-    raise_existing_same_open_contract_error,
+    get_existing_open_pack_contract,
+    raise_existing_same_open_pack_contract_error,
 )
 
 _CLOSING_ACTION_VALUES = _SALE_ORDER_SERVICE_INVOICING_ACTION_VALUES + [
@@ -106,9 +106,9 @@ class ContractContract(models.Model):
     def _constrain_unique_contract(self):
         for record in self:
             if record.community_company_id:
-                existing_contract = record._get_existing_same_open_contract()
+                existing_contract = record._get_existing_same_open_pack_contract()
                 if existing_contract:
-                    raise_existing_same_open_contract_error(existing_contract)
+                    raise_existing_same_open_pack_contract_error(existing_contract)
 
     def _compute_received_invoices_count(self):
         for record in self:
@@ -258,8 +258,8 @@ class ContractContract(models.Model):
                     received_invoices.append(invoice.id)
         return received_invoices
 
-    def _get_existing_same_open_contract(self):
-        return get_existing_open_contract(
+    def _get_existing_same_open_pack_contract(self):
+        return get_existing_open_pack_contract(
             self.env, self.partner_id, self.community_company_id, self
         )
 
diff --git a/energy_communities_service_invoicing/report/report_invoice.xml b/energy_communities_service_invoicing/report/report_invoice.xml
new file mode 100644
index 000000000..aed13d4d3
--- /dev/null
+++ b/energy_communities_service_invoicing/report/report_invoice.xml
@@ -0,0 +1,31 @@
+<odoo>
+  <template id="report_invoice_document" inherit_id="account.report_invoice_document">
+    <xpath expr="//div[@id='informations']" position="inside">
+      <div class="col-auto col-3 mw-100 mb-2" t-if="o.is_pack">
+        <strong>Community:</strong>
+        <t t-if="o.related_community_company_id.comercial_name">
+          <p class="m-0" t-field="o.related_community_company_id.comercial_name"/>
+        </t>
+        <t t-else="">
+          <p class="m-0" t-field="o.related_community_company_id.name"/>
+        </t>
+      </div>
+    </xpath>
+  </template>
+</odoo>
+<!--<xpath expr="//table" position="before">-->
+<!--  <div class="row">-->
+<!--    <div class="col-6" name="related_community_company_id">-->
+<!--      <label for="related_community_company_id">Related community company</label>-->
+<!--      <address-->
+<!--        class="mb-0"-->
+<!--        t-field="o.related_community_company_id.partner_id"-->
+<!--        t-options="{'widget': 'contact', 'fields': ['address', 'name'], 'no_marker': True}"-->
+<!--      />-->
+<!--      <div t-if="o.related_community_company_id.partner_id.vat">-->
+<!--        Tax ID: <span t-field="o.related_community_company_id.partner_id.vat"/>-->
+<!--      </div>-->
+<!--    </div>-->
+<!--  </div>-->
+<!--</xpath>-->
+
diff --git a/energy_communities_service_invoicing/utils.py b/energy_communities_service_invoicing/utils.py
index f24348955..18562a076 100644
--- a/energy_communities_service_invoicing/utils.py
+++ b/energy_communities_service_invoicing/utils.py
@@ -68,7 +68,7 @@ def service_invoicing_form_view_for_platform_admins(
 
 
 # TODO: Think a bit more about more about if this 3 methods must go to contract utils component
-def raise_existing_same_open_contract_error(existing_contract):
+def raise_existing_same_open_pack_contract_error(existing_contract):
     raise ValidationError(
         _(
             "It already exists an open contract ({}) with same company and community."
@@ -76,7 +76,7 @@ def raise_existing_same_open_contract_error(existing_contract):
     )
 
 
-def get_existing_open_contract(
+def get_existing_open_pack_contract(
     env, partner_id, community_company_id, contract_id=False
 ):
     query = [
@@ -90,7 +90,7 @@ def get_existing_open_contract(
     return env["contract.contract"].search(query, limit=1)
 
 
-def get_existing_last_closed_contract(
+def get_existing_last_closed_pack_contract(
     env, partner_id, community_company_id, contract_id=False
 ):
     query = [
diff --git a/energy_communities_service_invoicing/views/account_move_views.xml b/energy_communities_service_invoicing/views/account_move_views.xml
new file mode 100644
index 000000000..272df95a6
--- /dev/null
+++ b/energy_communities_service_invoicing/views/account_move_views.xml
@@ -0,0 +1,16 @@
+<odoo>
+  <record id="account_move_form" model="ir.ui.view">
+      <field name="name">account.move.form.inherit</field>
+      <field name="model">account.move</field>
+      <field name="inherit_id" ref="account.view_move_form" />
+      <field name="arch" type="xml">
+        <xpath expr="//field[@name='partner_id']" position="after">
+          <field name="is_pack" invisible="True" />
+          <field name="is_contract" invisible="True" />
+          <field name="invoice_origin" attrs="{'invisible': [('is_contract','=',False)]}" />
+          <field name="related_contract_id" attrs="{'invisible': [('is_contract','=',False)]}" />
+          <field name="related_community_company_id" attrs="{'invisible': [('is_pack','=',False)]}" />
+        </xpath>
+      </field>
+  </record>
+</odoo>
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action.py b/energy_communities_service_invoicing/wizards/service_invoicing_action.py
index ec3423774..59a6b2d9f 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action.py
@@ -87,5 +87,5 @@ class ServiceInvoicingActionWizard(models.TransientModel):
         if self.discount != self.service_invoicing_id.discount:
             if bool(executed_modification_action):
                 executed_modification_action += ","
-            executed_action += "modify_discount"
+            executed_modification_action += "modify_discount"
         return executed_modification_action
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
index 82768993b..e36abc4bb 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
@@ -8,9 +8,9 @@ from odoo.addons.energy_communities.utils import (
 )
 
 from ..utils import (
-    get_existing_last_closed_contract,
-    get_existing_open_contract,
-    raise_existing_same_open_contract_error,
+    get_existing_last_closed_pack_contract,
+    get_existing_open_pack_contract,
+    raise_existing_same_open_pack_contract_error,
     service_invoicing_form_view_for_platform_admins,
     service_invoicing_tree_view,
 )
@@ -110,7 +110,7 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
         self, community_company_id, company_id, payment_mode_id=False
     ):
         self._validate_service_invoicing_action_create([community_company_id.id])
-        existing_closed_contract = get_existing_last_closed_contract(
+        existing_closed_contract = get_existing_last_closed_pack_contract(
             self.env, company_id.partner_id, community_company_id
         )
         # If existing closed contract reopen it
@@ -181,11 +181,11 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
             raise ValidationError(_("You can only assign pack to communities"))
         # Check if already open one and raise error
         for record in impacted_records:
-            existing_contract = get_existing_open_contract(
+            existing_contract = get_existing_open_pack_contract(
                 self.env, record.parent_id.partner_id, record
             )
             if existing_contract:
-                raise_existing_same_open_contract_error(existing_contract)
+                raise_existing_same_open_pack_contract_error(existing_contract)
 
     def _validate_service_invoicing_action_create_multicommunity(self, company_id_list):
         impacted_records = self.env["res.company"].browse(company_id_list)
-- 
GitLab


From dfd670094baf1606f8d91608c6f4cf7a36a4b63f Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Fri, 28 Feb 2025 09:37:15 +0100
Subject: [PATCH 75/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Introducing=20active?=
 =?UTF-8?q?=20monitoring=20members=20formula?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../data/contract_line_qty_formula_data.xml   | 14 ++++++++--
 .../models/contract.py                        | 28 +++++++++++++++++++
 2 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/energy_communities_service_invoicing/data/contract_line_qty_formula_data.xml b/energy_communities_service_invoicing/data/contract_line_qty_formula_data.xml
index c65eae7e2..edef781e2 100644
--- a/energy_communities_service_invoicing/data/contract_line_qty_formula_data.xml
+++ b/energy_communities_service_invoicing/data/contract_line_qty_formula_data.xml
@@ -1,10 +1,10 @@
 <odoo>
   <data>
     <record
-      id="community_members_formula"
+      id="active_community_members_formula"
       model="contract.line.qty.formula"
     >
-      <field name="name">Community members</field>
+      <field name="name">Active community members</field>
       <field name="code">
 result = env['cooperative.membership'].sudo().search_count([
 ('company_id','=',contract.community_company_id.id),
@@ -13,5 +13,15 @@ result = env['cooperative.membership'].sudo().search_count([
       </field>
       <field name="company_id" eval="ref('base.main_company')" />
     </record>
+    <record
+      id="active_monitoring_members_formula"
+      model="contract.line.qty.formula"
+    >
+      <field name="name">Active monitoring members</field>
+      <field name="code">
+result = contract.get_active_monitoring_members()
+      </field>
+      <field name="company_id" eval="ref('base.main_company')" />
+    </record>
   </data>
 </odoo>
diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index 12ac6b4a1..512e65349 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -1,3 +1,4 @@
+from collections import namedtuple
 from datetime import datetime
 
 from odoo import _, api, fields, models
@@ -263,6 +264,33 @@ class ContractContract(models.Model):
             self.env, self.partner_id, self.community_company_id, self
         )
 
+    def get_active_monitoring_members(self):
+        QueryResult = namedtuple("QueryResult", ["total"])
+        QUERY = """
+            select count(energy_selfconsumption_supply_point.code) from energy_project_project
+            inner join energy_selfconsumption_selfconsumption on
+                energy_selfconsumption_selfconsumption.project_id = energy_project_project.id
+            inner join energy_selfconsumption_distribution_table on
+                energy_selfconsumption_distribution_table.selfconsumption_project_id = energy_selfconsumption_selfconsumption.id
+            inner join energy_selfconsumption_supply_point_assignation on
+                energy_selfconsumption_supply_point_assignation.distribution_table_id = energy_selfconsumption_distribution_table.id
+            inner join energy_selfconsumption_supply_point on
+                energy_selfconsumption_supply_point.id = energy_selfconsumption_supply_point_assignation.supply_point_id
+            inner join energy_project_service_contract on
+                energy_project_service_contract.project_id= energy_project_project.id
+            inner join energy_project_provider on energy_project_service_contract.provider_id=energy_project_provider.id
+            where
+                energy_project_project.company_id={current_company_id} and
+                energy_selfconsumption_distribution_table.state = 'active' and
+                energy_project_provider.name LIKE '{arkenova_like}';
+        """.format(
+            current_company_id=int(self.community_company_id.id),
+            arkenova_like="%Arkenova%",
+        )
+        self.env.cr.execute(QUERY)
+        members = QueryResult._make(self.env.cr.fetchone())
+        return members.total
+
     def set_close_status_type_by_date(self):
         if self.date_end.strftime("%Y-%m-%d") <= datetime.now().strftime("%Y-%m-%d"):
             self.write({"status": "closed"})
-- 
GitLab


From 16a1fc1fe37a96f5c16bc35b0de9eb5d6bfd615b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81lvaro=20Garc=C3=ADa?= <alvarogruiz8@gmail.com>
Date: Thu, 6 Mar 2025 13:17:08 +0100
Subject: [PATCH 76/85] =?UTF-8?q?[REF]=20=E2=99=BB=EF=B8=8F=20=20energy=5F?=
 =?UTF-8?q?communities=5Fservice=5Finvoicing?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: Alvaro Garcia <alvaro.garcia@somit.coop>
Author: Dani Quilez <dani.quilez@somenergia.coop>
---
 .../components/contract_utils.py              | 18 ++++----
 .../components/sale_order_utils.py            | 12 ++---
 .../data/product_data.xml                     |  4 +-
 .../models/account_move.py                    | 22 +++++----
 .../models/contract.py                        | 30 ++++++------
 .../models/contract_template.py               | 46 ++++++++++++-------
 .../models/product_template.py                | 12 ++---
 .../models/res_partner.py                     | 34 +++++++-------
 .../report/report_invoice.xml                 | 17 +------
 energy_communities_service_invoicing/utils.py | 14 +++---
 .../views/account_move_views.xml              |  4 +-
 .../views/contract_views.xml                  | 10 ++--
 .../views/res_partner_views.xml               |  4 +-
 .../views/service_invoicing_views.xml         | 10 ++--
 .../wizards/service_invoicing_action.py       | 13 +++---
 .../wizards/service_invoicing_action.xml      |  5 +-
 .../service_invoicing_action_create.py        | 29 ++++++------
 .../service_invoicing_action_create.xml       |  6 +--
 energy_selfconsumption/__manifest__.py        |  2 +
 energy_selfconsumption/data/product_data.xml  |  9 ++++
 energy_selfconsumption/models/__init__.py     |  1 +
 .../models/contract_template.py               | 15 ++++++
 22 files changed, 175 insertions(+), 142 deletions(-)
 create mode 100644 energy_selfconsumption/data/product_data.xml
 create mode 100644 energy_selfconsumption/models/contract_template.py

diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
index 00541918e..3269860b8 100644
--- a/energy_communities_service_invoicing/components/contract_utils.py
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -71,7 +71,7 @@ class ContractUtils(Component):
         execution_date,
         executed_modification_action,
         pricelist_id=None,
-        service_pack_id=None,
+        pack_id=None,
         discount=None,
         payment_mode_id=None,
     ):
@@ -89,7 +89,7 @@ class ContractUtils(Component):
                 executed_modification_action,
                 execution_date,
                 pricelist_id,
-                service_pack_id,
+                pack_id,
                 discount,
                 payment_mode_id,
             )
@@ -105,7 +105,7 @@ class ContractUtils(Component):
         self,
         execution_date,
         pricelist_id=None,
-        service_pack_id=None,
+        pack_id=None,
         discount=None,
         payment_mode_id=None,
     ):
@@ -115,10 +115,10 @@ class ContractUtils(Component):
         ).create_service_invoicing_initial(
             **self._build_service_invoicing_params(
                 "reopen",
-                "modify_service_pack,modify_pricelist,modify_discount,modify_payment_mode",
+                "modify_pack,modify_pricelist,modify_discount,modify_payment_mode",
                 execution_date,
                 pricelist_id,
-                service_pack_id,
+                pack_id,
                 discount,
                 payment_mode_id,
             )
@@ -132,7 +132,7 @@ class ContractUtils(Component):
         executed_action_description,
         execution_date,
         pricelist_id=None,
-        service_pack_id=None,
+        pack_id=None,
         discount=None,
         payment_mode_id=None,
     ):
@@ -140,9 +140,9 @@ class ContractUtils(Component):
         return {
             "company_id": self.work.record.partner_id.related_company_id,
             "community_company_id": self.work.record.community_company_id,
-            "service_pack_id": service_pack_id
-            if "modify_service_pack" in executed_action_description_list
-            else self.work.record.service_pack_id,
+            "pack_id": pack_id
+            if "modify_pack" in executed_action_description_list
+            else self.work.record.pack_id,
             "pricelist_id": pricelist_id
             if "modify_pricelist" in executed_action_description_list
             else self.work.record.pricelist_id,
diff --git a/energy_communities_service_invoicing/components/sale_order_utils.py b/energy_communities_service_invoicing/components/sale_order_utils.py
index 86ab78a50..d5bdbe3ee 100644
--- a/energy_communities_service_invoicing/components/sale_order_utils.py
+++ b/energy_communities_service_invoicing/components/sale_order_utils.py
@@ -9,7 +9,7 @@ class SaleOrderUtils(Component):
         self,
         company_id,
         community_company_id,
-        service_pack_id,
+        pack_id,
         pricelist_id,
         payment_mode_id,
         start_date,
@@ -28,7 +28,7 @@ class SaleOrderUtils(Component):
                     0,
                     0,
                     {
-                        "product_id": service_pack_id.id,
+                        "product_id": pack_id.id,
                         "date_start": start_date,
                         "date_end": start_date,
                     },
@@ -50,7 +50,7 @@ class SaleOrderUtils(Component):
         self,
         company_id,
         community_company_id,
-        service_pack_id,
+        pack_id,
         pricelist_id,
         payment_mode_id,
         start_date,
@@ -61,7 +61,7 @@ class SaleOrderUtils(Component):
         so = self.create_service_invoicing_sale_order(
             company_id,
             community_company_id,
-            service_pack_id,
+            pack_id,
             pricelist_id,
             payment_mode_id,
             start_date,
@@ -82,7 +82,7 @@ class SaleOrderUtils(Component):
         self,
         company_id,
         community_company_id,
-        service_pack_id,
+        pack_id,
         pricelist_id,
         start_date,
         discount,
@@ -93,7 +93,7 @@ class SaleOrderUtils(Component):
         service_invoicing_id = self._create_service_invoicing(
             company_id,
             community_company_id,
-            service_pack_id,
+            pack_id,
             pricelist_id,
             payment_mode_id,
             start_date,
diff --git a/energy_communities_service_invoicing/data/product_data.xml b/energy_communities_service_invoicing/data/product_data.xml
index 89e2a323c..bb69508a5 100644
--- a/energy_communities_service_invoicing/data/product_data.xml
+++ b/energy_communities_service_invoicing/data/product_data.xml
@@ -1,8 +1,8 @@
 <odoo>
-  <record id="product_category_pack" model="product.category">
+  <record id="product_category_platform_pack" model="product.category">
     <field name="name">Platform Service Pack</field>
   </record>
-  <record id="product_category_service" model="product.category">
+  <record id="product_category_platform_service" model="product.category">
     <field name="name">Platform Service</field>
   </record>
 </odoo>
diff --git a/energy_communities_service_invoicing/models/account_move.py b/energy_communities_service_invoicing/models/account_move.py
index 378c9bd62..381e6c69b 100644
--- a/energy_communities_service_invoicing/models/account_move.py
+++ b/energy_communities_service_invoicing/models/account_move.py
@@ -6,20 +6,24 @@ class AccountMove(models.Model):
 
     ref_invoice_id = fields.Many2one(
         comodel_name="account.move",
-        compute="_compute_ref_invoice_id_related_contract_id_is_pack_is_contract",
+        compute="_compute_ref_invoice_id_related_contract_id_pack_type_is_contract",
+        compute_sudo=True,
         store=False,
     )
     related_contract_id = fields.Many2one(
         comodel_name="contract.contract",
-        compute="_compute_ref_invoice_id_related_contract_id_is_pack_is_contract",
+        compute="_compute_ref_invoice_id_related_contract_id_pack_type_is_contract",
+        compute_sudo=True,
         store=False,
     )
-    is_pack = fields.Boolean(
-        compute="_compute_ref_invoice_id_related_contract_id_is_pack_is_contract",
+    pack_type = fields.Boolean(
+        compute="_compute_ref_invoice_id_related_contract_id_pack_type_is_contract",
+        compute_sudo=True,
         store=True,
     )
     is_contract = fields.Boolean(
-        compute="_compute_ref_invoice_id_related_contract_id_is_pack_is_contract",
+        compute="_compute_ref_invoice_id_related_contract_id_pack_type_is_contract",
+        compute_sudo=True,
         store=True,
     )
     related_community_company_id = fields.Many2one(
@@ -30,11 +34,11 @@ class AccountMove(models.Model):
     )
 
     @api.depends("invoice_line_ids", "ref")
-    def _compute_ref_invoice_id_related_contract_id_is_pack_is_contract(self):
+    def _compute_ref_invoice_id_related_contract_id_pack_type_is_contract(self):
         for record in self:
             record.ref_invoice_id = False
             record.related_contract_id = False
-            record.is_pack = False
+            record.pack_type = 'none'
             record.is_contract = False
             rel_inv = False
             if record.ref:
@@ -45,7 +49,7 @@ class AccountMove(models.Model):
                 )
                 if rel_inv:
                     record.ref_invoice_id = rel_inv.id
-                    record.is_pack = rel_inv.is_pack
+                    record.pack_type = rel_inv.pack_type
                     record.is_contract = rel_inv.is_contract
                     if rel_inv.related_contract_id:
                         record.related_contract_id = rel_inv.related_contract_id.id
@@ -54,6 +58,6 @@ class AccountMove(models.Model):
                     first_move_line = record.invoice_line_ids[0]
                     if first_move_line.contract_line_id:
                         rel_contract = first_move_line.contract_line_id.contract_id
-                        record.is_pack = rel_contract.is_pack
+                        record.pack_type = rel_contract.pack_type
                         record.related_contract_id = rel_contract.id
                         record.is_contract = True
diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index 512e65349..0d949cfe0 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -7,7 +7,7 @@ from ..utils import (
     _CONTRACT_STATUS_VALUES,
     _SALE_ORDER_SERVICE_INVOICING_ACTION_VALUES,
     get_existing_open_pack_contract,
-    raise_existing_same_open_pack_contract_error,
+    raise_existing_same_open_platform_pack_contract_error,
 )
 
 _CLOSING_ACTION_VALUES = _SALE_ORDER_SERVICE_INVOICING_ACTION_VALUES + [
@@ -45,7 +45,7 @@ class ContractContract(models.Model):
     last_date_invoiced = fields.Date(
         string="Last Date Invoiced", compute="_compute_last_date_invoiced", store=False
     )
-    is_pack = fields.Boolean(related="contract_template_id.is_pack")
+    pack_type = fields.Selection(related="contract_template_id.pack_type")
     is_free_pack = fields.Boolean(related="contract_template_id.is_free_pack")
     closing_action = fields.Selection(
         selection=_CLOSING_ACTION_VALUES,
@@ -65,10 +65,10 @@ class ContractContract(models.Model):
         compute="_compute_related_contract_product_ids",
         store=False,
     )
-    service_pack_id = fields.Many2one(
+    pack_id = fields.Many2one(
         "product.product",
         string="Service Pack",
-        compute="_compute_service_pack_id",
+        compute="_compute_pack_id",
         store=False,
     )
     sale_order_id = fields.Many2one(
@@ -107,9 +107,9 @@ class ContractContract(models.Model):
     def _constrain_unique_contract(self):
         for record in self:
             if record.community_company_id:
-                existing_contract = record._get_existing_same_open_pack_contract()
+                existing_contract = record._get_existing_same_open_platform_pack_contract()
                 if existing_contract:
-                    raise_existing_same_open_pack_contract_error(existing_contract)
+                    raise_existing_same_open_platform_pack_contract_error(existing_contract)
 
     def _compute_received_invoices_count(self):
         for record in self:
@@ -142,9 +142,9 @@ class ContractContract(models.Model):
                 ].last_date_invoiced
 
     @api.depends("contract_template_id")
-    def _compute_service_pack_id(self):
+    def _compute_pack_id(self):
         for record in self:
-            record.service_pack_id = False
+            record.pack_id = False
             if record.contract_template_id:
                 rel_product = self.env["product.product"].search(
                     [
@@ -157,7 +157,7 @@ class ContractContract(models.Model):
                     limit=1,
                 )
                 if rel_product:
-                    record.service_pack_id = rel_product.id
+                    record.pack_id = rel_product.id
 
     def _recurring_create_invoice(self, date_ref=False):
         moves = super()._recurring_create_invoice(date_ref)
@@ -177,11 +177,11 @@ class ContractContract(models.Model):
 
     def action_reopen_contract(self):
         return self._action_contract(
-            "reopen", self.service_pack_id, self.pricelist_id, self.payment_mode_id
+            "reopen", self.pack_id, self.pricelist_id, self.payment_mode_id
         )
 
     def _action_contract(
-        self, action, service_pack_id=False, pricelist_id=False, payment_mode_id=False
+        self, action, pack_id=False, pricelist_id=False, payment_mode_id=False
     ):
         self.ensure_one()
         create_dict = {
@@ -189,8 +189,8 @@ class ContractContract(models.Model):
             "executed_action": action,
             "discount": self.discount,
         }
-        if service_pack_id:
-            create_dict["service_pack_id"] = service_pack_id.id
+        if pack_id:
+            create_dict["pack_id"] = pack_id.id
         if pricelist_id:
             create_dict["pricelist_id"] = pricelist_id.id
         if payment_mode_id:
@@ -259,9 +259,9 @@ class ContractContract(models.Model):
                     received_invoices.append(invoice.id)
         return received_invoices
 
-    def _get_existing_same_open_pack_contract(self):
+    def _get_existing_same_open_platform_pack_contract(self):
         return get_existing_open_pack_contract(
-            self.env, self.partner_id, self.community_company_id, self
+            self.env, self.partner_id, "platform_pack", contract_id=self, custom_query=[("community_company_id", "=", self.community_company_id.id)]
         )
 
     def get_active_monitoring_members(self):
diff --git a/energy_communities_service_invoicing/models/contract_template.py b/energy_communities_service_invoicing/models/contract_template.py
index c4008db80..440855b79 100644
--- a/energy_communities_service_invoicing/models/contract_template.py
+++ b/energy_communities_service_invoicing/models/contract_template.py
@@ -1,31 +1,45 @@
-from odoo import api, fields, models
+from odoo import api, fields, models, _
 
+PACK_VALUES = [
+    ("platform_pack", _("Platform Pack")),
+    ("none", _("None")),
+]
 
 class ContractTemplate(models.Model):
     _name = "contract.template"
     _inherit = "contract.template"
 
-    is_pack = fields.Boolean(compute="compute_is_pack", store=True)
     is_free_pack = fields.Boolean(string="Is a free pack")
-
-    def compute_is_pack(self):
-        try:
-            categ_id = self.env.ref(
-                "energy_communities_service_invoicing.product_category_pack"
-            ).id
-        except:
-            categ_id = False
-        for record in self:
-            if categ_id:
-                record.is_pack = bool(
+    pack_type = fields.Selection(PACK_VALUES, compute="_compute_pack_type", string="Pack Type", store=True)
+    
+    def _get_pack_product_from_category(self, category_id, value):
+        return value if bool(
                     self.env["product.template"].search(
                         [
-                            ("property_contract_template_id", "=", record.id),
+                            ("property_contract_template_id", "=", self.id),
                             (
                                 "categ_id",
                                 "=",
-                                categ_id,
+                                category_id,
                             ),
                         ]
                     )
-                )
+                ) else 'none'
+    
+    def _set_custom_pack_type(self, ref_category, value):
+        try:
+            categ_id = self.env.ref(
+                ref_category
+            ).id
+        except:
+            categ_id = False
+        if categ_id:
+            self.pack_type = self._get_pack_product_from_category(categ_id, value)
+
+    def custom_compute_pack_type(self):
+        self._set_custom_pack_type("energy_communities_service_invoicing.product_category_platform_pack", 'platform_pack')
+
+    def _compute_pack_type(self):
+        for record in self:
+            record.custom_compute_pack_type()
+
diff --git a/energy_communities_service_invoicing/models/product_template.py b/energy_communities_service_invoicing/models/product_template.py
index d9b8d3eef..6b56c94ee 100644
--- a/energy_communities_service_invoicing/models/product_template.py
+++ b/energy_communities_service_invoicing/models/product_template.py
@@ -13,6 +13,7 @@ class ProductTemplate(models.Model):
         compute="_compute_related_contract_product_ids",
         store=False,
     )
+    pack_type = fields.Selection(related="property_contract_template_id.pack_type")
 
     @api.depends("property_contract_template_id")
     def _compute_related_contract_product_ids(self):
@@ -25,14 +26,13 @@ class ProductTemplate(models.Model):
                 record.related_contract_product_ids = rel_products
 
     @api.constrains("property_contract_template_id")
-    def compute_contract_template_is_pack(self):
-        for record in self:
-            ctemplates = self.env["contract.template"].search([])
-            for ctemplate in ctemplates:
-                ctemplate.compute_is_pack()
+    def _constraint_contract_template_pack_type(self):
+        ctemplates = self.env["contract.template"].search([])
+        for ctemplate in ctemplates:
+            ctemplate._compute_pack_type()
 
     @api.constrains("description_sale")
-    def compute_contract_template_line_name(self):
+    def _constraint_contract_template_line_name(self):
         for record in self:
             ctemplatelines = self.env["contract.template.line"].search(
                 [("product_id", "=", record.product_variant_id.id)]
diff --git a/energy_communities_service_invoicing/models/res_partner.py b/energy_communities_service_invoicing/models/res_partner.py
index 02db8bb7b..f71e7fe79 100644
--- a/energy_communities_service_invoicing/models/res_partner.py
+++ b/energy_communities_service_invoicing/models/res_partner.py
@@ -9,39 +9,39 @@ class ResPartner(models.Model):
     _name = "res.partner"
     _inherit = ["res.partner"]
 
-    service_pack_id = fields.Many2one(
+    platform_pack_id = fields.Many2one(
         "product.product",
-        string="Service Pack",
-        compute="_compute_service_pack_id",
+        string="Platform Service Pack",
+        compute="_compute_platform_pack_id",
         store=False,
     )
-    pack_contract_status = fields.Selection(
+    platform_pack_contract_status = fields.Selection(
         selection=_PACK_CONTRACT_STATUS_VALUES,
-        string="Service Pack Status",
-        compute="_compute_service_pack_status",
+        string="Platform Service Pack Status",
+        compute="_compute_platform_pack_status",
         store=False,
     )
 
-    def _compute_service_pack_status(self):
+    def _compute_platform_pack_status(self):
         for record in self:
-            record.pack_contract_status = "none"
-            rel_contract = record._get_related_service_contract()
+            record.platform_pack_contract_status = "none"
+            rel_contract = record._get_related_platform_pack_contract()
             if rel_contract:
-                record.pack_contract_status = rel_contract.status
+                record.platform_pack_contract_status = rel_contract.status
 
-    def _compute_service_pack_id(self):
+    def _compute_platform_pack_id(self):
         for record in self:
-            record.service_pack_id = False
-            rel_contract = record._get_related_service_contract()
+            record.platform_pack_id = False
+            rel_contract = record._get_related_platform_pack_contract()
             if rel_contract:
-                if rel_contract.service_pack_id:
-                    record.service_pack_id = rel_contract.service_pack_id.id
+                if rel_contract.pack_id:
+                    record.platform_pack_id = rel_contract.pack_id.id
 
-    def _get_related_service_contract(self):
+    def _get_related_platform_pack_contract(self):
         return self.env["contract.contract"].search(
             [
                 ("community_company_id", "=", self.related_company_id.id),
-                ("is_pack", "=", True),
+                ("pack_type", "=", "platform_pack"),
             ],
             limit=1,
         )
diff --git a/energy_communities_service_invoicing/report/report_invoice.xml b/energy_communities_service_invoicing/report/report_invoice.xml
index aed13d4d3..e1ce48ee5 100644
--- a/energy_communities_service_invoicing/report/report_invoice.xml
+++ b/energy_communities_service_invoicing/report/report_invoice.xml
@@ -1,7 +1,7 @@
 <odoo>
   <template id="report_invoice_document" inherit_id="account.report_invoice_document">
     <xpath expr="//div[@id='informations']" position="inside">
-      <div class="col-auto col-3 mw-100 mb-2" t-if="o.is_pack">
+      <div class="col-auto col-3 mw-100 mb-2" t-if="o.pack_type == 'platform_pack'">
         <strong>Community:</strong>
         <t t-if="o.related_community_company_id.comercial_name">
           <p class="m-0" t-field="o.related_community_company_id.comercial_name"/>
@@ -13,19 +13,4 @@
     </xpath>
   </template>
 </odoo>
-<!--<xpath expr="//table" position="before">-->
-<!--  <div class="row">-->
-<!--    <div class="col-6" name="related_community_company_id">-->
-<!--      <label for="related_community_company_id">Related community company</label>-->
-<!--      <address-->
-<!--        class="mb-0"-->
-<!--        t-field="o.related_community_company_id.partner_id"-->
-<!--        t-options="{'widget': 'contact', 'fields': ['address', 'name'], 'no_marker': True}"-->
-<!--      />-->
-<!--      <div t-if="o.related_community_company_id.partner_id.vat">-->
-<!--        Tax ID: <span t-field="o.related_community_company_id.partner_id.vat"/>-->
-<!--      </div>-->
-<!--    </div>-->
-<!--  </div>-->
-<!--</xpath>-->
 
diff --git a/energy_communities_service_invoicing/utils.py b/energy_communities_service_invoicing/utils.py
index 18562a076..2f63628b5 100644
--- a/energy_communities_service_invoicing/utils.py
+++ b/energy_communities_service_invoicing/utils.py
@@ -68,7 +68,7 @@ def service_invoicing_form_view_for_platform_admins(
 
 
 # TODO: Think a bit more about more about if this 3 methods must go to contract utils component
-def raise_existing_same_open_pack_contract_error(existing_contract):
+def raise_existing_same_open_platform_pack_contract_error(existing_contract):
     raise ValidationError(
         _(
             "It already exists an open contract ({}) with same company and community."
@@ -77,26 +77,26 @@ def raise_existing_same_open_pack_contract_error(existing_contract):
 
 
 def get_existing_open_pack_contract(
-    env, partner_id, community_company_id, contract_id=False
+    env, partner_id, pack_type, contract_id=False, custom_query=[]
 ):
+    #("community_company_id", "=", community_company_id.id),
     query = [
-        ("partner_id", "=", partner_id.id),
-        ("community_company_id", "=", community_company_id.id),
-        ("is_pack", "=", True),
+        ("partner_id", "=", partner_id.id), 
+        ("pack_type", "=", pack_type),
         ("status", "in", ["paused", "in_progress"]),
     ]
     if contract_id:
         query.append(("id", "!=", contract_id.id))
+    query = custom_query + query
     return env["contract.contract"].search(query, limit=1)
 
-
 def get_existing_last_closed_pack_contract(
     env, partner_id, community_company_id, contract_id=False
 ):
     query = [
         ("partner_id", "=", partner_id.id),
         ("community_company_id", "=", community_company_id.id),
-        ("is_pack", "=", True),
+        ("pack_type", "=", "platform_pack"),
         ("status", "in", ["closed_planned", "closed"]),
         ("successor_contract_id", "=", False),
     ]
diff --git a/energy_communities_service_invoicing/views/account_move_views.xml b/energy_communities_service_invoicing/views/account_move_views.xml
index 272df95a6..8778184dd 100644
--- a/energy_communities_service_invoicing/views/account_move_views.xml
+++ b/energy_communities_service_invoicing/views/account_move_views.xml
@@ -5,11 +5,11 @@
       <field name="inherit_id" ref="account.view_move_form" />
       <field name="arch" type="xml">
         <xpath expr="//field[@name='partner_id']" position="after">
-          <field name="is_pack" invisible="True" />
+          <field name="pack_type" invisible="True" />
           <field name="is_contract" invisible="True" />
           <field name="invoice_origin" attrs="{'invisible': [('is_contract','=',False)]}" />
           <field name="related_contract_id" attrs="{'invisible': [('is_contract','=',False)]}" />
-          <field name="related_community_company_id" attrs="{'invisible': [('is_pack','=',False)]}" />
+          <field name="related_community_company_id" attrs="{'invisible': [('pack_type' ,'=', 'platform_pack')]}" />
         </xpath>
       </field>
   </record>
diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index b19994cca..e0f63f4e5 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -47,9 +47,9 @@
           decoration-success="status == 'in_progress'"
         />
         <field name="partner_id" />
-        <field name="community_company_id" />
-        <field name="service_pack_id" />
-        <field name="is_pack" />
+        <field name="community_company_id" attrs="{'invisible': [('pack_type', '!=', 'platform_pack')]}" />
+        <field name="pack_id" />
+        <field name="pack_type" />
       </tree>
     </field>
   </record>
@@ -92,7 +92,7 @@
         <field name="community_company_id" />
       </xpath>
       <xpath expr="//field[@name='pricelist_id']" position="after">
-        <field name="service_pack_id" />
+        <field name="pack_id" />
       </xpath>
       <xpath expr="//field[@name='user_id']" position="after">
         <field name="date_start" />
@@ -135,7 +135,7 @@
           <!--</div>-->
           <group>
             <field name="name" />
-            <field name="service_pack_id" options="{'no_open': True}" />
+            <field name="pack_id" options="{'no_open': True}" />
             <field name="related_contract_product_ids" widget="one2many" >
               <tree editable="bottom">
                 <field name="name" readonly="1"/>
diff --git a/energy_communities_service_invoicing/views/res_partner_views.xml b/energy_communities_service_invoicing/views/res_partner_views.xml
index 87850b0f4..305418539 100644
--- a/energy_communities_service_invoicing/views/res_partner_views.xml
+++ b/energy_communities_service_invoicing/views/res_partner_views.xml
@@ -6,8 +6,8 @@
     <field name="arch" type="xml">
       <xpath expr="//field[@name='vat']" position="after">
         <field name="company_hierarchy_level" invisible="1" />
-        <field name="service_pack_id" attrs="{'invisible': [('company_hierarchy_level', '!=', 'community')]}" options="{'no_open': True}" />
-        <field name="pack_contract_status" attrs="{'invisible': [('company_hierarchy_level', '!=', 'community')]}" />
+        <field name="platform_pack_id" attrs="{'invisible': [('company_hierarchy_level', '!=', 'community')]}" options="{'no_open': True}" />
+        <field name="platform_pack_contract_status" attrs="{'invisible': [('company_hierarchy_level', '!=', 'community')]}" />
       </xpath>
     </field>
   </record>
diff --git a/energy_communities_service_invoicing/views/service_invoicing_views.xml b/energy_communities_service_invoicing/views/service_invoicing_views.xml
index 683cdfda0..52ce9ab42 100644
--- a/energy_communities_service_invoicing/views/service_invoicing_views.xml
+++ b/energy_communities_service_invoicing/views/service_invoicing_views.xml
@@ -28,7 +28,7 @@
     <field name="name">Packs</field>
     <field name="res_model">product.template</field>
     <field name="view_mode">tree,form</field>
-    <field name="domain" eval="[('categ_id','=',ref('product_category_pack'))]" />
+    <field name="domain" eval="[('categ_id','=',ref('product_category_platform_pack'))]" />
   </record>
 
   <record
@@ -38,7 +38,7 @@
     <field name="name">Services</field>
     <field name="res_model">product.template</field>
     <field name="view_mode">tree,form</field>
-    <field name="domain" eval="[('categ_id','=',ref('product_category_service'))]" />
+    <field name="domain" eval="[('categ_id','=',ref('product_category_platform_service'))]" />
   </record>
 
   <record
@@ -48,7 +48,7 @@
     <field name="name">Packs contract templates</field>
     <field name="res_model">contract.template</field>
     <field name="view_mode">tree,form</field>
-    <field name="domain">[('is_pack','=',True)]</field>
+    <field name="domain">[(pack_type, '=', 'platform_pack')]</field>
   </record>
 
   <record
@@ -58,7 +58,7 @@
     <field name="name">Service invoices (issued)</field>
     <field name="res_model">account.move</field>
     <field name="view_mode">tree,form</field>
-    <field name="domain" eval="[('move_type', 'in', ['out_invoice', 'out_refund']),('is_pack','=',True)]"/>
+    <field name="domain" eval="[('move_type', 'in', ['out_invoice', 'out_refund']), ('pack_type', '=', 'platform_pack')]"/>
   </record>
 
   <record
@@ -68,7 +68,7 @@
     <field name="name">Service invoices (received)</field>
     <field name="res_model">account.move</field>
     <field name="view_mode">tree,form</field>
-    <field name="domain" eval="[('move_type', 'in', ['in_invoice', 'in_refund']),('is_pack','=',True)]"/>
+    <field name="domain" eval="[('move_type', 'in', ['in_invoice', 'in_refund']), ('pack_type', '=', 'platform_pack')]"/>
   </record>
 
   <record
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action.py b/energy_communities_service_invoicing/wizards/service_invoicing_action.py
index 59a6b2d9f..a2778ad12 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action.py
@@ -22,9 +22,10 @@ class ServiceInvoicingActionWizard(models.TransientModel):
         selection=_SERVICE_INVOICING_EXECUTED_ACTION_VALUES
     )
     pricelist_id = fields.Many2one("product.pricelist", string="Select pricelist")
-    service_pack_id = fields.Many2one("product.product", string="Service pack")
+    pack_id = fields.Many2one("product.product", string="Pack")
     discount = fields.Float(string="Discount (%)", digits="Discount")
     payment_mode_id = fields.Many2one("account.payment.mode", string="Payment mode")
+    pack_type = fields.Selection(related="service_invoicing_id.pack_type")
 
     def execute_activate(self):
         with contract_utils(self.env, self.service_invoicing_id) as component:
@@ -42,7 +43,7 @@ class ServiceInvoicingActionWizard(models.TransientModel):
                 self.execution_date,
                 executed_modification_action,
                 self.pricelist_id,
-                self.service_pack_id,
+                self.pack_id,
                 self.discount,
                 self.payment_mode_id,
             )
@@ -55,7 +56,7 @@ class ServiceInvoicingActionWizard(models.TransientModel):
             service_invoicing_id = component.reopen(
                 self.execution_date,
                 self.pricelist_id,
-                self.service_pack_id,
+                self.pack_id,
                 self.discount,
                 self.payment_mode_id,
             )
@@ -66,7 +67,7 @@ class ServiceInvoicingActionWizard(models.TransientModel):
     def _validate_execute_modify(self):
         if (
             not self.pricelist_id
-            and not self.service_pack_id
+            and not self.pack_id
             and not self.payment_mode_id
             and self.discount == self.service_invoicing_id.discount
         ):
@@ -76,10 +77,10 @@ class ServiceInvoicingActionWizard(models.TransientModel):
         executed_modification_action = ""
         if self.pricelist_id:
             executed_modification_action += "modify_pricelist"
-        if self.service_pack_id:
+        if self.pack_id:
             if bool(executed_modification_action):
                 executed_modification_action += ","
-            executed_modification_action += "modify_service_pack"
+            executed_modification_action += "modify_pack"
         if self.payment_mode_id:
             if bool(executed_modification_action):
                 executed_modification_action += ","
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action.xml b/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
index f66cf95e0..f5585a315 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action.xml
@@ -10,6 +10,7 @@
         <sheet>
           <group>
             <field name="executed_action" invisible="1" />
+            <field name="pack_type" invisible="1" />
             <field
               name="service_invoicing_id"
               required="1"
@@ -19,8 +20,8 @@
             />
             <field name="execution_date" required="1"/>
             <field
-              name="service_pack_id"
-              domain="[('is_contract','=',True)]"
+              name="pack_id"
+              domain="[('pack_type','=', pack_type)]"
               attrs="{
                 'invisible': [('executed_action','not in',['modification','reopen'])],
                 'required': [('executed_action','=','reopen')]
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
index e36abc4bb..1258fdd77 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
@@ -10,7 +10,7 @@ from odoo.addons.energy_communities.utils import (
 from ..utils import (
     get_existing_last_closed_pack_contract,
     get_existing_open_pack_contract,
-    raise_existing_same_open_pack_contract_error,
+    raise_existing_same_open_platform_pack_contract_error,
     service_invoicing_form_view_for_platform_admins,
     service_invoicing_tree_view,
 )
@@ -34,9 +34,9 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
     community_company_mids = fields.Many2many(
         comodel_name="res.company",
     )
-    service_pack_id = fields.Many2one(
+    platform_pack_id = fields.Many2one(
         "product.product",
-        string="Service pack",
+        string="Platform service pack",
     )
     payment_mode_id = fields.Many2one(
         "account.payment.mode",
@@ -48,22 +48,22 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
 
     allowed_community_company_ids = fields.Many2many(
         comodel_name="res.company",
-        _compute="_compute_allowed_community_company_ids",
+        compute="_compute_allowed_community_company_ids",
         store=False,
     )
     allowed_payment_mode_ids = fields.Many2many(
         comodel_name="account.payment.mode",
-        _compute="_compute_allowed_payment_mode_ids",
+        compute="_compute_allowed_payment_mode_ids",
         store=False,
     )
-    pack_product_categ_id = fields.Many2one(
-        "product.category", compute="_compute_pack_product_categ_id", store=False
+    platform_pack_product_categ_id = fields.Many2one(
+        "product.category", compute="_compute_platform_pack_product_categ_id", store=False
     )
 
-    def _compute_pack_product_categ_id(self):
+    def _compute_platform_pack_product_categ_id(self):
         for record in self:
-            record.pack_product_categ_id = self.env.ref(
-                "energy_communities_service_invoicing.product_category_pack"
+            record.platform_pack_product_categ_id = self.env.ref(
+                "energy_communities_service_invoicing.product_category_platform_pack"
             ).id
 
     @api.depends("company_id", "community_company_mids")
@@ -119,7 +119,7 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
                 service_invoicing_id = component.reopen(
                     self.execution_date,
                     self.pricelist_id,
-                    self.service_pack_id,
+                    self.platform_pack_id,
                     self.discount,
                     payment_mode_id,
                 )
@@ -129,7 +129,7 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
                 service_invoicing_id = component.create_service_invoicing_initial(
                     company_id,
                     community_company_id,
-                    self.service_pack_id,
+                    self.platform_pack_id,
                     self.pricelist_id,
                     self.execution_date,
                     self.discount,
@@ -182,10 +182,11 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
         # Check if already open one and raise error
         for record in impacted_records:
             existing_contract = get_existing_open_pack_contract(
-                self.env, record.parent_id.partner_id, record
+                self.env, record.parent_id.partner_id, "platform_pack", contract_id=False, custom_query=[("community_company_id", "=", record.id)]
             )
+
             if existing_contract:
-                raise_existing_same_open_pack_contract_error(existing_contract)
+                raise_existing_same_open_platform_pack_contract_error(existing_contract)
 
     def _validate_service_invoicing_action_create_multicommunity(self, company_id_list):
         impacted_records = self.env["res.company"].browse(company_id_list)
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
index 309c02e08..c52f35648 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
@@ -12,7 +12,7 @@
             <field name="creation_type" invisible="1" />
             <field name="allowed_community_company_ids" invisible="1" />
             <field name="allowed_payment_mode_ids" invisible="1" />
-            <field name="pack_product_categ_id" invisible="1" />
+            <field name="platform_pack_product_categ_id" invisible="1" />
             <field name="execution_date" required="1"/>
             <field
               name="company_id"
@@ -33,8 +33,8 @@
                 <field name="parent_id"/>
              </tree>
             </field>
-            <field name="service_pack_id"
-              domain="[('categ_id','=',pack_product_categ_id)]"
+            <field name="platform_pack_id"
+              domain="[('categ_id','=', platform_pack_product_categ_id)]"
               required="1"
             />
             <field name="pricelist_id" required="1" domain="[('company_id','=',False)]"/>
diff --git a/energy_selfconsumption/__manifest__.py b/energy_selfconsumption/__manifest__.py
index 94378c23b..965109dc6 100644
--- a/energy_selfconsumption/__manifest__.py
+++ b/energy_selfconsumption/__manifest__.py
@@ -26,6 +26,7 @@
         "web_m2x_options",
         "l10n_es",
         "report_csv",
+        "energy_communities_service_invoicing",
     ],
     "external_dependencies": {
         "python": ["pandas>=2.0.3", "numpy>=1.24.4", "openupgradelib>=3.6.1"]
@@ -41,6 +42,7 @@
         "data/mail_template.xml",
         "data/ir_attachment_data.xml",
         "data/ir_cron.xml",
+        "data/product_data.xml",
         "views/contract_views.xml",
         "views/selfconsumption_views.xml",
         "views/supply_point_views.xml",
diff --git a/energy_selfconsumption/data/product_data.xml b/energy_selfconsumption/data/product_data.xml
new file mode 100644
index 000000000..3350c52e3
--- /dev/null
+++ b/energy_selfconsumption/data/product_data.xml
@@ -0,0 +1,9 @@
+<odoo>
+  <record id="product_category_selfconsumption_pack" model="product.category">
+    <field name="name">Selfconsumption Pack</field>
+  </record>
+  <record id="product_category_selfconsumption_service" model="product.category">
+    <field name="name">Selfconsumption Service</field>
+  </record>
+</odoo>
+
diff --git a/energy_selfconsumption/models/__init__.py b/energy_selfconsumption/models/__init__.py
index 3a53b3984..17238e412 100644
--- a/energy_selfconsumption/models/__init__.py
+++ b/energy_selfconsumption/models/__init__.py
@@ -14,3 +14,4 @@ from . import project
 from . import selfconsumption
 from . import supply_point
 from . import supply_point_assignation
+from . import contract_template
diff --git a/energy_selfconsumption/models/contract_template.py b/energy_selfconsumption/models/contract_template.py
new file mode 100644
index 000000000..bf4933d03
--- /dev/null
+++ b/energy_selfconsumption/models/contract_template.py
@@ -0,0 +1,15 @@
+from odoo import api, fields, models, _
+
+PACK_VALUES = [
+    ("selfconsumption_pack", _("Selfconsumption Pack")),
+]
+
+class ContractTemplate(models.Model):
+    _inherit = "contract.template"
+
+    pack_type = fields.Selection(selection_add=PACK_VALUES)
+
+    def custom_compute_pack_type(self):
+        super().custom_compute_pack_type()
+        if self.pack_type == 'none':
+            self.set_custom_pack_type("selfconsumption.product_category_selfconsumption_pack", 'selfconsumption_pack')
-- 
GitLab


From eb1cecdce1b07bff6a4770609febc186b28cd03a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81lvaro=20Garc=C3=ADa?= <alvarogruiz8@gmail.com>
Date: Thu, 6 Mar 2025 15:15:39 +0100
Subject: [PATCH 77/85] =?UTF-8?q?[FIX]=20=F0=9F=90=9B=20fix=20action=20ser?=
 =?UTF-8?q?vices?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: Alvaro Garcia <alvaro.garcia@somit.coop>
---
 .../views/service_invoicing_views.xml                           | 2 +-
 .../wizards/service_invoicing_action_create.py                  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/energy_communities_service_invoicing/views/service_invoicing_views.xml b/energy_communities_service_invoicing/views/service_invoicing_views.xml
index 52ce9ab42..a40d20f15 100644
--- a/energy_communities_service_invoicing/views/service_invoicing_views.xml
+++ b/energy_communities_service_invoicing/views/service_invoicing_views.xml
@@ -48,7 +48,7 @@
     <field name="name">Packs contract templates</field>
     <field name="res_model">contract.template</field>
     <field name="view_mode">tree,form</field>
-    <field name="domain">[(pack_type, '=', 'platform_pack')]</field>
+    <field name="domain">[('pack_type', '=', 'platform_pack')]</field>
   </record>
 
   <record
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
index 1258fdd77..fd06a8e04 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
@@ -86,7 +86,7 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
     @api.onchange("company_id")
     def _compute_service_invoicing_action_create_wizard_allowed_values(self):
         for record in self:
-            record._compute_pack_product_categ_id()
+            record._compute_platform_pack_product_categ_id()
             record._compute_allowed_community_company_ids()
             record._compute_allowed_payment_mode_ids()
 
-- 
GitLab


From 05fb631088413cbb2293722205d20a96d7994b1c Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Fri, 7 Mar 2025 12:05:54 +0100
Subject: [PATCH 78/85] =?UTF-8?q?[FIX]=20=F0=9F=90=9B=20Call=20to=20privat?=
 =?UTF-8?q?e=20method.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../views/contract_template_views.xml                  |  1 +
 energy_selfconsumption/models/contract_template.py     | 10 +++++++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/energy_communities_service_invoicing/views/contract_template_views.xml b/energy_communities_service_invoicing/views/contract_template_views.xml
index dfb1bece1..6a8ec84f7 100644
--- a/energy_communities_service_invoicing/views/contract_template_views.xml
+++ b/energy_communities_service_invoicing/views/contract_template_views.xml
@@ -5,6 +5,7 @@
   <field name="inherit_id" ref="contract.contract_template_form_view" />
   <field name="arch" type="xml">
     <xpath expr="//field[@name='contract_type']" position="after">
+      <field name="pack_type" />
       <field name="is_free_pack" />
     </xpath>
   </field>
diff --git a/energy_selfconsumption/models/contract_template.py b/energy_selfconsumption/models/contract_template.py
index bf4933d03..76734f7a3 100644
--- a/energy_selfconsumption/models/contract_template.py
+++ b/energy_selfconsumption/models/contract_template.py
@@ -1,9 +1,10 @@
-from odoo import api, fields, models, _
+from odoo import _, api, fields, models
 
 PACK_VALUES = [
     ("selfconsumption_pack", _("Selfconsumption Pack")),
 ]
 
+
 class ContractTemplate(models.Model):
     _inherit = "contract.template"
 
@@ -11,5 +12,8 @@ class ContractTemplate(models.Model):
 
     def custom_compute_pack_type(self):
         super().custom_compute_pack_type()
-        if self.pack_type == 'none':
-            self.set_custom_pack_type("selfconsumption.product_category_selfconsumption_pack", 'selfconsumption_pack')
+        if self.pack_type == "none":
+            self._set_custom_pack_type(
+                "selfconsumption.product_category_selfconsumption_pack",
+                "selfconsumption_pack",
+            )
-- 
GitLab


From 7333aa1360b7998594acab2f25a243920b98e96f Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Fri, 7 Mar 2025 12:38:28 +0100
Subject: [PATCH 79/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Better=20menu=20struc?=
 =?UTF-8?q?ture=20for=20service=20invoicing?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 energy_communities/views/menus.xml            |  69 ++++-----
 .../views/menus.xml                           | 146 ++++++++++--------
 .../views/service_invoicing_views.xml         |   9 --
 .../service_invoicing_action_create.xml       |   8 -
 4 files changed, 108 insertions(+), 124 deletions(-)

diff --git a/energy_communities/views/menus.xml b/energy_communities/views/menus.xml
index c4a37ce02..9bd2af50f 100644
--- a/energy_communities/views/menus.xml
+++ b/energy_communities/views/menus.xml
@@ -21,55 +21,38 @@
     groups="role_platform_admin_res_groups,role_coord_admin_res_groups,role_coord_worker_res_groups,role_ce_admin,role_ce_manager"
     web_icon="energy_communities,static/description/icon.png"
   />
-  <!--<menuitem-->
-  <!--  id="ce_root_menu_coord_admin"-->
-  <!--  name="Coordinator management"-->
-  <!--  sequence="10"-->
-  <!--  groups="role_coord_admin_res_groups,role_coord_worker_res_groups"-->
-  <!--  web_icon="energy_communities,static/description/icon.png"-->
-  <!--/>-->
-  <!--<menuitem-->
-  <!--  id="ce_root_menu_community_admin"-->
-  <!--  name="Community management"-->
-  <!--  sequence="10"-->
-  <!--  groups="role_ce_admin,role_ce_manager"-->
-  <!--  web_icon="energy_communities,static/description/icon.png"-->
-  <!--/>-->
-  <menuitem
-    id="ce_assistants_menu"
-    name="Assistants"
-    parent="ce_root_menu"
-    groups="role_platform_admin_res_groups"
-    sequence="99"
-  />
   <menuitem
     id="ce_config_menu"
     name="Configuration"
     parent="ce_root_menu"
     groups="role_platform_admin_res_groups"
     sequence="999"
-  />
-  <menuitem
-    id="ce_config_sources_menu"
-    name="Source types"
-    parent="ce_config_menu"
-    action="ce_utm_sources_action"
-    groups="group_platform_manager"
-  />
-  <menuitem
-    id="energy_actions_menu"
-    name="Energy actions"
-    parent="ce_config_menu"
-    action="energy_action_views"
-    groups="group_platform_manager"
-  />
-  <menuitem
-    id="ec_formulas_menu"
-    name="Formulas"
-    parent="ce_config_menu"
-    action="view_ec_formulas_window"
-    groups="group_platform_manager"
-  />
+  >
+    <menuitem
+      id="ce_config_sources_menu"
+      name="Source types"
+      action="ce_utm_sources_action"
+      groups="group_platform_manager"
+    />
+    <menuitem
+      id="energy_actions_menu"
+      name="Energy actions"
+      action="energy_action_views"
+      groups="group_platform_manager"
+    />
+    <menuitem
+      id="ec_formulas_menu"
+      name="Formulas"
+      action="view_ec_formulas_window"
+      groups="group_platform_manager"
+    />
+    <menuitem
+      name="Tariffs"
+      id="view_service_tariffs_menu"
+      action="product.product_pricelist_action2"
+      groups="role_platform_admin_res_groups"
+    />
+  </menuitem>
 
   <!-- Hide menu items unless platform manager -->
   <record model="ir.ui.menu" id="mail.menu_root_discuss">
diff --git a/energy_communities_service_invoicing/views/menus.xml b/energy_communities_service_invoicing/views/menus.xml
index 9c615fc6f..442ea07a9 100644
--- a/energy_communities_service_invoicing/views/menus.xml
+++ b/energy_communities_service_invoicing/views/menus.xml
@@ -6,77 +6,95 @@
     sequence="1"
     groups="energy_communities.role_platform_admin_res_groups,energy_communities.role_coord_admin_res_groups"
   />
-  <!--<menuitem id="ce_service_invoicing_menu_coord_admin" name="Services Coord" parent="energy_communities.ce_root_menu_platform_manager" sequence="1" />-->
+  
+
   <menuitem
-    name="Service Contracts"
-    id="view_service_invoicing_menu_platform_manager"
+    name="Activity"
+    id="view_service_invoicing_activity_menu"
     parent="ce_service_invoicing_menu"
-    action="view_service_invoicing_window_platform_manager"
-    groups="energy_communities.role_platform_admin_res_groups"
-    sequence="100"
-  />
-  <menuitem
-    name="Service Contracts"
-    id="view_service_invoicing_menu_coord_admin"
-    parent="ce_service_invoicing_menu"
-    action="view_service_invoicing_window_coord_admin"
-    groups="energy_communities.role_coord_admin_res_groups"
     sequence="100"
-  />
+  >
+    <menuitem
+      name="Service Contracts"
+      id="view_service_invoicing_menu_platform_manager"
+      action="view_service_invoicing_window_platform_manager"
+      groups="energy_communities.role_platform_admin_res_groups"
+      sequence="100"
+    />
+    <menuitem
+      name="Service Contracts"
+      id="view_service_invoicing_menu_coord_admin"
+      action="view_service_invoicing_window_coord_admin"
+      groups="energy_communities.role_coord_admin_res_groups"
+      sequence="100"
+    />
+    
+    <menuitem
+      name="Service invoices issued"
+      id="view_service_invoices_issued_menu"
+      action="view_service_invoices_issued_window"
+      groups="energy_communities.role_platform_admin_res_groups"
+      sequence="500"
+    />
+    <menuitem
+      name="Service invoices received"
+      id="view_service_invoices_received_menu"
+      action="view_service_invoices_received_window"
+      groups="energy_communities.role_platform_admin_res_groups,energy_communities.role_coord_admin_res_groups,energy_communities.role_coord_worker_res_groups"
+      sequence="500"
+    />
+    <menuitem
+      name="Service actions (sale orders)"
+      id="view_service_sale_orders_menu"
+      action="view_service_sale_orders_window"
+      groups="energy_communities.role_platform_admin_res_groups"
+      sequence="550"
+    />
+
+  </menuitem>
+
   <menuitem
-    name="Platform Services"
-    id="view_services_menu"
+    name="Configuration"
+    id="view_service_invoicing_configuration_menu"
     parent="ce_service_invoicing_menu"
-    action="view_services_window"
-    groups="energy_communities.role_platform_admin_res_groups,energy_communities.role_coord_admin_res_groups"
     sequence="200"
-  />
-  <menuitem
-    name="Service Packs"
-    id="view_service_packs_menu"
-    parent="ce_service_invoicing_menu"
-    action="view_service_packs_window"
-    groups="energy_communities.role_platform_admin_res_groups,energy_communities.role_coord_admin_res_groups"
-    sequence="300"
-  />
-  <menuitem
-    name="Service Packs templates"
-    id="view_service_contract_templates_menu"
-    parent="ce_service_invoicing_menu"
-    action="view_service_contract_templates_window"
-    groups="energy_communities.role_platform_admin_res_groups"
-    sequence="400"
-  />
+  >
+    <menuitem
+      name="Platform Services"
+      id="view_services_menu"
+      action="view_services_window"
+      groups="energy_communities.role_platform_admin_res_groups,energy_communities.role_coord_admin_res_groups"
+      sequence="200"
+    />
+    <menuitem
+      name="Service Packs"
+      id="view_service_packs_menu"
+      action="view_service_packs_window"
+      groups="energy_communities.role_platform_admin_res_groups,energy_communities.role_coord_admin_res_groups"
+      sequence="300"
+    />
+    <menuitem
+      name="Service Packs templates"
+      id="view_service_contract_templates_menu"
+      action="view_service_contract_templates_window"
+      groups="energy_communities.role_platform_admin_res_groups"
+      sequence="400"
+    />
+  </menuitem>
+
   <menuitem
-    name="Service invoices issued"
-    id="view_service_invoices_issued_menu"
+    name="Assistants"
+    id="view_service_invoicing_assistants_menu"
     parent="ce_service_invoicing_menu"
-    action="view_service_invoices_issued_window"
     groups="energy_communities.role_platform_admin_res_groups"
-    sequence="500"
-  />
-  <menuitem
-    name="Service invoices received"
-    id="view_service_invoices_received_menu"
-    parent="ce_service_invoicing_menu"
-    action="view_service_invoices_received_window"
-    groups="energy_communities.role_coord_admin_res_groups,energy_communities.role_coord_worker_res_groups"
-    sequence="500"
-  />
-  <menuitem
-    name="Service actions (sale orders)"
-    id="view_service_sale_orders_menu"
-    parent="ce_service_invoicing_menu"
-    action="view_service_sale_orders_window"
-    groups="energy_communities.role_platform_admin_res_groups"
-    sequence="550"
-  />
-  <menuitem
-    name="Tariffs"
-    id="view_service_tariffs_menu"
-    parent="ce_service_invoicing_menu"
-    action="view_service_tariffs_window"
-    groups="energy_communities.role_platform_admin_res_groups"
-    sequence="600"
-  />
+    sequence="300"
+  >
+    <menuitem
+      id="service_invoicing_action_create_wizard_menu"
+      name="Assign pack to community"
+      action="service_invoicing_action_create_wizard_action"
+      groups="energy_communities.role_platform_admin_res_groups"
+      sequence="100"
+    />
+  </menuitem>
 </odoo>
diff --git a/energy_communities_service_invoicing/views/service_invoicing_views.xml b/energy_communities_service_invoicing/views/service_invoicing_views.xml
index a40d20f15..d965cf606 100644
--- a/energy_communities_service_invoicing/views/service_invoicing_views.xml
+++ b/energy_communities_service_invoicing/views/service_invoicing_views.xml
@@ -81,15 +81,6 @@
     <field name="domain">[('service_invoicing_action','!=','none')]</field>
   </record>
 
-  <record
-      id="view_service_tariffs_window"
-      model="ir.actions.act_window"
-  >
-    <field name="name">Tariffs</field>
-    <field name="res_model">product.pricelist</field>
-    <field name="view_mode">tree,form</field>
-  </record>
-
   <record
     id="action_view_service_invoicing_tree_platform_manager"
     model="ir.actions.act_window.view"
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
index c52f35648..69cfde32f 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.xml
@@ -70,12 +70,4 @@
       <field name="view_mode">form</field>
       <field name="target">new</field>
   </record>
-  <menuitem
-    id="service_invoicing_action_create_wizard_menu"
-    name="Assign pack to community"
-    action="service_invoicing_action_create_wizard_action"
-    parent="energy_communities.ce_assistants_menu"
-    groups="energy_communities.role_platform_admin_res_groups"
-    sequence="100"
-  />
 </odoo>
-- 
GitLab


From a87372a9b23063b8cf3af3c26dcf5de3a9ece8ee Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Fri, 7 Mar 2025 15:47:43 +0100
Subject: [PATCH 80/85] =?UTF-8?q?[FIX]=20=F0=9F=90=9B=20Avoid=20creation?=
 =?UTF-8?q?=20of=202=20sale=20orders?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../components/sale_order_utils.py                        | 8 +++++---
 .../views/contract_views.xml                              | 1 +
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/energy_communities_service_invoicing/components/sale_order_utils.py b/energy_communities_service_invoicing/components/sale_order_utils.py
index d5bdbe3ee..24c5ae56f 100644
--- a/energy_communities_service_invoicing/components/sale_order_utils.py
+++ b/energy_communities_service_invoicing/components/sale_order_utils.py
@@ -38,13 +38,15 @@ class SaleOrderUtils(Component):
         if payment_mode_id:
             so_creation_dict["payment_mode_id"] = payment_mode_id.id
         # Apply configuration sales team to service invoicing sales order
-        if company_id.service_invoicing_sale_team_id:
-            so_creation_dict["team_id"] = company_id.service_invoicing_sale_team_id.id
+        if self.env.company.service_invoicing_sale_team_id:
+            so_creation_dict[
+                "team_id"
+            ] = self.env.company.service_invoicing_sale_team_id.id
         sale_order = self.env["sale.order"].create(so_creation_dict)
         # Trigger name computattion in oder to include product's description_sale
         for order_line in sale_order.order_line:
             order_line._compute_name()
-        return self.env["sale.order"].create(so_creation_dict)
+        return sale_order
 
     def _create_service_invoicing(
         self,
diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index e0f63f4e5..6e79bb912 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -93,6 +93,7 @@
       </xpath>
       <xpath expr="//field[@name='pricelist_id']" position="after">
         <field name="pack_id" />
+        <field name="pack_type" />
       </xpath>
       <xpath expr="//field[@name='user_id']" position="after">
         <field name="date_start" />
-- 
GitLab


From fdfbe70e34ff0c8ab6aa4b36e1a029f8df2c8c33 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Fri, 7 Mar 2025 16:17:53 +0100
Subject: [PATCH 81/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Setup=20better=20defa?=
 =?UTF-8?q?ults=20for=20action=20wizard?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../models/contract.py                        | 62 +++++++++++++------
 1 file changed, 43 insertions(+), 19 deletions(-)

diff --git a/energy_communities_service_invoicing/models/contract.py b/energy_communities_service_invoicing/models/contract.py
index 0d949cfe0..78a27de59 100644
--- a/energy_communities_service_invoicing/models/contract.py
+++ b/energy_communities_service_invoicing/models/contract.py
@@ -107,9 +107,13 @@ class ContractContract(models.Model):
     def _constrain_unique_contract(self):
         for record in self:
             if record.community_company_id:
-                existing_contract = record._get_existing_same_open_platform_pack_contract()
+                existing_contract = (
+                    record._get_existing_same_open_platform_pack_contract()
+                )
                 if existing_contract:
-                    raise_existing_same_open_platform_pack_contract_error(existing_contract)
+                    raise_existing_same_open_platform_pack_contract_error(
+                        existing_contract
+                    )
 
     def _compute_received_invoices_count(self):
         for record in self:
@@ -167,35 +171,51 @@ class ContractContract(models.Model):
         return moves
 
     def action_activate_contract(self):
-        return self._action_contract("activate")
+        return self._action_contract("activate", {"execution_date": self.date_start})
 
     def action_close_contract(self):
-        return self._action_contract("close")
+        return self._action_contract(
+            "close",
+            {
+                "execution_date": self.last_date_invoiced
+                if self.last_date_invoiced
+                else self.date_start
+            },
+        )
 
     def action_modify_contract(self):
-        return self._action_contract("modification")
+        return self._action_contract(
+            "modification",
+            {
+                "execution_date": self.last_date_invoiced
+                if self.last_date_invoiced
+                else self.date_start
+            },
+        )
 
     def action_reopen_contract(self):
         return self._action_contract(
-            "reopen", self.pack_id, self.pricelist_id, self.payment_mode_id
+            "reopen",
+            {
+                "execution_date": self.date_end,
+                "pack_id": self.pack_id.id if self.pack_id else False,
+                "pricelist_id": self.pricelist_id.id if self.pricelist_id else False,
+                "payment_mode_id": self.payment_mode_id.id
+                if self.payment_mode_id
+                else False,
+            },
         )
 
-    def _action_contract(
-        self, action, pack_id=False, pricelist_id=False, payment_mode_id=False
-    ):
+    def _action_contract(self, action, wizard_defaults_extra):
         self.ensure_one()
-        create_dict = {
+        # wizard params
+        wizard_defaults = {
             "service_invoicing_id": self.id,
             "executed_action": action,
             "discount": self.discount,
-        }
-        if pack_id:
-            create_dict["pack_id"] = pack_id.id
-        if pricelist_id:
-            create_dict["pricelist_id"] = pricelist_id.id
-        if payment_mode_id:
-            create_dict["payment_mode_id"] = payment_mode_id.id
-        wizard = self.env["service.invoicing.action.wizard"].create(create_dict)
+        } | wizard_defaults_extra
+        # wizard creation and display
+        wizard = self.env["service.invoicing.action.wizard"].create(wizard_defaults)
         return {
             "type": "ir.actions.act_window",
             "name": _("Executing: {}").format(action),
@@ -261,7 +281,11 @@ class ContractContract(models.Model):
 
     def _get_existing_same_open_platform_pack_contract(self):
         return get_existing_open_pack_contract(
-            self.env, self.partner_id, "platform_pack", contract_id=self, custom_query=[("community_company_id", "=", self.community_company_id.id)]
+            self.env,
+            self.partner_id,
+            "platform_pack",
+            contract_id=self,
+            custom_query=[("community_company_id", "=", self.community_company_id.id)],
         )
 
     def get_active_monitoring_members(self):
-- 
GitLab


From 60f7943a5900c7bd7ba2a7da38aeb139de1235c9 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Fri, 7 Mar 2025 18:46:58 +0100
Subject: [PATCH 82/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Define=20config=20jou?=
 =?UTF-8?q?rnal=20and=20pack=5Ftype=20mixin?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../__manifest__.py                           |  1 +
 .../components/contract_utils.py              | 10 +--
 .../components/sale_order_utils.py            |  2 +-
 .../models/__init__.py                        |  1 +
 .../models/account_move.py                    | 40 ++++++++----
 .../models/contract_template.py               | 43 ++----------
 .../models/pack_type_mixin.py                 | 65 +++++++++++++++++++
 .../models/res_company.py                     | 12 ++--
 energy_communities_service_invoicing/utils.py | 15 +++--
 .../views/account_move_views.xml              |  2 +-
 .../views/contract_views.xml                  |  1 +
 .../views/res_company_views.xml               |  3 +-
 energy_selfconsumption/models/__init__.py     |  1 +
 energy_selfconsumption/models/account_move.py |  3 +-
 .../models/contract_template.py               | 13 ++--
 .../models/pack_type_mixin.py                 | 11 ++++
 16 files changed, 146 insertions(+), 77 deletions(-)
 create mode 100644 energy_communities_service_invoicing/models/pack_type_mixin.py
 create mode 100644 energy_selfconsumption/models/pack_type_mixin.py

diff --git a/energy_communities_service_invoicing/__manifest__.py b/energy_communities_service_invoicing/__manifest__.py
index 38cac035e..1a6ac870a 100644
--- a/energy_communities_service_invoicing/__manifest__.py
+++ b/energy_communities_service_invoicing/__manifest__.py
@@ -22,6 +22,7 @@
         "contract_variable_quantity",
         "energy_communities",
         "energy_communities_cooperator",  # TODO: This dependency is needed for active members formula. Need to refactor this.
+        "account_invoice_inter_company",
     ],
     # always loaded
     "data": [
diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
index 3269860b8..bd18f5196 100644
--- a/energy_communities_service_invoicing/components/contract_utils.py
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -55,10 +55,12 @@ class ContractUtils(Component):
         for line in self.work.record.contract_line_ids:
             line.write({"discount": discount})
 
-    def set_configuration_service_invoicing_journal_if_defined(self):
-        journal_id = self.work.record.company_id.service_invoicing_journal_id
-        if journal_id:
-            self.work.record.write({"journal_id": journal_id.id})
+    # method to be extended if using component for another pack_type
+    def set_configuration_journal_if_defined(self):
+        if self.work.record.pack_type == "platform_pack":
+            journal_id = self.work.record.company_id.service_invoicing_sale_journal_id
+            if journal_id:
+                self.work.record.write({"journal_id": journal_id.id})
 
     def clean_non_service_lines(self):
         for line in self.work.record.contract_line_ids:
diff --git a/energy_communities_service_invoicing/components/sale_order_utils.py b/energy_communities_service_invoicing/components/sale_order_utils.py
index 24c5ae56f..e3e241ddc 100644
--- a/energy_communities_service_invoicing/components/sale_order_utils.py
+++ b/energy_communities_service_invoicing/components/sale_order_utils.py
@@ -77,7 +77,7 @@ class SaleOrderUtils(Component):
             component.clean_non_service_lines()
             component.set_start_date(start_date)
             component.set_discount(discount)
-            component.set_configuration_service_invoicing_journal_if_defined()
+            component.set_configuration_journal_if_defined()
         return service_invoicing_id
 
     def create_service_invoicing_initial(
diff --git a/energy_communities_service_invoicing/models/__init__.py b/energy_communities_service_invoicing/models/__init__.py
index 7ba9edcc6..8d39612f6 100644
--- a/energy_communities_service_invoicing/models/__init__.py
+++ b/energy_communities_service_invoicing/models/__init__.py
@@ -1,3 +1,4 @@
+from . import pack_type_mixin
 from . import abstract_contract
 from . import account_move
 from . import contract
diff --git a/energy_communities_service_invoicing/models/account_move.py b/energy_communities_service_invoicing/models/account_move.py
index 381e6c69b..fdfc3e71e 100644
--- a/energy_communities_service_invoicing/models/account_move.py
+++ b/energy_communities_service_invoicing/models/account_move.py
@@ -1,28 +1,26 @@
 from odoo import api, fields, models
 
+from ..utils import PACK_VALUES
+
 
 class AccountMove(models.Model):
-    _inherit = "account.move"
+    _name = "account.move"
+    _inherit = ["account.move", "pack.type.mixin"]
 
     ref_invoice_id = fields.Many2one(
         comodel_name="account.move",
-        compute="_compute_ref_invoice_id_related_contract_id_pack_type_is_contract",
+        compute="_compute_ref_invoice_id_related_contract_id_is_contract",
         compute_sudo=True,
         store=False,
     )
     related_contract_id = fields.Many2one(
         comodel_name="contract.contract",
-        compute="_compute_ref_invoice_id_related_contract_id_pack_type_is_contract",
+        compute="_compute_ref_invoice_id_related_contract_id_is_contract",
         compute_sudo=True,
         store=False,
     )
-    pack_type = fields.Boolean(
-        compute="_compute_ref_invoice_id_related_contract_id_pack_type_is_contract",
-        compute_sudo=True,
-        store=True,
-    )
     is_contract = fields.Boolean(
-        compute="_compute_ref_invoice_id_related_contract_id_pack_type_is_contract",
+        compute="_compute_ref_invoice_id_related_contract_id_is_contract",
         compute_sudo=True,
         store=True,
     )
@@ -34,11 +32,10 @@ class AccountMove(models.Model):
     )
 
     @api.depends("invoice_line_ids", "ref")
-    def _compute_ref_invoice_id_related_contract_id_pack_type_is_contract(self):
+    def _compute_ref_invoice_id_related_contract_id_is_contract(self):
         for record in self:
             record.ref_invoice_id = False
             record.related_contract_id = False
-            record.pack_type = 'none'
             record.is_contract = False
             rel_inv = False
             if record.ref:
@@ -49,7 +46,6 @@ class AccountMove(models.Model):
                 )
                 if rel_inv:
                     record.ref_invoice_id = rel_inv.id
-                    record.pack_type = rel_inv.pack_type
                     record.is_contract = rel_inv.is_contract
                     if rel_inv.related_contract_id:
                         record.related_contract_id = rel_inv.related_contract_id.id
@@ -58,6 +54,24 @@ class AccountMove(models.Model):
                     first_move_line = record.invoice_line_ids[0]
                     if first_move_line.contract_line_id:
                         rel_contract = first_move_line.contract_line_id.contract_id
-                        record.pack_type = rel_contract.pack_type
                         record.related_contract_id = rel_contract.id
                         record.is_contract = True
+
+    def custom_compute_pack_type(self):
+        self._set_custom_pack_type_on_invoice()
+
+    @api.depends("ref", "invoice_line_ids")
+    def _compute_pack_type(self):
+        super()._compute_pack_type()
+
+    # define configuration intercompany journal
+    def _prepare_invoice_data(self, dest_company):
+        inv_data = super()._prepare_invoice_data(dest_company)
+        if (
+            self.pack_type == "platform_pack"
+            and dest_company.sudo().service_invoicing_purchase_journal_id
+        ):
+            inv_data[
+                "journal_id"
+            ] = dest_company.sudo().service_invoicing_purchase_journal_id.id
+        return inv_data
diff --git a/energy_communities_service_invoicing/models/contract_template.py b/energy_communities_service_invoicing/models/contract_template.py
index 440855b79..e39c38163 100644
--- a/energy_communities_service_invoicing/models/contract_template.py
+++ b/energy_communities_service_invoicing/models/contract_template.py
@@ -1,45 +1,14 @@
-from odoo import api, fields, models, _
+from odoo import _, api, fields, models
 
-PACK_VALUES = [
-    ("platform_pack", _("Platform Pack")),
-    ("none", _("None")),
-]
 
 class ContractTemplate(models.Model):
     _name = "contract.template"
-    _inherit = "contract.template"
+    _inherit = ["contract.template", "pack.type.mixin"]
 
     is_free_pack = fields.Boolean(string="Is a free pack")
-    pack_type = fields.Selection(PACK_VALUES, compute="_compute_pack_type", string="Pack Type", store=True)
-    
-    def _get_pack_product_from_category(self, category_id, value):
-        return value if bool(
-                    self.env["product.template"].search(
-                        [
-                            ("property_contract_template_id", "=", self.id),
-                            (
-                                "categ_id",
-                                "=",
-                                category_id,
-                            ),
-                        ]
-                    )
-                ) else 'none'
-    
-    def _set_custom_pack_type(self, ref_category, value):
-        try:
-            categ_id = self.env.ref(
-                ref_category
-            ).id
-        except:
-            categ_id = False
-        if categ_id:
-            self.pack_type = self._get_pack_product_from_category(categ_id, value)
 
     def custom_compute_pack_type(self):
-        self._set_custom_pack_type("energy_communities_service_invoicing.product_category_platform_pack", 'platform_pack')
-
-    def _compute_pack_type(self):
-        for record in self:
-            record.custom_compute_pack_type()
-
+        self._set_custom_pack_type_on_contract_template(
+            "platform_pack",
+            "energy_communities_service_invoicing.product_category_platform_pack",
+        )
diff --git a/energy_communities_service_invoicing/models/pack_type_mixin.py b/energy_communities_service_invoicing/models/pack_type_mixin.py
new file mode 100644
index 000000000..7d3ce9e2a
--- /dev/null
+++ b/energy_communities_service_invoicing/models/pack_type_mixin.py
@@ -0,0 +1,65 @@
+from odoo import fields, models
+
+from ..utils import PACK_VALUES
+
+
+class PackTypeMixin(models.AbstractModel):
+    _name = "pack.type.mixin"
+    _description = "Add pack_type to any model"
+
+    pack_type = fields.Selection(
+        PACK_VALUES,
+        compute="_compute_pack_type",
+        compute_sudo=True,
+        string="Pack Type",
+        store=True,
+    )
+
+    def _get_pack_type_from_product_category(self, pack_type, category_id):
+        return (
+            pack_type
+            if bool(
+                self.env["product.template"].search(
+                    [
+                        ("property_contract_template_id", "=", self.id),
+                        ("categ_id", "=", category_id),
+                    ]
+                )
+            )
+            else "none"
+        )
+
+    def _set_custom_pack_type_on_contract_template(self, pack_type, ref_category):
+        try:
+            categ_id = self.env.ref(ref_category).id
+        except:
+            categ_id = False
+        if categ_id:
+            self.pack_type = self._get_pack_type_from_product_category(
+                pack_type, categ_id
+            )
+
+    def _set_custom_pack_type_on_invoice(self):
+        if self.ref:
+            rel_inv = (
+                self.env["account.move"]
+                .sudo()
+                .search([("name", "=", self.ref)], limit=1)
+            )
+            if rel_inv:
+                self.pack_type = rel_inv.pack_type
+        else:
+            if self.invoice_line_ids:
+                first_move_line = self.invoice_line_ids[0]
+                if first_move_line.contract_line_id:
+                    rel_contract = first_move_line.contract_line_id.contract_id
+                    self.pack_type = rel_contract.pack_type
+
+    # method to be overwriten on implementations
+    def custom_compute_pack_type(self):
+        pass
+
+    def _compute_pack_type(self):
+        for record in self:
+            record.pack_type = "none"
+            record.custom_compute_pack_type()
diff --git a/energy_communities_service_invoicing/models/res_company.py b/energy_communities_service_invoicing/models/res_company.py
index 0264c69bb..7ce76cc08 100644
--- a/energy_communities_service_invoicing/models/res_company.py
+++ b/energy_communities_service_invoicing/models/res_company.py
@@ -6,14 +6,14 @@ class ResCompany(models.Model):
     _name = "res.company"
     _inherit = ["res.company"]
 
-    service_invoicing_journal_id = fields.Many2one(
+    service_invoicing_sale_journal_id = fields.Many2one(
         comodel_name="account.journal",
-        string="Service invoicing journal",
+        string="Service invoicing sale journal",
+    )
+    service_invoicing_purchase_journal_id = fields.Many2one(
+        comodel_name="account.journal",
+        string="Service invoicing purchase journal",
     )
-    # service_invoicing_payment_mode_id = fields.Many2one(
-    #     comodel_name="account.payment.mode",
-    #     string="Service invoicing payment mode",
-    # )
     service_invoicing_sale_team_id = fields.Many2one(
         comodel_name="crm.team",
         string="Service invoicing sales team",
diff --git a/energy_communities_service_invoicing/utils.py b/energy_communities_service_invoicing/utils.py
index 2f63628b5..a99e7c972 100644
--- a/energy_communities_service_invoicing/utils.py
+++ b/energy_communities_service_invoicing/utils.py
@@ -4,6 +4,11 @@ from odoo.exceptions import ValidationError
 
 from odoo.addons.contract.models.contract import ContractContract
 
+PACK_VALUES = [
+    ("platform_pack", _("Platform Pack")),
+    ("none", _("None")),
+]
+
 _CONTRACT_STATUS_VALUES = [
     ("paused", _("Paused")),
     ("in_progress", _("In progress")),
@@ -77,19 +82,21 @@ def raise_existing_same_open_platform_pack_contract_error(existing_contract):
 
 
 def get_existing_open_pack_contract(
-    env, partner_id, pack_type, contract_id=False, custom_query=[]
+    env, partner_id, pack_type, contract_id=False, custom_query=False
 ):
-    #("community_company_id", "=", community_company_id.id),
+    # ("community_company_id", "=", community_company_id.id),
     query = [
-        ("partner_id", "=", partner_id.id), 
+        ("partner_id", "=", partner_id.id),
         ("pack_type", "=", pack_type),
         ("status", "in", ["paused", "in_progress"]),
     ]
     if contract_id:
         query.append(("id", "!=", contract_id.id))
-    query = custom_query + query
+    if custom_query:
+        query = custom_query + query
     return env["contract.contract"].search(query, limit=1)
 
+
 def get_existing_last_closed_pack_contract(
     env, partner_id, community_company_id, contract_id=False
 ):
diff --git a/energy_communities_service_invoicing/views/account_move_views.xml b/energy_communities_service_invoicing/views/account_move_views.xml
index 8778184dd..6b2f82309 100644
--- a/energy_communities_service_invoicing/views/account_move_views.xml
+++ b/energy_communities_service_invoicing/views/account_move_views.xml
@@ -5,7 +5,7 @@
       <field name="inherit_id" ref="account.view_move_form" />
       <field name="arch" type="xml">
         <xpath expr="//field[@name='partner_id']" position="after">
-          <field name="pack_type" invisible="True" />
+          <field name="pack_type" />
           <field name="is_contract" invisible="True" />
           <field name="invoice_origin" attrs="{'invisible': [('is_contract','=',False)]}" />
           <field name="related_contract_id" attrs="{'invisible': [('is_contract','=',False)]}" />
diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index 6e79bb912..3feaa068a 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -137,6 +137,7 @@
           <group>
             <field name="name" />
             <field name="pack_id" options="{'no_open': True}" />
+            <field name="pack_type" />
             <field name="related_contract_product_ids" widget="one2many" >
               <tree editable="bottom">
                 <field name="name" readonly="1"/>
diff --git a/energy_communities_service_invoicing/views/res_company_views.xml b/energy_communities_service_invoicing/views/res_company_views.xml
index 7c49d6fa3..97e3c0b2c 100644
--- a/energy_communities_service_invoicing/views/res_company_views.xml
+++ b/energy_communities_service_invoicing/views/res_company_views.xml
@@ -19,7 +19,8 @@
         <page string="Services Invoicing">
           <group>
             <field name="id" invisible="1"/>
-            <field name="service_invoicing_journal_id" domain="[('company_id', '=', id)]" />
+            <field name="service_invoicing_sale_journal_id" domain="[('company_id', '=', id)]" />
+            <field name="service_invoicing_purchase_journal_id" domain="[('company_id', '=', id)]" />
             <field name="service_invoicing_sale_team_id" domain="[('company_id', '=', id)]" />
           </group>
         </page>
diff --git a/energy_selfconsumption/models/__init__.py b/energy_selfconsumption/models/__init__.py
index 17238e412..85657e9a7 100644
--- a/energy_selfconsumption/models/__init__.py
+++ b/energy_selfconsumption/models/__init__.py
@@ -1,3 +1,4 @@
+from . import pack_type_mixin
 from . import account_move
 from . import contract
 from . import contract_csv_report
diff --git a/energy_selfconsumption/models/account_move.py b/energy_selfconsumption/models/account_move.py
index 760be4ee4..110e8e4bb 100644
--- a/energy_selfconsumption/models/account_move.py
+++ b/energy_selfconsumption/models/account_move.py
@@ -11,7 +11,8 @@ class AccountMoveLine(models.Model):
 
 
 class AccountMove(models.Model):
-    _inherit = "account.move"
+    _name = "account.move"
+    _inherit = ["account.move", "pack.type.mixin"]
 
     selfconsumption_invoicing_mode = fields.Selection(
         [
diff --git a/energy_selfconsumption/models/contract_template.py b/energy_selfconsumption/models/contract_template.py
index 76734f7a3..e45bdbfd4 100644
--- a/energy_selfconsumption/models/contract_template.py
+++ b/energy_selfconsumption/models/contract_template.py
@@ -1,19 +1,14 @@
 from odoo import _, api, fields, models
 
-PACK_VALUES = [
-    ("selfconsumption_pack", _("Selfconsumption Pack")),
-]
-
 
 class ContractTemplate(models.Model):
-    _inherit = "contract.template"
-
-    pack_type = fields.Selection(selection_add=PACK_VALUES)
+    _name = "contract.template"
+    _inherit = ["contract.template", "pack.type.mixin"]
 
     def custom_compute_pack_type(self):
         super().custom_compute_pack_type()
         if self.pack_type == "none":
-            self._set_custom_pack_type(
-                "selfconsumption.product_category_selfconsumption_pack",
+            self._set_custom_pack_type_on_contract_template(
                 "selfconsumption_pack",
+                "selfconsumption.product_category_selfconsumption_pack",
             )
diff --git a/energy_selfconsumption/models/pack_type_mixin.py b/energy_selfconsumption/models/pack_type_mixin.py
new file mode 100644
index 000000000..30bad5f15
--- /dev/null
+++ b/energy_selfconsumption/models/pack_type_mixin.py
@@ -0,0 +1,11 @@
+from odoo import _, fields, models
+
+PACK_VALUES = [
+    ("selfconsumption_pack", _("Selfconsumption Pack")),
+]
+
+
+class PackTypeMixin(models.AbstractModel):
+    _inherit = "pack.type.mixin"
+
+    pack_type = fields.Selection(selection_add=PACK_VALUES)
-- 
GitLab


From 54eb69d6c31cd73e928cd08fec10237742e85993 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Mon, 10 Mar 2025 15:17:16 +0100
Subject: [PATCH 83/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Metadata=20strategy?=
 =?UTF-8?q?=20on=20sale=20order=20contract=20activation?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../__manifest__.py                           |  1 +
 .../components/contract_utils.py              | 64 ++++++++++++-------
 .../components/sale_order_utils.py            | 58 +++++------------
 .../models/pack_type_mixin.py                 |  1 +
 .../models/sale_order.py                      | 24 +++----
 .../views/sale_order_views.xml                |  3 -
 .../service_invoicing_action_create.py        | 17 +++--
 7 files changed, 81 insertions(+), 87 deletions(-)

diff --git a/energy_communities_service_invoicing/__manifest__.py b/energy_communities_service_invoicing/__manifest__.py
index 1a6ac870a..f7b8a1d59 100644
--- a/energy_communities_service_invoicing/__manifest__.py
+++ b/energy_communities_service_invoicing/__manifest__.py
@@ -15,6 +15,7 @@
         "base",
         "contract",
         "sale",
+        "sale_order_metadata",
         "sales_team",
         "purchase",
         "product",
diff --git a/energy_communities_service_invoicing/components/contract_utils.py b/energy_communities_service_invoicing/components/contract_utils.py
index bd18f5196..181c63508 100644
--- a/energy_communities_service_invoicing/components/contract_utils.py
+++ b/energy_communities_service_invoicing/components/contract_utils.py
@@ -5,6 +5,20 @@ class ContractUtils(Component):
     _inherit = "contract.utils"
 
     def setup_initial_data(self):
+        self._set_configuration_journal_if_defined()
+        self._set_start_date(self.work.record.sale_order_id.commitment_date)
+        if "discount" in self.work.record.sale_order_id.metadata_line_ids.mapped("key"):
+            self._set_discount(
+                self.work.record.sale_order_id.get_metadata_value("discount")
+            )
+        contract_update_dict = {"status": "paused"}
+        for contract_update_data in self.work.record.sale_order_id.metadata_line_ids:
+            if contract_update_data.key not in ["discount"]:
+                value = contract_update_data.value
+                # TODO: Not a very robust condition. Assuming all Many2one fields are defined with _id at the end
+                if "_id" in contract_update_data.key:
+                    value = int(contract_update_data.value)
+                contract_update_dict[contract_update_data.key] = value
         for line in self.work.record.contract_line_ids:
             line.write(
                 {
@@ -15,7 +29,24 @@ class ContractUtils(Component):
                     "quantity": 0,
                 }
             )
-        self.work.record.write({"status": "paused"})
+        self.work.record.write(contract_update_dict)
+
+    def _set_start_date(self, date_start):
+        self.work.record.write({"date_start": date_start})
+        for line in self.work.record.contract_line_ids:
+            line.write({"date_start": date_start})
+            line._compute_state()
+
+    def _set_discount(self, discount):
+        for line in self.work.record.contract_line_ids:
+            line.write({"discount": discount})
+
+    # method to be extended if using component for another pack_type
+    def _set_configuration_journal_if_defined(self):
+        if self.work.record.pack_type == "platform_pack":
+            journal_id = self.work.record.company_id.service_invoicing_sale_journal_id
+            if journal_id:
+                self.work.record.write({"journal_id": journal_id.id})
 
     def _activate_contract_lines(self, execution_date):
         for line in self.work.record.contract_line_ids:
@@ -34,7 +65,7 @@ class ContractUtils(Component):
 
     def set_contract_status_active(self, execution_date):
         self._activate_contract_lines(execution_date)
-        self.set_start_date(execution_date)
+        self._set_start_date(execution_date)
         self.work.record.write({"status": "in_progress"})
 
     def set_contract_status_closed(self, execution_date):
@@ -45,23 +76,6 @@ class ContractUtils(Component):
             line._compute_state()
         self.work.record.set_close_status_type_by_date()
 
-    def set_start_date(self, date_start):
-        self.work.record.write({"date_start": date_start})
-        for line in self.work.record.contract_line_ids:
-            line.write({"date_start": date_start})
-            line._compute_state()
-
-    def set_discount(self, discount):
-        for line in self.work.record.contract_line_ids:
-            line.write({"discount": discount})
-
-    # method to be extended if using component for another pack_type
-    def set_configuration_journal_if_defined(self):
-        if self.work.record.pack_type == "platform_pack":
-            journal_id = self.work.record.company_id.service_invoicing_sale_journal_id
-            if journal_id:
-                self.work.record.write({"journal_id": journal_id.id})
-
     def clean_non_service_lines(self):
         for line in self.work.record.contract_line_ids:
             if not self._is_service_line(line):
@@ -141,7 +155,6 @@ class ContractUtils(Component):
         executed_action_description_list = executed_action_description.split(",")
         return {
             "company_id": self.work.record.partner_id.related_company_id,
-            "community_company_id": self.work.record.community_company_id,
             "pack_id": pack_id
             if "modify_pack" in executed_action_description_list
             else self.work.record.pack_id,
@@ -154,9 +167,14 @@ class ContractUtils(Component):
             "start_date": execution_date,
             "executed_action": executed_action,
             "executed_action_description": executed_action_description,
-            "discount": discount
-            if "modify_discount" in executed_action_description_list
-            else self.work.record.discount,
+            "metadata": {
+                "community_company_id": self.work.record.community_company_id.id
+                if self.work.record.community_company_id
+                else False,
+                "discount": discount
+                if "modify_discount" in executed_action_description_list
+                else self.work.record.discount,
+            },
         }
 
     def _is_service_line(self, contract_line):
diff --git a/energy_communities_service_invoicing/components/sale_order_utils.py b/energy_communities_service_invoicing/components/sale_order_utils.py
index e3e241ddc..460a084b1 100644
--- a/energy_communities_service_invoicing/components/sale_order_utils.py
+++ b/energy_communities_service_invoicing/components/sale_order_utils.py
@@ -5,21 +5,21 @@ from odoo.addons.energy_communities.utils import contract_utils
 class SaleOrderUtils(Component):
     _inherit = "sale.order.utils"
 
-    def create_service_invoicing_sale_order(
+    def _create_service_invoicing_sale_order(
         self,
         company_id,
-        community_company_id,
         pack_id,
         pricelist_id,
         payment_mode_id,
         start_date,
         executed_action,
         executed_action_description,
+        metadata,
     ):
         so_creation_dict = {
             "partner_id": company_id.partner_id.id,
-            # "company_id": company_id.id,
-            "community_company_id": community_company_id.id,
+            "company_id": self.env.company.id,
+            "commitment_date": start_date,
             "pricelist_id": pricelist_id.id,
             "service_invoicing_action": executed_action,
             "service_invoicing_action_description": executed_action_description,
@@ -42,70 +42,46 @@ class SaleOrderUtils(Component):
             so_creation_dict[
                 "team_id"
             ] = self.env.company.service_invoicing_sale_team_id.id
+        if metadata:
+            metadata_list = []
+            for meta_key in metadata.keys():
+                metadata_list.append(
+                    (0, 0, {"key": meta_key, "value": metadata[meta_key]})
+                )
+            so_creation_dict["metadata_line_ids"] = metadata_list
         sale_order = self.env["sale.order"].create(so_creation_dict)
         # Trigger name computattion in oder to include product's description_sale
         for order_line in sale_order.order_line:
             order_line._compute_name()
         return sale_order
 
-    def _create_service_invoicing(
-        self,
-        company_id,
-        community_company_id,
-        pack_id,
-        pricelist_id,
-        payment_mode_id,
-        start_date,
-        discount,
-        executed_action,
-        executed_action_description="none",
-    ):
-        so = self.create_service_invoicing_sale_order(
-            company_id,
-            community_company_id,
-            pack_id,
-            pricelist_id,
-            payment_mode_id,
-            start_date,
-            executed_action,
-            executed_action_description,
-        )
-        so.action_confirm()
-        service_invoicing_id = self._get_related_contracts(so)
-        # TODO: We must call contract_utils with a better component and workcontext modification approach
-        with contract_utils(self.env, service_invoicing_id) as component:
-            component.clean_non_service_lines()
-            component.set_start_date(start_date)
-            component.set_discount(discount)
-            component.set_configuration_journal_if_defined()
-        return service_invoicing_id
-
     def create_service_invoicing_initial(
         self,
         company_id,
-        community_company_id,
         pack_id,
         pricelist_id,
         start_date,
-        discount,
         executed_action,
         executed_action_description="none",
         payment_mode_id=False,
+        metadata=False,
     ):
-        service_invoicing_id = self._create_service_invoicing(
+        so = self._create_service_invoicing_sale_order(
             company_id,
-            community_company_id,
             pack_id,
             pricelist_id,
             payment_mode_id,
             start_date,
-            discount,
             executed_action,
             executed_action_description,
+            metadata,
         )
+        so.action_confirm()
+        service_invoicing_id = self._get_related_contracts(so)
         # TODO: We must call contract_utils with a better component and workcontext modification approach
         with contract_utils(self.env, service_invoicing_id) as component:
             component.setup_initial_data()
+            component.clean_non_service_lines()
             if service_invoicing_id.is_free_pack:
                 component.set_contract_status_active(start_date)
         return service_invoicing_id
diff --git a/energy_communities_service_invoicing/models/pack_type_mixin.py b/energy_communities_service_invoicing/models/pack_type_mixin.py
index 7d3ce9e2a..786ec9561 100644
--- a/energy_communities_service_invoicing/models/pack_type_mixin.py
+++ b/energy_communities_service_invoicing/models/pack_type_mixin.py
@@ -13,6 +13,7 @@ class PackTypeMixin(models.AbstractModel):
         compute_sudo=True,
         string="Pack Type",
         store=True,
+        default="none",
     )
 
     def _get_pack_type_from_product_category(self, pack_type, category_id):
diff --git a/energy_communities_service_invoicing/models/sale_order.py b/energy_communities_service_invoicing/models/sale_order.py
index ad4b23c5a..67447ae36 100644
--- a/energy_communities_service_invoicing/models/sale_order.py
+++ b/energy_communities_service_invoicing/models/sale_order.py
@@ -7,12 +7,6 @@ class SaleOrder(models.Model):
     _name = "sale.order"
     _inherit = "sale.order"
 
-    community_company_id = fields.Many2one(
-        "res.company",
-        string="Related community",
-        domain="[('hierarchy_level','=','community')]",
-    )
-
     service_invoicing_action = fields.Selection(
         selection=_SALE_ORDER_SERVICE_INVOICING_ACTION_VALUES,
         required=True,
@@ -26,16 +20,14 @@ class SaleOrder(models.Model):
 
     def action_create_contract(self):
         contracts = super().action_create_contract()
-        if self.community_company_id:
-            for contract in contracts:
-                contract.write(
-                    {
-                        "community_company_id": self.community_company_id.id,
-                        "pricelist_id": self.pricelist_id.id,
-                        "payment_mode_id": self.payment_mode_id.id,
-                        "sale_order_id": self.id,
-                    }
-                )
+        for contract in contracts:
+            contract.write(
+                {
+                    "pricelist_id": self.pricelist_id.id,
+                    "payment_mode_id": self.payment_mode_id.id,
+                    "sale_order_id": self.id,
+                }
+            )
         return contracts
 
     def action_show_contracts(self):
diff --git a/energy_communities_service_invoicing/views/sale_order_views.xml b/energy_communities_service_invoicing/views/sale_order_views.xml
index 72c636d92..632add91b 100644
--- a/energy_communities_service_invoicing/views/sale_order_views.xml
+++ b/energy_communities_service_invoicing/views/sale_order_views.xml
@@ -11,9 +11,6 @@
             attrs="{'readonly': 1,'invisible': [('service_invoicing_action','not in', ['modification','activate'])]}"
           />
         </xpath>
-        <xpath expr="//field[@name='partner_id']" position="after">
-          <field name="community_company_id" />
-        </xpath>
         <xpath expr="//field[@name='company_id']" position="attributes">
           <attribute name="required">0</attribute>
         </xpath>
diff --git a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
index fd06a8e04..d0c803047 100644
--- a/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
+++ b/energy_communities_service_invoicing/wizards/service_invoicing_action_create.py
@@ -57,7 +57,9 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
         store=False,
     )
     platform_pack_product_categ_id = fields.Many2one(
-        "product.category", compute="_compute_platform_pack_product_categ_id", store=False
+        "product.category",
+        compute="_compute_platform_pack_product_categ_id",
+        store=False,
     )
 
     def _compute_platform_pack_product_categ_id(self):
@@ -126,16 +128,19 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
         # If none of previous create a new contract
         else:
             with sale_order_utils(self.env) as component:
+                # TODO: pass community_company_id as metadata
                 service_invoicing_id = component.create_service_invoicing_initial(
                     company_id,
-                    community_company_id,
                     self.platform_pack_id,
                     self.pricelist_id,
                     self.execution_date,
-                    self.discount,
                     "activate",
                     "active_platform_service_invocing",
                     payment_mode_id,
+                    {
+                        "community_company_id": community_company_id.id,
+                        "discount": self.discount,
+                    },
                 )
         return service_invoicing_id
 
@@ -182,7 +187,11 @@ class ServiceInvoicingActionCreateWizard(models.TransientModel):
         # Check if already open one and raise error
         for record in impacted_records:
             existing_contract = get_existing_open_pack_contract(
-                self.env, record.parent_id.partner_id, "platform_pack", contract_id=False, custom_query=[("community_company_id", "=", record.id)]
+                self.env,
+                record.parent_id.partner_id,
+                "platform_pack",
+                contract_id=False,
+                custom_query=[("community_company_id", "=", record.id)],
             )
 
             if existing_contract:
-- 
GitLab


From 43bb984bbadc9ac4a32ada1dd4fd73efa9fbae3a Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Tue, 11 Mar 2025 10:17:11 +0100
Subject: [PATCH 84/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Hide=20service=20invo?=
 =?UTF-8?q?icing=20from=20selfconsumption=20contract=20views=20momentary?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../views/contract_views.xml                  | 24 +++++++++----------
 .../models/selfconsumption.py                 |  5 +++-
 2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/energy_communities_service_invoicing/views/contract_views.xml b/energy_communities_service_invoicing/views/contract_views.xml
index 3feaa068a..fc0b5473d 100644
--- a/energy_communities_service_invoicing/views/contract_views.xml
+++ b/energy_communities_service_invoicing/views/contract_views.xml
@@ -67,33 +67,33 @@
           name="action_activate_contract"
           type="object"
           string="Activate"
-          attrs="{'invisible':[('status','not in',['paused'])]}"
+          attrs="{'invisible':['|',('status','not in',['paused']),('pack_type','!=','platform_pack')]}"
         />
         <button
           name="action_modify_contract"
           type="object"
           string="Modify"
-          attrs="{'invisible':[('status','not in',['paused','in_progress'])]}"
+          attrs="{'invisible':['|',('status','not in',['paused','in_progress']),('pack_type','!=','platform_pack')]}"
         />
         <button
           name="action_close_contract"
           type="object"
           string="Close"
-          attrs="{'invisible':[('status','not in',['paused','in_progress'])]}"
+          attrs="{'invisible':['|',('status','not in',['paused','in_progress']),('pack_type','!=','platform_pack')]}"
         />
         <button
           name="action_reopen_contract"
           type="object"
           string="Reopen"
-          attrs="{'invisible':['|',('status','not in',['closed','closed_planned']),('successor_contract_id','!=',False)]}"
+          attrs="{'invisible':['|','|',('status','not in',['closed','closed_planned']),('successor_contract_id','!=',False),('pack_type','!=','platform_pack')]}"
         />
       </xpath>
       <xpath expr="//field[@name='partner_id']" position="after">
-        <field name="community_company_id" />
+        <field name="community_company_id" attrs="{'invisible': [('pack_type','!=','platform_pack')]}"/>
       </xpath>
       <xpath expr="//field[@name='pricelist_id']" position="after">
-        <field name="pack_id" />
-        <field name="pack_type" />
+        <field name="pack_id" attrs="{'invisible': [('pack_type','!=','platform_pack')]}" />
+        <field name="pack_type" attrs="{'invisible': [('pack_type','!=','platform_pack')]}" />
       </xpath>
       <xpath expr="//field[@name='user_id']" position="after">
         <field name="date_start" />
@@ -101,11 +101,11 @@
         <field name="recurring_next_date" />
         <field name="date_end" />
         <field name="discount" />
-        <field name="predecessor_contract_id" />
-        <field name="successor_contract_id" />
-        <field name="closing_action" attrs="{'invisible':[('status','not in',['closed','closed_planned'])]}" />
-        <field name="closing_action_description" attrs="{'invisible':[('status','not in',['closed','closed_planned'])]}" />
-        <field name="sale_order_id" />
+        <field name="predecessor_contract_id" attrs="{'invisible': [('pack_type','!=','platform_pack')]}" />
+        <field name="successor_contract_id" attrs="{'invisible': [('pack_type','!=','platform_pack')]}" />
+        <field name="closing_action" attrs="{'invisible':['|',('status','not in',['closed','closed_planned']),('pack_type','!=','platform_pack')]}" />
+        <field name="closing_action_description" attrs="{'invisible':['|',('status','not in',['closed','closed_planned']),('pack_type','!=','platform_pack')]}" />
+        <field name="sale_order_id" attrs="{'invisible': [('pack_type','!=','platform_pack')]}" />
       </xpath>
     </field>
   </record>
diff --git a/energy_selfconsumption/models/selfconsumption.py b/energy_selfconsumption/models/selfconsumption.py
index 4c5a243b0..18db4ee90 100644
--- a/energy_selfconsumption/models/selfconsumption.py
+++ b/energy_selfconsumption/models/selfconsumption.py
@@ -211,7 +211,10 @@ class Selfconsumption(models.Model):
             "name": "Contracts",
             "views": [
                 [self.env.ref("energy_selfconsumption.contract_tree_view").id, "tree"],
-                [False, "form"],
+                [
+                    self.env.ref("contract.contract_contract_customer_form_view").id,
+                    "form",
+                ],
             ],
             "res_model": "contract.contract",
             "domain": [("project_id", "=", self.id)],
-- 
GitLab


From 1b8ca8cce85886ea0bac1548e4c4d272833ed0b7 Mon Sep 17 00:00:00 2001
From: daniquilez <dani.quilez@gmail.com>
Date: Tue, 11 Mar 2025 10:22:59 +0100
Subject: [PATCH 85/85] =?UTF-8?q?[IMP]=20=E2=9C=A8=20Priorize=20contract?=
 =?UTF-8?q?=20form=20views.=20First=20regular=20one.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../views/service_invoicing_views.xml                           | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/energy_communities_service_invoicing/views/service_invoicing_views.xml b/energy_communities_service_invoicing/views/service_invoicing_views.xml
index d965cf606..4629ec8c5 100644
--- a/energy_communities_service_invoicing/views/service_invoicing_views.xml
+++ b/energy_communities_service_invoicing/views/service_invoicing_views.xml
@@ -115,7 +115,7 @@
     id="action_view_contract_contract_customer_form_coord_admin"
     model="ir.actions.act_window.view"
   >
-    <field name="sequence" eval="2"/>
+    <field name="sequence" eval="1"/>
     <field name="view_mode">form</field>
     <field name="view_id" ref="view_contract_contract_customer_form_coord_admin"/>
     <field name="act_window_id" ref="view_service_invoicing_window_coord_admin"/>
-- 
GitLab