[MIG] account_banking_mandate: Finish migration to v12

* Adapted test
* Removed unneeded constraint
* Fixed view for accessibility
This commit is contained in:
Pedro M. Baeza
2018-12-13 19:26:53 +01:00
parent e213d09316
commit f83ce92f88
3 changed files with 15 additions and 15 deletions

View File

@@ -3,8 +3,7 @@
# Copyright 2015-16 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
# 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 BankPaymentLine(models.Model):
@@ -20,13 +19,3 @@ class BankPaymentLine(models.Model):
same_fields_payment_line_and_bank_payment_line()
res.append('mandate_id')
return res
@api.constrains('mandate_id', 'company_id')
def _check_company_constrains(self):
for line in self:
if line.mandate_id.company_id and line.mandate_id.company_id != \
line.company_id:
raise ValidationError(_(
"The bank payment line %s has a different company than "
"that of the linked mandate %s).") %
(line.name, line.mandate_id.display_name))

View File

@@ -107,6 +107,7 @@ class TestMandate(TransactionCase):
bank_account_2 = self.env['res.partner.bank'].create({
'acc_number': '1234',
'company_id': self.company_2.id,
'partner_id': self.company_2.partner_id.id,
})
with self.assertRaises(ValidationError):
mandate.partner_bank_id = bank_account_2
@@ -119,6 +120,7 @@ class TestMandate(TransactionCase):
bank_account = self.env['res.partner.bank'].create({
'acc_number': '1234',
'company_id': self.company_2.id,
'partner_id': self.company_2.partner_id.id,
})
with self.assertRaises(ValidationError):
bank_account.mandate_ids += mandate

View File

@@ -68,11 +68,20 @@
<field name="unique_mandate_reference" string="Reference"/>
<field name="signature_date" string="Signature Date"/>
<field name="last_debit_date"/>
<button name="validate" type="object" icon="fa-check"
<button name="validate"
type="object"
icon="fa-check"
string="Validate"
attrs="{'invisible': ['|', ('id', '=', False), ('state', '!=', 'draft')]}"/>
<button name="cancel" type="object" icon="fa-times"
<button name="cancel"
type="object"
icon="fa-times"
string="Cancel"
attrs="{'invisible': ['|', ('id', '=', False), ('state', '=', 'cancel')]}"/>
<button name="back2draft" type="object" icon="fa-undo"
<button name="back2draft"
type="object"
icon="fa-undo"
string="Draft"
groups="account.group_account_manager"
attrs="{'invisible': ['|', ('id', '=', False), ('state', '!=', 'cancel')]}"/>
<field name="state"/>