From a1226552abc50d7abbf1b6f8eef300515de402d8 Mon Sep 17 00:00:00 2001
From: benjamin <benjamin@le-filament.com>
Date: Tue, 12 Apr 2022 14:10:54 +0200
Subject: [PATCH] [mig] Migration 13.0

---
 .pylintrc                           |  2 +-
 .pylintrc-mandatory                 |  2 +-
 __manifest__.py                     |  2 +-
 models/scop_bordereau_cg.py         | 12 ++++++------
 models/scop_cotisation_cg.py        |  6 +++---
 security/ir.model.access.csv        | 10 ----------
 templates/report_scop_bordereau.xml |  2 +-
 views/account_move.xml              |  4 ++--
 views/scop_bordereau_cg.xml         |  4 ++--
 9 files changed, 17 insertions(+), 27 deletions(-)

diff --git a/.pylintrc b/.pylintrc
index dc6270e..542c686 100644
--- a/.pylintrc
+++ b/.pylintrc
@@ -8,7 +8,7 @@ manifest_required_authors=Le Filament
 manifest_required_keys=license
 manifest_deprecated_keys=description,active
 license_allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3
-valid_odoo_versions=14.0
+valid_odoo_versions=13.0
 
 [MESSAGES CONTROL]
 disable=all
diff --git a/.pylintrc-mandatory b/.pylintrc-mandatory
index 43ea239..74be5ff 100644
--- a/.pylintrc-mandatory
+++ b/.pylintrc-mandatory
@@ -8,7 +8,7 @@ manifest_required_authors=Le Filament
 manifest_required_keys=license
 manifest_deprecated_keys=description,active
 license_allowed=AGPL-3,GPL-2,GPL-2 or any later version,GPL-3,GPL-3 or any later version,LGPL-3
-valid_odoo_versions=14.0
+valid_odoo_versions=13.0
 
 [MESSAGES CONTROL]
 disable=all
diff --git a/__manifest__.py b/__manifest__.py
index 64b1d36..e064d27 100644
--- a/__manifest__.py
+++ b/__manifest__.py
@@ -3,7 +3,7 @@
 {
     "name": "CG SCOP - Cotisations CG",
     "summary": "CG SCOP - Cotisations CG Scop",
-    "version": "14.0.1.0.0",
+    "version": "13.0.1.0.0",
     "author": "Le Filament",
     "license": "AGPL-3",
     "application": False,
diff --git a/models/scop_bordereau_cg.py b/models/scop_bordereau_cg.py
index 72ea1ee..a626d3a 100644
--- a/models/scop_bordereau_cg.py
+++ b/models/scop_bordereau_cg.py
@@ -239,7 +239,7 @@ class Bordereau(models.Model):
 
     @api.depends(
         "invoice_ids.state",
-        "invoice_ids.payment_state",
+        "invoice_ids.invoice_payment_state",
         "bordereau_version_ids",
         "bordereau_version_ids.state",
     )
@@ -257,7 +257,7 @@ class Bordereau(models.Model):
                 bordereau.state = "new"
             else:
                 unpaid_cotiz = bordereau.invoice_ids.filtered(
-                    lambda cotiz: cotiz.payment_state not in ("paid", "cancel")
+                    lambda cotiz: cotiz.invoice_payment_state not in ("paid", "cancel")
                 )
                 if not unpaid_cotiz:
                     bordereau.state = "paid"
@@ -833,7 +833,7 @@ class Bordereau(models.Model):
                 {
                     "partner_id": partner.id,
                     "liasse_fiscale_id": liasse.id,
-                    "move_type": type_invoice,
+                    "type": type_invoice,
                     "year": self.year,
                     "is_contribution": True,
                     "type_contribution_id": type_contribution,
@@ -892,7 +892,7 @@ class Bordereau(models.Model):
         for bordereau in self:
             inv_ids = bordereau.invoice_ids
             if bordereau.is_regul:
-                inv_ids = inv_ids.filtered(lambda i: i.move_type == "out_invoice")
+                inv_ids = inv_ids.filtered(lambda i: i.type == "out_invoice")
             move_lines = MoveLine.search(
                 [
                     ("move_id", "in", inv_ids.ids),
@@ -954,7 +954,7 @@ class Bordereau(models.Model):
         """
         domain = [("id", "in", self.invoice_ids.ids)]
         if self.is_regul:
-            domain.append(("move_type", "=", "out_invoice"))
+            domain.append(("type", "=", "out_invoice"))
         return self.invoice_ids.read_group(
             domain,
             ["type_contribution_id", "amount_total_signed"],
@@ -967,7 +967,7 @@ class Bordereau(models.Model):
         :return: dict type_contribution and amount
         """
         return self.invoice_ids.read_group(
-            [("id", "in", self.invoice_ids.ids), ("move_type", "=", "out_refund")],
+            [("id", "in", self.invoice_ids.ids), ("type", "=", "out_refund")],
             ["type_contribution_id", "amount_total_signed"],
             ["type_contribution_id"],
         )
diff --git a/models/scop_cotisation_cg.py b/models/scop_cotisation_cg.py
index 9c52596..4bbdd4a 100644
--- a/models/scop_cotisation_cg.py
+++ b/models/scop_cotisation_cg.py
@@ -32,7 +32,7 @@ class ScopCotisation(models.Model):
         inverse_name="cotisation_cg_id",
         string="Factures",
         domain=[
-            ("move_type", "in", ("out_invoice", "out_refund")),
+            ("type", "in", ("out_invoice", "out_refund")),
             ("is_contribution", "=", True),
         ],
     )
@@ -154,12 +154,12 @@ class ScopCotisation(models.Model):
             opened_count = len(
                 cotiz.invoice_ids.filtered(
                     lambda i: i.state == "posted"
-                    and i.payment_state not in ("paid", "reversed")
+                    and i.invoice_payment_state not in ("paid", "reversed")
                 )
             )
             paid_count = len(
                 cotiz.invoice_ids.filtered(
-                    lambda i: i.state == "posted" and i.payment_state == "paid"
+                    lambda i: i.state == "posted" and i.invoice_payment_state == "paid"
                 )
             )
             cotiz.graph_values = json.dumps(
diff --git a/security/ir.model.access.csv b/security/ir.model.access.csv
index 7c925ce..becfa54 100644
--- a/security/ir.model.access.csv
+++ b/security/ir.model.access.csv
@@ -7,13 +7,3 @@ access_scop_bordereau,access_scop_bordereau,model_scop_bordereau,cgscop_cotisati
 admin_access_scop_bordereau,admin_access_scop_bordereau,model_scop_bordereau,cgscop_partner.group_cg_administrator,1,1,1,1
 access_scop_bordereau_version,access_scop_bordereau_version,model_scop_bordereau_version,cgscop_cotisation_cg.group_cotisation_cg_administrative,1,1,1,1
 admin_access_scop_bordereau_version,admin_access_scop_bordereau_version,model_scop_bordereau_version,cgscop_partner.group_cg_administrator,1,1,1,1
-access_scop_bordereau_refund_wizard_quarter,access_scop_bordereau_refund_wizard_quarter,model_scop_bordereau_refund_wizard_quarter,cgscop_cotisation_cg.group_cotisation_cg_administrative,1,1,1,1
-admin_access_scop_bordereau_refund_wizard_quarter,admin_access_scop_bordereau_refund_wizard_quarter,model_scop_bordereau_refund_wizard_quarter,cgscop_partner.group_cg_administrator,1,1,1,1
-access_scop_bordereau_refund_wizard,access_scop_bordereau_refund_wizard,model_scop_bordereau_refund_wizard,base.group_user,1,1,1,1
-access_scop_bordereau_update,access_scop_bordereau_update,model_scop_bordereau_update,base.group_user,1,1,1,1
-access_scop_bordereau_validate,access_scop_bordereau_validate,model_scop_bordereau_validate,base.group_user,1,1,1,1
-access_scop_cotisation_regul_wizard,access_scop_cotisation_regul_wizard,model_scop_cotisation_regul_wizard,base.group_user,1,1,1,1
-access_scop_cotisation_cg_wizard,access_scop_cotisation_cg_wizard,model_scop_cotisation_cg_wizard,base.group_user,1,1,1,1
-access_export_journal_cg_wizard,access_export_journal_cg_wizard,model_export_journal_cg_wizard,base.group_user,1,1,1,1
-access_scop_bordereau_change_liasse_wizard,access_scop_bordereau_change_liasse_wizard,model_scop_bordereau_change_liasse_wizard,base.group_user,1,1,1,1
-access_scop_bordereau_change_payment_mode_wizard,access_scop_bordereau_change_payment_mode_wizard,model_scop_bordereau_change_payment_mode_wizard,base.group_user,1,1,1,1
diff --git a/templates/report_scop_bordereau.xml b/templates/report_scop_bordereau.xml
index e6db969..4c0ed67 100644
--- a/templates/report_scop_bordereau.xml
+++ b/templates/report_scop_bordereau.xml
@@ -130,7 +130,7 @@
                                         >
                                             <t t-if="o.is_regul">
                                                 <strong><span
-                                                        t-esc="sum(o.invoice_ids.filtered(lambda i: i.move_type == 'out_invoice').mapped('amount_total_signed'))"
+                                                        t-esc="sum(o.invoice_ids.filtered(lambda i: i.type == 'out_invoice').mapped('amount_total_signed'))"
                                                         t-options="{'widget': 'monetary', 'display_currency': o.company_id.currency_id}"
                                                     /></strong>
                                             </t>
diff --git a/views/account_move.xml b/views/account_move.xml
index 7bda03b..efc6a37 100644
--- a/views/account_move.xml
+++ b/views/account_move.xml
@@ -107,11 +107,11 @@
             <field name="view_mode">tree,form,kanban,graph,pivot</field>
             <field
                 name="domain"
-                eval="[('move_type','in', ['out_invoice', 'out_refund']), ('is_contribution', '!=', False), ('company_id', '=', ref('base.main_company'))]"
+                eval="[('type','in', ['out_invoice', 'out_refund']), ('is_contribution', '!=', False), ('company_id', '=', ref('base.main_company'))]"
             />
             <field
                 name="context"
-                eval="{'default_mov_type':'out_invoice', 'move_type':'out_invoice', 'journal_type': 'sale', 'default_is_contribution': True, 'create': False,}"
+                eval="{'default_mov_type':'out_invoice', 'type':'out_invoice', 'journal_type': 'sale', 'default_is_contribution': True, 'create': False,}"
             />
             <field name="search_view_id" ref="invoice_search_scop_cg_inherited" />
         </record>
diff --git a/views/scop_bordereau_cg.xml b/views/scop_bordereau_cg.xml
index 661365b..588fa16 100644
--- a/views/scop_bordereau_cg.xml
+++ b/views/scop_bordereau_cg.xml
@@ -264,9 +264,9 @@
                                         decoration-info="state == 'draft'"
                                         decoration-success="state == 'paid'"
                                         decoration-muted="state == 'cancel'"
-                                        decoration-danger="move_type == 'out_refund' and state == 'posted'"
+                                        decoration-danger="type == 'out_refund' and state == 'posted'"
                                     >
-                                        <field name="move_type" invisible="1" />
+                                        <field name="type" invisible="1" />
                                         <field name="type_contribution_id" />
                                         <field name="cotiz_quarter" />
                                         <field name="invoice_date_due" />
-- 
GitLab