From c4951e7b2379b25f0c568e9b7a215a455613fa7c Mon Sep 17 00:00:00 2001
From: benjamin <benjamin@le-filament.com>
Date: Thu, 9 Nov 2023 19:51:48 +0100
Subject: [PATCH] [REM] remove mail and PDF report

---
 __manifest__.py                               |   3 -
 report/report_scop_instance_adhesion.xml      | 330 ------------------
 views/scop_instance.xml                       |  18 -
 wizard/__init__.py                            |   2 -
 .../scop_instance_mail_membership_wizard.py   |  46 ---
 .../scop_instance_mail_membership_wizard.xml  |  40 ---
 wizard/scop_instance_report_per_ur_wizard.py  |  12 -
 wizard/scop_instance_report_per_ur_wizard.xml |  27 --
 8 files changed, 478 deletions(-)
 delete mode 100644 report/report_scop_instance_adhesion.xml
 delete mode 100644 wizard/scop_instance_mail_membership_wizard.py
 delete mode 100644 wizard/scop_instance_mail_membership_wizard.xml
 delete mode 100644 wizard/scop_instance_report_per_ur_wizard.py
 delete mode 100644 wizard/scop_instance_report_per_ur_wizard.xml

diff --git a/__manifest__.py b/__manifest__.py
index 2f2808d..4bf2ac8 100644
--- a/__manifest__.py
+++ b/__manifest__.py
@@ -18,10 +18,7 @@
         "views/res_partner.xml",
         "views/scop_instance.xml",
         # report
-        "report/report_scop_instance_adhesion.xml",
         # wizard
-        "wizard/scop_instance_mail_membership_wizard.xml",
-        "wizard/scop_instance_report_per_ur_wizard.xml",
         "wizard/scop_instance_wizard.xml",
     ],
 }
diff --git a/report/report_scop_instance_adhesion.xml b/report/report_scop_instance_adhesion.xml
deleted file mode 100644
index 11087a5..0000000
--- a/report/report_scop_instance_adhesion.xml
+++ /dev/null
@@ -1,330 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<!-- Copyright 2022 Le Filament
-     License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
-<odoo>
-    <data>
-
-        <template id="report_instance_adhesion_document">
-            <t t-call="web.external_layout">
-                <t t-set="o" t-value="o.with_context(lang='fr')" />
-                <t t-set="datas" t-value="o.get_report_datas()" />
-                <t t-set="partners" t-value="datas.get('partner_ids')" />
-                <t t-set="ur_ids" t-value="datas.get('ur_ids')" />
-
-                <div class="page">
-                    <div class="instance-layout">
-                        <!-- Title -->
-                        <div class="row">
-                            <div class="col-12 text-center mb64">
-                                <h2>
-                                    Bureau de la Direction Nationale - <span
-                                        t-field="o.date"
-                                        t-options="{'widget': 'date', 'format': 'dd/MM/YYYY'}"
-                                    />
-                                </h2>
-                                <h3>
-                                    Proposition d'adhésions définitives
-                                </h3>
-                                <hr />
-                            </div>
-                        </div>
-                        <!-- Global -->
-                        <div class="row">
-                            <div class="col-12">
-                                <h3 class="mb32">
-                                    Global par Union Régionale
-                                </h3>
-                                <t t-esc="datas" />
-                                <t t-esc="ur_ids" />
-                                <t t-esc="partners" />
-                                <div
-                                    class="row"
-                                    style="font-weight: 700; font-size: 16px;"
-                                >
-                                    <div class="col-4">Union Régionale</div>
-                                    <div class="col-3 text-center">Coopératives</div>
-                                    <div class="col-3 text-center">Salariés</div>
-                                    <div class="col-2 text-center">Associés</div>
-                                </div>
-                                <hr />
-                                <t t-set="total_staff_count" t-value="0" />
-                                <t t-set="total_shareholder_count" t-value="0" />
-                                <t t-foreach="ur_ids" t-as="ur">
-                                    <div style="page-break-inside: avoid;">
-                                        <div
-                                            class="row bgg"
-                                            style="font-weight: 700; font-size: 16px;"
-                                        >
-                                            <div class="col-4"><t
-                                                    t-esc="ur.name"
-                                                /></div>
-                                            <div class="col-3 text-center"><t
-                                                    t-esc="len(partners.filtered(lambda p: p.ur_id.id == ur.id))"
-                                                /></div>
-                                                <div class="col-3 text-center">
-                                                    <t
-                                                    t-set="total_staff_ur"
-                                                    t-value="sum(partners.filtered(lambda p: p.ur_id.id == ur.id).mapped(lambda p: p.get_last_membership_staff().staff_count if p.get_last_membership_staff() else 0))"
-                                                />
-                                                    <t t-esc="total_staff_ur" />
-                                                    <t
-                                                    t-set="total_staff_count + total_staff_ur"
-                                                    t-value="total_staff_ur"
-                                                />
-                                                </div>
-                                                <div class="col-2 text-center">
-                                                    <t
-                                                    t-set="total_staff_shareholder_ur"
-                                                    t-value="sum(partners.filtered(lambda p: p.ur_id.id == ur.id).mapped(lambda p: p.get_last_membership_staff().staff_shareholder_count if p.get_last_membership_staff() else 0))"
-                                                />
-                                                    <t
-                                                    t-esc="total_staff_shareholder_ur"
-                                                />
-                                                    <t
-                                                    t-set="total_staff_shareholder_count + total_staff_ur"
-                                                    t-value="total_staff_ur"
-                                                />
-                                                </div>
-                                        </div>
-                                        <t
-                                            t-set="type_coop"
-                                            t-value="partners.filtered(lambda p: p.ur_id.id == ur.id).mapped('cooperative_form_id')"
-                                        />
-                                        <t t-foreach="type_coop" t-as="type_id">
-                                            <div class="row" style="font-size: 14px;">
-                                                <div class="col-4 text-right"><t
-                                                        t-esc="type_id.name"
-                                                    /></div>
-                                                <div class="col-3 text-center"><t
-                                                        t-esc="len(partners.filtered(lambda p: p.ur_id.id == ur.id and p.cooperative_form_id.id == type_id.id))"
-                                                    /></div>
-                                                <div class="col-3 text-center"><t
-                                                        t-esc="sum(partners.filtered(lambda p: p.ur_id.id == ur.id and p.cooperative_form_id.id == type_id.id).mapped(lambda p: p.get_last_membership_staff().staff_count if p.get_last_membership_staff() else 0))"
-                                                    /></div>
-                                                <div class="col-2 text-center"><t
-                                                        t-esc="sum(partners.filtered(lambda p: p.ur_id.id == ur.id and p.cooperative_form_id.id == type_id.id).mapped(lambda p: p.get_last_membership_staff().staff_shareholder_count if p.get_last_membership_staff() else 0))"
-                                                    /></div>
-                                            </div>
-                                        </t>
-                                        <hr />
-                                    </div>
-                                </t>
-                                <div
-                                    class="row"
-                                    style="font-weight: 700; font-size: 16px;"
-                                >
-                                    <div class="col-4">TOTAL GÉNÉRAL</div>
-                                    <div class="col-3 text-center"><t
-                                            t-esc="len(partners)"
-                                        /></div>
-                                    <div class="col-3 text-center"><t
-                                            t-esc="total_staff_count"
-                                        /></div>
-                                    <div class="col-2 text-center"><t
-                                            t-esc="total_staff_shareholder_count"
-                                        /></div>
-                                </div>
-                            </div>
-                        </div>
-                        <p style="page-break-before:always;"> </p>
-                        <!-- Detail by UR -->
-                        <div>
-                            <t t-foreach="ur_ids" t-as="ur">
-                                <t
-                                    t-set="partner_ids"
-                                    t-value="partners.filtered(lambda p: p.ur_id.id == ur.id).sorted('cooperative_form_id')"
-                                />
-
-                                <div class="row">
-                                        <div class="col-12 mb32">
-                                            <h3>
-                                                UR : <span t-esc="ur.name" />
-                                            </h3>
-                                            <hr />
-                                        </div>
-                                    <hr />
-                                    </div>
-                                    <div class="row">
-                                        <div class="col-12">
-                                            <table class="table">
-                                                <thead>
-                                                    <tr>
-                                                        <th scope="col">Type</th>
-                                                        <th
-                                                        scope="col"
-                                                    >Raison sociale</th>
-                                                        <th scope="col">CP</th>
-                                                        <th scope="col">Ville</th>
-                                                        <th
-                                                        scope="col"
-                                                    >Effectif total</th>
-                                                        <th
-                                                        scope="col"
-                                                    >Salariés associés</th>
-                                                        <th scope="col">Capital</th>
-                                                        <th scope="col">CA</th>
-                                                        <th scope="col">VA</th>
-                                                        <th
-                                                        scope="col"
-                                                    >Origine de création</th>
-                                                        <th scope="col">NAF</th>
-                                                        <th
-                                                        scope="col"
-                                                    >Objet social</th>
-                                                        <th
-                                                        scope="col"
-                                                    >Adhésion Fédération</th>
-                                                        <th
-                                                        scope="col"
-                                                    >Forme juridique</th>
-                                                    </tr>
-                                                </thead>
-                                                <tbody>
-                                                    <t
-                                                    t-set="staff_count"
-                                                    t-value="0"
-                                                />
-                                                    <t
-                                                    t-set="staff_shareholder_count"
-                                                    t-value="0"
-                                                />
-                                                    <t
-                                                    t-foreach="partner_ids"
-                                                    t-as="partner"
-                                                >
-                                                        <t
-                                                        t-set="staff_id"
-                                                        t-value="partner.get_last_membership_staff()"
-                                                    />
-                                                        <tr>
-                                                            <td><t
-                                                                t-esc="partner.cooperative_form_id.name"
-                                                            /></td>
-                                                            <td><t
-                                                                t-esc="partner.name"
-                                                            /></td>
-                                                            <td><t
-                                                                t-esc="partner.zip"
-                                                            /></td>
-                                                            <td><t
-                                                                t-esc="partner.city"
-                                                            /></td>
-                                                            <td><t
-                                                                t-esc="staff_id.staff_count if staff_id else 0"
-                                                            />
-                                                                <t
-                                                                t-set="staff_count"
-                                                                t-value="staff_shareholder_count + (staff_id.staff_count if staff_id else 0)"
-                                                            />
-                                                            </td>
-                                                            <td><t
-                                                                t-esc="staff_id.staff_shareholder_count if staff_id else 0"
-                                                            />
-                                                                <t
-                                                                t-set="staff_shareholder_count"
-                                                                t-value="staff_shareholder_count + (staff_id.staff_shareholder_count if staff_id else 0)"
-                                                            />
-                                                            </td>
-                                                            <td><t
-                                                                t-esc="partner.capital"
-                                                                t-options="{'widget': 'float', 'precision': 0}"
-                                                            /> €</td>
-                                                            <td><t
-                                                                t-esc="partner.liasse_membership_id.revenue_cg"
-                                                                t-options="{'widget': 'float', 'precision': 0}"
-                                                            /> €</td>
-                                                            <td><t
-                                                                t-esc="partner.liasse_membership_id.av_cg"
-                                                                t-options="{'widget': 'float', 'precision': 0}"
-                                                            /> €</td>
-                                                            <td><t
-                                                                t-esc="partner.creation_origin_id.name"
-                                                            /></td>
-                                                            <td><t
-                                                                t-esc="partner.naf_id.name"
-                                                            /></td>
-                                                            <td><t
-                                                                t-esc="partner.social_object"
-                                                            /></td>
-                                                            <td><t
-                                                                t-esc="partner.project_federation.name"
-                                                            /></td>
-                                                            <td><t
-                                                                t-esc="partner.partner_company_type_id.name"
-                                                            /></td>
-                                                        </tr>
-                                                    </t>
-                                                </tbody>
-                                                <tfoot>
-                                                    <tr>
-                                                        <td>TOTAL</td>
-                                                        <td />
-                                                        <td colspan="2">
-                                                            <t
-                                                            t-esc="len(partner_ids)"
-                                                        /> coop(s)</td>
-                                                        <td><t
-                                                            t-esc="staff_count"
-                                                        /></td>
-                                                        <td><t
-                                                            t-esc="staff_shareholder_count"
-                                                        /></td>
-                                                        <td colspan="8" />
-                                                    </tr>
-                                                </tfoot>
-                                            </table>
-
-                                        </div>  <!-- col-12 -->
-                                    </div>  <!-- row -->
-                                    <p style="page-break-before:always;"> </p>
-                            </t>
-                        </div>
-                    </div> <!-- Instance Layout -->
-                </div> <!-- Page -->
-            </t> <!-- External Layout -->
-        </template>
-
-        <template id="report_instance_adhesion">
-            <t t-call="web.html_container">
-                <t t-set="docs" t-value="docs.with_context(lang='fr')" />
-                <t t-set="company" t-value="docs.env.user.company_id" />
-                <t t-foreach="docs" t-as="o">
-                    <t
-                        t-call="cgscop_adhesion_instance.report_instance_adhesion_document"
-                        t-lang="fr"
-                    />
-                </t>
-            </t>
-        </template>
-
-        <!-- Paper format -->
-        <record id="paperformat_a4_landscape" model="report.paperformat">
-            <field name="name">A4 Paysage Scop Instance</field>
-            <field name="default" eval="True" />
-            <field name="format">A4</field>
-            <field name="orientation">Landscape</field>
-            <field name="margin_top">35</field>
-            <field name="margin_bottom">20</field>
-            <field name="margin_left">10</field>
-            <field name="margin_right">10</field>
-            <field name="header_line" eval="False" />
-            <field name="header_spacing">30</field>
-            <field name="dpi">90</field>
-        </record>
-
-        <!-- QWeb Reports -->
-        <record id="cgscop_instance_adhesion_report" model="ir.actions.report">
-            <field name="name">CG Scop - États préparatoires</field>
-            <field name="model">scop.instance</field>
-            <field name="report_type">qweb-pdf</field>
-            <field
-                name="report_name"
-            >cgscop_adhesion_instance.report_instance_adhesion</field>
-            <field
-                name="report_file"
-            >cgscop_adhesion_instance.report_instance_adhesion</field>
-            <field name="paperformat_id" ref="paperformat_a4_landscape" />
-        </record>
-
-    </data>
-</odoo>
diff --git a/views/scop_instance.xml b/views/scop_instance.xml
index 74bb36d..0bd0c4f 100644
--- a/views/scop_instance.xml
+++ b/views/scop_instance.xml
@@ -27,12 +27,6 @@
                                 string="Associer des coopératives"
                                 class="btn-primary"
                             />
-                            <button
-                                name="create_report_instance_adhesion"
-                                type="object"
-                                string="États préparatoires"
-                                class="btn-info"
-                            />
                             <button
                                 name="scop_valid_cg_mass"
                                 type="object"
@@ -45,18 +39,6 @@
                                 string="Générer tous les courriers"
                                 class="btn-info"
                             />
-                            <button
-                                name="create_report_adhesion_per_ur"
-                                type="object"
-                                string="Générer les courriers par UR"
-                                class="btn-info"
-                            />
-                            <button
-                                name="action_send_mail_adhesion"
-                                type="object"
-                                string="Envoyer les mails d'adhésion"
-                                class="btn-info"
-                            />
                         </header>
                         <div class="oe_button_box mt-3" name="button_box">
                             <button
diff --git a/wizard/__init__.py b/wizard/__init__.py
index 2422f77..3744668 100644
--- a/wizard/__init__.py
+++ b/wizard/__init__.py
@@ -1,6 +1,4 @@
 # © 2022 Le Filament (<http://www.le-filament.com>)
 # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
 
-from . import scop_instance_mail_membership_wizard
-from . import scop_instance_report_per_ur_wizard
 from . import scop_instance_wizard
diff --git a/wizard/scop_instance_mail_membership_wizard.py b/wizard/scop_instance_mail_membership_wizard.py
deleted file mode 100644
index 9d5b27f..0000000
--- a/wizard/scop_instance_mail_membership_wizard.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# © 2022 Le Filament (<http://www.le-filament.com>)
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-from odoo import _, api, fields, models
-from odoo.exceptions import UserError
-
-
-class ScopInstanceMailWizard(models.TransientModel):
-    _name = "scop.instance.mail.wizard"
-    _description = "Wizard: Mail d'adhésion"
-
-    @api.model
-    def _get_partner_ids_domain(self):
-        """
-        Compute domain : coops from instance in active_id
-        """
-        res = [("id", "in", 0)]  # Nothing accepted by domain, by default
-        if self.env.context.get("active_model") == "scop.instance":
-            instance_id = self.env["scop.instance"].browse(
-                self.env.context.get("active_id")
-            )
-            partner_ids = instance_id._get_partners().filtered(
-                lambda i: i.membership_status == "member"
-            )
-            if partner_ids:
-                res = [("id", "in", partner_ids.ids)]
-        return res
-
-    partner_ids = fields.Many2many(
-        comodel_name="res.partner",
-        string="Coopératives",
-        domain=lambda self: self._get_partner_ids_domain(),
-    )
-
-    def send_mail(self):
-        """
-        Call function to send mail in mass from scop_instance
-        """
-        if self.env.context.get("active_model") == "scop.instance":
-            return (
-                self.env["scop.instance"]
-                .browse(self.env.context.get("active_id"))
-                .send_mass_mail_adhesion(self.partner_ids)
-            )
-        else:
-            raise UserError(_("Impossible d'envoyer le mail"))
diff --git a/wizard/scop_instance_mail_membership_wizard.xml b/wizard/scop_instance_mail_membership_wizard.xml
deleted file mode 100644
index a73e03f..0000000
--- a/wizard/scop_instance_mail_membership_wizard.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" ?>
-<!-- Copyright 2022 Le Filament
-     License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
-<odoo>
-    <data>
-
-        <record model="ir.ui.view" id="scop_instance_mail_wizard_form_view">
-            <field name="name">scop.instance.mail.wizard.form</field>
-            <field name="model">scop.instance.mail.wizard</field>
-            <field name="arch" type="xml">
-                <form create="false" edit="false">
-                    <field
-                        name="partner_ids"
-                        options="{'no_create': True, 'no_open': True}"
-                    >
-                        <tree>
-                            <field name="name" string="Coopératives" />
-                        </tree>
-                    </field>
-                    <footer>
-                        <button
-                            name="send_mail"
-                            string="Envoyer à ces coops"
-                            type="object"
-                            default_focus="1"
-                            class="oe_highlight"
-                        />
-                        <button
-                            name="cancel"
-                            string="Fermer"
-                            special="cancel"
-                            class="oe_highlight"
-                        />
-                    </footer>
-                </form>
-            </field>
-        </record>
-
-    </data>
-</odoo>
diff --git a/wizard/scop_instance_report_per_ur_wizard.py b/wizard/scop_instance_report_per_ur_wizard.py
deleted file mode 100644
index fd4ea82..0000000
--- a/wizard/scop_instance_report_per_ur_wizard.py
+++ /dev/null
@@ -1,12 +0,0 @@
-# © 2022 Le Filament (<http://www.le-filament.com>)
-# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-
-from odoo import fields, models
-
-
-class ScopInstanceReportWizard(models.TransientModel):
-    _name = "scop.instance.report.wizard"
-    _description = "Wizard: Imprimer les courriers par UR"
-
-    ur_ids = fields.Many2many(comodel_name="union.regionale", string="UR")
-    partner_ids = fields.Many2many(comodel_name="res.partner", string="Coopératives")
diff --git a/wizard/scop_instance_report_per_ur_wizard.xml b/wizard/scop_instance_report_per_ur_wizard.xml
deleted file mode 100644
index 821ecda..0000000
--- a/wizard/scop_instance_report_per_ur_wizard.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" ?>
-<!-- Copyright 2022 Le Filament
-     License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
-<odoo>
-    <data>
-
-        <record model="ir.ui.view" id="scop_instance_report_wizard_form_view">
-            <field name="name">scop.instance.report.wizard.form</field>
-            <field name="model">scop.instance.report.wizard</field>
-            <field name="arch" type="xml">
-                <form create="false" edit="false">
-                    <field name="ur_ids">
-                        <tree>
-                            <field name="name" string="UR" />
-                            <button
-                                name="create_report_adhesion_per_ur"
-                                type="object"
-                                icon="fa-print"
-                            />
-                        </tree>
-                    </field>
-                </form>
-            </field>
-        </record>
-
-    </data>
-</odoo>
-- 
GitLab