Skip to content
Extraits de code Groupes Projets
Valider c30d7a06 rédigé par Benjamin - Le Filament's avatar Benjamin - Le Filament
Parcourir les fichiers

[add] IBAN and mandate checks on payment order

parent e0d2fae5
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
"views/res_partner.xml", "views/res_partner.xml",
"views/scop_cotisation_task.xml", "views/scop_cotisation_task.xml",
"report/scop_contribution_report.xml", "report/scop_contribution_report.xml",
"wizard/account_payment_line_create_view.xml",
], ],
"qweb": [ "qweb": [
"static/src/xml/*.xml", "static/src/xml/*.xml",
......
...@@ -20,6 +20,7 @@ class AccountPaymentOrder(models.Model): ...@@ -20,6 +20,7 @@ class AccountPaymentOrder(models.Model):
comodel_name='ir.attachment', comodel_name='ir.attachment',
compute='_compute_attachment_ids' compute='_compute_attachment_ids'
) )
mandate_validity = fields.Boolean("Mandats valides", compute="_compute_mandate_validity")
# ------------------------------------------------------ # ------------------------------------------------------
# Compute fields # Compute fields
...@@ -47,6 +48,16 @@ class AccountPaymentOrder(models.Model): ...@@ -47,6 +48,16 @@ class AccountPaymentOrder(models.Model):
('res_id', '=', po.id) ('res_id', '=', po.id)
]) ])
@api.multi
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 # Button function
# ------------------------------------------------------ # ------------------------------------------------------
...@@ -78,6 +89,30 @@ class AccountPaymentOrder(models.Model): ...@@ -78,6 +89,30 @@ class AccountPaymentOrder(models.Model):
'domain': [['payment_order_id', '=', self.id]], '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 # Common function
# ------------------------------------------------------ # ------------------------------------------------------
......
...@@ -23,7 +23,24 @@ ...@@ -23,7 +23,24 @@
<button name="view_payment_line" <button name="view_payment_line"
type="object" type="object"
string="Modifier les lignes de paiement" string="Modifier les lignes de paiement"
attrs="{'invisible': [('state', '!=', 'draft')]}"/> attrs="{'invisible': [('state', '!=', 'draft')]}"
/>
</xpath>
<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> </xpath>
<xpath expr="//field[@name='description']" position="after"> <xpath expr="//field[@name='description']" position="after">
<button name="view_account_move" <button name="view_account_move"
......
...@@ -2,3 +2,4 @@ ...@@ -2,3 +2,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import account_invoice_refund from . import account_invoice_refund
from . import account_payment_line_create
# © 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
<?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>
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter