From a4aeac6fcfbffb635a5173be980aa04f826f3a2e Mon Sep 17 00:00:00 2001
From: jordan <jordan@le-filament.com>
Date: Wed, 24 Nov 2021 15:14:34 +0100
Subject: [PATCH] =?UTF-8?q?[update]=20remove=20payment=5Fterm=5Fid=20in=20?=
 =?UTF-8?q?cotiz=5Fcg=20and=20use=20"=C3=A9ch=C3=A9ancier"=20to=20generate?=
 =?UTF-8?q?=20invoices?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 __manifest__.py                |  1 -
 models/__init__.py             |  1 -
 models/account_invoice.py      | 57 ----------------------------------
 models/account_payment_term.py | 10 ------
 models/res_company.py          |  6 ----
 models/res_config_settings.py  |  8 -----
 models/scop_cotisation.py      |  6 ----
 views/account_payment_term.xml | 21 -------------
 views/res_config_settings.xml  |  7 -----
 9 files changed, 117 deletions(-)
 delete mode 100644 models/account_payment_term.py
 delete mode 100644 views/account_payment_term.xml

diff --git a/__manifest__.py b/__manifest__.py
index 3def71d..2f7efcd 100755
--- a/__manifest__.py
+++ b/__manifest__.py
@@ -19,7 +19,6 @@
         "security/ir.model.access.csv",
         "views/account_invoice.xml",
         "views/account_move.xml",
-        "views/account_payment_term.xml",
         "views/account_payment_order.xml",
         "views/account_payment_line.xml",
         "views/res_config_settings.xml",
diff --git a/models/__init__.py b/models/__init__.py
index 796e1a9..1a0bf4d 100755
--- a/models/__init__.py
+++ b/models/__init__.py
@@ -3,7 +3,6 @@
 
 from . import account_invoice
 from . import account_payment_order
-from . import account_payment_term
 from . import chart_template
 from . import res_company
 from . import res_config_settings
diff --git a/models/account_invoice.py b/models/account_invoice.py
index c7a13a6..16c9033 100755
--- a/models/account_invoice.py
+++ b/models/account_invoice.py
@@ -75,18 +75,6 @@ class ScopAccountInvoice(models.Model):
     # ------------------------------------------------------
     # Override Parent
     # ------------------------------------------------------
-    # @api.multi
-    # def action_invoice_open(self):
-    #     """
-    #     Création d'une ligne dans scop.contribution
-    #     quand une facture cotisation devient valide
-    #     """
-    #     results = super(ScopAccountInvoice, self).action_invoice_open()
-    #     # for inv in self:
-    #     #     if inv.is_contribution:
-    #     #         inv.set_scop_contribution()
-    #     return results
-
     @api.one
     def _get_outstanding_info_JSON(self):
         super(ScopAccountInvoice, self)._get_outstanding_info_JSON()
@@ -119,48 +107,3 @@ class ScopAccountInvoice(models.Model):
                                 'invoice': line.invoice_id.number
                             })
                 self.outstanding_credits_debits_widget = json.dumps(info)
-
-    # ------------------------------------------------------
-    # Common Function
-    # ------------------------------------------------------
-    # @api.multi
-    # def set_scop_contribution(self):
-    #     """
-    #     Création d'une ligne dans scop.contribution
-    #     """
-    #     self.ensure_one()
-    #     if self.is_contribution:
-    #         year = self.year
-    #         # Get existing contribution for this year
-    #         contrib_id = self.env['scop.contribution'].search([
-    #             ('partner_id', '=', self.partner_id.id),
-    #             ('year', '=', year),
-    #             ('type_id', '=', self.type_contribution_id.id)
-    #         ])
-    #
-    #         # Create scop.contribution line if not exists
-    #         # for year, partner and type
-    #         if not contrib_id:
-    #             contrib_line = self.env['scop.contribution'].create({
-    #                 'partner_id': self.partner_id.id,
-    #                 'type_id': self.type_contribution_id.id,
-    #                 'year': self.year,
-    #                 'calculation_date': fields.Datetime.now(),
-    #                 'amount_calculated': self.amount_total,
-    #                 'amount_called': self.amount_total,
-    #                 'spreading': self.nb_quarter,
-    #                 'invoice_id': self.id,
-    #             })
-    #         else:
-    #             contrib_line = self.set_scop_contribution_hook(contrib_id)
-    #         self.contribution_id = contrib_line.id
-    #         return contrib_line
-    #     return False
-
-    # def set_scop_contribution_hook(self, contrib_id):
-    #     """
-    #     Function that can be inherited if a contrib line already exists
-    #     :param contrib_id: scop.contribution line
-    #     :return: scop.contribution
-    #     """
-    #     return contrib_id
diff --git a/models/account_payment_term.py b/models/account_payment_term.py
deleted file mode 100644
index f0cc0f5..0000000
--- a/models/account_payment_term.py
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2020 Le Filament
-# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-
-from odoo import fields, models
-
-
-class AccountPaymentTerm(models.Model):
-    _inherit = 'account.payment.term'
-
-    is_contribution = fields.Boolean('Conditions de paiement des cotisations')
\ No newline at end of file
diff --git a/models/res_company.py b/models/res_company.py
index f346618..96f63c0 100644
--- a/models/res_company.py
+++ b/models/res_company.py
@@ -14,12 +14,6 @@ class ScopCotisationCompany(models.Model):
         domain="[('type', '=', 'sale')]"
     )
 
-    contribution_default_payment_term_id = fields.Many2one(
-        comodel_name='account.payment.term',
-        string="Conditions de paiement par défaut pour les cotisations",
-        domain=[('is_contribution', '=', True)],
-    )
-
     tag_cotiz_id = fields.Many2one(
         comodel_name='res.partner.category',
         string='Etiquette de cotisation',
diff --git a/models/res_config_settings.py b/models/res_config_settings.py
index c4835c2..61cb183 100644
--- a/models/res_config_settings.py
+++ b/models/res_config_settings.py
@@ -18,14 +18,6 @@ class CotisationsConfigSettings(models.TransientModel):
         string='Journal des cotisations',
         domain="[('type', '=', 'sale')]")
 
-    contribution_default_payment_term_id = fields.Many2one(
-        comodel_name='account.payment.term',
-        related="company_id.contribution_default_payment_term_id",
-        readonly=False,
-        string="Conditions de paiement par défaut pour les cotisations",
-        domain=[('is_contribution', '=', True)],
-    )
-
     tag_cotiz_id = fields.Many2one(
         comodel_name='res.partner.category',
         related="company_id.tag_cotiz_id",
diff --git a/models/scop_cotisation.py b/models/scop_cotisation.py
index da07bb3..3448962 100644
--- a/models/scop_cotisation.py
+++ b/models/scop_cotisation.py
@@ -37,12 +37,6 @@ class ScopCotisation(models.AbstractModel):
     company_currency_id = fields.Many2one(
         comodel_name='res.currency', related='company_id.currency_id',
         string="Company Currency", readonly=True)
-    payment_term_id = fields.Many2one(
-        comodel_name='account.payment.term',
-        string="Conditions de paiement",
-        domain=[('is_contribution', '=', True)],
-        required=True,
-    )
     date_cotisation = fields.Date(
         string="Date calcul cotisation",
         help="Date de calcul qui apparaitra sur le bordereau de cotisation"
diff --git a/views/account_payment_term.xml b/views/account_payment_term.xml
deleted file mode 100644
index 926975d..0000000
--- a/views/account_payment_term.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<odoo>
-    <!--  Copyright 2020 Le Filament
-          License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).  -->
-    <data>
-        
-        <record id="view_payment_term_form_inherited" model="ir.ui.view">
-            <field name="name">account.payment.term.form</field>
-            <field name="model">account.payment.term</field>
-            <field name="inherit_id" ref="account.view_payment_term_form"/>
-            <field name="arch" type="xml">
-                <xpath expr="//group" position="after">
-                    <group name="schedule">
-                        <field name="is_contribution" widget="boolean_toggle"/>
-                    </group>
-                </xpath>
-            </field>
-        </record>
-    
-    </data>
-</odoo>
\ No newline at end of file
diff --git a/views/res_config_settings.xml b/views/res_config_settings.xml
index 3cd000f..f97b36a 100644
--- a/views/res_config_settings.xml
+++ b/views/res_config_settings.xml
@@ -29,13 +29,6 @@
                                 </div>
                                 <field name="contribution_journal_id" options="{'no_open': True, 'no_create': True}"/>
                             </div>
-                            <div class="o_setting_right_pane">
-                                <label for="contribution_default_payment_term_id"/>
-                                <div class="text-muted">
-                                    Conditions de paiement par défault
-                                </div>
-                                <field name="contribution_default_payment_term_id" options="{'no_open': True, 'no_create': True}"/>
-                            </div>
                             <div class="o_setting_left_pane"/>
                             <div class="o_setting_right_pane">
                                 <label for="tag_cotiz_id"/>
-- 
GitLab