[MIG] account_payment_mandate: Migration to 11.0

This commit is contained in:
etobella
2017-10-16 16:28:26 +02:00
committed by Reyes4711
parent 15eb8d72e6
commit e7f520e410
21 changed files with 99 additions and 26 deletions

View File

@@ -34,7 +34,7 @@ To use this module, see menu "Accounting > payment > SEPA direct debit mandates"
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/173/9.0
:target: https://runbot.odoo-community.org/runbot/173/11.0
Known issues / Roadmap
======================
@@ -65,12 +65,12 @@ Contributors
Maintainer
----------
.. image:: http://odoo-community.org/logo.png
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: http://odoo-community.org
:target: https://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
To contribute to this module, please visit http://odoo-community.org.
To contribute to this module, please visit https://odoo-community.org.

View File

@@ -2,12 +2,12 @@
# © 2014 Compassion CH - Cyril Sester <csester@compassion.ch>
# © 2014 Tecnativa - Pedro M. Baeza
# © 2015-2016 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
'name': 'Account Banking Mandate',
'summary': 'Banking mandates',
'version': '10.0.1.1.2',
'version': '11.0.1.0.1',
'license': 'AGPL-3',
'author': "Compassion CH, "
"Tecnativa, "

View File

@@ -2,7 +2,7 @@
# © 2014 Compassion CH - Cyril Sester <csester@compassion.ch>
# © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza
# © 2015-2016 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import models, fields, api, _
from odoo.exceptions import UserError, ValidationError
@@ -22,6 +22,11 @@ class AccountBankingMandate(models.Model):
format = fields.Selection(
[('basic', 'Basic Mandate')], default='basic', required=True,
string='Mandate Format', track_visibility='onchange')
type = fields.Selection(
[('generic', 'Generic Mandate')],
string='Type of Mandate',
track_visibility='onchange'
)
partner_bank_id = fields.Many2one(
comodel_name='res.partner.bank', string='Bank Account',
track_visibility='onchange')

View File

@@ -2,7 +2,7 @@
# © 2014 Compassion CH - Cyril Sester <csester@compassion.ch>
# © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza
# © 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import models, fields, api
@@ -36,7 +36,7 @@ class AccountInvoice(models.Model):
onchanges = {
'_onchange_partner_id': ['mandate_id'],
}
for onchange_method, changed_fields in onchanges.items():
for onchange_method, changed_fields in list(onchanges.items()):
if any(f not in vals for f in changed_fields):
invoice = self.new(vals)
getattr(invoice, onchange_method)()
@@ -84,8 +84,8 @@ class AccountInvoice(models.Model):
return res
@api.onchange('payment_mode_id')
def payment_mode_id_change(self):
super(AccountInvoice, self).payment_mode_id_change()
def _onchange_payment_mode_id(self):
super(AccountInvoice, self)._onchange_payment_mode_id()
if (
self.payment_mode_id and
self.payment_mode_id.payment_type == 'inbound' and

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# © 2016 Akretion (http://www.akretion.com/)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import models, fields, api

View File

@@ -2,7 +2,7 @@
# © 2014 Compassion CH - Cyril Sester <csester@compassion.ch>
# © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza
# © 2015-2016 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError, UserError

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# © 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import models, fields

View File

@@ -2,7 +2,7 @@
# © 2014 Compassion CH - Cyril Sester <csester@compassion.ch>
# © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza
# © 2015-2016 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import models, fields, api

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# © 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import models, fields, api

View File

@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# © 2014 Compassion CH - Cyril Sester <csester@compassion.ch>
# © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import models, fields

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2015-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo noupdate="1">

View File

@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from . import test_mandate
from . import test_invoice_mandate

View File

@@ -0,0 +1,65 @@
# -*- coding: utf-8 -*-
# © 2017 Creu Blanca
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo.tests.common import TransactionCase
class TestInvoiceMandate(TransactionCase):
def test_post_invoice_and_refund(self):
self.invoice._onchange_partner_id()
self.invoice.action_invoice_open()
self.env['account.invoice.payment.line.multi'].with_context(
active_model='account.invoice',
active_ids=self.invoice.ids
).create({}).run()
payment_order = self.env['account.payment.order'].search([])
self.assertEqual(len(payment_order.ids), 1)
payment_order.draft2open()
payment_order.open2generated()
payment_order.generated2uploaded()
def test_post_invoice_and_refund(self):
self.invoice._onchange_partner_id()
self.invoice.action_invoice_open()
self.assertEqual(self.invoice.mandate_id, self.mandate)
self.invoice.refund()
def setUp(self):
res = super(TestInvoiceMandate, self).setUp()
self.partner = self.env.ref('base.res_partner_12')
bank_account = self.env.ref('account_payment_mode.res_partner_12_iban')
self.mandate = self.env['account.banking.mandate'].create({
'partner_bank_id': bank_account.id,
'signature_date': '2015-01-01',
})
self.mandate.validate()
mode = self.env.ref('account_payment_mode.payment_mode_inbound_ct1')
self.partner.customer_payment_mode_id = mode
mode.payment_method_id.mandate_required = True
invoice_account = self.env['account.account'].search(
[('user_type_id', '=', self.env.ref(
'account.data_account_type_payable').id)],
limit=1).id
invoice_line_account = self.env['account.account'].search(
[('user_type_id', '=', self.env.ref(
'account.data_account_type_expenses').id)],
limit=1).id
self.invoice = self.env['account.invoice'].create({
'partner_id': self.partner.id,
'account_id': invoice_account,
'type': 'out_invoice'
})
self.env['account.invoice.line'].create({
'product_id': self.env.ref('product.product_product_4').id,
'quantity': 1.0,
'price_unit': 100.0,
'invoice_id': self.invoice.id,
'name': 'product that cost 100',
'account_id': invoice_line_account,
})
return res

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# © 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo.tests.common import TransactionCase
@@ -16,6 +16,7 @@ class TestMandate(TransactionCase):
self.assertEqual(mandate.state, 'draft')
mandate.validate()
self.assertEqual(mandate.state, 'valid')
self.assertEqual(bank_account.partner_id.mandate_count, 1)
mandate.cancel()
self.assertEqual(mandate.state, 'cancel')
mandate.back2draft()

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2013-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo>
@@ -30,6 +30,7 @@
<group name="main">
<field name="company_id" groups="base.group_multi_company"/>
<field name="format" string="Format"/>
<field name="type" string="Type"/>
<field name="partner_bank_id"
invisible="context.get('mandate_bank_partner_view')" />
<field name="partner_id"

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2013-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2013-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2015-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2013-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo>