mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[MIG] account_banking_mandate: Migration to 14.0
Replace constrains on company by check_company=True on fields
This commit is contained in:
committed by
Reyes4711
parent
ca73a1056f
commit
32e73536f6
@@ -50,7 +50,7 @@ This module is part of the OCA/bank-payment suite.
|
||||
Usage
|
||||
=====
|
||||
|
||||
To use this module, see menu "Invoicing/Accounting > Payments > Debit Orders"
|
||||
To use this module, see menu "Invoicing/Accounting > Customers > Debit Orders"
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
# Copyright 2014 Compassion CH - Cyril Sester <csester@compassion.ch>
|
||||
# Copyright 2014 Tecnativa - Pedro M. Baeza
|
||||
# Copyright 2015-16 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# Copyright 2015-2020 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# Copyright 2017 Tecnativa - Carlos Dauden <carlos.dauden@tecnativa.com>
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
{
|
||||
"name": "Account Banking Mandate",
|
||||
"summary": "Banking mandates",
|
||||
"version": "13.0.1.1.2",
|
||||
"version": "14.0.1.0.0",
|
||||
"license": "AGPL-3",
|
||||
"author": "Compassion CH, "
|
||||
"Tecnativa, "
|
||||
@@ -24,7 +24,6 @@
|
||||
"views/res_partner_bank_view.xml",
|
||||
"views/res_partner.xml",
|
||||
"views/bank_payment_line_view.xml",
|
||||
"views/account_move_line.xml",
|
||||
"data/mandate_reference_sequence.xml",
|
||||
"security/mandate_security.xml",
|
||||
"security/ir.model.access.csv",
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8' ?>
|
||||
<odoo>
|
||||
<record id="account_banking_mandate_rule" model="ir.rule">
|
||||
<field
|
||||
name="domain_force"
|
||||
>['|',('company_id','=',False),('company_id','in',company_ids)]</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -1,19 +0,0 @@
|
||||
# Copyright 2020 Tecnativa - Pedro M. Baeza
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from openupgradelib import openupgrade # pylint: disable=W7936
|
||||
|
||||
|
||||
@openupgrade.migrate()
|
||||
def migrate(env, version):
|
||||
openupgrade.load_data(
|
||||
env.cr, "account_banking_mandate", "migrations/13.0.1.0.0/noupdate_changes.xml"
|
||||
)
|
||||
openupgrade.logged_query(
|
||||
env.cr,
|
||||
"""
|
||||
UPDATE account_move am
|
||||
SET mandate_id = ai.mandate_id
|
||||
FROM account_invoice ai
|
||||
WHERE ai.id = am.old_invoice_id""",
|
||||
)
|
||||
@@ -1,6 +1,6 @@
|
||||
# Copyright 2014 Compassion CH - Cyril Sester <csester@compassion.ch>
|
||||
# Copyright 2014 Tecnativa - Pedro M. Baeza
|
||||
# Copyright 2015-16 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# Copyright 2015-2020 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# Copyright 2020 Tecnativa - Carlos Dauden
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
@@ -16,8 +16,9 @@ class AccountBankingMandate(models.Model):
|
||||
|
||||
_name = "account.banking.mandate"
|
||||
_description = "A generic banking mandate"
|
||||
_inherit = ["mail.thread"]
|
||||
_inherit = ["mail.thread", "mail.activity.mixin"]
|
||||
_order = "signature_date desc"
|
||||
_check_company_auto = True
|
||||
|
||||
def _get_default_partner_bank_id_domain(self):
|
||||
if "default_partner_id" in self.env.context:
|
||||
@@ -30,20 +31,21 @@ class AccountBankingMandate(models.Model):
|
||||
default="basic",
|
||||
required=True,
|
||||
string="Mandate Format",
|
||||
track_visibility="onchange",
|
||||
tracking=20,
|
||||
)
|
||||
type = fields.Selection(
|
||||
[("generic", "Generic Mandate")],
|
||||
string="Type of Mandate",
|
||||
track_visibility="onchange",
|
||||
tracking=30,
|
||||
)
|
||||
partner_bank_id = fields.Many2one(
|
||||
comodel_name="res.partner.bank",
|
||||
string="Bank Account",
|
||||
track_visibility="onchange",
|
||||
tracking=40,
|
||||
domain=lambda self: self._get_default_partner_bank_id_domain(),
|
||||
ondelete="restrict",
|
||||
index=True,
|
||||
check_company=True,
|
||||
)
|
||||
partner_id = fields.Many2one(
|
||||
comodel_name="res.partner",
|
||||
@@ -59,10 +61,10 @@ class AccountBankingMandate(models.Model):
|
||||
default=lambda self: self.env.company,
|
||||
)
|
||||
unique_mandate_reference = fields.Char(
|
||||
string="Unique Mandate Reference", track_visibility="onchange", copy=False
|
||||
string="Unique Mandate Reference", tracking=10, copy=False
|
||||
)
|
||||
signature_date = fields.Date(
|
||||
string="Date of Signature of the Mandate", track_visibility="onchange"
|
||||
string="Date of Signature of the Mandate", tracking=50,
|
||||
)
|
||||
scan = fields.Binary(string="Scan of the Mandate")
|
||||
last_debit_date = fields.Date(string="Date of the Last Debit", readonly=True)
|
||||
@@ -75,7 +77,7 @@ class AccountBankingMandate(models.Model):
|
||||
],
|
||||
string="Status",
|
||||
default="draft",
|
||||
track_visibility="onchange",
|
||||
tracking=60,
|
||||
help="Only valid mandates can be used in a payment line. A cancelled "
|
||||
"mandate is a mandate that has been cancelled by the customer.",
|
||||
)
|
||||
@@ -131,10 +133,11 @@ class AccountBankingMandate(models.Model):
|
||||
|
||||
@api.constrains("signature_date", "last_debit_date")
|
||||
def _check_dates(self):
|
||||
today = fields.Date.context_today(self)
|
||||
for mandate in self:
|
||||
if (
|
||||
mandate.signature_date
|
||||
and mandate.signature_date > fields.Date.context_today(mandate)
|
||||
and mandate.signature_date > today
|
||||
):
|
||||
raise ValidationError(
|
||||
_("The date of signature of mandate '%s' " "is in the future!")
|
||||
@@ -153,101 +156,6 @@ class AccountBankingMandate(models.Model):
|
||||
% mandate.unique_mandate_reference
|
||||
)
|
||||
|
||||
@api.constrains("company_id", "payment_line_ids", "partner_bank_id")
|
||||
def _company_constrains(self):
|
||||
for mandate in self:
|
||||
if (
|
||||
mandate.partner_bank_id.company_id
|
||||
and mandate.partner_bank_id.company_id != mandate.company_id
|
||||
):
|
||||
raise ValidationError(
|
||||
_(
|
||||
"The company of the mandate %s differs from the "
|
||||
"company of partner %s."
|
||||
)
|
||||
% (mandate.display_name, mandate.partner_id.name)
|
||||
)
|
||||
|
||||
if (
|
||||
self.env["account.payment.line"]
|
||||
.sudo()
|
||||
.search(
|
||||
[
|
||||
("mandate_id", "=", mandate.id),
|
||||
("company_id", "!=", mandate.company_id.id),
|
||||
],
|
||||
limit=1,
|
||||
)
|
||||
):
|
||||
raise ValidationError(
|
||||
_(
|
||||
"You cannot change the company of mandate %s, "
|
||||
"as there exists payment lines referencing it that "
|
||||
"belong to another company."
|
||||
)
|
||||
% (mandate.display_name,)
|
||||
)
|
||||
|
||||
if (
|
||||
self.env["account.move"]
|
||||
.sudo()
|
||||
.search(
|
||||
[
|
||||
("mandate_id", "=", mandate.id),
|
||||
("company_id", "!=", mandate.company_id.id),
|
||||
],
|
||||
limit=1,
|
||||
)
|
||||
):
|
||||
raise ValidationError(
|
||||
_(
|
||||
"You cannot change the company of mandate %s, "
|
||||
"as there exists invoices referencing it that belong to "
|
||||
"another company."
|
||||
)
|
||||
% (mandate.display_name,)
|
||||
)
|
||||
|
||||
if (
|
||||
self.env["account.move.line"]
|
||||
.sudo()
|
||||
.search(
|
||||
[
|
||||
("mandate_id", "=", mandate.id),
|
||||
("company_id", "!=", mandate.company_id.id),
|
||||
],
|
||||
limit=1,
|
||||
)
|
||||
):
|
||||
raise ValidationError(
|
||||
_(
|
||||
"You cannot change the company of mandate %s, "
|
||||
"as there exists journal items referencing it that "
|
||||
"belong to another company."
|
||||
)
|
||||
% (mandate.display_name,)
|
||||
)
|
||||
|
||||
if (
|
||||
self.env["bank.payment.line"]
|
||||
.sudo()
|
||||
.search(
|
||||
[
|
||||
("mandate_id", "=", mandate.id),
|
||||
("company_id", "!=", mandate.company_id.id),
|
||||
],
|
||||
limit=1,
|
||||
)
|
||||
):
|
||||
raise ValidationError(
|
||||
_(
|
||||
"You cannot change the company of mandate %s, "
|
||||
"as there exists bank payment lines referencing it that "
|
||||
"belong to another company."
|
||||
)
|
||||
% (mandate.display_name,)
|
||||
)
|
||||
|
||||
@api.constrains("state", "partner_bank_id", "signature_date")
|
||||
def _check_valid_state(self):
|
||||
for mandate in self:
|
||||
@@ -276,7 +184,7 @@ class AccountBankingMandate(models.Model):
|
||||
vals["unique_mandate_reference"] = (
|
||||
self.env["ir.sequence"].next_by_code("account.banking.mandate") or "New"
|
||||
)
|
||||
return super(AccountBankingMandate, self).create(vals)
|
||||
return super().create(vals)
|
||||
|
||||
@api.onchange("partner_bank_id")
|
||||
def mandate_partner_bank_change(self):
|
||||
@@ -288,14 +196,12 @@ class AccountBankingMandate(models.Model):
|
||||
if mandate.state != "draft":
|
||||
raise UserError(_("Mandate should be in draft state."))
|
||||
self.write({"state": "valid"})
|
||||
return True
|
||||
|
||||
def cancel(self):
|
||||
for mandate in self:
|
||||
if mandate.state not in ("draft", "valid"):
|
||||
raise UserError(_("Mandate should be in draft or valid state."))
|
||||
self.write({"state": "cancel"})
|
||||
return True
|
||||
|
||||
def back2draft(self):
|
||||
"""Allows to set the mandate back to the draft state.
|
||||
@@ -305,4 +211,3 @@ class AccountBankingMandate(models.Model):
|
||||
if mandate.state != "cancel":
|
||||
raise UserError(_("Mandate should be in cancel state."))
|
||||
self.write({"state": "draft"})
|
||||
return True
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class AccountMove(models.Model):
|
||||
@@ -14,16 +13,17 @@ class AccountMove(models.Model):
|
||||
string="Direct Debit Mandate",
|
||||
ondelete="restrict",
|
||||
readonly=True,
|
||||
check_company=True,
|
||||
states={"draft": [("readonly", False)]},
|
||||
)
|
||||
mandate_required = fields.Boolean(
|
||||
related="payment_mode_id.payment_method_id.mandate_required", readonly=True
|
||||
)
|
||||
|
||||
def post(self):
|
||||
def _post(self, soft=True):
|
||||
for record in self:
|
||||
record.line_ids.write({"mandate_id": record.mandate_id})
|
||||
return super(AccountMove, self).post()
|
||||
return super()._post(soft=soft)
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
@@ -35,15 +35,15 @@ class AccountMove(models.Model):
|
||||
}
|
||||
for onchange_method, changed_fields in list(onchanges.items()):
|
||||
if any(f not in vals for f in changed_fields):
|
||||
invoice = self.new(vals)
|
||||
invoice = invoice.with_context(force_company=invoice.company_id.id,)
|
||||
getattr(invoice, onchange_method)()
|
||||
move = self.new(vals)
|
||||
move = move.with_company(move.company_id.id)
|
||||
getattr(move, onchange_method)()
|
||||
for field in changed_fields:
|
||||
if field not in vals and invoice[field]:
|
||||
vals[field] = invoice._fields[field].convert_to_write(
|
||||
invoice[field], invoice
|
||||
if field not in vals and move[field]:
|
||||
vals[field] = move._fields[field].convert_to_write(
|
||||
move[field], move
|
||||
)
|
||||
return super(AccountMove, self).create(vals)
|
||||
return super().create(vals)
|
||||
|
||||
def set_mandate(self):
|
||||
if self.payment_mode_id.payment_method_id.mandate_required:
|
||||
@@ -54,25 +54,10 @@ class AccountMove(models.Model):
|
||||
@api.onchange("partner_id", "company_id")
|
||||
def _onchange_partner_id(self):
|
||||
"""Select by default the first valid mandate of the partner"""
|
||||
res = super(AccountMove, self)._onchange_partner_id()
|
||||
res = super()._onchange_partner_id()
|
||||
self.set_mandate()
|
||||
return res
|
||||
|
||||
@api.onchange("payment_mode_id")
|
||||
def _onchange_payment_mode_id(self):
|
||||
self.set_mandate()
|
||||
|
||||
@api.constrains("mandate_id", "company_id")
|
||||
def _check_company_constrains(self):
|
||||
for inv in self:
|
||||
if (
|
||||
inv.mandate_id.company_id
|
||||
and inv.mandate_id.company_id != inv.company_id
|
||||
):
|
||||
raise ValidationError(
|
||||
_(
|
||||
"The invoice %s has a different company than "
|
||||
"that of the linked mandate %s)."
|
||||
)
|
||||
% (inv.name, inv.mandate_id.display_name)
|
||||
)
|
||||
|
||||
@@ -3,19 +3,19 @@
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class AccountMoveLine(models.Model):
|
||||
_inherit = "account.move.line"
|
||||
|
||||
mandate_id = fields.Many2one(
|
||||
"account.banking.mandate", string="Direct Debit Mandate", ondelete="restrict"
|
||||
"account.banking.mandate", string="Direct Debit Mandate", ondelete="restrict",
|
||||
check_company=True,
|
||||
)
|
||||
|
||||
def _prepare_payment_line_vals(self, payment_order):
|
||||
vals = super(AccountMoveLine, self)._prepare_payment_line_vals(payment_order)
|
||||
vals = super()._prepare_payment_line_vals(payment_order)
|
||||
if payment_order.payment_type != "inbound":
|
||||
return vals
|
||||
mandate = self.mandate_id
|
||||
@@ -36,16 +36,3 @@ class AccountMoveLine(models.Model):
|
||||
}
|
||||
)
|
||||
return vals
|
||||
|
||||
@api.constrains("mandate_id", "company_id")
|
||||
def _check_company_constrains(self):
|
||||
for ml in self:
|
||||
mandate = ml.mandate_id
|
||||
if mandate.company_id and mandate.company_id != ml.company_id:
|
||||
raise ValidationError(
|
||||
_(
|
||||
"The item %s of journal %s has a different company than "
|
||||
"that of the linked mandate %s)."
|
||||
)
|
||||
% (ml.name, ml.move_id.name, ml.mandate_id.display_name)
|
||||
)
|
||||
|
||||
@@ -14,6 +14,7 @@ class AccountPaymentLine(models.Model):
|
||||
comodel_name="account.banking.mandate",
|
||||
string="Direct Debit Mandate",
|
||||
domain=[("state", "=", "valid")],
|
||||
check_company=True,
|
||||
)
|
||||
mandate_required = fields.Boolean(
|
||||
related="order_id.payment_method_id.mandate_required", readonly=True
|
||||
@@ -57,7 +58,7 @@ class AccountPaymentLine(models.Model):
|
||||
)
|
||||
|
||||
def draft2open_payment_line_check(self):
|
||||
res = super(AccountPaymentLine, self).draft2open_payment_line_check()
|
||||
res = super().draft2open_payment_line_check()
|
||||
if self.mandate_required and not self.mandate_id:
|
||||
raise UserError(_("Missing Mandate on payment line %s") % self.name)
|
||||
return res
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# Copyright 2016-2020 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
@@ -13,12 +13,11 @@ class BankPaymentLine(models.Model):
|
||||
comodel_name="account.banking.mandate",
|
||||
string="Direct Debit Mandate",
|
||||
related="payment_line_ids.mandate_id",
|
||||
check_company=True,
|
||||
)
|
||||
|
||||
@api.model
|
||||
def same_fields_payment_line_and_bank_payment_line(self):
|
||||
res = super(
|
||||
BankPaymentLine, self
|
||||
).same_fields_payment_line_and_bank_payment_line()
|
||||
res = super().same_fields_payment_line_and_bank_payment_line()
|
||||
res.append("mandate_id")
|
||||
return res
|
||||
|
||||
@@ -30,13 +30,11 @@ class ResPartner(models.Model):
|
||||
|
||||
def _compute_valid_mandate_id(self):
|
||||
# Dict for reducing the duplicated searches on parent/child partners
|
||||
company_id = self.env.context.get("force_company", False)
|
||||
company_id = self.env.company.id
|
||||
if company_id:
|
||||
company = self.env["res.company"].browse(company_id)
|
||||
else:
|
||||
company = self.env["res.company"]._company_default_get(
|
||||
"account.banking.mandate"
|
||||
)
|
||||
company = self.env.company
|
||||
|
||||
mandates_dic = {}
|
||||
for partner in self:
|
||||
|
||||
@@ -1 +1 @@
|
||||
To use this module, see menu "Invoicing/Accounting > Payments > Debit Orders"
|
||||
To use this module, see menu "Invoicing/Accounting > Customers > Debit Orders"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import fields
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.tests.common import TransactionCase
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ class TestInvoiceMandate(TransactionCase):
|
||||
lambda s: s.account_id == self.invoice_account
|
||||
)
|
||||
if payable_move_lines:
|
||||
with self.assertRaises(ValidationError):
|
||||
with self.assertRaises(UserError):
|
||||
payable_move_lines[0].mandate_id = mandate_2
|
||||
|
||||
def test_post_invoice_and_refund_02(self):
|
||||
@@ -107,7 +107,7 @@ class TestInvoiceMandate(TransactionCase):
|
||||
invoice = self.env["account.move"].new(
|
||||
{
|
||||
"partner_id": self.partner.id,
|
||||
"type": "out_invoice",
|
||||
"move_type": "out_invoice",
|
||||
"company_id": self.company.id,
|
||||
}
|
||||
)
|
||||
@@ -120,7 +120,7 @@ class TestInvoiceMandate(TransactionCase):
|
||||
invoice = self.env["account.move"].new(
|
||||
{
|
||||
"partner_id": self.partner.id,
|
||||
"type": "out_invoice",
|
||||
"move_type": "out_invoice",
|
||||
"company_id": self.company.id,
|
||||
}
|
||||
)
|
||||
@@ -171,12 +171,12 @@ class TestInvoiceMandate(TransactionCase):
|
||||
invoice = self.env["account.move"].create(
|
||||
{
|
||||
"partner_id": self.partner.id,
|
||||
"type": "out_invoice",
|
||||
"move_type": "out_invoice",
|
||||
"company_id": self.company.id,
|
||||
}
|
||||
)
|
||||
|
||||
with self.assertRaises(ValidationError):
|
||||
with self.assertRaises(UserError):
|
||||
invoice.mandate_id = mandate_2
|
||||
|
||||
def _create_res_partner(self, name):
|
||||
@@ -228,8 +228,10 @@ class TestInvoiceMandate(TransactionCase):
|
||||
}
|
||||
)
|
||||
bank_journal = self.env["account.journal"].search(
|
||||
[("type", "=", "bank")], limit=1
|
||||
)
|
||||
[
|
||||
("type", "=", "bank"),
|
||||
('company_id', '=', self.company.id),
|
||||
], limit=1)
|
||||
self.mode_inbound_acme.variable_journal_ids = bank_journal
|
||||
self.mode_inbound_acme.payment_method_id.mandate_required = True
|
||||
self.mode_inbound_acme.payment_order_ok = True
|
||||
@@ -279,10 +281,12 @@ class TestInvoiceMandate(TransactionCase):
|
||||
self.invoice = self.env["account.move"].create(
|
||||
{
|
||||
"partner_id": self.partner.id,
|
||||
"type": "out_invoice",
|
||||
"move_type": "out_invoice",
|
||||
"company_id": self.company.id,
|
||||
"journal_id": self.env["account.journal"]
|
||||
.search([("type", "=", "sale")], limit=1)
|
||||
.search([
|
||||
("type", "=", "sale"),
|
||||
('company_id', '=', self.company.id)], limit=1)
|
||||
.id,
|
||||
"invoice_line_ids": invoice_vals,
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ class TestMandate(TransactionCase):
|
||||
bank_account_2 = self.env.ref("account_payment_mode.res_partner_2_iban")
|
||||
mandate.partner_bank_id = bank_account_2
|
||||
mandate.mandate_partner_bank_change()
|
||||
self.assertEquals(mandate.partner_id, bank_account_2.partner_id)
|
||||
self.assertEqual(mandate.partner_id, bank_account_2.partner_id)
|
||||
|
||||
def test_constrains_01(self):
|
||||
bank_account = self.env.ref("account_payment_mode.res_partner_12_iban")
|
||||
@@ -106,7 +106,7 @@ class TestMandate(TransactionCase):
|
||||
}
|
||||
)
|
||||
|
||||
with self.assertRaises(ValidationError):
|
||||
with self.assertRaises(UserError):
|
||||
mandate.company_id = self.company_2
|
||||
|
||||
def test_constrains_03(self):
|
||||
@@ -125,7 +125,7 @@ class TestMandate(TransactionCase):
|
||||
"partner_id": self.company_2.partner_id.id,
|
||||
}
|
||||
)
|
||||
with self.assertRaises(ValidationError):
|
||||
with self.assertRaises(UserError):
|
||||
mandate.partner_bank_id = bank_account_2
|
||||
|
||||
def test_constrains_04(self):
|
||||
@@ -139,7 +139,7 @@ class TestMandate(TransactionCase):
|
||||
"partner_id": self.company_2.partner_id.id,
|
||||
}
|
||||
)
|
||||
with self.assertRaises(ValidationError):
|
||||
with self.assertRaises(UserError):
|
||||
bank_account.mandate_ids += mandate
|
||||
|
||||
def test_mandate_reference_01(self):
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!--
|
||||
© 2013-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
Copyright 2013-2020 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
<odoo>
|
||||
@@ -15,26 +15,29 @@
|
||||
type="object"
|
||||
string="Validate"
|
||||
states="draft"
|
||||
class="oe_highlight"
|
||||
class="btn-primary"
|
||||
invisible="context.get('mandate_bank_partner_view')"
|
||||
groups="account_payment_order.group_account_payment"
|
||||
/>
|
||||
<button
|
||||
name="cancel"
|
||||
type="object"
|
||||
string="Cancel"
|
||||
states="draft,valid"
|
||||
confirm="Are you sure you want to cancel this mandate?"
|
||||
invisible="context.get('mandate_bank_partner_view')"
|
||||
groups="account_payment_order.group_account_payment"
|
||||
/>
|
||||
<button
|
||||
name="back2draft"
|
||||
type="object"
|
||||
string="Back to Draft"
|
||||
states="cancel"
|
||||
groups="account.group_account_manager"
|
||||
groups="account_payment_order.group_account_payment"
|
||||
confirm="You should set a mandate back to draft only if you cancelled it by mistake. Do you want to continue?"
|
||||
invisible="context.get('mandate_bank_partner_view')"
|
||||
/>
|
||||
<field name="state" widget="statusbar" />
|
||||
<field name="state" widget="statusbar" statusbar_visible="draft,valid,expired"/>
|
||||
</header>
|
||||
<sheet>
|
||||
<div class="oe_button_box" name="button_box" />
|
||||
@@ -61,13 +64,15 @@
|
||||
invisible="context.get('mandate_bank_partner_view')"
|
||||
readonly="True"
|
||||
/>
|
||||
<field name="signature_date" />
|
||||
<field name="signature_date"
|
||||
options="{'datepicker': {'warn_future': true}}"/>
|
||||
<field name="scan" />
|
||||
<field name="last_debit_date" />
|
||||
</group>
|
||||
</sheet>
|
||||
<div class="oe_chatter">
|
||||
<field name="message_follower_ids" widget="mail_followers" />
|
||||
<field name="activity_ids" widget="mail_activity"/>
|
||||
<field name="message_ids" widget="mail_thread" />
|
||||
</div>
|
||||
</form>
|
||||
@@ -103,44 +108,51 @@
|
||||
<field name="name">view.mandate.tree</field>
|
||||
<field name="model">account.banking.mandate</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree
|
||||
string="Banking Mandate"
|
||||
decoration-info="state=='draft'"
|
||||
decoration-muted="state in ('expired','cancel')"
|
||||
>
|
||||
<tree string="Banking Mandate">
|
||||
<field name="id" invisible="1" />
|
||||
<field name="company_id" groups="base.group_multi_company" />
|
||||
<field name="unique_mandate_reference" string="Reference" />
|
||||
<field
|
||||
name="partner_id"
|
||||
invisible="context.get('mandate_bank_partner_view')"
|
||||
/>
|
||||
<field name="format" string="Format" />
|
||||
<field name="unique_mandate_reference" string="Reference" />
|
||||
<field
|
||||
name="format"
|
||||
string="Format"
|
||||
widget="badge"
|
||||
decoration-muted="format == 'basic'"
|
||||
/>
|
||||
<field
|
||||
name="type"
|
||||
string="Type"
|
||||
widget="badge"
|
||||
decoration-muted="type == 'generic'"
|
||||
/>
|
||||
<field name="signature_date" string="Signature Date" />
|
||||
<field name="last_debit_date" />
|
||||
<field name="company_id" groups="base.group_multi_company" />
|
||||
<button
|
||||
name="validate"
|
||||
type="object"
|
||||
icon="fa-check"
|
||||
string="Validate"
|
||||
groups="account_payment_order.group_account_payment"
|
||||
attrs="{'invisible': ['|', ('id', '=', False), ('state', '!=', 'draft')]}"
|
||||
/>
|
||||
<button
|
||||
name="cancel"
|
||||
type="object"
|
||||
icon="fa-times"
|
||||
string="Cancel"
|
||||
attrs="{'invisible': ['|', ('id', '=', False), ('state', '=', 'cancel')]}"
|
||||
/>
|
||||
<!-- Removed cancel button in tree view. Too dangerous.
|
||||
'confirm' attribute doesn't work in tree view. -->
|
||||
<button
|
||||
name="back2draft"
|
||||
type="object"
|
||||
icon="fa-undo"
|
||||
string="Draft"
|
||||
groups="account.group_account_manager"
|
||||
groups="account_payment_order.group_account_payment"
|
||||
attrs="{'invisible': ['|', ('id', '=', False), ('state', '!=', 'cancel')]}"
|
||||
/>
|
||||
<field name="state" />
|
||||
<field name="state" widget="badge"
|
||||
decoration-info="state == 'draft'"
|
||||
decoration-success="state == 'valid'"
|
||||
decoration-muted="state == 'cancel'"
|
||||
decoration-warning="state == 'expired'"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
@@ -165,16 +177,16 @@
|
||||
string="Valid"
|
||||
domain="[('state', '=', 'valid')]"
|
||||
/>
|
||||
<filter
|
||||
name="cancel"
|
||||
string="Cancelled"
|
||||
domain="[('state', '=', 'cancel')]"
|
||||
/>
|
||||
<filter
|
||||
name="expired"
|
||||
string="Expired"
|
||||
domain="[('state', '=', 'expired')]"
|
||||
/>
|
||||
<filter
|
||||
name="cancel"
|
||||
string="Cancelled"
|
||||
domain="[('state', '=', 'cancel')]"
|
||||
/>
|
||||
<group string="Group By" name="groupby">
|
||||
<filter
|
||||
name="state_groupby"
|
||||
@@ -186,6 +198,12 @@
|
||||
string="Signature Date"
|
||||
context="{'group_by': 'signature_date'}"
|
||||
/>
|
||||
<filter
|
||||
name="partner_groupby"
|
||||
string="Partner"
|
||||
context="{'group_by': 'partner_id'}"
|
||||
/>
|
||||
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<field name="model">account.move</field>
|
||||
<field name="inherit_id" ref="account_payment_partner.view_move_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="invoice_partner_bank_id" position="after">
|
||||
<field name="partner_bank_id" position="after">
|
||||
<field
|
||||
name="mandate_id"
|
||||
domain="[('partner_id', '=', commercial_partner_id), ('state', '=', 'valid')]"
|
||||
|
||||
Reference in New Issue
Block a user