From 5905d89eb3f0bd22ea3b5edbe30afe8d5f623d57 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 25 Feb 2014 00:19:57 +0100 Subject: [PATCH 01/33] Add 4 new modules to handle payment type and bank accounts: - account_payment_partner - account_payment_sale - account_payment_sale_stock - account_payment_purchase Filter the selection of invoices per payment type. Add active field on payment.mode and payment.mode.type. Add menu entry for Payment Types. --- account_payment_partner/__init__.py | 23 ++++++++ account_payment_partner/__openerp__.py | 55 ++++++++++++++++++ account_payment_partner/demo/partner_demo.xml | 51 +++++++++++++++++ .../i18n/account_payment_partner.pot | 57 +++++++++++++++++++ account_payment_partner/model/__init__.py | 25 ++++++++ .../model/account_invoice.py | 56 ++++++++++++++++++ account_payment_partner/model/partner.py | 44 ++++++++++++++ .../model/payment_order_create.py | 39 +++++++++++++ .../view/account_invoice.xml | 38 +++++++++++++ account_payment_partner/view/partner.xml | 31 ++++++++++ 10 files changed, 419 insertions(+) create mode 100644 account_payment_partner/__init__.py create mode 100644 account_payment_partner/__openerp__.py create mode 100644 account_payment_partner/demo/partner_demo.xml create mode 100644 account_payment_partner/i18n/account_payment_partner.pot create mode 100644 account_payment_partner/model/__init__.py create mode 100644 account_payment_partner/model/account_invoice.py create mode 100644 account_payment_partner/model/partner.py create mode 100644 account_payment_partner/model/payment_order_create.py create mode 100644 account_payment_partner/view/account_invoice.xml create mode 100644 account_payment_partner/view/partner.xml diff --git a/account_payment_partner/__init__.py b/account_payment_partner/__init__.py new file mode 100644 index 000000000..161123944 --- /dev/null +++ b/account_payment_partner/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Partner module for OpenERP +# Copyright (C) 2014 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import model diff --git a/account_payment_partner/__openerp__.py b/account_payment_partner/__openerp__.py new file mode 100644 index 000000000..4e0217c98 --- /dev/null +++ b/account_payment_partner/__openerp__.py @@ -0,0 +1,55 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Partner module for OpenERP +# Copyright (C) 2014 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + + +{ + 'name': 'Account Payment Partner', + 'version': '0.1', + 'category': 'Banking addons', + 'license': 'AGPL-3', + 'summary': 'Adds payment mode on partners and invoices', + 'description': """ +Account Payment Partner +======================= + +This module adds severals fields : + +* the *Supplier Payment Mode* and *Customer Payment Mode* on Partners, + +* the *Payment Mode* on Invoices. + +On a Payment Order, in the wizard *Select Invoices to Pay*, the invoices will +be filtered per Payment Mode. + +Please contact Alexis de Lattre from Akretion +for any help or question about this module. + """, + 'author': 'Akretion', + 'website': 'http://www.akretion.com', + 'depends': ['account_banking_payment_export'], + 'data': [ + 'view/partner.xml', + 'view/account_invoice.xml', + ], + 'demo': ['demo/partner_demo.xml'], + 'active': False, +} diff --git a/account_payment_partner/demo/partner_demo.xml b/account_payment_partner/demo/partner_demo.xml new file mode 100644 index 000000000..776058d44 --- /dev/null +++ b/account_payment_partner/demo/partner_demo.xml @@ -0,0 +1,51 @@ + + + + + + + + supplier_payment_mode_12 + + + + + + + + customer_payment_mode_12 + + + + + + + + + customer_payment_mode_2 + + + + + + + + + supplier_payment_mode_1 + + + + + + + + + diff --git a/account_payment_partner/i18n/account_payment_partner.pot b/account_payment_partner/i18n/account_payment_partner.pot new file mode 100644 index 000000000..ca26e532d --- /dev/null +++ b/account_payment_partner/i18n/account_payment_partner.pot @@ -0,0 +1,57 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_payment_partner +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-06-09 23:22+0000\n" +"PO-Revision-Date: 2014-06-09 23:22+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_payment_partner +#: field:res.partner,customer_payment_mode:0 +msgid "Customer Payment Mode" +msgstr "" + +#. module: account_payment_partner +#: model:ir.model,name:account_payment_partner.model_account_invoice +msgid "Invoice" +msgstr "" + +#. module: account_payment_partner +#: model:ir.model,name:account_payment_partner.model_res_partner +msgid "Partner" +msgstr "" + +#. module: account_payment_partner +#: field:account.invoice,payment_mode_id:0 +msgid "Payment Mode" +msgstr "" + +#. module: account_payment_partner +#: help:res.partner,customer_payment_mode:0 +msgid "Select the default payment mode for this customer." +msgstr "" + +#. module: account_payment_partner +#: help:res.partner,supplier_payment_mode:0 +msgid "Select the default payment mode for this supplier." +msgstr "" + +#. module: account_payment_partner +#: field:res.partner,supplier_payment_mode:0 +msgid "Supplier Payment Mode" +msgstr "" + +#. module: account_payment_partner +#: model:ir.model,name:account_payment_partner.model_payment_order_create +msgid "payment.order.create" +msgstr "" + diff --git a/account_payment_partner/model/__init__.py b/account_payment_partner/model/__init__.py new file mode 100644 index 000000000..16ab8bc9e --- /dev/null +++ b/account_payment_partner/model/__init__.py @@ -0,0 +1,25 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Partner module for OpenERP +# Copyright (C) 2014 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import partner +from . import account_invoice +from . import payment_order_create diff --git a/account_payment_partner/model/account_invoice.py b/account_payment_partner/model/account_invoice.py new file mode 100644 index 000000000..607cda29a --- /dev/null +++ b/account_payment_partner/model/account_invoice.py @@ -0,0 +1,56 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Partner module for OpenERP +# Copyright (C) 2014 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.osv import orm, fields + + +class account_invoice(orm.Model): + _inherit = 'account.invoice' + + _columns = { + 'payment_mode_id': fields.many2one( + 'payment.mode', 'Payment Mode'), + } + + def onchange_partner_id( + self, cr, uid, ids, type, partner_id, date_invoice=False, + payment_term=False, partner_bank_id=False, company_id=False): + res = super(account_invoice, self).onchange_partner_id( + cr, uid, ids, type, partner_id, date_invoice=date_invoice, + payment_term=payment_term, partner_bank_id=partner_bank_id, + company_id=company_id) + if partner_id: + partner = self.pool['res.partner'].browse(cr, uid, partner_id) + if type == 'in_invoice': + res['value']['payment_mode_id'] = \ + partner.supplier_payment_mode.id or False + elif type == 'out_invoice': + res['value'].update({ + 'payment_mode_id': + partner.customer_payment_mode.id or False, + 'partner_bank_id': + partner.customer_payment_mode and + partner.customer_payment_mode.bank_id.id or False, + }) + else: + res['value']['payment_mode_id'] = False + return res diff --git a/account_payment_partner/model/partner.py b/account_payment_partner/model/partner.py new file mode 100644 index 000000000..4bfe4c787 --- /dev/null +++ b/account_payment_partner/model/partner.py @@ -0,0 +1,44 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Partner module for OpenERP +# Copyright (C) 2014 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.osv import orm, fields + + +class res_partner(orm.Model): + _inherit = 'res.partner' + + _columns = { + 'supplier_payment_mode': fields.property( + 'payment.mode', type='many2one', relation='payment.mode', + string='Supplier Payment Mode', view_load=True, + help="Select the default payment mode for this supplier."), + 'customer_payment_mode': fields.property( + 'payment.mode', type='many2one', relation='payment.mode', + string='Customer Payment Mode', view_load=True, + help="Select the default payment mode for this customer."), + } + + def _commercial_fields(self, cr, uid, context=None): + res = super(res_partner, self)._commercial_fields( + cr, uid, context=context) + res += ['supplier_payment_mode', 'customer_payment_mode'] + return res diff --git a/account_payment_partner/model/payment_order_create.py b/account_payment_partner/model/payment_order_create.py new file mode 100644 index 000000000..ea8b1ccb3 --- /dev/null +++ b/account_payment_partner/model/payment_order_create.py @@ -0,0 +1,39 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Partner module for OpenERP +# Copyright (C) 2014 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.osv import orm + + +class payment_order_create(orm.TransientModel): + _inherit = 'payment.order.create' + + def extend_payment_order_domain( + self, cr, uid, payment_order, domain, context=None): + super(payment_order_create, self).extend_payment_order_domain( + cr, uid, payment_order, domain, context=context) + domain += [ + '|', '|', + ('invoice', '=', False), + ('invoice.payment_mode_id', '=', False), + ('invoice.payment_mode_id', '=', payment_order.mode.id) + ] + return True diff --git a/account_payment_partner/view/account_invoice.xml b/account_payment_partner/view/account_invoice.xml new file mode 100644 index 000000000..0bfd2d1f5 --- /dev/null +++ b/account_payment_partner/view/account_invoice.xml @@ -0,0 +1,38 @@ + + + + + + + + + + account_payment_partner.invoice_form + account.invoice + + + + + + + + + + + account_payment_partner.invoice_supplier_form + account.invoice + + + + + + + + + + + diff --git a/account_payment_partner/view/partner.xml b/account_payment_partner/view/partner.xml new file mode 100644 index 000000000..02eb8cc0f --- /dev/null +++ b/account_payment_partner/view/partner.xml @@ -0,0 +1,31 @@ + + + + + + + + + + account_partner_payment.partner_form + res.partner + + + + + + + + + + + + + + From 136de0dca00ad94b20b329b2bb35a253a2b14dfe Mon Sep 17 00:00:00 2001 From: Launchpad Translations on behalf of banking-addons-team Date: Fri, 27 Jun 2014 07:13:31 +0000 Subject: [PATCH 02/33] Launchpad automatic translations update. --- account_payment_partner/i18n/nl.po | 58 ++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 account_payment_partner/i18n/nl.po diff --git a/account_payment_partner/i18n/nl.po b/account_payment_partner/i18n/nl.po new file mode 100644 index 000000000..4c90fe776 --- /dev/null +++ b/account_payment_partner/i18n/nl.po @@ -0,0 +1,58 @@ +# Dutch translation for banking-addons +# Copyright (c) 2014 Rosetta Contributors and Canonical Ltd 2014 +# This file is distributed under the same license as the banking-addons package. +# FIRST AUTHOR , 2014. +# +msgid "" +msgstr "" +"Project-Id-Version: banking-addons\n" +"Report-Msgid-Bugs-To: FULL NAME \n" +"POT-Creation-Date: 2014-06-09 23:22+0000\n" +"PO-Revision-Date: 2014-06-26 14:13+0000\n" +"Last-Translator: Erwin van der Ploeg (BAS Solutions) \n" +"Language-Team: Dutch \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Launchpad-Export-Date: 2014-06-27 07:13+0000\n" +"X-Generator: Launchpad (build 17077)\n" + +#. module: account_payment_partner +#: field:res.partner,customer_payment_mode:0 +msgid "Customer Payment Mode" +msgstr "Betaalwijze klant" + +#. module: account_payment_partner +#: model:ir.model,name:account_payment_partner.model_account_invoice +msgid "Invoice" +msgstr "Factuur" + +#. module: account_payment_partner +#: model:ir.model,name:account_payment_partner.model_res_partner +msgid "Partner" +msgstr "Relatie" + +#. module: account_payment_partner +#: field:account.invoice,payment_mode_id:0 +msgid "Payment Mode" +msgstr "Betaalwijze" + +#. module: account_payment_partner +#: help:res.partner,customer_payment_mode:0 +msgid "Select the default payment mode for this customer." +msgstr "Selecteer de standaard betaalwijze voor deze klant." + +#. module: account_payment_partner +#: help:res.partner,supplier_payment_mode:0 +msgid "Select the default payment mode for this supplier." +msgstr "Selecteer de standaard betaalwijze voor deze leverancier." + +#. module: account_payment_partner +#: field:res.partner,supplier_payment_mode:0 +msgid "Supplier Payment Mode" +msgstr "Betaalwijze leverancier" + +#. module: account_payment_partner +#: model:ir.model,name:account_payment_partner.model_payment_order_create +msgid "payment.order.create" +msgstr "payment.order.create" From 4032b073ab598475297b3dfff56d8f8b5c3f1771 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Wed, 10 Sep 2014 12:19:20 +0200 Subject: [PATCH 03/33] [MIG] account_payment_partner: Migration to v8 * Migration and enhancement of all modules involved in SEPA * Clean files * Replace deprecated workflow calls * Translation template files * Translations to spanish * Use sale_ok and purchase_ok instead of tweaking payment type --- account_payment_partner/__init__.py | 3 +- account_payment_partner/__openerp__.py | 14 ++--- .../i18n/account_payment_partner.pot | 13 ++-- account_payment_partner/i18n/es.po | 52 ++++++++++++++++ account_payment_partner/i18n/fr.po | 57 ++++++++++++++++++ account_payment_partner/models/__init__.py | 24 ++++++++ .../{model => models}/account_invoice.py | 31 +++++----- .../{model => models}/payment_order_create.py | 7 +-- .../partner.py => models/res_partner.py} | 28 ++++----- .../static/description/icon.png | Bin 0 -> 9455 bytes .../view/account_invoice.xml | 38 ------------ .../views/account_invoice_view.xml | 40 ++++++++++++ .../res_partner_view.xml} | 8 +-- .../{model => wizard}/__init__.py | 2 - .../wizard/payment_order_create.py | 37 ++++++++++++ 15 files changed, 254 insertions(+), 100 deletions(-) create mode 100644 account_payment_partner/i18n/es.po create mode 100644 account_payment_partner/i18n/fr.po create mode 100644 account_payment_partner/models/__init__.py rename account_payment_partner/{model => models}/account_invoice.py (65%) rename account_payment_partner/{model => models}/payment_order_create.py (91%) rename account_payment_partner/{model/partner.py => models/res_partner.py} (60%) create mode 100644 account_payment_partner/static/description/icon.png delete mode 100644 account_payment_partner/view/account_invoice.xml create mode 100644 account_payment_partner/views/account_invoice_view.xml rename account_payment_partner/{view/partner.xml => views/res_partner_view.xml} (75%) rename account_payment_partner/{model => wizard}/__init__.py (95%) create mode 100644 account_payment_partner/wizard/payment_order_create.py diff --git a/account_payment_partner/__init__.py b/account_payment_partner/__init__.py index 161123944..fe47437f2 100644 --- a/account_payment_partner/__init__.py +++ b/account_payment_partner/__init__.py @@ -20,4 +20,5 @@ # ############################################################################## -from . import model +from . import models +from . import wizard diff --git a/account_payment_partner/__openerp__.py b/account_payment_partner/__openerp__.py index 4e0217c98..99df885ea 100644 --- a/account_payment_partner/__openerp__.py +++ b/account_payment_partner/__openerp__.py @@ -23,7 +23,7 @@ { 'name': 'Account Payment Partner', - 'version': '0.1', + 'version': '8.0.0.1.0', 'category': 'Banking addons', 'license': 'AGPL-3', 'summary': 'Adds payment mode on partners and invoices', @@ -39,17 +39,15 @@ This module adds severals fields : On a Payment Order, in the wizard *Select Invoices to Pay*, the invoices will be filtered per Payment Mode. - -Please contact Alexis de Lattre from Akretion -for any help or question about this module. """, - 'author': 'Akretion', + 'author': "Akretion,Odoo Community Association (OCA)", 'website': 'http://www.akretion.com', + 'contributors': ['Pedro M. Baeza '], 'depends': ['account_banking_payment_export'], 'data': [ - 'view/partner.xml', - 'view/account_invoice.xml', + 'views/res_partner_view.xml', + 'views/account_invoice_view.xml', ], 'demo': ['demo/partner_demo.xml'], - 'active': False, + 'installable': True, } diff --git a/account_payment_partner/i18n/account_payment_partner.pot b/account_payment_partner/i18n/account_payment_partner.pot index ca26e532d..3c5a39686 100644 --- a/account_payment_partner/i18n/account_payment_partner.pot +++ b/account_payment_partner/i18n/account_payment_partner.pot @@ -1,13 +1,13 @@ -# Translation of OpenERP Server. +# Translation of Odoo Server. # This file contains the translation of the following modules: # * account_payment_partner # msgid "" msgstr "" -"Project-Id-Version: OpenERP Server 7.0\n" +"Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-06-09 23:22+0000\n" -"PO-Revision-Date: 2014-06-09 23:22+0000\n" +"POT-Creation-Date: 2014-10-31 22:53+0000\n" +"PO-Revision-Date: 2014-10-31 22:53+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -50,8 +50,3 @@ msgstr "" msgid "Supplier Payment Mode" msgstr "" -#. module: account_payment_partner -#: model:ir.model,name:account_payment_partner.model_payment_order_create -msgid "payment.order.create" -msgstr "" - diff --git a/account_payment_partner/i18n/es.po b/account_payment_partner/i18n/es.po new file mode 100644 index 000000000..63748b988 --- /dev/null +++ b/account_payment_partner/i18n/es.po @@ -0,0 +1,52 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_payment_partner +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-10-31 22:53+0000\n" +"PO-Revision-Date: 2014-10-31 22:53+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_payment_partner +#: field:res.partner,customer_payment_mode:0 +msgid "Customer Payment Mode" +msgstr "Modo de pago de cliente" + +#. module: account_payment_partner +#: model:ir.model,name:account_payment_partner.model_account_invoice +msgid "Invoice" +msgstr "Factura" + +#. module: account_payment_partner +#: model:ir.model,name:account_payment_partner.model_res_partner +msgid "Partner" +msgstr "Empresa" + +#. module: account_payment_partner +#: field:account.invoice,payment_mode_id:0 +msgid "Payment Mode" +msgstr "Modo de pago" + +#. module: account_payment_partner +#: help:res.partner,customer_payment_mode:0 +msgid "Select the default payment mode for this customer." +msgstr "Seleccione el modo de pago por defecto cuando esta empresa actúa como cliente." + +#. module: account_payment_partner +#: help:res.partner,supplier_payment_mode:0 +msgid "Select the default payment mode for this supplier." +msgstr "Seleccione el modo de pago por defecto cuando esta empresa actúa como proveedor." + +#. module: account_payment_partner +#: field:res.partner,supplier_payment_mode:0 +msgid "Supplier Payment Mode" +msgstr "Modo de pago de proveedor" + diff --git a/account_payment_partner/i18n/fr.po b/account_payment_partner/i18n/fr.po new file mode 100644 index 000000000..ca26e532d --- /dev/null +++ b/account_payment_partner/i18n/fr.po @@ -0,0 +1,57 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_payment_partner +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-06-09 23:22+0000\n" +"PO-Revision-Date: 2014-06-09 23:22+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_payment_partner +#: field:res.partner,customer_payment_mode:0 +msgid "Customer Payment Mode" +msgstr "" + +#. module: account_payment_partner +#: model:ir.model,name:account_payment_partner.model_account_invoice +msgid "Invoice" +msgstr "" + +#. module: account_payment_partner +#: model:ir.model,name:account_payment_partner.model_res_partner +msgid "Partner" +msgstr "" + +#. module: account_payment_partner +#: field:account.invoice,payment_mode_id:0 +msgid "Payment Mode" +msgstr "" + +#. module: account_payment_partner +#: help:res.partner,customer_payment_mode:0 +msgid "Select the default payment mode for this customer." +msgstr "" + +#. module: account_payment_partner +#: help:res.partner,supplier_payment_mode:0 +msgid "Select the default payment mode for this supplier." +msgstr "" + +#. module: account_payment_partner +#: field:res.partner,supplier_payment_mode:0 +msgid "Supplier Payment Mode" +msgstr "" + +#. module: account_payment_partner +#: model:ir.model,name:account_payment_partner.model_payment_order_create +msgid "payment.order.create" +msgstr "" + diff --git a/account_payment_partner/models/__init__.py b/account_payment_partner/models/__init__.py new file mode 100644 index 000000000..c2c7b405d --- /dev/null +++ b/account_payment_partner/models/__init__.py @@ -0,0 +1,24 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Partner module for OpenERP +# Copyright (C) 2014 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import res_partner +from . import account_invoice diff --git a/account_payment_partner/model/account_invoice.py b/account_payment_partner/models/account_invoice.py similarity index 65% rename from account_payment_partner/model/account_invoice.py rename to account_payment_partner/models/account_invoice.py index 607cda29a..e14c0d956 100644 --- a/account_payment_partner/model/account_invoice.py +++ b/account_payment_partner/models/account_invoice.py @@ -20,37 +20,34 @@ # ############################################################################## -from openerp.osv import orm, fields +from openerp import models, fields, api -class account_invoice(orm.Model): +class AccountInvoice(models.Model): _inherit = 'account.invoice' - _columns = { - 'payment_mode_id': fields.many2one( - 'payment.mode', 'Payment Mode'), - } + payment_mode_id = fields.Many2one( + comodel_name='payment.mode', string="Payment Mode", + domain="[('type', '=', type)]") + @api.multi def onchange_partner_id( - self, cr, uid, ids, type, partner_id, date_invoice=False, + self, type, partner_id, date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False): - res = super(account_invoice, self).onchange_partner_id( - cr, uid, ids, type, partner_id, date_invoice=date_invoice, + res = super(AccountInvoice, self).onchange_partner_id( + type, partner_id, date_invoice=date_invoice, payment_term=payment_term, partner_bank_id=partner_bank_id, company_id=company_id) if partner_id: - partner = self.pool['res.partner'].browse(cr, uid, partner_id) + partner = self.env['res.partner'].browse(partner_id) if type == 'in_invoice': res['value']['payment_mode_id'] = \ - partner.supplier_payment_mode.id or False + partner.supplier_payment_mode.id elif type == 'out_invoice': res['value'].update({ - 'payment_mode_id': - partner.customer_payment_mode.id or False, - 'partner_bank_id': - partner.customer_payment_mode and - partner.customer_payment_mode.bank_id.id or False, - }) + 'payment_mode_id': partner.customer_payment_mode.id, + 'partner_bank_id': partner.customer_payment_mode.bank_id.id + }) else: res['value']['payment_mode_id'] = False return res diff --git a/account_payment_partner/model/payment_order_create.py b/account_payment_partner/models/payment_order_create.py similarity index 91% rename from account_payment_partner/model/payment_order_create.py rename to account_payment_partner/models/payment_order_create.py index ea8b1ccb3..3b9b536a7 100644 --- a/account_payment_partner/model/payment_order_create.py +++ b/account_payment_partner/models/payment_order_create.py @@ -23,17 +23,16 @@ from openerp.osv import orm -class payment_order_create(orm.TransientModel): +class PaymentOrderCreate(orm.TransientModel): _inherit = 'payment.order.create' def extend_payment_order_domain( self, cr, uid, payment_order, domain, context=None): - super(payment_order_create, self).extend_payment_order_domain( + super(PaymentOrderCreate, self).extend_payment_order_domain( cr, uid, payment_order, domain, context=context) domain += [ '|', '|', ('invoice', '=', False), ('invoice.payment_mode_id', '=', False), - ('invoice.payment_mode_id', '=', payment_order.mode.id) - ] + ('invoice.payment_mode_id', '=', payment_order.mode.id)] return True diff --git a/account_payment_partner/model/partner.py b/account_payment_partner/models/res_partner.py similarity index 60% rename from account_payment_partner/model/partner.py rename to account_payment_partner/models/res_partner.py index 4bfe4c787..5726da446 100644 --- a/account_payment_partner/model/partner.py +++ b/account_payment_partner/models/res_partner.py @@ -20,25 +20,23 @@ # ############################################################################## -from openerp.osv import orm, fields +from openerp import models, fields, api -class res_partner(orm.Model): +class ResPartner(models.Model): _inherit = 'res.partner' - _columns = { - 'supplier_payment_mode': fields.property( - 'payment.mode', type='many2one', relation='payment.mode', - string='Supplier Payment Mode', view_load=True, - help="Select the default payment mode for this supplier."), - 'customer_payment_mode': fields.property( - 'payment.mode', type='many2one', relation='payment.mode', - string='Customer Payment Mode', view_load=True, - help="Select the default payment mode for this customer."), - } + supplier_payment_mode = fields.Many2one( + 'payment.mode', string='Supplier Payment Mode', company_dependent=True, + domain="[('purchase_ok', '=', True)]", + help="Select the default payment mode for this supplier.") + customer_payment_mode = fields.Many2one( + 'payment.mode', string='Customer Payment Mode', company_dependent=True, + domain="[('sale_ok', '=', True)]", + help="Select the default payment mode for this customer.") - def _commercial_fields(self, cr, uid, context=None): - res = super(res_partner, self)._commercial_fields( - cr, uid, context=context) + @api.model + def _commercial_fields(self): + res = super(ResPartner, self)._commercial_fields() res += ['supplier_payment_mode', 'customer_payment_mode'] return res diff --git a/account_payment_partner/static/description/icon.png b/account_payment_partner/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..3a0328b516c4980e8e44cdb63fd945757ddd132d GIT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IgY>}^5w`vTB(G`PTZaDiGBo5o(tp)qli|NeV( z@H_=R8V39rt5J5YB2Ky?4eJJ#b`_iBe2ot~6%7mLt5t8Vwi^Jy7|jWXqa3amOIoRb zOr}WVFP--DsS`1WpN%~)t3R!arKF^Q$e12KEqU36AWwnCBICpH4XCsfnyrHr>$I$4 z!DpKX$OKLWarN7nv@!uIA+~RNO)l$$w}p(;b>mx8pwYvu;dD_unryX_NhT8*Tj>BTrTTL&!?O+%Rv;b?B??gSzdp?6Uug9{ zd@V08Z$BdI?fpoCS$)t4mg4rT8Q_I}h`0d-vYZ^|dOB*Q^S|xqTV*vIg?@fVFSmMpaw0qtTRbx} z({Pg?#{2`sc9)M5N$*N|4;^t$+QP?#mov zGVC@I*lBVrOU-%2y!7%)fAKjpEFsgQc4{amtiHb95KQEwvf<(3T<9-Zm$xIew#P22 zc2Ix|App^>v6(3L_MCU0d3W##AB0M~3D00EWoKZqsJYT(#@w$Y_H7G22M~ApVFTRHMI_3be)Lkn#0F*V8Pq zc}`Cjy$bE;FJ6H7p=0y#R>`}-m4(0F>%@P|?7fx{=R^uFdISRnZ2W_xQhD{YuR3t< z{6yxu=4~JkeA;|(J6_nv#>Nvs&FuLA&PW^he@t(UwFFE8)|a!R{`E`K`i^ZnyE4$k z;(749Ix|oi$c3QbEJ3b~D_kQsPz~fIUKym($a_7dJ?o+40*OLl^{=&oq$<#Q(yyrp z{J-FAniyAw9tPbe&IhQ|a`DqFTVQGQ&Gq3!C2==4x{6EJwiPZ8zub-iXoUtkJiG{} zPaR&}_fn8_z~(=;5lD-aPWD3z8PZS@AaUiomF!G8I}Mf>e~0g#BelA-5#`cj;O5>N Xviia!U7SGha1wx#SCgwmn*{w2TRX*I literal 0 HcmV?d00001 diff --git a/account_payment_partner/view/account_invoice.xml b/account_payment_partner/view/account_invoice.xml deleted file mode 100644 index 0bfd2d1f5..000000000 --- a/account_payment_partner/view/account_invoice.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - account_payment_partner.invoice_form - account.invoice - - - - - - - - - - - account_payment_partner.invoice_supplier_form - account.invoice - - - - - - - - - - - diff --git a/account_payment_partner/views/account_invoice_view.xml b/account_payment_partner/views/account_invoice_view.xml new file mode 100644 index 000000000..534822ea9 --- /dev/null +++ b/account_payment_partner/views/account_invoice_view.xml @@ -0,0 +1,40 @@ + + + + + + + + + + account_payment_partner.invoice_form + account.invoice + + + + + + + + + + + account_payment_partner.invoice_supplier_form + account.invoice + + + + + + + + + + + diff --git a/account_payment_partner/view/partner.xml b/account_payment_partner/views/res_partner_view.xml similarity index 75% rename from account_payment_partner/view/partner.xml rename to account_payment_partner/views/res_partner_view.xml index 02eb8cc0f..3c6d670aa 100644 --- a/account_payment_partner/view/partner.xml +++ b/account_payment_partner/views/res_partner_view.xml @@ -9,23 +9,19 @@ - account_partner_payment.partner_form res.partner - + - + - diff --git a/account_payment_partner/model/__init__.py b/account_payment_partner/wizard/__init__.py similarity index 95% rename from account_payment_partner/model/__init__.py rename to account_payment_partner/wizard/__init__.py index 16ab8bc9e..f7107a63f 100644 --- a/account_payment_partner/model/__init__.py +++ b/account_payment_partner/wizard/__init__.py @@ -20,6 +20,4 @@ # ############################################################################## -from . import partner -from . import account_invoice from . import payment_order_create diff --git a/account_payment_partner/wizard/payment_order_create.py b/account_payment_partner/wizard/payment_order_create.py new file mode 100644 index 000000000..c26b7f9d9 --- /dev/null +++ b/account_payment_partner/wizard/payment_order_create.py @@ -0,0 +1,37 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Partner module for OpenERP +# Copyright (C) 2014 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp import models, api + + +class PaymentOrderCreate(models.TransientModel): + _inherit = 'payment.order.create' + + @api.model + def extend_payment_order_domain(self, payment_order, domain): + res = super(PaymentOrderCreate, self).extend_payment_order_domain( + payment_order, domain) + domain += ['|', '|', + ('invoice', '=', False), + ('invoice.payment_mode_id', '=', False), + ('invoice.payment_mode_id', '=', payment_order.mode.id)] + return res From 90261098702c946944907d611180f375c87cb7d4 Mon Sep 17 00:00:00 2001 From: Roberto Lizana Date: Thu, 27 Nov 2014 12:55:21 +0100 Subject: [PATCH 04/33] [FIX+IMP] account_payment_partner: 2 things: * IMP: Add filter group by payment mode in account invoices * FIX: Remove deprecated tag type --- .../views/account_invoice_view.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/account_payment_partner/views/account_invoice_view.xml b/account_payment_partner/views/account_invoice_view.xml index 534822ea9..5655e3d25 100644 --- a/account_payment_partner/views/account_invoice_view.xml +++ b/account_payment_partner/views/account_invoice_view.xml @@ -9,6 +9,17 @@ + + account_payment_partner.invoice_filter + account.invoice + + + + + + + + account_payment_partner.invoice_form From 7a4347d3401ccd3a84b119ba1bb8e4afbacef73b Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 14 Jan 2015 15:25:50 +0100 Subject: [PATCH 05/33] [IMP] account_payment_partner: Several things: * move unused file + cleanup code * Add sale_ok and purchase_ok filters in partner/sale/purchase form views * Use widget=selection for payment_mode_id fields * Update demo data * Return res in inherit (even if res is empty in this case) --- .../models/payment_order_create.py | 38 ------------------- .../views/account_invoice_view.xml | 6 ++- .../views/res_partner_view.xml | 8 +++- 3 files changed, 10 insertions(+), 42 deletions(-) delete mode 100644 account_payment_partner/models/payment_order_create.py diff --git a/account_payment_partner/models/payment_order_create.py b/account_payment_partner/models/payment_order_create.py deleted file mode 100644 index 3b9b536a7..000000000 --- a/account_payment_partner/models/payment_order_create.py +++ /dev/null @@ -1,38 +0,0 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# Account Payment Partner module for OpenERP -# Copyright (C) 2014 Akretion (http://www.akretion.com) -# @author Alexis de Lattre -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - -from openerp.osv import orm - - -class PaymentOrderCreate(orm.TransientModel): - _inherit = 'payment.order.create' - - def extend_payment_order_domain( - self, cr, uid, payment_order, domain, context=None): - super(PaymentOrderCreate, self).extend_payment_order_domain( - cr, uid, payment_order, domain, context=context) - domain += [ - '|', '|', - ('invoice', '=', False), - ('invoice.payment_mode_id', '=', False), - ('invoice.payment_mode_id', '=', payment_order.mode.id)] - return True diff --git a/account_payment_partner/views/account_invoice_view.xml b/account_payment_partner/views/account_invoice_view.xml index 5655e3d25..72afbb2a5 100644 --- a/account_payment_partner/views/account_invoice_view.xml +++ b/account_payment_partner/views/account_invoice_view.xml @@ -28,7 +28,8 @@ + domain="[('sale_ok', '=', True)]" + widget="selection"/> @@ -41,7 +42,8 @@ + domain="[('purchase_ok', '=', True)]" + widget="selection"/> diff --git a/account_payment_partner/views/res_partner_view.xml b/account_payment_partner/views/res_partner_view.xml index 3c6d670aa..f52579b2c 100644 --- a/account_payment_partner/views/res_partner_view.xml +++ b/account_payment_partner/views/res_partner_view.xml @@ -15,10 +15,14 @@ - + - + From 74107ab0a4f8304d844d02283e163d279a753a17 Mon Sep 17 00:00:00 2001 From: Danimar Ribeiro Date: Fri, 13 Feb 2015 19:18:41 -0200 Subject: [PATCH 06/33] Portuguese translations --- account_payment_partner/i18n/pt_BR.po | 52 +++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 account_payment_partner/i18n/pt_BR.po diff --git a/account_payment_partner/i18n/pt_BR.po b/account_payment_partner/i18n/pt_BR.po new file mode 100644 index 000000000..63cd2737f --- /dev/null +++ b/account_payment_partner/i18n/pt_BR.po @@ -0,0 +1,52 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * account_payment_partner +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-10-31 22:53+0000\n" +"PO-Revision-Date: 2014-10-31 22:53+0000\n" +"Last-Translator: Danimar Ribeiro \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_payment_partner +#: field:res.partner,customer_payment_mode:0 +msgid "Customer Payment Mode" +msgstr "Modo de Pagamento do Cliente" + +#. module: account_payment_partner +#: model:ir.model,name:account_payment_partner.model_account_invoice +msgid "Invoice" +msgstr "Fatura" + +#. module: account_payment_partner +#: model:ir.model,name:account_payment_partner.model_res_partner +msgid "Partner" +msgstr "Parceiro" + +#. module: account_payment_partner +#: field:account.invoice,payment_mode_id:0 +msgid "Payment Mode" +msgstr "Modo de Pagamento" + +#. module: account_payment_partner +#: help:res.partner,customer_payment_mode:0 +msgid "Select the default payment mode for this customer." +msgstr "Selecione o modo de pagamento padrão para este cliente." + +#. module: account_payment_partner +#: help:res.partner,supplier_payment_mode:0 +msgid "Select the default payment mode for this supplier." +msgstr "Selecione o modo de pagamento padrão para este fornecedor." + +#. module: account_payment_partner +#: field:res.partner,supplier_payment_mode:0 +msgid "Supplier Payment Mode" +msgstr "Modo de Pagamento do Fornecedor" + From 232fea9a18086ab629a9764d640f0245bacb2774 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 16 Mar 2015 11:07:21 +0100 Subject: [PATCH 07/33] Add read access on payment.mode to employees --- account_payment_partner/__openerp__.py | 1 + account_payment_partner/security/ir.model.access.csv | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 account_payment_partner/security/ir.model.access.csv diff --git a/account_payment_partner/__openerp__.py b/account_payment_partner/__openerp__.py index 99df885ea..e50726d48 100644 --- a/account_payment_partner/__openerp__.py +++ b/account_payment_partner/__openerp__.py @@ -47,6 +47,7 @@ be filtered per Payment Mode. 'data': [ 'views/res_partner_view.xml', 'views/account_invoice_view.xml', + 'security/ir.model.access.csv', ], 'demo': ['demo/partner_demo.xml'], 'installable': True, diff --git a/account_payment_partner/security/ir.model.access.csv b/account_payment_partner/security/ir.model.access.csv new file mode 100644 index 000000000..b277f0229 --- /dev/null +++ b/account_payment_partner/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_payment_mode_read,Read access on payment.mode to Employees,account_payment.model_payment_mode,base.group_user,1,0,0,0 From 16443e96b9b986c009d6254b8582d9e2bb7ae355 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Mon, 9 Mar 2015 09:15:19 +0100 Subject: [PATCH 08/33] [FIX] account_payment_partner: Fix for finding account move lines without invoice (manual entries in receivables/payables) --- .../wizard/payment_order_create.py | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/account_payment_partner/wizard/payment_order_create.py b/account_payment_partner/wizard/payment_order_create.py index c26b7f9d9..a07ed280e 100644 --- a/account_payment_partner/wizard/payment_order_create.py +++ b/account_payment_partner/wizard/payment_order_create.py @@ -30,8 +30,29 @@ class PaymentOrderCreate(models.TransientModel): def extend_payment_order_domain(self, payment_order, domain): res = super(PaymentOrderCreate, self).extend_payment_order_domain( payment_order, domain) - domain += ['|', '|', - ('invoice', '=', False), + # Monkey patch for fixing problem with the core search function + # when args has ('invoice', '=', False), referred in the issue #4857 + # (https://github.com/odoo/odoo/issues/4857) + # + # Original domain: + # domain += ['|', '|', + # ('invoice', '=', False), + # ('invoice.payment_mode_id', '=', False), + # ('invoice.payment_mode_id', '=', payment_order.mode.id)] + self.env.cr.execute( + "SELECT l.id " + "FROM account_move_line l " + "LEFT OUTER JOIN account_invoice i " + "ON l.move_id = i.move_id " + "INNER JOIN account_account a " + "ON a.id = l.account_id " + "WHERE i.id IS NULL" + " AND l.reconcile_id IS NULL" + " AND a.type in ('receivable', 'payable')") + ids = [x[0] for x in self.env.cr.fetchall()] + domain += ['|', + ('id', 'in', ids), + '|', ('invoice.payment_mode_id', '=', False), ('invoice.payment_mode_id', '=', payment_order.mode.id)] return res From e03accab6d2c92c923d273e71dc20b85010e7c7e Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Mon, 25 May 2015 17:14:05 +0200 Subject: [PATCH 09/33] [IMP] Expand authors + manifest cleaning --- account_payment_partner/__openerp__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/account_payment_partner/__openerp__.py b/account_payment_partner/__openerp__.py index e50726d48..4f5d9b796 100644 --- a/account_payment_partner/__openerp__.py +++ b/account_payment_partner/__openerp__.py @@ -40,9 +40,10 @@ This module adds severals fields : On a Payment Order, in the wizard *Select Invoices to Pay*, the invoices will be filtered per Payment Mode. """, - 'author': "Akretion,Odoo Community Association (OCA)", - 'website': 'http://www.akretion.com', - 'contributors': ['Pedro M. Baeza '], + 'author': "Akretion, " + "Serv. Tecnol. Avanzados - Pedro M. Baeza, " + "Odoo Community Association (OCA)", + 'website': 'https://github.com/OCA/bank-payment', 'depends': ['account_banking_payment_export'], 'data': [ 'views/res_partner_view.xml', From 589187a2e05ed6aced7cad352bcfed13baab336a Mon Sep 17 00:00:00 2001 From: Philippe Schmidt Date: Mon, 1 Jun 2015 17:10:58 +0200 Subject: [PATCH 10/33] Add requested descriptions in an OCA README.rst file --- account_payment_partner/README.rst | 79 ++++++++++++++++++++++++++ account_payment_partner/__openerp__.py | 13 ----- 2 files changed, 79 insertions(+), 13 deletions(-) create mode 100644 account_payment_partner/README.rst diff --git a/account_payment_partner/README.rst b/account_payment_partner/README.rst new file mode 100644 index 000000000..e4e4d0a52 --- /dev/null +++ b/account_payment_partner/README.rst @@ -0,0 +1,79 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License: AGPL-3 + +Account Payment Partner +======================= + +This module adds severals fields : + +* the *Supplier Payment Mode* and *Customer Payment Mode* on Partners, + +* the *Payment Mode* on Invoices. + +On a Payment Order, in the wizard *Select Invoices to Pay*, the invoices will +be filtered per Payment Mode. + +Installation +============ + +This module depends on : +* account_banking_payment_export + +This module is part of the OCA/bank-payment suite. + +Configuration +============= + +There is nothing to configure. + +Usage +===== + +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. + +For further information, please visit: + + * https://www.odoo.com/forum/help-1 + +Known issues / Roadmap +====================== + + * No known issues. + +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 +`here `_. + +Credits +======= + +Contributors +------------ + +* Pedro M. Baeza +* Alexis de Lattre +* Raphaël Valyi +* Stefan Rijnhart (Therp) +* Alexandre Fayolle +* Stéphane Bidoul +* Danimar Ribeiro + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://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. diff --git a/account_payment_partner/__openerp__.py b/account_payment_partner/__openerp__.py index 4f5d9b796..bb0fd91eb 100644 --- a/account_payment_partner/__openerp__.py +++ b/account_payment_partner/__openerp__.py @@ -27,19 +27,6 @@ 'category': 'Banking addons', 'license': 'AGPL-3', 'summary': 'Adds payment mode on partners and invoices', - 'description': """ -Account Payment Partner -======================= - -This module adds severals fields : - -* the *Supplier Payment Mode* and *Customer Payment Mode* on Partners, - -* the *Payment Mode* on Invoices. - -On a Payment Order, in the wizard *Select Invoices to Pay*, the invoices will -be filtered per Payment Mode. - """, 'author': "Akretion, " "Serv. Tecnol. Avanzados - Pedro M. Baeza, " "Odoo Community Association (OCA)", From 0540244e48b6b6ac754d9a472b501c4acf5bbe5b Mon Sep 17 00:00:00 2001 From: AngelMoya-Domatix Date: Thu, 2 Jul 2015 12:58:05 +0200 Subject: [PATCH 11/33] ADD description on payment mode and show it on invoice report FIX tabs FIX translate --- account_payment_partner/README.rst | 1 + account_payment_partner/__openerp__.py | 1 + .../i18n/account_payment_partner.pot | 14 ++++++++++++-- account_payment_partner/i18n/es.po | 14 ++++++++++++-- .../views/report_invoice.xml | 17 +++++++++++++++++ 5 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 account_payment_partner/views/report_invoice.xml diff --git a/account_payment_partner/README.rst b/account_payment_partner/README.rst index e4e4d0a52..2837e36a1 100644 --- a/account_payment_partner/README.rst +++ b/account_payment_partner/README.rst @@ -64,6 +64,7 @@ Contributors * Alexandre Fayolle * Stéphane Bidoul * Danimar Ribeiro +* Angel Moya Maintainer ---------- diff --git a/account_payment_partner/__openerp__.py b/account_payment_partner/__openerp__.py index bb0fd91eb..ef8b028ce 100644 --- a/account_payment_partner/__openerp__.py +++ b/account_payment_partner/__openerp__.py @@ -35,6 +35,7 @@ 'data': [ 'views/res_partner_view.xml', 'views/account_invoice_view.xml', + 'views/report_invoice.xml', 'security/ir.model.access.csv', ], 'demo': ['demo/partner_demo.xml'], diff --git a/account_payment_partner/i18n/account_payment_partner.pot b/account_payment_partner/i18n/account_payment_partner.pot index 3c5a39686..82c70d780 100644 --- a/account_payment_partner/i18n/account_payment_partner.pot +++ b/account_payment_partner/i18n/account_payment_partner.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-10-31 22:53+0000\n" -"PO-Revision-Date: 2014-10-31 22:53+0000\n" +"POT-Creation-Date: 2015-07-02 10:53+0000\n" +"PO-Revision-Date: 2015-07-02 10:53+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -15,6 +15,11 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" +#. module: account_payment_partner +#: view:website:account.report_invoice_document +msgid "Bank Account:" +msgstr "" + #. module: account_payment_partner #: field:res.partner,customer_payment_mode:0 msgid "Customer Payment Mode" @@ -35,6 +40,11 @@ msgstr "" msgid "Payment Mode" msgstr "" +#. module: account_payment_partner +#: view:website:account.report_invoice_document +msgid "Payment Mode:" +msgstr "" + #. module: account_payment_partner #: help:res.partner,customer_payment_mode:0 msgid "Select the default payment mode for this customer." diff --git a/account_payment_partner/i18n/es.po b/account_payment_partner/i18n/es.po index 63748b988..8d9b6b91a 100644 --- a/account_payment_partner/i18n/es.po +++ b/account_payment_partner/i18n/es.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-10-31 22:53+0000\n" -"PO-Revision-Date: 2014-10-31 22:53+0000\n" +"POT-Creation-Date: 2015-07-02 10:55+0000\n" +"PO-Revision-Date: 2015-07-02 10:55+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -15,6 +15,11 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" +#. module: account_payment_partner +#: view:website:account.report_invoice_document +msgid "Bank Account:" +msgstr "Cuenta bancaria:" + #. module: account_payment_partner #: field:res.partner,customer_payment_mode:0 msgid "Customer Payment Mode" @@ -35,6 +40,11 @@ msgstr "Empresa" msgid "Payment Mode" msgstr "Modo de pago" +#. module: account_payment_partner +#: view:website:account.report_invoice_document +msgid "Payment Mode:" +msgstr "Modo de pago:" + #. module: account_payment_partner #: help:res.partner,customer_payment_mode:0 msgid "Select the default payment mode for this customer." diff --git a/account_payment_partner/views/report_invoice.xml b/account_payment_partner/views/report_invoice.xml new file mode 100644 index 000000000..356ec1d4d --- /dev/null +++ b/account_payment_partner/views/report_invoice.xml @@ -0,0 +1,17 @@ + + + + + + From e79e5b3c9cafd512951b21d784f2b4727c72f8e2 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Wed, 8 Jul 2015 14:55:31 +0200 Subject: [PATCH 12/33] [RFR] decorate overridable methods in wizard as api.multi --- account_payment_partner/wizard/payment_order_create.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_payment_partner/wizard/payment_order_create.py b/account_payment_partner/wizard/payment_order_create.py index a07ed280e..442047610 100644 --- a/account_payment_partner/wizard/payment_order_create.py +++ b/account_payment_partner/wizard/payment_order_create.py @@ -26,7 +26,7 @@ from openerp import models, api class PaymentOrderCreate(models.TransientModel): _inherit = 'payment.order.create' - @api.model + @api.multi def extend_payment_order_domain(self, payment_order, domain): res = super(PaymentOrderCreate, self).extend_payment_order_domain( payment_order, domain) From 85e753eb4a0c606e386a58c4c928bd740d6bcfba Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 19 Oct 2015 17:50:53 +0200 Subject: [PATCH 13/33] [FIX+IMP] account_payment_partner: Several things: * Forgot to remove a usecase of debit_denied * Add ACL * Better filters on payment.order.create wizard * Add default values for those filters on payment.mode * FIX remove coma at end of line * Add translatable 'label' field on payment.mode, designed to be used in invoice report --- account_payment_partner/__openerp__.py | 2 + account_payment_partner/models/__init__.py | 23 +------ .../models/payment_mode.py | 35 +++++++++++ .../security/ir.model.access.csv | 1 + .../views/payment_mode.xml | 23 +++++++ .../wizard/payment_order_create.py | 60 ++++++++++--------- .../wizard/payment_order_create_view.xml | 25 ++++++++ 7 files changed, 119 insertions(+), 50 deletions(-) create mode 100644 account_payment_partner/models/payment_mode.py create mode 100644 account_payment_partner/views/payment_mode.xml create mode 100644 account_payment_partner/wizard/payment_order_create_view.xml diff --git a/account_payment_partner/__openerp__.py b/account_payment_partner/__openerp__.py index ef8b028ce..2bbc92f96 100644 --- a/account_payment_partner/__openerp__.py +++ b/account_payment_partner/__openerp__.py @@ -36,7 +36,9 @@ 'views/res_partner_view.xml', 'views/account_invoice_view.xml', 'views/report_invoice.xml', + 'views/payment_mode.xml', 'security/ir.model.access.csv', + 'wizard/payment_order_create_view.xml', ], 'demo': ['demo/partner_demo.xml'], 'installable': True, diff --git a/account_payment_partner/models/__init__.py b/account_payment_partner/models/__init__.py index c2c7b405d..be3f531bb 100644 --- a/account_payment_partner/models/__init__.py +++ b/account_payment_partner/models/__init__.py @@ -1,24 +1,5 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# Account Payment Partner module for OpenERP -# Copyright (C) 2014 Akretion (http://www.akretion.com) -# @author Alexis de Lattre -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- from . import res_partner from . import account_invoice +from . import payment_mode diff --git a/account_payment_partner/models/payment_mode.py b/account_payment_partner/models/payment_mode.py new file mode 100644 index 000000000..62b8767e6 --- /dev/null +++ b/account_payment_partner/models/payment_mode.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2015 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp import models, fields + + +class PaymentMode(models.Model): + _inherit = "payment.mode" + + label = fields.Char( + string='Label', translate=True, + help="This field is designed to be used in the invoice report") + default_payment_mode = fields.Selection([ + ('same', 'Same'), + ('same_or_null', 'Same or empty'), + ('any', 'Any'), + ], string='Payment Mode on Invoice', default='same') diff --git a/account_payment_partner/security/ir.model.access.csv b/account_payment_partner/security/ir.model.access.csv index b277f0229..ac6d96dfd 100644 --- a/account_payment_partner/security/ir.model.access.csv +++ b/account_payment_partner/security/ir.model.access.csv @@ -1,2 +1,3 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_payment_mode_read,Read access on payment.mode to Employees,account_payment.model_payment_mode,base.group_user,1,0,0,0 +access_payment_mode_type_read,Read access on payment.mode.type to Employees,account_banking_payment_export.model_payment_mode_type,base.group_user,1,0,0,0 diff --git a/account_payment_partner/views/payment_mode.xml b/account_payment_partner/views/payment_mode.xml new file mode 100644 index 000000000..b32d52b01 --- /dev/null +++ b/account_payment_partner/views/payment_mode.xml @@ -0,0 +1,23 @@ + + + + + + + account_payment_partner.payment.mode.form + payment.mode + + + + + + + + + + + + + + diff --git a/account_payment_partner/wizard/payment_order_create.py b/account_payment_partner/wizard/payment_order_create.py index 442047610..fbf4939fb 100644 --- a/account_payment_partner/wizard/payment_order_create.py +++ b/account_payment_partner/wizard/payment_order_create.py @@ -1,8 +1,8 @@ -# -*- encoding: utf-8 -*- +# -*- coding: utf-8 -*- ############################################################################## # -# Account Payment Partner module for OpenERP -# Copyright (C) 2014 Akretion (http://www.akretion.com) +# Account Payment Partner module for Odoo +# Copyright (C) 2014-2015 Akretion (http://www.akretion.com) # @author Alexis de Lattre # # This program is free software: you can redistribute it and/or modify @@ -20,39 +20,41 @@ # ############################################################################## -from openerp import models, api +from openerp import models, fields, api class PaymentOrderCreate(models.TransientModel): _inherit = 'payment.order.create' + payment_mode = fields.Selection([ + ('same', 'Same'), + ('same_or_null', 'Same or empty'), + ('any', 'Any'), + ], string='Payment Mode on Invoice') + + @api.model + def default_get(self, field_list): + res = super(PaymentOrderCreate, self).default_get(field_list) + context = self.env.context + assert context.get('active_model') == 'payment.order',\ + 'active_model should be payment.order' + assert context.get('active_id'), 'Missing active_id in context !' + pay_order = self.env['payment.order'].browse(context['active_id']) + res['payment_mode'] = pay_order.mode.default_payment_mode + return res + @api.multi def extend_payment_order_domain(self, payment_order, domain): res = super(PaymentOrderCreate, self).extend_payment_order_domain( payment_order, domain) - # Monkey patch for fixing problem with the core search function - # when args has ('invoice', '=', False), referred in the issue #4857 - # (https://github.com/odoo/odoo/issues/4857) - # - # Original domain: - # domain += ['|', '|', - # ('invoice', '=', False), - # ('invoice.payment_mode_id', '=', False), - # ('invoice.payment_mode_id', '=', payment_order.mode.id)] - self.env.cr.execute( - "SELECT l.id " - "FROM account_move_line l " - "LEFT OUTER JOIN account_invoice i " - "ON l.move_id = i.move_id " - "INNER JOIN account_account a " - "ON a.id = l.account_id " - "WHERE i.id IS NULL" - " AND l.reconcile_id IS NULL" - " AND a.type in ('receivable', 'payable')") - ids = [x[0] for x in self.env.cr.fetchall()] - domain += ['|', - ('id', 'in', ids), - '|', - ('invoice.payment_mode_id', '=', False), - ('invoice.payment_mode_id', '=', payment_order.mode.id)] + if self.invoice and self.payment_mode: + if self.payment_mode == 'same': + domain.append( + ('invoice.payment_mode_id', '=', payment_order.mode.id)) + elif self.payment_mode == 'same_or_null': + domain += [ + '|', + ('invoice.payment_mode_id', '=', False), + ('invoice.payment_mode_id', '=', payment_order.mode.id)] + # if payment_mode == 'any', don't modify domain return res diff --git a/account_payment_partner/wizard/payment_order_create_view.xml b/account_payment_partner/wizard/payment_order_create_view.xml new file mode 100644 index 000000000..f163b8cd6 --- /dev/null +++ b/account_payment_partner/wizard/payment_order_create_view.xml @@ -0,0 +1,25 @@ + + + + + + + + account_payment_partner.payment.order.create.form + payment.order.create + + + + + + + + + + + From 93ae52c50670fe985251ef6c2dc25850744e948a Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Mon, 15 Feb 2016 23:10:18 +0100 Subject: [PATCH 14/33] [IMP] account_payment_partner: Several things * Short headers * Remove label field There's already a field in the payment mode called 'note' that is printed on the invoices, so there's no need of another field for that purpose. This field is added by account_banking_payment_export * Bump version numbers * es translations * Name to filter for better inheratiblity --- account_payment_partner/__init__.py | 24 ++------------- account_payment_partner/__openerp__.py | 28 ++++-------------- account_payment_partner/i18n/es.po | 29 +++++++++++++++++-- .../models/account_invoice.py | 25 +++------------- .../models/payment_mode.py | 25 ++-------------- account_payment_partner/models/res_partner.py | 25 +++------------- .../views/account_invoice_view.xml | 2 +- .../views/payment_mode.xml | 3 -- 8 files changed, 47 insertions(+), 114 deletions(-) diff --git a/account_payment_partner/__init__.py b/account_payment_partner/__init__.py index fe47437f2..794e1a243 100644 --- a/account_payment_partner/__init__.py +++ b/account_payment_partner/__init__.py @@ -1,24 +1,6 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# Account Payment Partner module for OpenERP -# Copyright (C) 2014 Akretion (http://www.akretion.com) -# @author Alexis de Lattre -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- +# © 2014 Akretion - Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import models from . import wizard diff --git a/account_payment_partner/__openerp__.py b/account_payment_partner/__openerp__.py index 2bbc92f96..0460a7c26 100644 --- a/account_payment_partner/__openerp__.py +++ b/account_payment_partner/__openerp__.py @@ -1,29 +1,11 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# Account Payment Partner module for OpenERP -# Copyright (C) 2014 Akretion (http://www.akretion.com) -# @author Alexis de Lattre -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## - +# -*- coding: utf-8 -*- +# © 2014 Akretion - Alexis de Lattre +# © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { 'name': 'Account Payment Partner', - 'version': '8.0.0.1.0', + 'version': '8.0.0.2.0', 'category': 'Banking addons', 'license': 'AGPL-3', 'summary': 'Adds payment mode on partners and invoices', diff --git a/account_payment_partner/i18n/es.po b/account_payment_partner/i18n/es.po index 8d9b6b91a..c78c3e344 100644 --- a/account_payment_partner/i18n/es.po +++ b/account_payment_partner/i18n/es.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-07-02 10:55+0000\n" -"PO-Revision-Date: 2015-07-02 10:55+0000\n" +"POT-Creation-Date: 2016-02-16 08:01+0000\n" +"PO-Revision-Date: 2016-02-16 08:01+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -15,6 +15,12 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" +#. module: account_payment_partner +#: selection:payment.mode,default_payment_mode:0 +#: selection:payment.order.create,payment_mode:0 +msgid "Any" +msgstr "Cualquiera" + #. module: account_payment_partner #: view:website:account.report_invoice_document msgid "Bank Account:" @@ -37,14 +43,33 @@ msgstr "Empresa" #. module: account_payment_partner #: field:account.invoice,payment_mode_id:0 +#: model:ir.model,name:account_payment_partner.model_payment_mode msgid "Payment Mode" msgstr "Modo de pago" +#. module: account_payment_partner +#: field:payment.mode,default_payment_mode:0 +#: field:payment.order.create,payment_mode:0 +msgid "Payment Mode on Invoice" +msgstr "Modo de pago en la factura" + #. module: account_payment_partner #: view:website:account.report_invoice_document msgid "Payment Mode:" msgstr "Modo de pago:" +#. module: account_payment_partner +#: selection:payment.mode,default_payment_mode:0 +#: selection:payment.order.create,payment_mode:0 +msgid "Same" +msgstr "Igual" + +#. module: account_payment_partner +#: selection:payment.mode,default_payment_mode:0 +#: selection:payment.order.create,payment_mode:0 +msgid "Same or empty" +msgstr "Igual o vacío" + #. module: account_payment_partner #: help:res.partner,customer_payment_mode:0 msgid "Select the default payment mode for this customer." diff --git a/account_payment_partner/models/account_invoice.py b/account_payment_partner/models/account_invoice.py index e14c0d956..4c5b971c6 100644 --- a/account_payment_partner/models/account_invoice.py +++ b/account_payment_partner/models/account_invoice.py @@ -1,24 +1,7 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# Account Payment Partner module for OpenERP -# Copyright (C) 2014 Akretion (http://www.akretion.com) -# @author Alexis de Lattre -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- +# © 2014 Akretion - Alexis de Lattre +# © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from openerp import models, fields, api diff --git a/account_payment_partner/models/payment_mode.py b/account_payment_partner/models/payment_mode.py index 62b8767e6..6d2fa946b 100644 --- a/account_payment_partner/models/payment_mode.py +++ b/account_payment_partner/models/payment_mode.py @@ -1,23 +1,7 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# Copyright (C) 2015 Akretion (http://www.akretion.com) -# @author Alexis de Lattre -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# © 2014 Akretion - Alexis de Lattre +# © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from openerp import models, fields @@ -25,9 +9,6 @@ from openerp import models, fields class PaymentMode(models.Model): _inherit = "payment.mode" - label = fields.Char( - string='Label', translate=True, - help="This field is designed to be used in the invoice report") default_payment_mode = fields.Selection([ ('same', 'Same'), ('same_or_null', 'Same or empty'), diff --git a/account_payment_partner/models/res_partner.py b/account_payment_partner/models/res_partner.py index 5726da446..7b6c850aa 100644 --- a/account_payment_partner/models/res_partner.py +++ b/account_payment_partner/models/res_partner.py @@ -1,24 +1,7 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# Account Payment Partner module for OpenERP -# Copyright (C) 2014 Akretion (http://www.akretion.com) -# @author Alexis de Lattre -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# -############################################################################## +# -*- coding: utf-8 -*- +# © 2014 Akretion - Alexis de Lattre +# © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from openerp import models, fields, api diff --git a/account_payment_partner/views/account_invoice_view.xml b/account_payment_partner/views/account_invoice_view.xml index 72afbb2a5..895e03bf5 100644 --- a/account_payment_partner/views/account_invoice_view.xml +++ b/account_payment_partner/views/account_invoice_view.xml @@ -15,7 +15,7 @@ - + diff --git a/account_payment_partner/views/payment_mode.xml b/account_payment_partner/views/payment_mode.xml index b32d52b01..120ca6970 100644 --- a/account_payment_partner/views/payment_mode.xml +++ b/account_payment_partner/views/payment_mode.xml @@ -12,9 +12,6 @@ - - - From 318287f085066e6af485253b53958c8e30532d83 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sat, 30 Apr 2016 01:46:34 +0200 Subject: [PATCH 15/33] [MIG] account_payment_partner: Start to port bank-payment to v9 (with a lot of improvements) during the Sorrento Code sprint 2016 Improvements include: - full re-organisation of modules and big re-organisation of the code - simplification of the code related to the fact that support for direct debit is now in t he base module, not added by an optional module account_direct_debit (module was removed) - new design of the wizard to select move lines to pay - support for non-SEPA file transfer- - support for German direct debit SEPA files (fixes bug #129) - remove workflow of payment.order * Finalise the wizard of selection of move lines to pay * Add button "Add to payment/debit order" on invoice form view * Started to integrate payment transfer in account_payment_order (not finished at all though) * Copy payment mode and mandate from invoice to refund * Run dos2unix on the few files that had DOS carriage return * Add _id suffix on M2O fields customer_payment_mode and supplier_payment_mode (Odoo did the same on all the M2O property fields of res.partner) * Better handling of partner_bank_id and mandate_id on invoice: invisible/required/onchange * Move field bank_account_required from module account_payment_partner to account_payment_mode --- account_payment_partner/README.rst | 22 ++--- account_payment_partner/__init__.py | 1 - account_payment_partner/__openerp__.py | 8 +- account_payment_partner/demo/partner_demo.xml | 42 ++------- account_payment_partner/models/__init__.py | 2 +- .../models/account_invoice.py | 87 ++++++++++++++----- .../models/account_move_line.py | 12 +++ .../models/payment_mode.py | 16 ---- account_payment_partner/models/res_partner.py | 17 ++-- .../security/ir.model.access.csv | 3 - .../views/account_invoice_view.xml | 58 ++++++++++--- .../views/account_move_line.xml | 28 ++++++ .../views/payment_mode.xml | 20 ----- .../views/report_invoice.xml | 2 +- .../views/res_partner_view.xml | 17 ++-- account_payment_partner/wizard/__init__.py | 23 ----- .../wizard/payment_order_create.py | 60 ------------- .../wizard/payment_order_create_view.xml | 25 ------ 18 files changed, 192 insertions(+), 251 deletions(-) create mode 100644 account_payment_partner/models/account_move_line.py delete mode 100644 account_payment_partner/models/payment_mode.py delete mode 100644 account_payment_partner/security/ir.model.access.csv create mode 100644 account_payment_partner/views/account_move_line.xml delete mode 100644 account_payment_partner/views/payment_mode.xml delete mode 100644 account_payment_partner/wizard/__init__.py delete mode 100644 account_payment_partner/wizard/payment_order_create.py delete mode 100644 account_payment_partner/wizard/payment_order_create_view.xml diff --git a/account_payment_partner/README.rst b/account_payment_partner/README.rst index 2837e36a1..704ca358a 100644 --- a/account_payment_partner/README.rst +++ b/account_payment_partner/README.rst @@ -1,6 +1,7 @@ .. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg :alt: License: AGPL-3 +======================= Account Payment Partner ======================= @@ -17,7 +18,8 @@ Installation ============ This module depends on : -* account_banking_payment_export + +* account_payment_mode This module is part of the OCA/bank-payment suite. @@ -34,22 +36,22 @@ This payment mode is automatically associated to the invoice related to the part When you create an payment order, only invoices related to chosen payment mode are displayed. Invoices without any payment mode are displayed to. -For further information, please visit: - - * https://www.odoo.com/forum/help-1 +.. 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 Known issues / Roadmap ====================== * No known issues. - + 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 -`here `_. +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. Credits ======= @@ -58,7 +60,7 @@ Contributors ------------ * Pedro M. Baeza -* Alexis de Lattre +* Alexis de Lattre * Raphaël Valyi * Stefan Rijnhart (Therp) * Alexandre Fayolle diff --git a/account_payment_partner/__init__.py b/account_payment_partner/__init__.py index 794e1a243..3845dd2da 100644 --- a/account_payment_partner/__init__.py +++ b/account_payment_partner/__init__.py @@ -3,4 +3,3 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from . import models -from . import wizard diff --git a/account_payment_partner/__openerp__.py b/account_payment_partner/__openerp__.py index 0460a7c26..8c1068021 100644 --- a/account_payment_partner/__openerp__.py +++ b/account_payment_partner/__openerp__.py @@ -5,7 +5,7 @@ { 'name': 'Account Payment Partner', - 'version': '8.0.0.2.0', + 'version': '9.0.1.0.0', 'category': 'Banking addons', 'license': 'AGPL-3', 'summary': 'Adds payment mode on partners and invoices', @@ -13,14 +13,12 @@ "Serv. Tecnol. Avanzados - Pedro M. Baeza, " "Odoo Community Association (OCA)", 'website': 'https://github.com/OCA/bank-payment', - 'depends': ['account_banking_payment_export'], + 'depends': ['account_payment_mode'], 'data': [ 'views/res_partner_view.xml', 'views/account_invoice_view.xml', + 'views/account_move_line.xml', 'views/report_invoice.xml', - 'views/payment_mode.xml', - 'security/ir.model.access.csv', - 'wizard/payment_order_create_view.xml', ], 'demo': ['demo/partner_demo.xml'], 'installable': True, diff --git a/account_payment_partner/demo/partner_demo.xml b/account_payment_partner/demo/partner_demo.xml index 776058d44..20545d978 100644 --- a/account_payment_partner/demo/partner_demo.xml +++ b/account_payment_partner/demo/partner_demo.xml @@ -3,49 +3,23 @@ - - - supplier_payment_mode_12 + + Default Supplier Payment Mode + search="[('model','=','res.partner'),('name','=','supplier_payment_mode_id')]"/> + eval="'account.payment.mode,'+str(ref('account_payment_mode.payment_mode_outbound_ct1'))"/> - - - customer_payment_mode_12 + + Default Customer Payment Mode + search="[('model','=','res.partner'),('name','=','customer_payment_mode_id')]"/> + eval="'account.payment.mode,'+str(ref('account_payment_mode.payment_mode_inbound_ct1'))"/> - - - - customer_payment_mode_2 - - - - - - - - - supplier_payment_mode_1 - - - - - - - diff --git a/account_payment_partner/models/__init__.py b/account_payment_partner/models/__init__.py index be3f531bb..152bb919c 100644 --- a/account_payment_partner/models/__init__.py +++ b/account_payment_partner/models/__init__.py @@ -2,4 +2,4 @@ from . import res_partner from . import account_invoice -from . import payment_mode +from . import account_move_line diff --git a/account_payment_partner/models/account_invoice.py b/account_payment_partner/models/account_invoice.py index 4c5b971c6..14ac17a77 100644 --- a/account_payment_partner/models/account_invoice.py +++ b/account_payment_partner/models/account_invoice.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2014 Akretion - Alexis de Lattre +# © 2014-2016 Akretion - Alexis de Lattre # © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). @@ -10,27 +10,70 @@ class AccountInvoice(models.Model): _inherit = 'account.invoice' payment_mode_id = fields.Many2one( - comodel_name='payment.mode', string="Payment Mode", - domain="[('type', '=', type)]") + comodel_name='account.payment.mode', string="Payment Mode", + ondelete='restrict', + readonly=True, states={'draft': [('readonly', False)]}) + bank_account_required = fields.Boolean( + related='payment_mode_id.payment_method_id.bank_account_required', + readonly=True) - @api.multi - def onchange_partner_id( - self, type, partner_id, date_invoice=False, - payment_term=False, partner_bank_id=False, company_id=False): - res = super(AccountInvoice, self).onchange_partner_id( - type, partner_id, date_invoice=date_invoice, - payment_term=payment_term, partner_bank_id=partner_bank_id, - company_id=company_id) - if partner_id: - partner = self.env['res.partner'].browse(partner_id) - if type == 'in_invoice': - res['value']['payment_mode_id'] = \ - partner.supplier_payment_mode.id - elif type == 'out_invoice': - res['value'].update({ - 'payment_mode_id': partner.customer_payment_mode.id, - 'partner_bank_id': partner.customer_payment_mode.bank_id.id - }) + @api.onchange('partner_id', 'company_id') + def _onchange_partner_id(self): + super(AccountInvoice, self)._onchange_partner_id() + if self.partner_id: + if self.type == 'in_invoice': + pay_mode = self.partner_id.supplier_payment_mode_id + self.payment_mode_id = pay_mode + if ( + pay_mode and + pay_mode.payment_type == 'outbound' and + pay_mode.payment_method_id.bank_account_required and + self.commercial_partner_id.bank_ids): + self.partner_bank_id =\ + self.commercial_partner_id.bank_ids[0] + elif self.type == 'out_invoice': + pay_mode = self.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: - res['value']['payment_mode_id'] = False + self.payment_mode_id = False + if self.type == 'in_invoice': + self.partner_bank_id = False + + @api.onchange('payment_mode_id') + def payment_mode_id_change(self): + if ( + self.payment_mode_id and + self.payment_mode_id.payment_type == 'outbound' and + not self.payment_mode_id.payment_method_id. + bank_account_required): + self.partner_bank_id = False + elif not self.payment_mode_id: + self.partner_bank_id = False + + @api.model + def line_get_convert(self, line, part): + """Copy payment mode from invoice to account move line""" + 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']) + res['payment_mode_id'] = invoice.payment_mode_id.id or False return res + + # I think copying payment mode from invoice to refund by default + # is a good idea because the most common way of "paying" a refund is to + # deduct it on the payment of the next invoice (and OCA/bank-payment + # allows to have negative payment lines since March 2016) + @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) + vals['payment_mode_id'] = invoice.payment_mode_id.id + if invoice.type == 'in_invoice': + vals['partner_bank_id'] = invoice.partner_bank_id.id + return vals diff --git a/account_payment_partner/models/account_move_line.py b/account_payment_partner/models/account_move_line.py new file mode 100644 index 000000000..080e73369 --- /dev/null +++ b/account_payment_partner/models/account_move_line.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# © 2016 Akretion (http://www.akretion.com/) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp import models, fields + + +class AccountMoveLine(models.Model): + _inherit = 'account.move.line' + + payment_mode_id = fields.Many2one( + 'account.payment.mode', string='Payment Mode', ondelete='restrict') diff --git a/account_payment_partner/models/payment_mode.py b/account_payment_partner/models/payment_mode.py deleted file mode 100644 index 6d2fa946b..000000000 --- a/account_payment_partner/models/payment_mode.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- coding: utf-8 -*- -# © 2014 Akretion - Alexis de Lattre -# © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from openerp import models, fields - - -class PaymentMode(models.Model): - _inherit = "payment.mode" - - default_payment_mode = fields.Selection([ - ('same', 'Same'), - ('same_or_null', 'Same or empty'), - ('any', 'Any'), - ], string='Payment Mode on Invoice', default='same') diff --git a/account_payment_partner/models/res_partner.py b/account_payment_partner/models/res_partner.py index 7b6c850aa..b7a35e93c 100644 --- a/account_payment_partner/models/res_partner.py +++ b/account_payment_partner/models/res_partner.py @@ -9,17 +9,20 @@ from openerp import models, fields, api class ResPartner(models.Model): _inherit = 'res.partner' - supplier_payment_mode = fields.Many2one( - 'payment.mode', string='Supplier Payment Mode', company_dependent=True, - domain="[('purchase_ok', '=', True)]", + # v8 fields : same without the _id suffix + supplier_payment_mode_id = fields.Many2one( + 'account.payment.mode', string='Supplier Payment Mode', + company_dependent=True, + domain=[('payment_type', '=', 'outbound')], help="Select the default payment mode for this supplier.") - customer_payment_mode = fields.Many2one( - 'payment.mode', string='Customer Payment Mode', company_dependent=True, - domain="[('sale_ok', '=', True)]", + customer_payment_mode_id = fields.Many2one( + 'account.payment.mode', string='Customer Payment Mode', + company_dependent=True, + domain=[('payment_type', '=', 'inbound')], help="Select the default payment mode for this customer.") @api.model def _commercial_fields(self): res = super(ResPartner, self)._commercial_fields() - res += ['supplier_payment_mode', 'customer_payment_mode'] + res += ['supplier_payment_mode_id', 'customer_payment_mode_id'] return res diff --git a/account_payment_partner/security/ir.model.access.csv b/account_payment_partner/security/ir.model.access.csv deleted file mode 100644 index ac6d96dfd..000000000 --- a/account_payment_partner/security/ir.model.access.csv +++ /dev/null @@ -1,3 +0,0 @@ -id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_payment_mode_read,Read access on payment.mode to Employees,account_payment.model_payment_mode,base.group_user,1,0,0,0 -access_payment_mode_type_read,Read access on payment.mode.type to Employees,account_banking_payment_export.model_payment_mode_type,base.group_user,1,0,0,0 diff --git a/account_payment_partner/views/account_invoice_view.xml b/account_payment_partner/views/account_invoice_view.xml index 895e03bf5..0e59c514d 100644 --- a/account_payment_partner/views/account_invoice_view.xml +++ b/account_payment_partner/views/account_invoice_view.xml @@ -1,21 +1,20 @@ - - + - - account_payment_partner.invoice_filter + + account_payment_partner.account_invoice_search account.invoice - - + + @@ -28,8 +27,12 @@ + + + + 0 @@ -40,14 +43,43 @@ account.invoice - + + + + + + [('partner_id', '=', commercial_partner_id)] + 0 + {'invisible': [('bank_account_required', '=', False)], 'required': [('bank_account_required', '=', True)]} + + + + + + account_payment_partner.customer_invoice_tree + account.invoice + + + + + + + + + + account_payment_partner.supplier_invoice_tree + account.invoice + + + + - + diff --git a/account_payment_partner/views/account_move_line.xml b/account_payment_partner/views/account_move_line.xml new file mode 100644 index 000000000..b0d0ca102 --- /dev/null +++ b/account_payment_partner/views/account_move_line.xml @@ -0,0 +1,28 @@ + + + + + + + + + + account_payment_partner.move_line_form + account.move.line + + + + + + + + + + + + + diff --git a/account_payment_partner/views/payment_mode.xml b/account_payment_partner/views/payment_mode.xml deleted file mode 100644 index 120ca6970..000000000 --- a/account_payment_partner/views/payment_mode.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - account_payment_partner.payment.mode.form - payment.mode - - - - - - - - - - - diff --git a/account_payment_partner/views/report_invoice.xml b/account_payment_partner/views/report_invoice.xml index 356ec1d4d..9368238f1 100644 --- a/account_payment_partner/views/report_invoice.xml +++ b/account_payment_partner/views/report_invoice.xml @@ -2,7 +2,7 @@ From 2fd992a284429d807dc5baddf020be25a793382d Mon Sep 17 00:00:00 2001 From: cubells Date: Mon, 3 Dec 2018 12:45:56 +0100 Subject: [PATCH 30/33] [IMP] account_payment_partner: Add several tests --- account_payment_partner/__init__.py | 4 +- .../models/account_invoice.py | 12 +- .../models/account_move_line.py | 7 +- account_payment_partner/models/res_partner.py | 9 +- .../readme/CONTRIBUTORS.rst | 4 +- .../readme/DESCRIPTION.rst | 4 +- account_payment_partner/readme/HISTORY.rst | 10 -- account_payment_partner/readme/USAGE.rst | 19 ++- account_payment_partner/tests/__init__.py | 1 - .../tests/test_account_payment_partner.py | 112 ++++++++++++++++++ .../views/account_invoice_view.xml | 4 +- .../views/account_move_line.xml | 3 +- .../views/report_invoice.xml | 2 +- .../views/res_partner_view.xml | 3 +- 14 files changed, 142 insertions(+), 52 deletions(-) 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/models/account_invoice.py b/account_payment_partner/models/account_invoice.py index 86942cbcf..0fc72bb14 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 @@ -121,12 +120,13 @@ class AccountInvoice(models.Model): 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: + 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': + 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 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/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 index 95f514aae..df652cc34 100644 --- a/account_payment_partner/readme/CONTRIBUTORS.rst +++ b/account_payment_partner/readme/CONTRIBUTORS.rst @@ -7,5 +7,5 @@ * Angel Moya * `Tecnativa `_: - * Pedro M. Baeza - * Carlos Dauden + * Pedro M. Baeza + * Carlos Dauden diff --git a/account_payment_partner/readme/DESCRIPTION.rst b/account_payment_partner/readme/DESCRIPTION.rst index 27c9e82be..8ad4f4f64 100644 --- a/account_payment_partner/readme/DESCRIPTION.rst +++ b/account_payment_partner/readme/DESCRIPTION.rst @@ -1,6 +1,4 @@ -[ This file must be max 2-3 paragraphs, and is required. ] - -This module adds severals fields : +This module adds severals fields: * the *Supplier Payment Mode* and *Customer Payment Mode* on Partners, diff --git a/account_payment_partner/readme/HISTORY.rst b/account_payment_partner/readme/HISTORY.rst index a6168b334..8424df5d0 100644 --- a/account_payment_partner/readme/HISTORY.rst +++ b/account_payment_partner/readme/HISTORY.rst @@ -1,13 +1,3 @@ -[ 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) ~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/account_payment_partner/readme/USAGE.rst b/account_payment_partner/readme/USAGE.rst index c2bbf0fbc..09ef27577 100644 --- a/account_payment_partner/readme/USAGE.rst +++ b/account_payment_partner/readme/USAGE.rst @@ -1,12 +1,9 @@ -[ 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. + +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/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..14ad3cb59 100644 --- a/account_payment_partner/tests/test_account_payment_partner.py +++ b/account_payment_partner/tests/test_account_payment_partner.py @@ -132,6 +132,49 @@ 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, + }) + mode_in = cls.env['account.payment.mode'].create({ + 'name': 'Payment Mode Inbound', + 'payment_method_id': + cls.env.ref('account.account_payment_method_manual_in').id, + 'bank_account_link': 'fixed', + 'fixed_journal_id': cls.journal.id, + }) + method_out = cls.env.ref('account.account_payment_method_manual_out') + method_out.bank_account_required = True + cls.mode_out = cls.env['account.payment.mode'].create({ + 'name': 'Payment Mode Outbound', + 'payment_method_id': method_out.id, + 'bank_account_link': 'fixed', + 'fixed_journal_id': cls.journal.id, + }) + cls.partner = cls.env['res.partner'].create({ + 'name': 'Test Partner', + 'customer': True, + 'customer_payment_mode_id': mode_in.id, + }) + cls.supplier = cls.env['res.partner'].create({ + 'name': 'Test Supplier', + 'supplier': True, + 'supplier_payment_mode_id': cls.mode_out.id, + }) + cls.supplier_bank = cls.env['res.partner.bank'].create({ + 'acc_number': 'GB18BARC20040131665123', + 'partner_id': cls.supplier.id, + }) + cls.supplier_invoice = cls.env['account.invoice'].create({ + 'partner_id': cls.supplier.id, + 'type': 'in_invoice', + }) def _create_invoice(self): @@ -313,3 +356,72 @@ 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.partner.id, + 'type': 'out_invoice', + }) + customer_invoice._onchange_partner_id() + self.assertEqual(customer_invoice.payment_mode_id, + self.partner.customer_payment_mode_id) + + 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_payment_mode_id_change(self): + self.supplier_invoice.payment_mode_id = self.mode_out.id + self.supplier_invoice.payment_mode_id_change() + self.assertEqual(self.supplier_invoice.partner_bank_id, + self.supplier_bank) + self.mode_out.payment_method_id.bank_account_required = False + self.supplier_invoice.payment_mode_id = self.mode_out.id + self.supplier_invoice.payment_mode_id_change() + self.assertFalse(self.supplier_invoice.partner_bank_id) + self.supplier_invoice.payment_mode_id = False + self.supplier_invoice.payment_mode_id_change() + self.assertFalse(self.supplier_invoice.partner_bank_id) + + def test_print_report(self): + self.env['account.invoice.line'].create({ + 'invoice_id': self.supplier_invoice.id, + 'name': 'Product Text', + 'price_unit': 10.0, + 'account_id': self.env.ref('l10n_generic_coa.1_conf_o_income').id, + }) + self.supplier_invoice.action_invoice_open() + self.assertEqual( + self.supplier_invoice.move_id.line_ids[0].payment_mode_id, + self.supplier_invoice.payment_mode_id) + (res, _) = report.render_report( + self.env.cr, self.env.uid, + [self.supplier_invoice.id], 'account.report_invoice', {}) + self.assertRegexpMatches(res, self.supplier_bank.acc_number) + self.supplier_invoice.partner_bank_id = False + self.supplier_invoice.payment_mode_id\ + .show_bank_account_from_journal = True + (res, _) = report.render_report( + self.env.cr, self.env.uid, + [self.supplier_invoice.id], 'account.report_invoice', {}) + self.assertRegexpMatches(res, self.journal_bank.acc_number) + payment_mode = self.supplier_invoice.payment_mode_id + self.supplier_invoice.payment_mode_id = False + payment_mode.bank_account_link = 'variable' + payment_mode.variable_journal_ids = [ + (6, 0, [self.journal.id])] + self.supplier_invoice.payment_mode_id = payment_mode.id + self.supplier_invoice.payment_mode_id_change() + (res, _) = report.render_report( + self.env.cr, self.env.uid, + [self.supplier_invoice.id], 'account.report_invoice', {}) + self.assertRegexpMatches( + res, self.journal_bank.acc_number) 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/report_invoice.xml b/account_payment_partner/views/report_invoice.xml index 1838444d8..b22767685 100644 --- a/account_payment_partner/views/report_invoice.xml +++ b/account_payment_partner/views/report_invoice.xml @@ -20,7 +20,7 @@ - +

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 @@ From d6070a5481584681e5b0d5a6e37ae7ebd2611579 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Tue, 4 Dec 2018 23:56:16 +0100 Subject: [PATCH 31/33] [MIG] account_payment_partner: Adapt tests + code to latest version --- .../post-migrate.py | 0 .../models/account_invoice.py | 4 +- .../tests/test_account_payment_partner.py | 135 ++++++------------ 3 files changed, 48 insertions(+), 91 deletions(-) rename account_payment_partner/migrations/{10.0.1.2.0 => 11.0.1.3.0}/post-migrate.py (100%) diff --git a/account_payment_partner/migrations/10.0.1.2.0/post-migrate.py b/account_payment_partner/migrations/11.0.1.3.0/post-migrate.py similarity index 100% rename from account_payment_partner/migrations/10.0.1.2.0/post-migrate.py rename to account_payment_partner/migrations/11.0.1.3.0/post-migrate.py diff --git a/account_payment_partner/models/account_invoice.py b/account_payment_partner/models/account_invoice.py index 0fc72bb14..791ea10ff 100644 --- a/account_payment_partner/models/account_invoice.py +++ b/account_payment_partner/models/account_invoice.py @@ -44,7 +44,9 @@ class AccountInvoice(models.Model): # 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.partner_id.customer_payment_mode_id + self.payment_mode_id = self.with_context( + force_company=self.company_id.id, + ).partner_id.customer_payment_mode_id else: self.payment_mode_id = False if self.type == 'in_invoice': diff --git a/account_payment_partner/tests/test_account_payment_partner.py b/account_payment_partner/tests/test_account_payment_partner.py index 14ad3cb59..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 @@ -142,38 +145,10 @@ class TestAccountPaymentPartner(common.SavepointCase): 'type': 'bank', 'bank_account_id': cls.journal_bank.id, }) - mode_in = cls.env['account.payment.mode'].create({ - 'name': 'Payment Mode Inbound', - 'payment_method_id': - cls.env.ref('account.account_payment_method_manual_in').id, - 'bank_account_link': 'fixed', - 'fixed_journal_id': cls.journal.id, - }) - method_out = cls.env.ref('account.account_payment_method_manual_out') - method_out.bank_account_required = True - cls.mode_out = cls.env['account.payment.mode'].create({ - 'name': 'Payment Mode Outbound', - 'payment_method_id': method_out.id, - 'bank_account_link': 'fixed', - 'fixed_journal_id': cls.journal.id, - }) - cls.partner = cls.env['res.partner'].create({ - 'name': 'Test Partner', - 'customer': True, - 'customer_payment_mode_id': mode_in.id, - }) - cls.supplier = cls.env['res.partner'].create({ - 'name': 'Test Supplier', - 'supplier': True, - 'supplier_payment_mode_id': cls.mode_out.id, - }) - cls.supplier_bank = cls.env['res.partner.bank'].create({ - 'acc_number': 'GB18BARC20040131665123', - 'partner_id': cls.supplier.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): @@ -223,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() @@ -247,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() @@ -359,12 +325,12 @@ class TestAccountPaymentPartner(common.SavepointCase): def test_partner_onchange(self): customer_invoice = self.env['account.invoice'].create({ - 'partner_id': self.partner.id, + 'partner_id': self.customer.id, 'type': 'out_invoice', }) customer_invoice._onchange_partner_id() self.assertEqual(customer_invoice.payment_mode_id, - self.partner.customer_payment_mode_id) + self.customer_payment_mode) self.supplier_invoice._onchange_partner_id() self.assertEqual(self.supplier_invoice.partner_bank_id, @@ -378,50 +344,39 @@ class TestAccountPaymentPartner(common.SavepointCase): invoice._onchange_partner_id() self.assertFalse(invoice.partner_bank_id) - def test_payment_mode_id_change(self): - self.supplier_invoice.payment_mode_id = self.mode_out.id - self.supplier_invoice.payment_mode_id_change() + 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) - self.mode_out.payment_method_id.bank_account_required = False - self.supplier_invoice.payment_mode_id = self.mode_out.id - self.supplier_invoice.payment_mode_id_change() + 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.payment_mode_id_change() + self.supplier_invoice._onchange_payment_mode_id() self.assertFalse(self.supplier_invoice.partner_bank_id) def test_print_report(self): - self.env['account.invoice.line'].create({ - 'invoice_id': self.supplier_invoice.id, - 'name': 'Product Text', - 'price_unit': 10.0, - 'account_id': self.env.ref('l10n_generic_coa.1_conf_o_income').id, - }) - self.supplier_invoice.action_invoice_open() - self.assertEqual( - self.supplier_invoice.move_id.line_ids[0].payment_mode_id, - self.supplier_invoice.payment_mode_id) - (res, _) = report.render_report( - self.env.cr, self.env.uid, - [self.supplier_invoice.id], 'account.report_invoice', {}) - self.assertRegexpMatches(res, self.supplier_bank.acc_number) - self.supplier_invoice.partner_bank_id = False - self.supplier_invoice.payment_mode_id\ - .show_bank_account_from_journal = True - (res, _) = report.render_report( - self.env.cr, self.env.uid, - [self.supplier_invoice.id], 'account.report_invoice', {}) - self.assertRegexpMatches(res, self.journal_bank.acc_number) - payment_mode = self.supplier_invoice.payment_mode_id - self.supplier_invoice.payment_mode_id = False - payment_mode.bank_account_link = 'variable' - payment_mode.variable_journal_ids = [ - (6, 0, [self.journal.id])] + 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.payment_mode_id_change() - (res, _) = report.render_report( - self.env.cr, self.env.uid, - [self.supplier_invoice.id], 'account.report_invoice', {}) - self.assertRegexpMatches( - res, self.journal_bank.acc_number) + 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) From c54bdbdeba1382e70e608e22e027053f5f3202db Mon Sep 17 00:00:00 2001 From: Mourad Date: Tue, 2 Oct 2018 17:29:25 +0200 Subject: [PATCH 32/33] [MIG] account_payment_partner: migrate to 12.0 --- account_payment_partner/README.rst | 52 +++++------- account_payment_partner/__manifest__.py | 2 +- account_payment_partner/readme/CONFIGURE.rst | 1 + .../static/description/index.html | 80 ++++++++----------- .../views/account_move_line.xml | 4 +- 5 files changed, 58 insertions(+), 81 deletions(-) create mode 100644 account_payment_partner/readme/CONFIGURE.rst diff --git a/account_payment_partner/README.rst b/account_payment_partner/README.rst index 33edfef25..d83a4c51b 100644 --- a/account_payment_partner/README.rst +++ b/account_payment_partner/README.rst @@ -14,20 +14,18 @@ Account Payment Partner :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 + :target: https://github.com/OCA/bank-payment/tree/12.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 + :target: https://translation.odoo-community.org/projects/bank-payment-12-0/bank-payment-12-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 + :target: https://runbot.odoo-community.org/runbot/97/12.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 : +This module adds severals fields: * the *Supplier Payment Mode* and *Customer Payment Mode* on Partners, @@ -53,35 +51,27 @@ word about that), so that's the reason behind the several options. .. contents:: :local: +Configuration +============= + +There is nothing to configure. + 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. + +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. 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) ~~~~~~~~~~~~~~~~~~~~~~~ @@ -94,7 +84,7 @@ 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -119,8 +109,8 @@ Contributors * Angel Moya * `Tecnativa `_: - * Pedro M. Baeza - * Carlos Dauden + * Pedro M. Baeza + * Carlos Dauden Maintainers ~~~~~~~~~~~ @@ -135,6 +125,6 @@ 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. +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/__manifest__.py b/account_payment_partner/__manifest__.py index 44d90fa79..5644036d8 100644 --- a/account_payment_partner/__manifest__.py +++ b/account_payment_partner/__manifest__.py @@ -5,7 +5,7 @@ { 'name': 'Account Payment Partner', - 'version': '11.0.1.3.0', + 'version': '12.0.1.0.0', 'category': 'Banking addons', 'license': 'AGPL-3', 'summary': 'Adds payment mode on partners and invoices', diff --git a/account_payment_partner/readme/CONFIGURE.rst b/account_payment_partner/readme/CONFIGURE.rst new file mode 100644 index 000000000..d088e17bc --- /dev/null +++ b/account_payment_partner/readme/CONFIGURE.rst @@ -0,0 +1 @@ +There is nothing to configure. \ No newline at end of file diff --git a/account_payment_partner/static/description/index.html b/account_payment_partner/static/description/index.html index 641f3296e..b36e11b42 100644 --- a/account_payment_partner/static/description/index.html +++ b/account_payment_partner/static/description/index.html @@ -367,9 +367,8 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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 :

+

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

+

This module adds severals fields:

  • the Supplier Payment Mode and Customer Payment Mode on Partners,
  • the Payment Mode on Invoices.
  • @@ -387,51 +386,38 @@ word about that), so that’s the reason behind the several options.

    Table of contents

    +
    +

    Configuration

    +

    There is nothing to configure.

    +
    -

    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.

    +

    Usage

    +

    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.

    -

    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. ]

    -
    -
    +

    Changelog

    -

    10.0.1.2.0 (2018-05-24)

    +

    10.0.1.2.0 (2018-05-24)

    • [IMP] Add options to show partner bank account in invoice report (#458)
    • @@ -439,24 +425,24 @@ or other documents where this fragment is included. ]

    -

    Bug Tracker

    +

    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.

    +feedback.

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

    -

    Credits

    +

    Credits

    -

    Authors

    +

    Authors

    • Akretion
    • Tecnativa
    -

    Contributors

    +

    Contributors

    -

    Maintainers

    +

    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.

    +

    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/views/account_move_line.xml b/account_payment_partner/views/account_move_line.xml index 601018111..fe2a916f2 100644 --- a/account_payment_partner/views/account_move_line.xml +++ b/account_payment_partner/views/account_move_line.xml @@ -13,11 +13,11 @@ account.move.line - + - + From 98de40cbd57a305ed7ab41fec4ddb3b671a87a22 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Thu, 13 Dec 2018 14:03:03 +0100 Subject: [PATCH 33/33] [MIG] account_payment_partner: Fix tests for new version --- .../migrations/11.0.1.3.0/post-migrate.py | 12 --------- .../tests/test_account_payment_partner.py | 27 ++++++------------- 2 files changed, 8 insertions(+), 31 deletions(-) delete mode 100644 account_payment_partner/migrations/11.0.1.3.0/post-migrate.py 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 deleted file mode 100644 index e63be7140..000000000 --- a/account_payment_partner/migrations/11.0.1.3.0/post-migrate.py +++ /dev/null @@ -1,12 +0,0 @@ -# -*- 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/tests/test_account_payment_partner.py b/account_payment_partner/tests/test_account_payment_partner.py index 3bdb459a1..abd2349de 100644 --- a/account_payment_partner/tests/test_account_payment_partner.py +++ b/account_payment_partner/tests/test_account_payment_partner.py @@ -33,16 +33,10 @@ class TestAccountPaymentPartner(common.SavepointCase): else: raise ValidationError( _("No Chart of Account Template has been defined !")) - cls.wizard = cls.env['wizard.multi.charts.accounts'].create({ - 'company_id': cls.company_2.id, - 'chart_template_id': cls.chart.id, - 'sale_tax_id': False, - 'purchase_tax_id': False, - 'code_digits': 6, - 'currency_id': cls.env.ref('base.EUR').id, - 'transfer_account_id': cls.chart.transfer_account_id.id, - }) - cls.wizard.execute() + old_company = cls.env.user.company_id + cls.env.user.company_id = cls.company_2.id + cls.chart.try_loading_for_current_company() + cls.env.user.company_id = old_company.id # refs cls.manual_out = cls.env.ref( @@ -295,6 +289,7 @@ class TestAccountPaymentPartner(common.SavepointCase): def test_invoice_refund(self): invoice = self._create_invoice() + invoice.partner_bank_id = False invoice.action_invoice_open() # Lets create a refund invoice for invoice_1. # I refund the invoice Using Refund Button. @@ -362,21 +357,15 @@ class TestAccountPaymentPartner(common.SavepointCase): 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]) + res = str(report.render_qweb_html(self.supplier_invoice.ids)[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]) + res = str(report.render_qweb_html(self.supplier_invoice.ids)[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]) + res = str(report.render_qweb_html(self.supplier_invoice.ids)[0]) self.assertIn(self.journal_bank.acc_number, res)