diff --git a/__manifest__.py b/__manifest__.py index 42fe4fde0cf5c1416d74e9ec3c73544e4e0d4a21..2dc5e4a2a1eee070489c02b372b4b678916401a6 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 560f87ecd15bc19c322aa955363f23981c5189de..04ac9290fb0adaff1e5e91f41daa14aca494657f 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 2409b9d1c9b2892866df8b8f00ae823058008973..3a947e5cdfdd56f127f16bfeb0c48bab277b8de2 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 5c6a0d2adec3293c5b2759bc001d9bd7ab78a973..09f61798b427cb8e0d5986847446a830cc39bd80 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 ac2aa5abe51ad3aef7008504fe44438456ff3e5f..2433504a59e5539cb183ae13436aee88fe6054d9 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 36466709d99673c0b455b72acb4d04c17863519d..be6f5c5cc7f273524234529cfbb65d38f629ce6b 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 297d8bc8bf5f40b5699675a0645cb530981858b8..54427bcaa6291de20285411f9edf7781e10b7b7a 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 75605fe40a17c1a9ebccef48ce01a010b6c850a8..0ee62ff3b8f88c07a8633206227ad2e9fc600e12 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 6873d4668272811793930aee0f9058339ecec1c8..5d626a84098f01951f47b5b44c0dafc1b5d002b7 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 4428605f3f804497a1f65454611cb4b689d313a0..de7ac630de919bf3c8375adc8e2ef0cdb936b00a 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"]],