From 814147fedcd4363826c5d89d33305d2064037421 Mon Sep 17 00:00:00 2001
From: Daniil Digtyar Vasilieva <daniildigtyar@gmail.com>
Date: Fri, 7 Jul 2023 12:28:18 +0200
Subject: [PATCH] [IMP] energy_selfconsumption: new partner_id field in supply
 point

---
 energy_selfconsumption/models/supply_point.py                | 5 ++++-
 energy_selfconsumption/views/supply_point_views.xml          | 2 ++
 .../wizards/selfconsumption_import_wizard.py                 | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/energy_selfconsumption/models/supply_point.py b/energy_selfconsumption/models/supply_point.py
index 67b494886..82bf7a41a 100644
--- a/energy_selfconsumption/models/supply_point.py
+++ b/energy_selfconsumption/models/supply_point.py
@@ -8,7 +8,10 @@ class SupplyPoint(models.Model):
 
     name = fields.Char(required=True)
     code = fields.Char(string="CUPS", required=True)
-    owner_id = fields.Many2one("res.partner", string="Owner", required=True)
+    owner_id = fields.Many2one("res.partner", string="Owner", required=True,
+                               help="Partner with the legal obligation of the supply point")
+    partner_id = fields.Many2one("res.partner", string="Partner", required=True,
+                                 help="Partner subscribed to the self-consumption project")
     company_id = fields.Many2one(
         "res.company", default=lambda self: self.env.company, readonly=True
     )
diff --git a/energy_selfconsumption/views/supply_point_views.xml b/energy_selfconsumption/views/supply_point_views.xml
index b784773e2..53c40316a 100644
--- a/energy_selfconsumption/views/supply_point_views.xml
+++ b/energy_selfconsumption/views/supply_point_views.xml
@@ -17,6 +17,7 @@
                         <group>
                             <group>
                                 <field name="code"/>
+                                <field name="partner_id"/>
                                 <field name="owner_id"/>
                             </group>
                             <group>
@@ -65,6 +66,7 @@
                 <tree string="Supply Points">
                     <field name="name"/>
                     <field name="code"/>
+                    <field name="partner_id"/>
                     <field name="owner_id"/>
                 </tree>
             </field>
diff --git a/energy_selfconsumption/wizards/selfconsumption_import_wizard.py b/energy_selfconsumption/wizards/selfconsumption_import_wizard.py
index 12b22710c..d3090df5e 100644
--- a/energy_selfconsumption/wizards/selfconsumption_import_wizard.py
+++ b/energy_selfconsumption/wizards/selfconsumption_import_wizard.py
@@ -107,5 +107,5 @@ class SelfconsumptionImportWizard(models.TransientModel):
             'zip': zip,
             'country_id': country.id,
             'owner_id': owner.id,
-            'cooperator_id': owner.id  # TODO move it to other module
+            'partner_id': partner.id
         })
-- 
GitLab