From 3b6b4154c1b5658b9c701957249590ff1a4f11e4 Mon Sep 17 00:00:00 2001
From: jordan <jordan@le-filament.com>
Date: Thu, 16 Dec 2021 12:27:34 +0100
Subject: [PATCH] [fix] rename cotisation without final 's' and
look_for_lettrage into reconcile
---
__manifest__.py | 2 +-
controllers/banner_scop_invoice_idf.py | 4 +-
models/__init__.py | 2 +-
...isations_idf.py => scop_cotisation_idf.py} | 22 ++++----
models/scop_invoice_idf.py | 2 +-
security/ir.model.access.csv | 2 +-
.../scop_invoice_idf_header_template.xml | 4 +-
...ations_idf.xml => scop_cotisation_idf.xml} | 50 +++++++++----------
views/scop_invoice_idf.xml | 6 +--
wizard/scop_invoice_idf_wizard.py | 6 +--
10 files changed, 50 insertions(+), 50 deletions(-)
rename models/{scop_cotisations_idf.py => scop_cotisation_idf.py} (92%)
rename views/{scop_cotisations_idf.xml => scop_cotisation_idf.xml} (84%)
diff --git a/__manifest__.py b/__manifest__.py
index 42fe4fd..2dc5e4a 100644
--- a/__manifest__.py
+++ b/__manifest__.py
@@ -16,7 +16,7 @@
"security/ir.model.access.csv",
"views/scop_invoice_idf.xml",
"views/scop_invoice_idf_logs.xml",
- "views/scop_cotisations_idf.xml",
+ "views/scop_cotisation_idf.xml",
"views/res_config_settings.xml",
"templates/scop_invoice_idf_header_template.xml",
"wizard/scop_invoice_idf_wizard.xml",
diff --git a/controllers/banner_scop_invoice_idf.py b/controllers/banner_scop_invoice_idf.py
index 560f87e..04ac929 100644
--- a/controllers/banner_scop_invoice_idf.py
+++ b/controllers/banner_scop_invoice_idf.py
@@ -14,8 +14,8 @@ class BannerScopInvoiceIDFController(http.Controller):
'cgscop_invoice_idf.header_template').render({})
}
- @http.route(['/cgscop_cotisations_idf/header'], type="json", auth="user")
- def scop_cotisations_idf_header(self):
+ @http.route(['/cgscop_cotisation_idf/header'], type="json", auth="user")
+ def scop_cotisation_idf_header(self):
return {
'html': request.env.ref(
'cgscop_invoice_idf.header_template_cotisations').render({})
diff --git a/models/__init__.py b/models/__init__.py
index 2409b9d..3a947e5 100644
--- a/models/__init__.py
+++ b/models/__init__.py
@@ -4,5 +4,5 @@
from . import res_company
from . import res_config_settings
from . import scop_invoice_idf
-from . import scop_cotisations_idf
+from . import scop_cotisation_idf
from . import scop_invoice_idf_logs
diff --git a/models/scop_cotisations_idf.py b/models/scop_cotisation_idf.py
similarity index 92%
rename from models/scop_cotisations_idf.py
rename to models/scop_cotisation_idf.py
index 5c6a0d2..09f6179 100644
--- a/models/scop_cotisations_idf.py
+++ b/models/scop_cotisation_idf.py
@@ -5,7 +5,7 @@ from odoo import models, fields, api
class ScopCotisationsIDF(models.Model):
- _name = "scop.cotisations.idf"
+ _name = "scop.cotisation.idf"
_description = "Cotisations IDF"
# ------------------------------------------------------
@@ -54,10 +54,10 @@ class ScopCotisationsIDF(models.Model):
compute='_compute_state')
invoice_id = fields.Many2one(
- comodel_name='scop.cotisations.idf',
+ comodel_name='scop.cotisation.idf',
string='Cotisation')
payments_ids = fields.One2many(
- comodel_name='scop.cotisations.idf',
+ comodel_name='scop.cotisation.idf',
inverse_name='invoice_id',
string='Paiments / Avoirs',
required=False, readonly=True)
@@ -140,7 +140,7 @@ class ScopCotisationsIDF(models.Model):
# ------------------------------------------------------
# Actions
# ------------------------------------------------------
- def look_for_lettrage(self):
+ def reconcile(self):
"""
Link payments and invoices if same letter for a given year
:return:
@@ -169,11 +169,11 @@ class ScopCotisationsIDF(models.Model):
'name': 'Paiement / Avoir',
'views': [
[self.env.ref(
- 'cgscop_invoice_idf.view_scop_cotisations_idf_form').id,
+ 'cgscop_invoice_idf.view_scop_cotisation_idf_form').id,
"form"]
],
'view_mode': 'form',
- 'res_model': 'scop.cotisations.idf',
+ 'res_model': 'scop.cotisation.idf',
'target': 'current',
'res_id': self.id
}
@@ -183,9 +183,9 @@ class ScopCotisationsIDF(models.Model):
def action_show_payments(self):
form_view = self.env.ref(
- 'cgscop_invoice_idf.view_scop_cotisations_idf_form').id
+ 'cgscop_invoice_idf.view_scop_cotisation_idf_form').id
tree_view = self.env.ref(
- 'cgscop_invoice_idf.view_scop_cotisations_idf_tree').id
+ 'cgscop_invoice_idf.view_scop_cotisation_idf_tree').id
return {
'type': 'ir.actions.act_window',
'name': 'Paiement / Avoir',
@@ -193,14 +193,14 @@ class ScopCotisationsIDF(models.Model):
[tree_view, "tree"], [form_view, "form"]
],
'view_mode': 'form',
- 'res_model': 'scop.cotisations.idf',
+ 'res_model': 'scop.cotisation.idf',
'target': 'current',
'domain': [('id', 'in', self.payments_ids.ids)]
}
def action_show_invoice(self):
form_view = self.env.ref(
- 'cgscop_invoice_idf.view_scop_cotisations_idf_form').id
+ 'cgscop_invoice_idf.view_scop_cotisation_idf_form').id
return {
'type': 'ir.actions.act_window',
'name': 'Cotisation',
@@ -208,7 +208,7 @@ class ScopCotisationsIDF(models.Model):
[form_view, "form"]
],
'view_mode': 'form',
- 'res_model': 'scop.cotisations.idf',
+ 'res_model': 'scop.cotisation.idf',
'target': 'current',
'res_id': self.invoice_id.id
}
diff --git a/models/scop_invoice_idf.py b/models/scop_invoice_idf.py
index ac2aa5a..2433504 100644
--- a/models/scop_invoice_idf.py
+++ b/models/scop_invoice_idf.py
@@ -123,7 +123,7 @@ class ScopInvoiceIDF(models.Model):
# ------------------------------------------------------
# Actions
# ------------------------------------------------------
- def look_for_lettrage(self):
+ def reconcile(self):
"""
Link payments and invoices if same letter for a given year
:return:
diff --git a/security/ir.model.access.csv b/security/ir.model.access.csv
index 3646670..be6f5c5 100644
--- a/security/ir.model.access.csv
+++ b/security/ir.model.access.csv
@@ -1,4 +1,4 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_scop_invoice_idf,access_scop_invoice_idf,model_scop_invoice_idf,base.group_user,1,1,1,1
-access_scop_cotisations_idf,access_scop_cotisations_idf,model_scop_cotisations_idf,base.group_user,1,1,1,1
+access_scop_cotisation_idf,access_scop_cotisation_idf,model_scop_cotisation_idf,base.group_user,1,1,1,1
access_scop_invoice_idf_logs,access_scop_invoice_idf_logs,model_scop_invoice_idf_logs,base.group_user,1,1,1,1
diff --git a/templates/scop_invoice_idf_header_template.xml b/templates/scop_invoice_idf_header_template.xml
index 297d8bc..54427bc 100644
--- a/templates/scop_invoice_idf_header_template.xml
+++ b/templates/scop_invoice_idf_header_template.xml
@@ -22,14 +22,14 @@
</div>
</template>
- <template id="header_template_cotisations" name="cgscop_cotisations_idf.header_template">
+ <template id="header_template_cotisations" name="cgscop_cotisation_idf.header_template">
<div id="lm" style="background-color: #fff; padding: 16px 0">
<div class="container">
<div class="row">
<div class="col-12">
<span style="font-size: 1.4rem; margin-right: 32px;"><strong>Importer : </strong></span>
<a type="action"
- data-method="scop_cotisations_idf_wizard_action"
+ data-method="scop_cotisation_idf_wizard_action"
data-model="scop.invoice.idf.wizard"
class="btn btn-secondary" style="margin-right: 32px;">
<u>Cotisations</u>
diff --git a/views/scop_cotisations_idf.xml b/views/scop_cotisation_idf.xml
similarity index 84%
rename from views/scop_cotisations_idf.xml
rename to views/scop_cotisation_idf.xml
index 75605fe..0ee62ff 100644
--- a/views/scop_cotisations_idf.xml
+++ b/views/scop_cotisation_idf.xml
@@ -3,25 +3,25 @@
<data>
<!-- Ajoute l'action "Lettrage" dans le menu du modèle -->
- <record id="action_server_scop_cotisations_idf" model="ir.actions.server">
+ <record id="action_server_scop_cotisation_idf" model="ir.actions.server">
<field name="name">Lettrage</field>
<field name="type">ir.actions.server</field>
- <field name="model_id" ref="model_scop_cotisations_idf"/>
- <field name="binding_model_id" ref="model_scop_cotisations_idf"/>
+ <field name="model_id" ref="model_scop_cotisation_idf"/>
+ <field name="binding_model_id" ref="model_scop_cotisation_idf"/>
<field name="state">code</field>
<field name="code">
if records:
- action = records.look_for_lettrage()
+ action = records.reconcile()
</field>
</record>
<!-- TREE VIEW -->
- <record model="ir.ui.view" id="view_scop_cotisations_idf_tree">
- <field name="name">scop.cotisations.idf.tree</field>
- <field name="model">scop.cotisations.idf</field>
+ <record model="ir.ui.view" id="view_scop_cotisation_idf_tree">
+ <field name="name">scop.cotisation.idf.tree</field>
+ <field name="model">scop.cotisation.idf</field>
<field name="arch" type="xml">
<tree string="Cotisations IDF"
- banner_route="/cgscop_cotisations_idf/header"
+ banner_route="/cgscop_cotisation_idf/header"
decoration-danger="state in ['no_invoice', 'overpaid']"
decoration-info="state == 'awaiting_payments'"
import='False' default_order='writing_date desc'>
@@ -45,17 +45,17 @@
</record>
<!-- FORM -->
- <record id="view_scop_cotisations_idf_form" model="ir.ui.view">
- <field name="name">scop.cotisations.idf.form</field>
- <field name="model">scop.cotisations.idf</field>
+ <record id="view_scop_cotisation_idf_form" model="ir.ui.view">
+ <field name="name">scop.cotisation.idf.form</field>
+ <field name="model">scop.cotisation.idf</field>
<field name="arch" type="xml">
<form string="Cotisations IDF">
<sheet>
<div class="oe_button_box" name="button_box">
<button name="action_show_payments" type="object" class="oe_stat_button" icon="fa-eur"
- attrs="{'invisible': [('type', '!=', 'inv')]}">Paiments</button>
+ attrs="{'invisible': ['|', ('type', '!=', 'inv'), ('payments_ids', '=', False)]}">Paiments</button>
<button name="action_show_invoice" type="object" class="oe_stat_button" icon="fa-calculator"
- attrs="{'invisible': [('type', '=', 'inv')]}">Cotisation</button>
+ attrs="{'invisible': ['|', ('type', '=', 'inv'), ('invoice_id', '=', False)]}">Cotisation</button>
</div>
<div class="oe_title">
<h1>
@@ -122,9 +122,9 @@
</record>
<!-- GRAPH -->
- <record id="view_scop_cotisations_idf_graph" model="ir.ui.view">
- <field name="name">scop.cotisations.idf.graph</field>
- <field name="model">scop.cotisations.idf</field>
+ <record id="view_scop_cotisation_idf_graph" model="ir.ui.view">
+ <field name="name">scop.cotisation.idf.graph</field>
+ <field name="model">scop.cotisation.idf</field>
<field name="arch" type="xml">
<graph string="Cotisations IDF">
<field name="year" type="row"/>
@@ -134,9 +134,9 @@
</record>
<!-- PIVOT -->
- <record id="view_scop_cotisations_idf_pivot" model="ir.ui.view">
- <field name="name">scop.cotisations.idf.pivot</field>
- <field name="model">scop.cotisations.idf</field>
+ <record id="view_scop_cotisation_idf_pivot" model="ir.ui.view">
+ <field name="name">scop.cotisation.idf.pivot</field>
+ <field name="model">scop.cotisation.idf</field>
<field name="arch" type="xml">
<pivot string="Cotisations IDF" display_quantity="True">
<field name="partner_id" type="row"/>
@@ -147,9 +147,9 @@
</record>
<!-- SEARCH -->
- <record id="view_scop_cotisations_idf_search" model="ir.ui.view">
- <field name="name">scop.cotisations.idf.search</field>
- <field name="model">scop.cotisations.idf</field>
+ <record id="view_scop_cotisation_idf_search" model="ir.ui.view">
+ <field name="name">scop.cotisation.idf.search</field>
+ <field name="model">scop.cotisation.idf</field>
<field name="arch" type="xml">
<search string="Paiements IDF">
<field name="partner_id"/>
@@ -175,9 +175,9 @@
</record>
<!-- ACTION -->
- <record id="action_scop_cotisations_idf" model="ir.actions.act_window">
+ <record id="action_scop_cotisation_idf" model="ir.actions.act_window">
<field name="name">Cotisations IDF</field>
- <field name="res_model">scop.cotisations.idf</field>
+ <field name="res_model">scop.cotisation.idf</field>
<field name="view_mode">tree,form,pivot,graph</field>
</record>
@@ -186,7 +186,7 @@
name="Cotisations"
parent="menu_scop_invoice_idf"
sequence="20"
- action="action_scop_cotisations_idf"/>
+ action="action_scop_cotisation_idf"/>
</data>
</odoo>
diff --git a/views/scop_invoice_idf.xml b/views/scop_invoice_idf.xml
index 6873d46..5d626a8 100644
--- a/views/scop_invoice_idf.xml
+++ b/views/scop_invoice_idf.xml
@@ -11,7 +11,7 @@
<field name="state">code</field>
<field name="code">
if records:
- action = records.look_for_lettrage()
+ action = records.reconcile()
</field>
</record>
@@ -51,9 +51,9 @@
<sheet>
<div class="oe_button_box" name="button_box">
<button name="action_show_payments" type="object" class="oe_stat_button" icon="fa-eur"
- attrs="{'invisible': [('type', '!=', 'inv')]}">Paiments</button>
+ attrs="{'invisible': ['|', ('type', '!=', 'inv'), ('payments_ids', '=', False)]}">Paiments</button>
<button name="action_show_invoice" type="object" class="oe_stat_button" icon="fa-calculator"
- attrs="{'invisible': [('type', '=', 'inv')]}">Facture</button>
+ attrs="{'invisible': ['|', ('type', '=', 'inv'), ('invoice_id', '=', False)]}">Facture</button>
</div>
<div class="oe_title">
<h1>
diff --git a/wizard/scop_invoice_idf_wizard.py b/wizard/scop_invoice_idf_wizard.py
index 4428605..de7ac63 100644
--- a/wizard/scop_invoice_idf_wizard.py
+++ b/wizard/scop_invoice_idf_wizard.py
@@ -48,7 +48,7 @@ class ScopImportIDFWizard(models.TransientModel):
}
@api.model
- def scop_cotisations_idf_wizard_action(self):
+ def scop_cotisation_idf_wizard_action(self):
return {
'type': 'ir.actions.act_window',
'name': 'Import Cotisations',
@@ -93,7 +93,7 @@ class ScopImportIDFWizard(models.TransientModel):
if self.type == 'inv':
model = 'scop.invoice.idf'
else:
- model = 'scop.cotisations.idf'
+ model = 'scop.cotisation.idf'
for row in reader:
line += 1
@@ -170,7 +170,7 @@ class ScopImportIDFWizard(models.TransientModel):
# Lettrage for all line in updated years
recordset_for_lettrage = self.env[model].search([
['year', 'in', list(new_lines_years)]])
- recordset_for_lettrage.look_for_lettrage()
+ recordset_for_lettrage.reconcile()
return {
'type': 'ir.actions.act_window',
'views': [[False, "form"]],
--
GitLab