diff --git a/account_payment_partner/README.rst b/account_payment_partner/README.rst index 15ee4b252..33edfef25 100644 --- a/account_payment_partner/README.rst +++ b/account_payment_partner/README.rst @@ -1,65 +1,115 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :alt: License: AGPL-3 - ======================= Account Payment Partner ======================= +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fbank--payment-lightgray.png?logo=github + :target: https://github.com/OCA/bank-payment/tree/10.0/account_payment_partner + :alt: OCA/bank-payment +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/bank-payment-10-0/bank-payment-10-0-account_payment_partner + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/97/10.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +[ This file must be max 2-3 paragraphs, and is required. ] + This module adds severals fields : * the *Supplier Payment Mode* and *Customer Payment Mode* on Partners, * the *Payment Mode* on Invoices. +* the *Show bank account* on Payment Mode. + +* the *# of digits for customer bank account* on Payment Mode. + +* the *Bank account from journals* on Payment Mode. + On a Payment Order, in the wizard *Select Invoices to Pay*, the invoices will be filtered per Payment Mode. -Installation -============ +Allows to print in the invoice to which account number the payment +(via SEPA direct debit) is going to be charged so the customer knows that +information, but there are some customers that don't want that everyone +looking at the invoice sees the full account number (and even GDPR can say a +word about that), so that's the reason behind the several options. -This module depends on : +**Table of contents** -* account_payment_mode - -This module is part of the OCA/bank-payment suite. - -Configuration -============= - -There is nothing to configure. +.. contents:: + :local: Usage ===== +[ This file must be present and contains the usage instructions + for end-users. As all other rst files included in the README, + it MUST NOT contain reStructuredText sections + only body text (paragraphs, lists, tables, etc). Should you need + a more elaborate structure to explain the addon, please create a + Sphinx documentation (which may include this file as a "quick start" + section). ] + You are able to add a payment mode directly on a partner. This payment mode is automatically associated to the invoice related to the partner. This default value could be change in a draft invoice. When you create an payment order, only invoices related to chosen payment mode are displayed. Invoices without any payment mode are displayed to. -.. 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/11.0 +Changelog +========= -Known issues / Roadmap -====================== +[ The change log. The goal of this file is to help readers + understand changes between version. The primary audience is + end users and integrators. Purely technical changes such as + code refactoring must not be mentioned here. - * No known issues. + This file may contain ONE level of section titles, underlined + with the ~ (tilde) character. Other section markers are + forbidden and will likely break the structure of the README.rst + or other documents where this fragment is included. ] + +10.0.1.2.0 (2018-05-24) +~~~~~~~~~~~~~~~~~~~~~~~ + +* [IMP] Add options to show partner bank account in invoice report + (`#458 `_) Bug Tracker =========== -Bugs are tracked on `GitHub Issues -`_. 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 feedback. +Bugs are tracked on `GitHub Issues `_. +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 +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. Credits ======= -Contributors ------------- +Authors +~~~~~~~ + +* Akretion +* Tecnativa + +Contributors +~~~~~~~~~~~~ -* Pedro M. Baeza * Alexis de Lattre * Raphaël Valyi * Stefan Rijnhart (Therp) @@ -67,16 +117,24 @@ Contributors * Stéphane Bidoul * Danimar Ribeiro * Angel Moya +* `Tecnativa `_: -Maintainer ----------- + * Pedro M. Baeza + * Carlos Dauden + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. .. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association :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. -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. +This module is part of the `OCA/bank-payment `_ project on GitHub. -To contribute to this module, please visit https://odoo-community.org. +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/account_payment_partner/__init__.py b/account_payment_partner/__init__.py index 50def6204..83e553ac4 100644 --- a/account_payment_partner/__init__.py +++ b/account_payment_partner/__init__.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -# © 2014 Akretion - Alexis de Lattre -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import models diff --git a/account_payment_partner/__manifest__.py b/account_payment_partner/__manifest__.py index 403803b29..44d90fa79 100644 --- a/account_payment_partner/__manifest__.py +++ b/account_payment_partner/__manifest__.py @@ -1,11 +1,11 @@ -# -*- coding: utf-8 -*- -# © 2014 Akretion - Alexis de Lattre -# © 2014 Tecnativa - Pedro M. Baeza -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +# Copyright 2014 Akretion - Alexis de Lattre +# Copyright 2014 Tecnativa - Pedro M. Baeza +# Copyright 2018 Tecnativa - Carlos Dauden +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { 'name': 'Account Payment Partner', - 'version': '11.0.1.2.1', + 'version': '11.0.1.3.0', 'category': 'Banking addons', 'license': 'AGPL-3', 'summary': 'Adds payment mode on partners and invoices', @@ -18,6 +18,7 @@ 'views/res_partner_view.xml', 'views/account_invoice_view.xml', 'views/account_move_line.xml', + 'views/account_payment_mode.xml', 'views/report_invoice.xml', ], 'demo': ['demo/partner_demo.xml'], diff --git a/account_payment_partner/i18n/es.po b/account_payment_partner/i18n/es.po index 9a399315d..f30143010 100644 --- a/account_payment_partner/i18n/es.po +++ b/account_payment_partner/i18n/es.po @@ -19,6 +19,11 @@ msgstr "" "Plural-Forms: nplurals=2; plural=n != 1;\n" "X-Generator: Weblate 3.0.1\n" +#. module: account_payment_partner +#: model:ir.ui.view,arch_db:account_payment_partner.account_payment_mode_form +msgid "# of chars" +msgstr "Nº de caracteres" + #. module: account_payment_partner #: model:ir.ui.view,arch_db:account_payment_partner.report_invoice_payment_mode msgid "Bank Account:" @@ -31,12 +36,8 @@ msgstr "Modo de pago:" #. module: account_payment_partner #: model:ir.model.fields,help:account_payment_partner.field_account_invoice_bank_account_required -msgid "" -"Activate this option if this payment method requires you to know the bank " -"account number of your customer or supplier." -msgstr "" -"Activa esta opción si este método de pago debe requerirte informar el número " -"de cuenta bancaria de tu cliente o proveedor" +msgid "Activate this option if this payment method requires you to know the bank account number of your customer or supplier." +msgstr "Activa esta opción si este método de pago debe requerirte informar el número de cuenta bancaria de tu cliente o proveedor" #. module: account_payment_partner #: model:ir.model.fields,field_description:account_payment_partner.field_account_invoice_bank_account_required @@ -48,12 +49,26 @@ msgstr "Cuenta bancaria requerida" msgid "Contact" msgstr "Contacto" +#: model:ir.model.fields,field_description:account_payment_partner.field_account_payment_mode_show_bank_account_from_journal +msgid "Bank account from journals" +msgstr "Cuenta bancaria de los diarios" + #. module: account_payment_partner #: model:ir.model.fields,field_description:account_payment_partner.field_res_partner_customer_payment_mode_id #: model:ir.model.fields,field_description:account_payment_partner.field_res_users_customer_payment_mode_id msgid "Customer Payment Mode" msgstr "Modo de pago de cliente" +#. module: account_payment_partner +#: selection:account.payment.mode,show_bank_account:0 +msgid "First n chars" +msgstr "Primeros n caracteres" + +#. module: account_payment_partner +#: selection:account.payment.mode,show_bank_account:0 +msgid "Full" +msgstr "Completo" + #. module: account_payment_partner #: model:ir.model,name:account_payment_partner.model_account_invoice msgid "Invoice" @@ -70,6 +85,31 @@ msgstr "Apunte contable" msgid "No Chart of Account Template has been defined !" msgstr "No se ha definido un Plan Contable!" +#. module: account_payment_partner +#: selection:account.payment.mode,show_bank_account:0 +msgid "Last n chars" +msgstr "Últimos n caracteres" + +#. module: account_payment_partner +#: selection:account.payment.mode,show_bank_account:0 +msgid "No" +msgstr "No" + +#. module: account_payment_partner +#: model:ir.model.fields,field_description:account_payment_partner.field_account_payment_mode_show_bank_account_chars +msgid "# of digits for customer bank account" +msgstr "Nº de dígitos de cuenta bancaria del cliente" + +#. module: account_payment_partner +#: model:ir.model,name:account_payment_partner.model_res_partner +msgid "Partner" +msgstr "Empresa" + +#. module: account_payment_partner +#: model:ir.model,name:account_payment_partner.model_account_payment_method +msgid "Payment Methods" +msgstr "Métodos de pago" + #. module: account_payment_partner #: model:ir.model.fields,field_description:account_payment_partner.field_account_invoice_payment_mode_id #: model:ir.model.fields,field_description:account_payment_partner.field_account_move_line_payment_mode_id @@ -89,19 +129,29 @@ msgstr "Pagos" #. module: account_payment_partner #: model:ir.model.fields,help:account_payment_partner.field_res_partner_customer_payment_mode_id -#: model:ir.model.fields,help:account_payment_partner.field_res_users_customer_payment_mode_id msgid "Select the default payment mode for this customer." -msgstr "" -"Seleccione el modo de pago por defecto cuando esta empresa actúa como " -"cliente." +msgstr "Seleccione el modo de pago por defecto cuando esta empresa actúa como cliente." #. module: account_payment_partner #: model:ir.model.fields,help:account_payment_partner.field_res_partner_supplier_payment_mode_id #: model:ir.model.fields,help:account_payment_partner.field_res_users_supplier_payment_mode_id msgid "Select the default payment mode for this supplier." -msgstr "" -"Seleccione el modo de pago por defecto cuando esta empresa actúa como " -"proveedor." +msgstr "Seleccione el modo de pago por defecto cuando esta empresa actúa como proveedor." + +#. module: account_payment_partner +#: model:ir.model.fields,field_description:account_payment_partner.field_account_payment_mode_show_bank_account +msgid "Show bank account" +msgstr "Mostrar cuenta bancaria" + +#. module: account_payment_partner +#: model:ir.ui.view,arch_db:account_payment_partner.account_payment_mode_form +msgid "Show bank account in invoice report" +msgstr "Mostrar cuenta bancaria en informe factura" + +#. module: account_payment_partner +#: model:ir.model.fields,help:account_payment_partner.field_account_payment_mode_show_bank_account +msgid "Show in invoices partial or full bank account number" +msgstr "Mostrar en facturas nº de cuenta bancaria parcial o completo" #. module: account_payment_partner #: model:ir.model.fields,field_description:account_payment_partner.field_res_partner_supplier_payment_mode_id diff --git a/account_payment_partner/migrations/11.0.1.3.0/post-migrate.py b/account_payment_partner/migrations/11.0.1.3.0/post-migrate.py new file mode 100644 index 000000000..e63be7140 --- /dev/null +++ b/account_payment_partner/migrations/11.0.1.3.0/post-migrate.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Carlos Dauden - Tecnativa +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + + +def migrate(cr, version): + """Update database from previous versions, after updating module.""" + cr.execute( + "UPDATE account_payment_mode " + "SET show_bank_account_from_journal = true " + "WHERE bank_account_link = 'fixed'" + ) diff --git a/account_payment_partner/models/account_invoice.py b/account_payment_partner/models/account_invoice.py index 71c415e56..791ea10ff 100644 --- a/account_payment_partner/models/account_invoice.py +++ b/account_payment_partner/models/account_invoice.py @@ -1,7 +1,6 @@ -# -*- coding: utf-8 -*- -# © 2014-2016 Akretion - Alexis de Lattre -# © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +# Copyright 2014-16 Akretion - Alexis de Lattre +# Copyright 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import api, fields, models, _ from odoo.exceptions import ValidationError @@ -42,13 +41,12 @@ class AccountInvoice(models.Model): self.partner_bank_id = False elif self.type == 'out_invoice': - pay_mode = self.with_context( - force_company=self.company_id.id + # No bank account assignation is done here as this is only + # needed for printing purposes and it can conflict with + # SEPA direct debit payments. Current report prints it. + self.payment_mode_id = self.with_context( + force_company=self.company_id.id, ).partner_id.customer_payment_mode_id - self.payment_mode_id = pay_mode - if pay_mode and pay_mode.bank_account_link == 'fixed': - self.partner_bank_id = pay_mode.fixed_journal_id. \ - bank_account_id else: self.payment_mode_id = False if self.type == 'in_invoice': @@ -118,3 +116,20 @@ class AccountInvoice(models.Model): raise ValidationError( _("The company of the invoice %s does not match " "with that of the payment mode") % rec.name) + + def partner_banks_to_show(self): + self.ensure_one() + if self.partner_bank_id: + return self.partner_bank_id + if self.payment_mode_id.show_bank_account_from_journal: + if self.payment_mode_id.bank_account_link == 'fixed': + return self.payment_mode_id.fixed_journal_id.bank_account_id + else: + return self.payment_mode_id.variable_journal_ids.mapped( + 'bank_account_id') + if self.payment_mode_id.payment_method_id.code == \ + 'sepa_direct_debit': # pragma: no cover + return (self.mandate_id.partner_bank_id or + self.partner_id.valid_mandate_id.partner_bank_id) + # Return this as empty recordset + return self.partner_bank_id diff --git a/account_payment_partner/models/account_move_line.py b/account_payment_partner/models/account_move_line.py index 9bdcec4e6..4bfe0ff70 100644 --- a/account_payment_partner/models/account_move_line.py +++ b/account_payment_partner/models/account_move_line.py @@ -1,8 +1,7 @@ -# -*- coding: utf-8 -*- -# © 2016 Akretion (https://www.akretion.com/) -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +# Copyright 2016 Akretion (http://www.akretion.com/) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import models, fields +from odoo import fields, models class AccountMoveLine(models.Model): diff --git a/account_payment_partner/models/account_payment_mode.py b/account_payment_partner/models/account_payment_mode.py index 2b0f618ab..861b749ff 100644 --- a/account_payment_partner/models/account_payment_mode.py +++ b/account_payment_partner/models/account_payment_mode.py @@ -1,13 +1,31 @@ # Copyright 2017 Eficent Business and IT Consulting Services S.L. +# Copyright 2018 Carlos Dauden - Tecnativa # License AGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). -from odoo import models, api, _ +from odoo import api, fields, models, _ from odoo.exceptions import ValidationError class AccountPaymentMode(models.Model): _inherit = "account.payment.mode" + show_bank_account = fields.Selection( + selection=[ + ('full', 'Full'), + ('first', 'First n chars'), + ('last', 'Last n chars'), + ('no', 'No'), + ], + string='Show bank account', + default='full', + help="Show in invoices partial or full bank account number") + show_bank_account_from_journal = fields.Boolean( + string='Bank account from journals' + ) + show_bank_account_chars = fields.Integer( + string="# of digits for customer bank account", + ) + @api.constrains('company_id') def account_invoice_company_constrains(self): for mode in self: diff --git a/account_payment_partner/models/res_partner.py b/account_payment_partner/models/res_partner.py index 0b6585aa0..aa60a42f8 100644 --- a/account_payment_partner/models/res_partner.py +++ b/account_payment_partner/models/res_partner.py @@ -1,9 +1,8 @@ -# -*- coding: utf-8 -*- -# © 2014 Akretion - Alexis de Lattre -# © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +# Copyright 2014 Akretion - Alexis de Lattre +# Copyright 2014 Tecnativa - Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import models, fields, api +from odoo import api, fields, models class ResPartner(models.Model): diff --git a/account_payment_partner/readme/CONTRIBUTORS.rst b/account_payment_partner/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..df652cc34 --- /dev/null +++ b/account_payment_partner/readme/CONTRIBUTORS.rst @@ -0,0 +1,11 @@ +* Alexis de Lattre +* Raphaël Valyi +* Stefan Rijnhart (Therp) +* Alexandre Fayolle +* Stéphane Bidoul +* Danimar Ribeiro +* Angel Moya +* `Tecnativa `_: + + * Pedro M. Baeza + * Carlos Dauden diff --git a/account_payment_partner/readme/DESCRIPTION.rst b/account_payment_partner/readme/DESCRIPTION.rst new file mode 100644 index 000000000..8ad4f4f64 --- /dev/null +++ b/account_payment_partner/readme/DESCRIPTION.rst @@ -0,0 +1,20 @@ +This module adds severals fields: + +* the *Supplier Payment Mode* and *Customer Payment Mode* on Partners, + +* the *Payment Mode* on Invoices. + +* the *Show bank account* on Payment Mode. + +* the *# of digits for customer bank account* on Payment Mode. + +* the *Bank account from journals* on Payment Mode. + +On a Payment Order, in the wizard *Select Invoices to Pay*, the invoices will +be filtered per Payment Mode. + +Allows to print in the invoice to which account number the payment +(via SEPA direct debit) is going to be charged so the customer knows that +information, but there are some customers that don't want that everyone +looking at the invoice sees the full account number (and even GDPR can say a +word about that), so that's the reason behind the several options. diff --git a/account_payment_partner/readme/HISTORY.rst b/account_payment_partner/readme/HISTORY.rst new file mode 100644 index 000000000..8424df5d0 --- /dev/null +++ b/account_payment_partner/readme/HISTORY.rst @@ -0,0 +1,5 @@ +10.0.1.2.0 (2018-05-24) +~~~~~~~~~~~~~~~~~~~~~~~ + +* [IMP] Add options to show partner bank account in invoice report + (`#458 `_) diff --git a/account_payment_partner/readme/USAGE.rst b/account_payment_partner/readme/USAGE.rst new file mode 100644 index 000000000..09ef27577 --- /dev/null +++ b/account_payment_partner/readme/USAGE.rst @@ -0,0 +1,9 @@ +You are able to add a payment mode directly on a partner. + +This payment mode is automatically associated to the invoice related to the +partner. This default value could be changed in a draft invoice. + +When you create a payment order, only invoices related to chosen payment mode +are displayed. + +Invoices without any payment mode are displayed too. diff --git a/account_payment_partner/static/description/index.html b/account_payment_partner/static/description/index.html new file mode 100644 index 000000000..641f3296e --- /dev/null +++ b/account_payment_partner/static/description/index.html @@ -0,0 +1,488 @@ + + + + + + +Account Payment Partner + + + +
+

Account Payment Partner

+ + +

Beta License: AGPL-3 OCA/bank-payment Translate me on Weblate Try me on Runbot

+

[ This file must be max 2-3 paragraphs, and is required. ]

+

This module adds severals fields :

+
    +
  • the Supplier Payment Mode and Customer Payment Mode on Partners,
  • +
  • the Payment Mode on Invoices.
  • +
  • the Show bank account on Payment Mode.
  • +
  • the # of digits for customer bank account on Payment Mode.
  • +
  • the Bank account from journals on Payment Mode.
  • +
+

On a Payment Order, in the wizard Select Invoices to Pay, the invoices will +be filtered per Payment Mode.

+

Allows to print in the invoice to which account number the payment +(via SEPA direct debit) is going to be charged so the customer knows that +information, but there are some customers that don’t want that everyone +looking at the invoice sees the full account number (and even GDPR can say a +word about that), so that’s the reason behind the several options.

+

Table of contents

+ +
+

Usage

+
+
[ This file must be present and contains the usage instructions
+
for end-users. As all other rst files included in the README, +it MUST NOT contain reStructuredText sections +only body text (paragraphs, lists, tables, etc). Should you need +a more elaborate structure to explain the addon, please create a +Sphinx documentation (which may include this file as a “quick start” +section). ]
+
+

You are able to add a payment mode directly on a partner. +This payment mode is automatically associated to the invoice related to the partner. This default value could be change in a draft invoice. +When you create an payment order, only invoices related to chosen payment mode are displayed. +Invoices without any payment mode are displayed to.

+
+
+

Changelog

+
+
[ The change log. The goal of this file is to help readers
+

understand changes between version. The primary audience is +end users and integrators. Purely technical changes such as +code refactoring must not be mentioned here.

+

This file may contain ONE level of section titles, underlined +with the ~ (tilde) character. Other section markers are +forbidden and will likely break the structure of the README.rst +or other documents where this fragment is included. ]

+
+
+
+

10.0.1.2.0 (2018-05-24)

+
    +
  • [IMP] Add options to show partner bank account in invoice report +(#458)
  • +
+
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +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 +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Akretion
  • +
  • Tecnativa
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

This module is part of the OCA/bank-payment project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/account_payment_partner/tests/__init__.py b/account_payment_partner/tests/__init__.py index 0d757b027..3449d9e90 100644 --- a/account_payment_partner/tests/__init__.py +++ b/account_payment_partner/tests/__init__.py @@ -1,2 +1 @@ - from . import test_account_payment_partner diff --git a/account_payment_partner/tests/test_account_payment_partner.py b/account_payment_partner/tests/test_account_payment_partner.py index b02016463..3bdb459a1 100644 --- a/account_payment_partner/tests/test_account_payment_partner.py +++ b/account_payment_partner/tests/test_account_payment_partner.py @@ -47,6 +47,7 @@ class TestAccountPaymentPartner(common.SavepointCase): # refs cls.manual_out = cls.env.ref( 'account.account_payment_method_manual_out') + cls.manual_out.bank_account_required = True cls.manual_in = cls.env.ref( 'account.account_payment_method_manual_in') @@ -77,6 +78,7 @@ class TestAccountPaymentPartner(common.SavepointCase): 'name': 'Suppliers Bank 1', 'bank_account_link': 'variable', 'payment_method_id': cls.manual_out.id, + 'show_bank_account_from_journal': True, 'company_id': cls.company.id, 'fixed_journal_id': cls.journal_c1.id, 'variable_journal_ids': [(6, 0, [cls.journal_c1.id])] @@ -110,16 +112,17 @@ class TestAccountPaymentPartner(common.SavepointCase): force_company=cls.company.id).create({ 'name': 'Test supplier', 'supplier_payment_mode_id': cls.supplier_payment_mode, - 'bank_ids': [ - (0, 0, { - 'acc_number': '5345345', - 'company_id': cls.company.id, - }), - (0, 0, { - 'acc_number': '3452342', - 'company_id': cls.company_2.id, - })] }) + cls.supplier_bank = cls.env['res.partner.bank'].create({ + 'acc_number': '5345345', + 'partner_id': cls.supplier.id, + 'company_id': cls.company.id, + }) + cls.supplier_bank_2 = cls.env['res.partner.bank'].create({ + 'acc_number': '3452342', + 'partner_id': cls.supplier.id, + 'company_id': cls.company_2.id, + }) cls.supplier.with_context( force_company=cls.company_2.id).supplier_payment_mode_id = \ cls.supplier_payment_mode_c2 @@ -132,6 +135,21 @@ class TestAccountPaymentPartner(common.SavepointCase): [('user_type_id', '=', cls.acct_type_expenses.id), ('company_id', '=', cls.company.id)], limit=1) + cls.journal_bank = cls.env['res.partner.bank'].create({ + 'acc_number': 'GB95LOYD87430237296288', + 'partner_id': cls.env.user.company_id.id, + }) + cls.journal = cls.env['account.journal'].create({ + 'name': 'BANK TEST', + 'code': 'TEST', + 'type': 'bank', + 'bank_account_id': cls.journal_bank.id, + }) + cls.supplier_invoice = cls.env['account.invoice'].create({ + 'partner_id': cls.supplier.id, + 'type': 'in_invoice', + 'journal_id': cls.journal_c1.id, + }) def _create_invoice(self): @@ -180,9 +198,6 @@ class TestAccountPaymentPartner(common.SavepointCase): invoice._onchange_partner_id() self.assertEquals(invoice.payment_mode_id, self.customer_payment_mode) - self.assertEquals( - invoice.partner_bank_id, - self.customer_payment_mode.fixed_journal_id.bank_account_id) invoice.company_id = self.company_2 invoice._onchange_partner_id() @@ -204,19 +219,13 @@ class TestAccountPaymentPartner(common.SavepointCase): invoice._onchange_partner_id() self.assertEquals(invoice.payment_mode_id, self.supplier_payment_mode) - bank = self.partner_bank_model.search( - [('acc_number', '=', '5345345')], limit=1) - self.assertEquals( - invoice.partner_bank_id, - bank) + self.assertEquals(invoice.partner_bank_id, self.supplier_bank) invoice.company_id = self.company_2 invoice._onchange_partner_id() self.assertEquals(invoice.payment_mode_id, self.supplier_payment_mode_c2) - bank = self.partner_bank_model.search( - [('acc_number', '=', '3452342')], limit=1) - self.assertEquals(invoice.partner_bank_id, bank) + self.assertEquals(invoice.partner_bank_id, self.supplier_bank_2) invoice.payment_mode_id = self.supplier_payment_mode invoice._onchange_payment_mode_id() @@ -313,3 +322,61 @@ class TestAccountPaymentPartner(common.SavepointCase): self.customer.customer_payment_mode_id, self.customer_payment_mode ) + + def test_partner_onchange(self): + customer_invoice = self.env['account.invoice'].create({ + 'partner_id': self.customer.id, + 'type': 'out_invoice', + }) + customer_invoice._onchange_partner_id() + self.assertEqual(customer_invoice.payment_mode_id, + self.customer_payment_mode) + + self.supplier_invoice._onchange_partner_id() + self.assertEqual(self.supplier_invoice.partner_bank_id, + self.supplier_bank) + vals = {'partner_id': False, 'type': 'out_invoice'} + invoice = self.env['account.invoice'].new(vals) + invoice._onchange_partner_id() + self.assertFalse(invoice.payment_mode_id) + vals = {'partner_id': False, 'type': 'in_invoice'} + invoice = self.env['account.invoice'].new(vals) + invoice._onchange_partner_id() + self.assertFalse(invoice.partner_bank_id) + + def test_onchange_payment_mode_id(self): + mode = self.supplier_payment_mode + mode.payment_method_id.bank_account_required = True + self.supplier_invoice.partner_bank_id = self.supplier_bank.id + self.supplier_invoice.payment_mode_id = mode.id + self.supplier_invoice._onchange_payment_mode_id() + self.assertEqual(self.supplier_invoice.partner_bank_id, + self.supplier_bank) + mode.payment_method_id.bank_account_required = False + self.supplier_invoice._onchange_payment_mode_id() + self.assertFalse(self.supplier_invoice.partner_bank_id) + self.supplier_invoice.payment_mode_id = False + self.supplier_invoice._onchange_payment_mode_id() + self.assertFalse(self.supplier_invoice.partner_bank_id) + + def test_print_report(self): + self.supplier_invoice.partner_bank_id = self.supplier_bank.id + report = self.env.ref('account.account_invoices') + res = str(report.render_qweb_html( + self.supplier_invoice.ids, report.report_name, + )[0]) + self.assertIn(self.supplier_bank.acc_number, res) + payment_mode = self.supplier_payment_mode + payment_mode.show_bank_account_from_journal = True + self.supplier_invoice.payment_mode_id = payment_mode.id + self.supplier_invoice.partner_bank_id = False + res = str(report.render_qweb_html( + self.supplier_invoice.ids, report.report_name, + )[0]) + self.assertIn(self.journal_c1.bank_acc_number, res) + payment_mode.bank_account_link = 'variable' + payment_mode.variable_journal_ids = [(6, 0, self.journal.ids)] + res = str(report.render_qweb_html( + self.supplier_invoice.ids, report.report_name, + )[0]) + self.assertIn(self.journal_bank.acc_number, res) diff --git a/account_payment_partner/views/account_invoice_view.xml b/account_payment_partner/views/account_invoice_view.xml index 859e4572c..f76fac182 100644 --- a/account_payment_partner/views/account_invoice_view.xml +++ b/account_payment_partner/views/account_invoice_view.xml @@ -1,7 +1,7 @@ diff --git a/account_payment_partner/views/account_move_line.xml b/account_payment_partner/views/account_move_line.xml index 1abe8b5e1..601018111 100644 --- a/account_payment_partner/views/account_move_line.xml +++ b/account_payment_partner/views/account_move_line.xml @@ -1,8 +1,7 @@ diff --git a/account_payment_partner/views/account_payment_mode.xml b/account_payment_partner/views/account_payment_mode.xml new file mode 100644 index 000000000..da62bf405 --- /dev/null +++ b/account_payment_partner/views/account_payment_mode.xml @@ -0,0 +1,24 @@ + + + + + + account.payment.mode + + + + + + + + + + + + + + + diff --git a/account_payment_partner/views/report_invoice.xml b/account_payment_partner/views/report_invoice.xml index 3a25d8c13..b22767685 100644 --- a/account_payment_partner/views/report_invoice.xml +++ b/account_payment_partner/views/report_invoice.xml @@ -7,13 +7,23 @@ Payment Mode:

-

- Bank Account: - - - - -

+ +

+ Bank Account: + + + + + + + + + + + + +

+
diff --git a/account_payment_partner/views/res_partner_view.xml b/account_payment_partner/views/res_partner_view.xml index ad7ceeafe..1c7662232 100644 --- a/account_payment_partner/views/res_partner_view.xml +++ b/account_payment_partner/views/res_partner_view.xml @@ -1,7 +1,6 @@