From 151a34533d393b689e499ce14406d783a25addb1 Mon Sep 17 00:00:00 2001
From: Benjami <benjami94@gmail.com>
Date: Wed, 23 Aug 2023 07:38:09 +0200
Subject: [PATCH] =?UTF-8?q?Added=20new=20fields=20in=20create=20company=20?=
 =?UTF-8?q?wiz=20=F0=9F=93=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../wizards/multicompany_easy_creation.py     | 54 +++++++++++++++++--
 .../wizards/multicompany_easy_creation.xml    | 17 +++---
 2 files changed, 60 insertions(+), 11 deletions(-)

diff --git a/energy_communities/wizards/multicompany_easy_creation.py b/energy_communities/wizards/multicompany_easy_creation.py
index 355a168e4..2b4b04b03 100644
--- a/energy_communities/wizards/multicompany_easy_creation.py
+++ b/energy_communities/wizards/multicompany_easy_creation.py
@@ -23,12 +23,8 @@ class AccountMulticompanyEasyCreationWiz(models.TransientModel):
     )
     crm_lead_id = fields.Many2one("crm.lead", string="CRM Lead")
     property_cooperator_account = fields.Many2one(
-        comodel_name="account.account",
+        comodel_name="account.account.template",
         string="Cooperator Account",
-        domain=[
-            ("internal_type", "=", "receivable"),
-            ("deprecated", "=", False),
-        ],
         help="This account will be"
         " the default one as the"
         " receivable account for the"
@@ -53,6 +49,54 @@ class AccountMulticompanyEasyCreationWiz(models.TransientModel):
         readonly=True,
     )
 
+    default_lang_id = fields.Many2one(
+        comodel_name="res.lang",
+        string="Language",
+    )
+
+    street = fields.Char(
+        string="Address",
+    )
+
+    city = fields.Char(
+        string="City",
+    )
+
+    zip_code = fields.Char(
+        string="ZIP code",
+    )
+
+    foundation_date = fields.Date(
+        string="Foundation date"
+    )
+
+    vat = fields.Char(
+        string="ZIP code",
+    )
+
+    email = fields.Char(
+        string="Email",
+    )
+
+    phone = fields.Char(
+        string="Phone",
+    )
+
+    def add_company_managers(self):
+        coord_members = self.parent_id.get_users(["role_coord_admin", "role_coord_worker"])
+        for manager in coord_members:
+            manager.make_ce_user(self.new_company_id, "role_ce_manager")
+
+    def add_company_log(self):
+        message = _("Community created from: <a href='/web#id={id}&view_type=form&model=crm.lead&menu_id={menu_id}'>{name}</a>")
+        self.new_company_id.message_post(
+            body=message.format(
+                id=self.crm_lead_id.id,
+                menu_id=self.env.ref("crm.crm_menu_root").id,
+                name=self.crm_lead_id.name,
+            )
+        )
+
     def update_product_category_company_share(self):
         new_company_id = self.new_company_id.id
         self_new_company = self.with_company(new_company_id)
diff --git a/energy_communities/wizards/multicompany_easy_creation.xml b/energy_communities/wizards/multicompany_easy_creation.xml
index 4b15a9064..e1240c424 100644
--- a/energy_communities/wizards/multicompany_easy_creation.xml
+++ b/energy_communities/wizards/multicompany_easy_creation.xml
@@ -23,12 +23,17 @@
                     </page>
                 </xpath>
                 <xpath expr="//page" position="before">
-                    <page string="Energy Communities">
-                        <group string="Energy Communities">
-                            <field name="parent_id" />
-                        </group>
-                        <group string="Create from CRM Lead">
-                            <field name="crm_lead_id" />
+                    <page string="Energy Community">
+                        <group string="Energy Community">
+                            <field name="parent_id"></field>
+                            <field name="default_lang_id"></field>
+                            <field name="street"></field>
+                            <field name="city"></field>
+                            <field name="zip_code"></field>
+                            <field name="foundation_date"></field>
+                            <field name="vat"></field>
+                            <field name="email"></field>
+                            <field name="phone"></field>
                         </group>
                     </page>
                 </xpath>
-- 
GitLab