diff --git a/__manifest__.py b/__manifest__.py index 5e73bf3bc6eb3c7912aa6157bbde2d847d4ca11b..9954c36c114867b0313335e0dd3d1554e15e7f0e 100644 --- a/__manifest__.py +++ b/__manifest__.py @@ -25,6 +25,7 @@ "views/res_config_settings.xml", "views/res_partner.xml", "report/scop_contribution_report.xml", + "wizard/account_payment_line_create_view.xml", ], "qweb": [ "static/src/xml/*.xml", diff --git a/models/account_payment_order.py b/models/account_payment_order.py index 846d3bc58367a46832720cb82638febf4c2a5a42..e0879193ed7cae446dd134310ee0dfbea92ddb66 100644 --- a/models/account_payment_order.py +++ b/models/account_payment_order.py @@ -17,6 +17,7 @@ class AccountPaymentOrder(models.Model): attachment_ids = fields.One2many( comodel_name="ir.attachment", compute="_compute_attachment_ids" ) + mandate_validity = fields.Boolean("Mandats valides", compute="_compute_mandate_validity") # ------------------------------------------------------ # Compute fields @@ -39,6 +40,15 @@ class AccountPaymentOrder(models.Model): ] ) + def _compute_mandate_validity(self): + for o in self: + validity = o.mapped("payment_line_ids.mandate_id").filtered( + lambda m: m.state != "valid") + if validity: + o.mandate_validity = False + else: + o.mandate_validity = True + # ------------------------------------------------------ # Button function # ------------------------------------------------------ @@ -68,6 +78,30 @@ class AccountPaymentOrder(models.Model): "domain": [["payment_order_id", "=", self.id]], } + def view_wrong_iban(self): + self.ensure_one() + bank_ids = self.mapped("payment_line_ids.partner_bank_id").filtered( + lambda b: b.acc_type != 'iban') + return { + 'type': 'ir.actions.act_window', + 'name': "Comptes bancaires", + 'res_model': 'res.partner.bank', + 'views': [[False, 'tree'], [False, 'form']], + 'domain': [['id', 'in', bank_ids.ids]], + } + + def view_wrong_mandate(self): + self.ensure_one() + mandate_ids = self.mapped("payment_line_ids.mandate_id").filtered( + lambda m: m.state != "valid") + return { + 'type': 'ir.actions.act_window', + 'name': "Mandats non valides", + 'res_model': 'account.banking.mandate', + 'views': [[False, 'tree'], [False, 'form']], + 'domain': [['id', 'in', mandate_ids.ids]], + } + # ------------------------------------------------------ # Common function # ------------------------------------------------------ diff --git a/views/account_payment_order.xml b/views/account_payment_order.xml index 51df21e2ad57386c556ab137c28d100817ae7065..d73a89847c29a1153d18ecb301b06b12c7661f92 100644 --- a/views/account_payment_order.xml +++ b/views/account_payment_order.xml @@ -51,6 +51,24 @@ attrs="{'invisible': [('state', 'not in', ('uploaded', 'done'))]}" /> </xpath> + <!-- Boutons de vérification IBAN et mandats --> + <xpath expr="//notebook" position="before"> + <field name="mandate_validity" invisible="1"/> + <button name="view_wrong_iban" + type="object" + string="Voir les IBAN à corriger" + class="btn-danger" + attrs="{'invisible': [('sepa', '=', True)]}" + style="margin-right: 10px;" + /> + <button name="view_wrong_mandate" + type="object" + string="Voir les Mandats non valides" + class="btn-danger" + attrs="{'invisible': [('mandate_validity', '=', True)]}" + /> + </xpath> + <!-- Affichage des fichers XML --> <xpath expr="//notebook" position="inside"> <page name="attachments" string="Fichiers de prélèvements"> <field name="attachment_ids"> diff --git a/wizard/__init__.py b/wizard/__init__.py index 6e7a64ae019f927458367555b9c806f7f1cd7fe0..95b3bde4f8f1e35bc95b4dbba7109abc3fc947ec 100644 --- a/wizard/__init__.py +++ b/wizard/__init__.py @@ -2,3 +2,4 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import account_move_reversal +from . import account_payment_line_create diff --git a/wizard/account_payment_line_create.py b/wizard/account_payment_line_create.py new file mode 100755 index 0000000000000000000000000000000000000000..b7e39f67310801148b15e38fbba14604aee8befb --- /dev/null +++ b/wizard/account_payment_line_create.py @@ -0,0 +1,24 @@ +# © 2020 Le Filament (<http://www.le-filament.com>) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models, fields, api, _ + + +class AccountPaymentLineCreate(models.TransientModel): + _inherit = 'account.payment.line.create' + + start_date = fields.Date(string="Date Mini") + ur_ids = fields.Many2many( + comodel_name="union.regionale", + string="Union Régionale" + ) + + def _prepare_move_line_domain(self): + self.ensure_one() + domain = super()._prepare_move_line_domain() + if self.start_date: + domain += [("date_maturity", ">=", self.start_date)] + if self.ur_ids: + domain += [("partner_id.ur_id", "in", self.ur_ids.ids)] + + return domain diff --git a/wizard/account_payment_line_create_view.xml b/wizard/account_payment_line_create_view.xml new file mode 100755 index 0000000000000000000000000000000000000000..5faf1d6471a404f14d8814d5d0bc937b77f42e39 --- /dev/null +++ b/wizard/account_payment_line_create_view.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<odoo> + <data> + <record id="account_payment_line_create_form" model="ir.ui.view"> + <field name="name">account_payment_line_create.form</field> + <field name="model">account.payment.line.create</field> + <field name="inherit_id" ref="account_payment_order.account_payment_line_create_form"/> + <field name="arch" type="xml"> + <xpath expr="//field[@name='due_date']" position="before"> + <field name="start_date" + attrs="{'invisible': [('date_type', '!=', 'due')]}" + /> + </xpath> + <xpath expr="//field[@name='journal_ids']" position="after"> + <field name="ur_ids" + widget="many2many_tags" + options="{'no_create': 1, 'no_edit': 1}" + placeholder="Laisser vide pour toutes les UR" + /> + </xpath> + </field> + </record> + </data> +</odoo>