mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[MIG] account_banking_mandate: Migration to 13.0
This commit is contained in:
@@ -14,13 +14,13 @@ Account Banking Mandate
|
|||||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||||
:alt: License: AGPL-3
|
:alt: License: AGPL-3
|
||||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fbank--payment-lightgray.png?logo=github
|
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fbank--payment-lightgray.png?logo=github
|
||||||
:target: https://github.com/OCA/bank-payment/tree/12.0/account_banking_mandate
|
:target: https://github.com/OCA/bank-payment/tree/13.0/account_banking_mandate
|
||||||
:alt: OCA/bank-payment
|
:alt: OCA/bank-payment
|
||||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||||
:target: https://translation.odoo-community.org/projects/bank-payment-12-0/bank-payment-12-0-account_banking_mandate
|
:target: https://translation.odoo-community.org/projects/bank-payment-13-0/bank-payment-13-0-account_banking_mandate
|
||||||
:alt: Translate me on Weblate
|
:alt: Translate me on Weblate
|
||||||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
||||||
:target: https://runbot.odoo-community.org/runbot/173/12.0
|
:target: https://runbot.odoo-community.org/runbot/173/13.0
|
||||||
:alt: Try me on Runbot
|
:alt: Try me on Runbot
|
||||||
|
|
||||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||||
@@ -58,7 +58,7 @@ Bug Tracker
|
|||||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/bank-payment/issues>`_.
|
Bugs are tracked on `GitHub Issues <https://github.com/OCA/bank-payment/issues>`_.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||||
`feedback <https://github.com/OCA/bank-payment/issues/new?body=module:%20account_banking_mandate%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
`feedback <https://github.com/OCA/bank-payment/issues/new?body=module:%20account_banking_mandate%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||||
|
|
||||||
Do not contact contributors directly about support or help with technical issues.
|
Do not contact contributors directly about support or help with technical issues.
|
||||||
|
|
||||||
@@ -82,6 +82,7 @@ Contributors
|
|||||||
* Sergio Teruel <sergio.teruel@tecnativa.com>
|
* Sergio Teruel <sergio.teruel@tecnativa.com>
|
||||||
* Cédric Pigeon <cedric.pigeon@acsone.eu>
|
* Cédric Pigeon <cedric.pigeon@acsone.eu>
|
||||||
* Carlos Dauden <carlos.dauden@tecnativa.com>
|
* Carlos Dauden <carlos.dauden@tecnativa.com>
|
||||||
|
* Marçal Isern <marsal.isern@qubiq.es>
|
||||||
|
|
||||||
Maintainers
|
Maintainers
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
@@ -96,6 +97,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
|
|||||||
mission is to support the collaborative development of Odoo features and
|
mission is to support the collaborative development of Odoo features and
|
||||||
promote its widespread use.
|
promote its widespread use.
|
||||||
|
|
||||||
This module is part of the `OCA/bank-payment <https://github.com/OCA/bank-payment/tree/12.0/account_banking_mandate>`_ project on GitHub.
|
This module is part of the `OCA/bank-payment <https://github.com/OCA/bank-payment/tree/13.0/account_banking_mandate>`_ project on GitHub.
|
||||||
|
|
||||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Account Banking Mandate",
|
"name": "Account Banking Mandate",
|
||||||
"summary": "Banking mandates",
|
"summary": "Banking mandates",
|
||||||
"version": "12.0.2.0.0",
|
"version": "13.0.1.0.0",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"author": "Compassion CH, "
|
"author": "Compassion CH, "
|
||||||
"Tecnativa, "
|
"Tecnativa, "
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
"data": [
|
"data": [
|
||||||
"views/account_banking_mandate_view.xml",
|
"views/account_banking_mandate_view.xml",
|
||||||
"views/account_payment_method.xml",
|
"views/account_payment_method.xml",
|
||||||
"views/account_invoice_view.xml",
|
"views/account_move_view.xml",
|
||||||
"views/account_payment_line.xml",
|
"views/account_payment_line.xml",
|
||||||
"views/res_partner_bank_view.xml",
|
"views/res_partner_bank_view.xml",
|
||||||
"views/res_partner.xml",
|
"views/res_partner.xml",
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
# Copyright 2019 Tecnativa - Pedro M. Baeza
|
|
||||||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
|
||||||
|
|
||||||
from openupgradelib import openupgrade, openupgrade_90
|
|
||||||
|
|
||||||
|
|
||||||
@openupgrade.migrate(use_env=True)
|
|
||||||
def migrate(env, version):
|
|
||||||
column = openupgrade.get_legacy_name("scan")
|
|
||||||
if openupgrade.column_exists(env.cr, "account_banking_mandate", column):
|
|
||||||
openupgrade_90.convert_binary_field_to_attachment(
|
|
||||||
env, {"account.banking.mandate": [("scan", None)]},
|
|
||||||
)
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
# Copyright 2019 Tecnativa - Pedro M. Baeza
|
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|
||||||
|
|
||||||
from openupgradelib import openupgrade
|
|
||||||
|
|
||||||
column_renames = {
|
|
||||||
"account_banking_mandate": [("scan", None)],
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@openupgrade.migrate()
|
|
||||||
def migrate(env, version):
|
|
||||||
if openupgrade.column_exists(env.cr, "account_banking_mandate", "scan"):
|
|
||||||
openupgrade.rename_columns(env.cr, column_renames)
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
from . import account_banking_mandate
|
from . import account_banking_mandate
|
||||||
from . import account_payment_method
|
from . import account_payment_method
|
||||||
from . import account_invoice
|
from . import account_move
|
||||||
from . import res_partner_bank
|
from . import res_partner_bank
|
||||||
from . import res_partner
|
from . import res_partner
|
||||||
from . import account_payment_line
|
from . import account_payment_line
|
||||||
|
|||||||
@@ -56,17 +56,15 @@ class AccountBankingMandate(models.Model):
|
|||||||
comodel_name="res.company",
|
comodel_name="res.company",
|
||||||
string="Company",
|
string="Company",
|
||||||
required=True,
|
required=True,
|
||||||
default=lambda self: self.env["res.company"]._company_default_get(
|
default=lambda self: self.env.company,
|
||||||
"account.banking.mandate"
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
unique_mandate_reference = fields.Char(
|
unique_mandate_reference = fields.Char(
|
||||||
string="Unique Mandate Reference", track_visibility="onchange", copy=False,
|
string="Unique Mandate Reference", track_visibility="onchange", copy=False
|
||||||
)
|
)
|
||||||
signature_date = fields.Date(
|
signature_date = fields.Date(
|
||||||
string="Date of Signature of the Mandate", track_visibility="onchange"
|
string="Date of Signature of the Mandate", track_visibility="onchange"
|
||||||
)
|
)
|
||||||
scan = fields.Binary(string="Scan of the Mandate", attachment=True,)
|
scan = fields.Binary(string="Scan of the Mandate")
|
||||||
last_debit_date = fields.Date(string="Date of the Last Debit", readonly=True)
|
last_debit_date = fields.Date(string="Date of the Last Debit", readonly=True)
|
||||||
state = fields.Selection(
|
state = fields.Selection(
|
||||||
[
|
[
|
||||||
@@ -86,7 +84,7 @@ class AccountBankingMandate(models.Model):
|
|||||||
inverse_name="mandate_id",
|
inverse_name="mandate_id",
|
||||||
string="Related Payment Lines",
|
string="Related Payment Lines",
|
||||||
)
|
)
|
||||||
payment_line_ids_count = fields.Integer(compute="_compute_payment_line_ids_count",)
|
payment_line_ids_count = fields.Integer(compute="_compute_payment_line_ids_count")
|
||||||
|
|
||||||
_sql_constraints = [
|
_sql_constraints = [
|
||||||
(
|
(
|
||||||
@@ -106,13 +104,12 @@ class AccountBankingMandate(models.Model):
|
|||||||
result.append((mandate.id, name))
|
result.append((mandate.id, name))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.depends("payment_line_ids")
|
@api.depends("payment_line_ids")
|
||||||
def _compute_payment_line_ids_count(self):
|
def _compute_payment_line_ids_count(self):
|
||||||
payment_line_model = self.env["account.payment.line"]
|
payment_line_model = self.env["account.payment.line"]
|
||||||
domain = [("mandate_id", "in", self.ids)]
|
domain = [("mandate_id", "in", self.ids)]
|
||||||
res = payment_line_model.read_group(
|
res = payment_line_model.read_group(
|
||||||
domain=domain, fields=["mandate_id"], groupby=["mandate_id"],
|
domain=domain, fields=["mandate_id"], groupby=["mandate_id"]
|
||||||
)
|
)
|
||||||
payment_line_dict = {}
|
payment_line_dict = {}
|
||||||
for dic in res:
|
for dic in res:
|
||||||
@@ -122,7 +119,6 @@ class AccountBankingMandate(models.Model):
|
|||||||
for rec in self:
|
for rec in self:
|
||||||
rec.payment_line_ids_count = payment_line_dict.get(rec.id, 0)
|
rec.payment_line_ids_count = payment_line_dict.get(rec.id, 0)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def show_payment_lines(self):
|
def show_payment_lines(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
return {
|
return {
|
||||||
@@ -133,7 +129,6 @@ class AccountBankingMandate(models.Model):
|
|||||||
"domain": [("mandate_id", "=", self.id)],
|
"domain": [("mandate_id", "=", self.id)],
|
||||||
}
|
}
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.constrains("signature_date", "last_debit_date")
|
@api.constrains("signature_date", "last_debit_date")
|
||||||
def _check_dates(self):
|
def _check_dates(self):
|
||||||
for mandate in self:
|
for mandate in self:
|
||||||
@@ -194,7 +189,7 @@ class AccountBankingMandate(models.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
self.env["account.invoice"]
|
self.env["account.move"]
|
||||||
.sudo()
|
.sudo()
|
||||||
.search(
|
.search(
|
||||||
[
|
[
|
||||||
@@ -253,7 +248,6 @@ class AccountBankingMandate(models.Model):
|
|||||||
% (mandate.display_name,)
|
% (mandate.display_name,)
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.constrains("state", "partner_bank_id", "signature_date")
|
@api.constrains("state", "partner_bank_id", "signature_date")
|
||||||
def _check_valid_state(self):
|
def _check_valid_state(self):
|
||||||
for mandate in self:
|
for mandate in self:
|
||||||
@@ -284,13 +278,11 @@ class AccountBankingMandate(models.Model):
|
|||||||
)
|
)
|
||||||
return super(AccountBankingMandate, self).create(vals)
|
return super(AccountBankingMandate, self).create(vals)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.onchange("partner_bank_id")
|
@api.onchange("partner_bank_id")
|
||||||
def mandate_partner_bank_change(self):
|
def mandate_partner_bank_change(self):
|
||||||
for mandate in self:
|
for mandate in self:
|
||||||
mandate.partner_id = mandate.partner_bank_id.partner_id
|
mandate.partner_id = mandate.partner_bank_id.partner_id
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
for mandate in self:
|
for mandate in self:
|
||||||
if mandate.state != "draft":
|
if mandate.state != "draft":
|
||||||
@@ -298,7 +290,6 @@ class AccountBankingMandate(models.Model):
|
|||||||
self.write({"state": "valid"})
|
self.write({"state": "valid"})
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def cancel(self):
|
def cancel(self):
|
||||||
for mandate in self:
|
for mandate in self:
|
||||||
if mandate.state not in ("draft", "valid"):
|
if mandate.state not in ("draft", "valid"):
|
||||||
@@ -306,7 +297,6 @@ class AccountBankingMandate(models.Model):
|
|||||||
self.write({"state": "cancel"})
|
self.write({"state": "cancel"})
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def back2draft(self):
|
def back2draft(self):
|
||||||
"""Allows to set the mandate back to the draft state.
|
"""Allows to set the mandate back to the draft state.
|
||||||
This is for mandates cancelled by mistake.
|
This is for mandates cancelled by mistake.
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
# Copyright 2014 Compassion CH - Cyril Sester <csester@compassion.ch>
|
# Copyright 2020 Marçal Isern <marsal.isern@qubiq.es>
|
||||||
# Copyright 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza
|
|
||||||
# Copyright 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
|
||||||
# Copyright 2017 Carlos Dauden <carlos.dauden@tecnativa.com>
|
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
|
|
||||||
@@ -9,8 +6,8 @@ from odoo import _, api, fields, models
|
|||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
class AccountInvoice(models.Model):
|
class AccountMove(models.Model):
|
||||||
_inherit = "account.invoice"
|
_inherit = "account.move"
|
||||||
|
|
||||||
mandate_id = fields.Many2one(
|
mandate_id = fields.Many2one(
|
||||||
"account.banking.mandate",
|
"account.banking.mandate",
|
||||||
@@ -23,15 +20,9 @@ class AccountInvoice(models.Model):
|
|||||||
related="payment_mode_id.payment_method_id.mandate_required", readonly=True
|
related="payment_mode_id.payment_method_id.mandate_required", readonly=True
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.model
|
def post(self):
|
||||||
def line_get_convert(self, line, part):
|
self.line_ids.mandate_id = self.mandate_id
|
||||||
"""Copy mandate from invoice to account move line"""
|
super(AccountMove, self).post()
|
||||||
res = super(AccountInvoice, self).line_get_convert(line, part)
|
|
||||||
if line.get("type") == "dest" and line.get("invoice_id"):
|
|
||||||
invoice = self.browse(line["invoice_id"])
|
|
||||||
if invoice.type in ("out_invoice", "out_refund"):
|
|
||||||
res["mandate_id"] = invoice.mandate_id.id or False
|
|
||||||
return res
|
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def create(self, vals):
|
def create(self, vals):
|
||||||
@@ -48,28 +39,9 @@ class AccountInvoice(models.Model):
|
|||||||
for field in changed_fields:
|
for field in changed_fields:
|
||||||
if field not in vals and invoice[field]:
|
if field not in vals and invoice[field]:
|
||||||
vals[field] = invoice._fields[field].convert_to_write(
|
vals[field] = invoice._fields[field].convert_to_write(
|
||||||
invoice[field], invoice,
|
invoice[field], invoice
|
||||||
)
|
)
|
||||||
return super(AccountInvoice, self).create(vals)
|
return super(AccountMove, self).create(vals)
|
||||||
|
|
||||||
# If a customer pays via direct debit, it's refunds should
|
|
||||||
# be deducted form the next debit by default. The module
|
|
||||||
# account_payment_partner copies payment_mode_id from invoice
|
|
||||||
# to refund, and we also need to copy mandate from invoice to refund
|
|
||||||
@api.model
|
|
||||||
def _prepare_refund(
|
|
||||||
self, invoice, date_invoice=None, date=None, description=None, journal_id=None
|
|
||||||
):
|
|
||||||
vals = super(AccountInvoice, self)._prepare_refund(
|
|
||||||
invoice,
|
|
||||||
date_invoice=date_invoice,
|
|
||||||
date=date,
|
|
||||||
description=description,
|
|
||||||
journal_id=journal_id,
|
|
||||||
)
|
|
||||||
if invoice.type == "out_invoice":
|
|
||||||
vals["mandate_id"] = invoice.mandate_id.id
|
|
||||||
return vals
|
|
||||||
|
|
||||||
def set_mandate(self):
|
def set_mandate(self):
|
||||||
if self.payment_mode_id.payment_method_id.mandate_required:
|
if self.payment_mode_id.payment_method_id.mandate_required:
|
||||||
@@ -80,13 +52,12 @@ class AccountInvoice(models.Model):
|
|||||||
@api.onchange("partner_id", "company_id")
|
@api.onchange("partner_id", "company_id")
|
||||||
def _onchange_partner_id(self):
|
def _onchange_partner_id(self):
|
||||||
"""Select by default the first valid mandate of the partner"""
|
"""Select by default the first valid mandate of the partner"""
|
||||||
res = super(AccountInvoice, self)._onchange_partner_id()
|
res = super(AccountMove, self)._onchange_partner_id()
|
||||||
self.set_mandate()
|
self.set_mandate()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@api.onchange("payment_mode_id")
|
@api.onchange("payment_mode_id")
|
||||||
def _onchange_payment_mode_id(self):
|
def _onchange_payment_mode_id(self):
|
||||||
super(AccountInvoice, self)._onchange_payment_mode_id()
|
|
||||||
self.set_mandate()
|
self.set_mandate()
|
||||||
|
|
||||||
@api.constrains("mandate_id", "company_id")
|
@api.constrains("mandate_id", "company_id")
|
||||||
@@ -14,7 +14,6 @@ class AccountMoveLine(models.Model):
|
|||||||
"account.banking.mandate", string="Direct Debit Mandate", ondelete="restrict"
|
"account.banking.mandate", string="Direct Debit Mandate", ondelete="restrict"
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _prepare_payment_line_vals(self, payment_order):
|
def _prepare_payment_line_vals(self, payment_order):
|
||||||
vals = super(AccountMoveLine, self)._prepare_payment_line_vals(payment_order)
|
vals = super(AccountMoveLine, self)._prepare_payment_line_vals(payment_order)
|
||||||
if payment_order.payment_type != "inbound":
|
if payment_order.payment_type != "inbound":
|
||||||
@@ -38,7 +37,6 @@ class AccountMoveLine(models.Model):
|
|||||||
)
|
)
|
||||||
return vals
|
return vals
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.constrains("mandate_id", "company_id")
|
@api.constrains("mandate_id", "company_id")
|
||||||
def _check_company_constrains(self):
|
def _check_company_constrains(self):
|
||||||
for ml in self:
|
for ml in self:
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ class AccountPaymentLine(models.Model):
|
|||||||
related="order_id.payment_method_id.mandate_required", readonly=True
|
related="order_id.payment_method_id.mandate_required", readonly=True
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.constrains("mandate_id", "partner_bank_id")
|
@api.constrains("mandate_id", "partner_bank_id")
|
||||||
def _check_mandate_bank_link(self):
|
def _check_mandate_bank_link(self):
|
||||||
for pline in self:
|
for pline in self:
|
||||||
@@ -42,7 +41,6 @@ class AccountPaymentLine(models.Model):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
@api.constrains("mandate_id", "company_id")
|
@api.constrains("mandate_id", "company_id")
|
||||||
def _check_company_constrains(self):
|
def _check_company_constrains(self):
|
||||||
for pline in self:
|
for pline in self:
|
||||||
@@ -58,7 +56,6 @@ class AccountPaymentLine(models.Model):
|
|||||||
% (pline.name, pline.mandate_id.display_name)
|
% (pline.name, pline.mandate_id.display_name)
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def draft2open_payment_line_check(self):
|
def draft2open_payment_line_check(self):
|
||||||
res = super(AccountPaymentLine, self).draft2open_payment_line_check()
|
res = super(AccountPaymentLine, self).draft2open_payment_line_check()
|
||||||
if self.mandate_required and not self.mandate_id:
|
if self.mandate_required and not self.mandate_id:
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# Copyright 2017 Carlos Dauden <carlos.dauden@tecnativa.com>
|
# Copyright 2017 Carlos Dauden <carlos.dauden@tecnativa.com>
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
from odoo import api, fields, models
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
class ResPartner(models.Model):
|
class ResPartner(models.Model):
|
||||||
@@ -17,7 +17,6 @@ class ResPartner(models.Model):
|
|||||||
string="First Valid Mandate",
|
string="First Valid Mandate",
|
||||||
)
|
)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _compute_mandate_count(self):
|
def _compute_mandate_count(self):
|
||||||
mandate_data = self.env["account.banking.mandate"].read_group(
|
mandate_data = self.env["account.banking.mandate"].read_group(
|
||||||
[("partner_id", "in", self.ids)], ["partner_id"], ["partner_id"]
|
[("partner_id", "in", self.ids)], ["partner_id"], ["partner_id"]
|
||||||
@@ -29,7 +28,6 @@ class ResPartner(models.Model):
|
|||||||
for partner in self:
|
for partner in self:
|
||||||
partner.mandate_count = mapped_data.get(partner.id, 0)
|
partner.mandate_count = mapped_data.get(partner.id, 0)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def _compute_valid_mandate_id(self):
|
def _compute_valid_mandate_id(self):
|
||||||
# Dict for reducing the duplicated searches on parent/child partners
|
# Dict for reducing the duplicated searches on parent/child partners
|
||||||
company_id = self.env.context.get("force_company", False)
|
company_id = self.env.context.get("force_company", False)
|
||||||
|
|||||||
@@ -5,3 +5,4 @@
|
|||||||
* Sergio Teruel <sergio.teruel@tecnativa.com>
|
* Sergio Teruel <sergio.teruel@tecnativa.com>
|
||||||
* Cédric Pigeon <cedric.pigeon@acsone.eu>
|
* Cédric Pigeon <cedric.pigeon@acsone.eu>
|
||||||
* Carlos Dauden <carlos.dauden@tecnativa.com>
|
* Carlos Dauden <carlos.dauden@tecnativa.com>
|
||||||
|
* Marçal Isern <marsal.isern@qubiq.es>
|
||||||
|
|||||||
@@ -367,7 +367,7 @@ ul.auto-toc {
|
|||||||
!! This file is generated by oca-gen-addon-readme !!
|
!! This file is generated by oca-gen-addon-readme !!
|
||||||
!! changes will be overwritten. !!
|
!! changes will be overwritten. !!
|
||||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/bank-payment/tree/12.0/account_banking_mandate"><img alt="OCA/bank-payment" src="https://img.shields.io/badge/github-OCA%2Fbank--payment-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/bank-payment-12-0/bank-payment-12-0-account_banking_mandate"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/173/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/bank-payment/tree/13.0/account_banking_mandate"><img alt="OCA/bank-payment" src="https://img.shields.io/badge/github-OCA%2Fbank--payment-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/bank-payment-13-0/bank-payment-13-0-account_banking_mandate"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/173/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||||
<p>This module adds a generic model for banking mandates.
|
<p>This module adds a generic model for banking mandates.
|
||||||
These mandates can be specialized to fit any banking mandates (such as sepa or lsv).</p>
|
These mandates can be specialized to fit any banking mandates (such as sepa or lsv).</p>
|
||||||
<p>A banking mandate is attached to a bank account and represents an
|
<p>A banking mandate is attached to a bank account and represents an
|
||||||
@@ -404,7 +404,7 @@ account.</p>
|
|||||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/bank-payment/issues">GitHub Issues</a>.
|
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/bank-payment/issues">GitHub Issues</a>.
|
||||||
In case of trouble, please check there if your issue has already been reported.
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||||
<a class="reference external" href="https://github.com/OCA/bank-payment/issues/new?body=module:%20account_banking_mandate%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
<a class="reference external" href="https://github.com/OCA/bank-payment/issues/new?body=module:%20account_banking_mandate%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="credits">
|
<div class="section" id="credits">
|
||||||
@@ -427,6 +427,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
|||||||
<li>Sergio Teruel <<a class="reference external" href="mailto:sergio.teruel@tecnativa.com">sergio.teruel@tecnativa.com</a>></li>
|
<li>Sergio Teruel <<a class="reference external" href="mailto:sergio.teruel@tecnativa.com">sergio.teruel@tecnativa.com</a>></li>
|
||||||
<li>Cédric Pigeon <<a class="reference external" href="mailto:cedric.pigeon@acsone.eu">cedric.pigeon@acsone.eu</a>></li>
|
<li>Cédric Pigeon <<a class="reference external" href="mailto:cedric.pigeon@acsone.eu">cedric.pigeon@acsone.eu</a>></li>
|
||||||
<li>Carlos Dauden <<a class="reference external" href="mailto:carlos.dauden@tecnativa.com">carlos.dauden@tecnativa.com</a>></li>
|
<li>Carlos Dauden <<a class="reference external" href="mailto:carlos.dauden@tecnativa.com">carlos.dauden@tecnativa.com</a>></li>
|
||||||
|
<li>Marçal Isern <<a class="reference external" href="mailto:marsal.isern@qubiq.es">marsal.isern@qubiq.es</a>></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="section" id="maintainers">
|
<div class="section" id="maintainers">
|
||||||
@@ -436,7 +437,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
|||||||
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||||
mission is to support the collaborative development of Odoo features and
|
mission is to support the collaborative development of Odoo features and
|
||||||
promote its widespread use.</p>
|
promote its widespread use.</p>
|
||||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/bank-payment/tree/12.0/account_banking_mandate">OCA/bank-payment</a> project on GitHub.</p>
|
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/bank-payment/tree/13.0/account_banking_mandate">OCA/bank-payment</a> project on GitHub.</p>
|
||||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
# Copyright 2017 Creu Blanca
|
# Copyright 2017 Creu Blanca
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
# 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 ValidationError
|
||||||
from odoo.tests.common import TransactionCase
|
from odoo.tests.common import TransactionCase
|
||||||
|
|
||||||
@@ -11,16 +12,16 @@ class TestInvoiceMandate(TransactionCase):
|
|||||||
|
|
||||||
self.assertEqual(self.invoice.mandate_id, self.mandate)
|
self.assertEqual(self.invoice.mandate_id, self.mandate)
|
||||||
|
|
||||||
self.invoice.action_invoice_open()
|
self.invoice.action_post()
|
||||||
|
|
||||||
payable_move_lines = self.invoice.move_id.line_ids.filtered(
|
payable_move_lines = self.invoice.line_ids.filtered(
|
||||||
lambda s: s.account_id == self.invoice_account
|
lambda s: s.account_id == self.invoice_account
|
||||||
)
|
)
|
||||||
if payable_move_lines:
|
if payable_move_lines:
|
||||||
self.assertEqual(payable_move_lines[0].mandate_id, self.mandate)
|
self.assertEqual(payable_move_lines[0].mandate_id, self.mandate)
|
||||||
|
|
||||||
self.env["account.invoice.payment.line.multi"].with_context(
|
self.env["account.invoice.payment.line.multi"].with_context(
|
||||||
active_model="account.invoice", active_ids=self.invoice.ids
|
active_model="account.move", active_ids=self.invoice.ids
|
||||||
).create({}).run()
|
).create({}).run()
|
||||||
|
|
||||||
payment_order = self.env["account.payment.order"].search([])
|
payment_order = self.env["account.payment.order"].search([])
|
||||||
@@ -54,9 +55,9 @@ class TestInvoiceMandate(TransactionCase):
|
|||||||
|
|
||||||
self.invoice._onchange_partner_id()
|
self.invoice._onchange_partner_id()
|
||||||
self.assertEqual(self.invoice.mandate_id, self.mandate)
|
self.assertEqual(self.invoice.mandate_id, self.mandate)
|
||||||
self.invoice.action_invoice_open()
|
self.invoice.action_post()
|
||||||
|
|
||||||
payable_move_lines = self.invoice.move_id.line_ids.filtered(
|
payable_move_lines = self.invoice.line_ids.filtered(
|
||||||
lambda s: s.account_id == self.invoice_account
|
lambda s: s.account_id == self.invoice_account
|
||||||
)
|
)
|
||||||
if payable_move_lines:
|
if payable_move_lines:
|
||||||
@@ -65,9 +66,22 @@ class TestInvoiceMandate(TransactionCase):
|
|||||||
|
|
||||||
def test_post_invoice_and_refund_02(self):
|
def test_post_invoice_and_refund_02(self):
|
||||||
self.invoice._onchange_partner_id()
|
self.invoice._onchange_partner_id()
|
||||||
self.invoice.action_invoice_open()
|
self.invoice.action_post()
|
||||||
self.assertEqual(self.invoice.mandate_id, self.mandate)
|
self.assertEqual(self.invoice.mandate_id, self.mandate)
|
||||||
self.invoice.refund()
|
move_reversal = (
|
||||||
|
self.env["account.move.reversal"]
|
||||||
|
.with_context(active_model="account.move", active_ids=self.invoice.ids)
|
||||||
|
.create(
|
||||||
|
{
|
||||||
|
"date": fields.Date.today(),
|
||||||
|
"reason": "no reason",
|
||||||
|
"refund_method": "refund",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
reversal = move_reversal.reverse_moves()
|
||||||
|
ref = self.env["account.move"].browse(reversal["res_id"])
|
||||||
|
self.assertEqual(self.invoice.mandate_id, ref.mandate_id)
|
||||||
|
|
||||||
def test_onchange_partner(self):
|
def test_onchange_partner(self):
|
||||||
partner_2 = self._create_res_partner("Jane with ACME Bank")
|
partner_2 = self._create_res_partner("Jane with ACME Bank")
|
||||||
@@ -90,10 +104,9 @@ class TestInvoiceMandate(TransactionCase):
|
|||||||
)
|
)
|
||||||
mandate_2.validate()
|
mandate_2.validate()
|
||||||
|
|
||||||
invoice = self.env["account.invoice"].new(
|
invoice = self.env["account.move"].new(
|
||||||
{
|
{
|
||||||
"partner_id": self.partner.id,
|
"partner_id": self.partner.id,
|
||||||
"account_id": self.invoice_account.id,
|
|
||||||
"type": "out_invoice",
|
"type": "out_invoice",
|
||||||
"company_id": self.company.id,
|
"company_id": self.company.id,
|
||||||
}
|
}
|
||||||
@@ -104,10 +117,9 @@ class TestInvoiceMandate(TransactionCase):
|
|||||||
self.assertEqual(invoice.mandate_id, mandate_2)
|
self.assertEqual(invoice.mandate_id, mandate_2)
|
||||||
|
|
||||||
def test_onchange_payment_mode(self):
|
def test_onchange_payment_mode(self):
|
||||||
invoice = self.env["account.invoice"].new(
|
invoice = self.env["account.move"].new(
|
||||||
{
|
{
|
||||||
"partner_id": self.partner.id,
|
"partner_id": self.partner.id,
|
||||||
"account_id": self.invoice_account.id,
|
|
||||||
"type": "out_invoice",
|
"type": "out_invoice",
|
||||||
"company_id": self.company.id,
|
"company_id": self.company.id,
|
||||||
}
|
}
|
||||||
@@ -156,10 +168,9 @@ class TestInvoiceMandate(TransactionCase):
|
|||||||
)
|
)
|
||||||
mandate_2.validate()
|
mandate_2.validate()
|
||||||
|
|
||||||
invoice = self.env["account.invoice"].create(
|
invoice = self.env["account.move"].create(
|
||||||
{
|
{
|
||||||
"partner_id": self.partner.id,
|
"partner_id": self.partner.id,
|
||||||
"account_id": self.invoice_account.id,
|
|
||||||
"type": "out_invoice",
|
"type": "out_invoice",
|
||||||
"company_id": self.company.id,
|
"company_id": self.company.id,
|
||||||
}
|
}
|
||||||
@@ -252,23 +263,29 @@ class TestInvoiceMandate(TransactionCase):
|
|||||||
.id
|
.id
|
||||||
)
|
)
|
||||||
|
|
||||||
self.invoice = self.env["account.invoice"].create(
|
invoice_vals = [
|
||||||
|
(
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
{
|
||||||
|
"product_id": self.env.ref("product.product_product_4").id,
|
||||||
|
"quantity": 1.0,
|
||||||
|
"account_id": invoice_line_account,
|
||||||
|
"price_unit": 200.00,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
|
self.invoice = self.env["account.move"].create(
|
||||||
{
|
{
|
||||||
"partner_id": self.partner.id,
|
"partner_id": self.partner.id,
|
||||||
"account_id": self.invoice_account.id,
|
|
||||||
"type": "out_invoice",
|
"type": "out_invoice",
|
||||||
"company_id": self.company.id,
|
"company_id": self.company.id,
|
||||||
|
"journal_id": self.env["account.journal"]
|
||||||
|
.search([("type", "=", "sale")], limit=1)
|
||||||
|
.id,
|
||||||
|
"invoice_line_ids": invoice_vals,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
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
|
return res
|
||||||
|
|||||||
@@ -105,7 +105,8 @@
|
|||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree
|
<tree
|
||||||
string="Banking Mandate"
|
string="Banking Mandate"
|
||||||
colors="blue:state=='draft';black:state in ('expired', 'cancel')"
|
decoration-info="state=='draft'"
|
||||||
|
decoration-muted="state in ('expired','cancel')"
|
||||||
>
|
>
|
||||||
<field name="id" invisible="1" />
|
<field name="id" invisible="1" />
|
||||||
<field name="company_id" groups="base.group_multi_company" />
|
<field name="company_id" groups="base.group_multi_company" />
|
||||||
|
|||||||
@@ -4,12 +4,12 @@
|
|||||||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
-->
|
-->
|
||||||
<odoo>
|
<odoo>
|
||||||
<record id="invoice_form" model="ir.ui.view">
|
<record id="view_move_form" model="ir.ui.view">
|
||||||
<field name="name">add.mandate.on.customer.invoice.form</field>
|
<field name="name">add.mandate.on.account.move.form</field>
|
||||||
<field name="model">account.invoice</field>
|
<field name="model">account.move</field>
|
||||||
<field name="inherit_id" ref="account_payment_partner.invoice_form" />
|
<field name="inherit_id" ref="account_payment_partner.view_move_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="partner_bank_id" position="after">
|
<field name="invoice_partner_bank_id" position="after">
|
||||||
<field
|
<field
|
||||||
name="mandate_id"
|
name="mandate_id"
|
||||||
domain="[('partner_id', '=', commercial_partner_id), ('state', '=', 'valid')]"
|
domain="[('partner_id', '=', commercial_partner_id), ('state', '=', 'valid')]"
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
<field name="model">res.partner.bank</field>
|
<field name="model">res.partner.bank</field>
|
||||||
<field name="inherit_id" ref="base.view_partner_bank_form" />
|
<field name="inherit_id" ref="base.view_partner_bank_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<xpath expr="//form/group" position="inside">
|
<xpath expr="//form/sheet/group" position="inside">
|
||||||
<group name="mandates" string="Direct Debit Mandates">
|
<group name="mandates" string="Direct Debit Mandates">
|
||||||
<field
|
<field
|
||||||
name="mandate_ids"
|
name="mandate_ids"
|
||||||
|
|||||||
Reference in New Issue
Block a user