From 948772d1b0cd95d36275b1f342f72d5dc2c53f56 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 25 Feb 2014 00:19:57 +0100 Subject: [PATCH 01/11] 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. --- .../model/__init__.py | 1 + .../model/account_payment.py | 3 + .../model/payment_mode.py | 5 ++ .../model/payment_mode_type.py | 2 + .../view/account_payment.xml | 13 +-- .../view/payment_mode.xml | 1 + .../view/payment_mode_type.xml | 36 ++++++-- account_payment_partner/__init__.py | 23 ++++++ account_payment_partner/__openerp__.py | 55 +++++++++++++ .../i18n/account_payment_partner.pot | 67 +++++++++++++++ account_payment_partner/model/__init__.py | 25 ++++++ .../model/account_invoice.py | 53 ++++++++++++ account_payment_partner/model/partner.py | 53 ++++++++++++ .../model/payment_order_create.py | 38 +++++++++ .../view/account_invoice.xml | 38 +++++++++ account_payment_partner/view/partner.xml | 34 ++++++++ account_payment_purchase/__init__.py | 23 ++++++ account_payment_purchase/__openerp__.py | 48 +++++++++++ .../i18n/account_payment_purchase.pot | 42 ++++++++++ account_payment_purchase/i18n/fr.po | 42 ++++++++++ account_payment_purchase/model/__init__.py | 24 ++++++ account_payment_purchase/model/purchase.py | 82 +++++++++++++++++++ account_payment_purchase/model/stock.py | 42 ++++++++++ account_payment_purchase/view/purchase.xml | 26 ++++++ account_payment_sale/__init__.py | 23 ++++++ account_payment_sale/__openerp__.py | 48 +++++++++++ .../i18n/account_payment_sale.pot | 37 +++++++++ account_payment_sale/model/__init__.py | 23 ++++++ account_payment_sale/model/sale.py | 66 +++++++++++++++ account_payment_sale/view/sale.xml | 28 +++++++ account_payment_sale_stock/__init__.py | 23 ++++++ account_payment_sale_stock/__openerp__.py | 43 ++++++++++ account_payment_sale_stock/model/__init__.py | 23 ++++++ account_payment_sale_stock/model/stock.py | 42 ++++++++++ 34 files changed, 1121 insertions(+), 11 deletions(-) create mode 100644 account_payment_partner/__init__.py create mode 100644 account_payment_partner/__openerp__.py 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 create mode 100644 account_payment_purchase/__init__.py create mode 100644 account_payment_purchase/__openerp__.py create mode 100644 account_payment_purchase/i18n/account_payment_purchase.pot create mode 100644 account_payment_purchase/i18n/fr.po create mode 100644 account_payment_purchase/model/__init__.py create mode 100644 account_payment_purchase/model/purchase.py create mode 100644 account_payment_purchase/model/stock.py create mode 100644 account_payment_purchase/view/purchase.xml create mode 100644 account_payment_sale/__init__.py create mode 100644 account_payment_sale/__openerp__.py create mode 100644 account_payment_sale/i18n/account_payment_sale.pot create mode 100644 account_payment_sale/model/__init__.py create mode 100644 account_payment_sale/model/sale.py create mode 100644 account_payment_sale/view/sale.xml create mode 100644 account_payment_sale_stock/__init__.py create mode 100644 account_payment_sale_stock/__openerp__.py create mode 100644 account_payment_sale_stock/model/__init__.py create mode 100644 account_payment_sale_stock/model/stock.py diff --git a/account_banking_payment_export/model/__init__.py b/account_banking_payment_export/model/__init__.py index ea50d43a4..74ab85c8d 100644 --- a/account_banking_payment_export/model/__init__.py +++ b/account_banking_payment_export/model/__init__.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from . import account_move_line from . import account_payment from . import bank_payment_manual diff --git a/account_banking_payment_export/model/account_payment.py b/account_banking_payment_export/model/account_payment.py index 045b3d867..fe69c290f 100644 --- a/account_banking_payment_export/model/account_payment.py +++ b/account_banking_payment_export/model/account_payment.py @@ -37,6 +37,9 @@ class payment_order(orm.Model): 'Payment order type', required=True, readonly=True, states={'draft': [('readonly', False)]}, ), + 'mode_type': fields.related( + 'mode', 'type', type='many2one', relation='payment.mode.type', + string='Payment Type'), } _defaults = { diff --git a/account_banking_payment_export/model/payment_mode.py b/account_banking_payment_export/model/payment_mode.py index 798c8ed20..cac103402 100644 --- a/account_banking_payment_export/model/payment_mode.py +++ b/account_banking_payment_export/model/payment_mode.py @@ -53,4 +53,9 @@ class payment_mode(orm.Model): 'type', 'payment_order_type', readonly=True, type='selection', selection=[('payment', 'Payment'), ('debit', 'Direct debit')], string="Payment Order Type"), + 'active': fields.boolean('Active'), + } + + _defaults = { + 'active': True, } diff --git a/account_banking_payment_export/model/payment_mode_type.py b/account_banking_payment_export/model/payment_mode_type.py index a50e56a85..e65727715 100644 --- a/account_banking_payment_export/model/payment_mode_type.py +++ b/account_banking_payment_export/model/payment_mode_type.py @@ -53,10 +53,12 @@ class payment_mode_type(orm.Model): [('payment', 'Payment'), ('debit', 'Direct debit')], 'Payment order type', required=True, ), + 'active': fields.boolean('Active'), } _defaults = { 'payment_order_type': 'payment', + 'active': True, } def _auto_init(self, cr, context=None): diff --git a/account_banking_payment_export/view/account_payment.xml b/account_banking_payment_export/view/account_payment.xml index a8e7ed547..3e9d35882 100644 --- a/account_banking_payment_export/view/account_payment.xml +++ b/account_banking_payment_export/view/account_payment.xml @@ -9,12 +9,13 @@ payment.order - - - launch_wizard - - + + launch_wizard + + + + diff --git a/account_banking_payment_export/view/payment_mode.xml b/account_banking_payment_export/view/payment_mode.xml index 98fa44475..611b233e8 100644 --- a/account_banking_payment_export/view/payment_mode.xml +++ b/account_banking_payment_export/view/payment_mode.xml @@ -11,6 +11,7 @@ + diff --git a/account_banking_payment_export/view/payment_mode_type.xml b/account_banking_payment_export/view/payment_mode_type.xml index 682265a2d..45e99656c 100644 --- a/account_banking_payment_export/view/payment_mode_type.xml +++ b/account_banking_payment_export/view/payment_mode_type.xml @@ -18,14 +18,40 @@ view.payment.mode.type.form payment.mode.type -
- - - - + + + + + + + + + + view.payment.mode.type.tree + payment.mode.type + + + + + + + + + + + Payment Type + payment.mode.type + form + tree,form + + + + diff --git a/account_payment_partner/__init__.py b/account_payment_partner/__init__.py new file mode 100644 index 000000000..da25c5761 --- /dev/null +++ b/account_payment_partner/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Partner Payment 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..e67a7fc2b --- /dev/null +++ b/account_payment_partner/__openerp__.py @@ -0,0 +1,55 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Partner Payment 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 Partner Payment', + 'version': '0.1', + 'category': 'Banking addons', + 'license': 'AGPL-3', + 'summary': 'Adds payment type and receivable bank account on partners', + 'description': """ +Account Partner Payment +======================= + +This module adds severals fields : + +* the *Supplier Payment Type* and *Customer Payment Type* on Partners, + +* the *Receivable Bank Account* on Partners, + +* the *Payment Type* on Invoices. + +On a Payment Order, in the wizard *Select Invoices to Pay*, the invoices will be filtered per Payment Type. + +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': [], + 'active': False, +} 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..0e83b63de --- /dev/null +++ b/account_payment_partner/i18n/account_payment_partner.pot @@ -0,0 +1,67 @@ +# 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-02-24 23:06+0000\n" +"PO-Revision-Date: 2014-02-24 23:06+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:account.invoice,payment_mode_type:0 +msgid "Payment Type" +msgstr "" + +#. module: account_payment_partner +#: model:ir.model,name:account_payment_partner.model_payment_order_create +msgid "payment.order.create" +msgstr "" + +#. module: account_payment_partner +#: field:res.partner,supplier_payment_mode_type:0 +msgid "Supplier Payment Type" +msgstr "" + +#. module: account_payment_partner +#: help:res.partner,partner_bank_receivable:0 +msgid "Select the bank account of your company on which the customer should pay." +msgstr "" + +#. module: account_payment_partner +#: field:res.partner,partner_bank_receivable:0 +msgid "Receivable Bank Account" +msgstr "" + +#. module: account_payment_partner +#: help:res.partner,supplier_payment_mode_type:0 +msgid "Select the default payment type for this supplier." +msgstr "" + +#. module: account_payment_partner +#: field:res.partner,customer_payment_mode_type:0 +msgid "Customer Payment Type" +msgstr "" + +#. module: account_payment_partner +#: model:ir.model,name:account_payment_partner.model_account_invoice +msgid "Invoice" +msgstr "" + +#. module: account_payment_partner +#: help:res.partner,customer_payment_mode_type:0 +msgid "Select the default payment type for this customer." +msgstr "" + +#. module: account_payment_partner +#: model:ir.model,name:account_payment_partner.model_res_partner +msgid "Partner" +msgstr "" + diff --git a/account_payment_partner/model/__init__.py b/account_payment_partner/model/__init__.py new file mode 100644 index 000000000..3fae22c2a --- /dev/null +++ b/account_payment_partner/model/__init__.py @@ -0,0 +1,25 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Partner Payment 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..1e34729df --- /dev/null +++ b/account_payment_partner/model/account_invoice.py @@ -0,0 +1,53 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Partner Payment 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_type': fields.many2one( + 'payment.mode.type', 'Payment Type'), + } + + 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) + # TODO what about refunds ? Should be really copy + # the payment type for refunds ? + if type and type in ('in_invoice', 'in_refund'): + res['value']['payment_mode_type'] = \ + partner.supplier_payment_mode_type.id or False + elif type and type in ('out_invoice', 'out_refund'): + res['value']['payment_mode_type'] = \ + partner.customer_payment_mode_type.id or False + else: + res['value']['payment_mode_type'] = 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..caef3c0a5 --- /dev/null +++ b/account_payment_partner/model/partner.py @@ -0,0 +1,53 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Partner Payment 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_type': fields.property( + 'payment.mode.type', type='many2one', relation='payment.mode.type', + string='Supplier Payment Type', view_load=True, + help="Select the default payment type for this supplier."), + 'customer_payment_mode_type': fields.property( + 'payment.mode.type', type='many2one', relation='payment.mode.type', + string='Customer Payment Type', view_load=True, + help="Select the default payment type for this customer."), + 'partner_bank_receivable': fields.property( + 'res.partner.bank', type='many2one', relation='res.partner.bank', + string='Receivable Bank Account', view_load=True, + help="Select the bank account of your company on which the " + "customer should pay."), + } + + def _commercial_fields(self, cr, uid, context=None): + res = super(res_partner, self)._commercial_fields( + cr, uid, context=context) + res += [ + 'supplier_payment_mode_type', + 'customer_payment_mode_type', + 'partner_bank_receivable', + ] + 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..0168f1ae4 --- /dev/null +++ b/account_payment_partner/model/payment_order_create.py @@ -0,0 +1,38 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Partner Payment 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.Model): + _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_type', '=', payment_order.mode_type.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..85e0e9bf1 --- /dev/null +++ b/account_payment_partner/view/account_invoice.xml @@ -0,0 +1,38 @@ + + + + + + + + + + account_partner_payment.invoice_form + account.invoice + + + + + + + + + + + account_partner_payment.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..2273ef07a --- /dev/null +++ b/account_payment_partner/view/partner.xml @@ -0,0 +1,34 @@ + + + + + + + + + + account_partner_payment.partner_form + res.partner + + + + + + + + + + + + + + + diff --git a/account_payment_purchase/__init__.py b/account_payment_purchase/__init__.py new file mode 100644 index 000000000..59199014f --- /dev/null +++ b/account_payment_purchase/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Purchase 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_purchase/__openerp__.py b/account_payment_purchase/__openerp__.py new file mode 100644 index 000000000..e2fc219eb --- /dev/null +++ b/account_payment_purchase/__openerp__.py @@ -0,0 +1,48 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Purchase 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 Purchase', + 'version': '1.0', + 'category': 'Banking addons', + 'license': 'AGPL-3', + 'summary': "Adds Bank Account and Payment Type on Purchase Orders", + 'description': """ +Account Payment Purchase +======================== + +This modules adds 2 fields on purchase orders : *Bank Account* and *Payment Type*. These fields are copied from partner to purchase order and then from purchase order to supplier invoice. + +This module is similar to the *purchase_payment* module ; the main difference is that it doesn't depend on the *account_payment_extension* module (it's not the only module to conflict with *account_payment_extension* ; all the SEPA modules in the banking addons conflict with *account_payment_extension*, cf banking-addons-70/account_banking_payment_export/__openerp__.py). + +Please contact Alexis de Lattre from Akretion for any help or question about this module. + """, + 'author': 'Akretion', + 'website': 'http://www.akretion.com', + 'depends': ['purchase', 'account_payment_partner'], + 'conflicts': ['purchase_payment'], + 'data': [ + 'view/purchase.xml', + ], + 'installable': True, + 'active': False, +} diff --git a/account_payment_purchase/i18n/account_payment_purchase.pot b/account_payment_purchase/i18n/account_payment_purchase.pot new file mode 100644 index 000000000..49f775a6e --- /dev/null +++ b/account_payment_purchase/i18n/account_payment_purchase.pot @@ -0,0 +1,42 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_payment_purchase +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-02-24 23:07+0000\n" +"PO-Revision-Date: 2014-02-24 23:07+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_purchase +#: field:purchase.order,payment_mode_type:0 +msgid "Payment Type" +msgstr "" + +#. module: account_payment_purchase +#: model:ir.model,name:account_payment_purchase.model_purchase_order +msgid "Purchase Order" +msgstr "" + +#. module: account_payment_purchase +#: help:purchase.order,supplier_partner_bank:0 +msgid "Select the bank account of your supplier on which your company should send the payment. This field is copied from the partner and will be copied to the supplier invoice." +msgstr "" + +#. module: account_payment_purchase +#: field:purchase.order,supplier_partner_bank:0 +msgid "Supplier Bank Account" +msgstr "" + +#. module: account_payment_purchase +#: model:ir.model,name:account_payment_purchase.model_stock_picking +msgid "Picking List" +msgstr "" + diff --git a/account_payment_purchase/i18n/fr.po b/account_payment_purchase/i18n/fr.po new file mode 100644 index 000000000..54d2b3b2a --- /dev/null +++ b/account_payment_purchase/i18n/fr.po @@ -0,0 +1,42 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_payment_purchase +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-02-24 23:09+0000\n" +"PO-Revision-Date: 2014-02-24 23:09+0000\n" +"Last-Translator: Alexis de Lattre \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_purchase +#: field:purchase.order,payment_mode_type:0 +msgid "Payment Type" +msgstr "Type de Paiement" + +#. module: account_payment_purchase +#: model:ir.model,name:account_payment_purchase.model_purchase_order +msgid "Purchase Order" +msgstr "Bon de commande" + +#. module: account_payment_purchase +#: help:purchase.order,supplier_partner_bank:0 +msgid "Select the bank account of your supplier on which your company should send the payment. This field is copied from the partner and will be copied to the supplier invoice." +msgstr "Selectionnez le compte bancaire du fournisseur sur lequel votre société devra effectuer le règlement. Ce champ est copié depuis le partenaire et sera recopié sur la facture fournisseur." + +#. module: account_payment_purchase +#: field:purchase.order,supplier_partner_bank:0 +msgid "Supplier Bank Account" +msgstr "Compte bancaire du fournisseur" + +#. module: account_payment_purchase +#: model:ir.model,name:account_payment_purchase.model_stock_picking +msgid "Picking List" +msgstr "Bon de livraison" + diff --git a/account_payment_purchase/model/__init__.py b/account_payment_purchase/model/__init__.py new file mode 100644 index 000000000..fe39c6366 --- /dev/null +++ b/account_payment_purchase/model/__init__.py @@ -0,0 +1,24 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Purchase 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 purchase +from . import stock diff --git a/account_payment_purchase/model/purchase.py b/account_payment_purchase/model/purchase.py new file mode 100644 index 000000000..639fdce6d --- /dev/null +++ b/account_payment_purchase/model/purchase.py @@ -0,0 +1,82 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Purchase 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 purchase_order(orm.Model): + _inherit = "purchase.order" + + _columns = { + 'supplier_partner_bank': fields.many2one( + 'res.partner.bank', 'Supplier Bank Account', + help="Select the bank account of your supplier on which " + "your company should send the payment. This field is copied " + "from the partner and will be copied to the supplier invoice."), + 'payment_mode_type': fields.many2one( + 'payment.mode.type', 'Payment Type'), + } + + def _get_default_supplier_partner_bank( + self, cr, uid, partner, context=None): + '''This function is designed to be inherited''' + if partner.bank_ids: + return partner.bank_ids[0].id + else: + return False + + def onchange_partner_id(self, cr, uid, ids, partner_id): + res = super(purchase_order, self).onchange_partner_id( + cr, uid, ids, partner_id) + if partner_id: + partner = self.pool['res.partner'].browse( + cr, uid, partner_id) + res['value'].update({ + 'supplier_partner_bank': + self._get_default_supplier_partner_bank( + cr, uid, partner), + 'payment_mode_type': + partner.supplier_payment_mode_type.id or False, + }) + else: + res['value'].update({ + 'supplier_partner_bank': False, + 'payment_mode_type': False, + }) + return res + + def action_invoice_create(self, cr, uid, ids, context=None): + """Copy bank partner + payment type from PO to invoice""" + # as of OpenERP 7.0, there is no _prepare function for + # the invoice (the _prepare function only exists for invoice lines) + res = super(purchase_order, self).action_invoice_create( + cr, uid, ids, context=context) + for order in self.browse(cr, uid, ids, context=context): + for invoice in order.invoice_ids: + if invoice.state == 'draft': + invoice.write({ + 'partner_bank_id': + order.supplier_partner_bank.id or False, + 'payment_mode_type': + order.payment_mode_type.id or False, + }, context=context) + return res diff --git a/account_payment_purchase/model/stock.py b/account_payment_purchase/model/stock.py new file mode 100644 index 000000000..e2f83663b --- /dev/null +++ b/account_payment_purchase/model/stock.py @@ -0,0 +1,42 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Purchase 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 stock_picking(orm.Model): + _inherit = "stock.picking" + + def _prepare_invoice( + self, cr, uid, picking, partner, inv_type, journal_id, + context=None): + """Copy bank partner and payment type from PO to invoice""" + invoice_vals = super(stock_picking, self)._prepare_invoice( + cr, uid, picking, partner, inv_type, journal_id, context=context) + if picking.purchase_id: + invoice_vals.update({ + 'partner_bank_id': + picking.purchase_id.supplier_partner_bank.id or False, + 'payment_mode_type': + picking.purchase_id.payment_mode_type.id or False, + }) + return invoice_vals diff --git a/account_payment_purchase/view/purchase.xml b/account_payment_purchase/view/purchase.xml new file mode 100644 index 000000000..3875fefda --- /dev/null +++ b/account_payment_purchase/view/purchase.xml @@ -0,0 +1,26 @@ + + + + + + + + + account_payment_purchase.purchase_order.form + purchase.order + + + + + + + + + + + diff --git a/account_payment_sale/__init__.py b/account_payment_sale/__init__.py new file mode 100644 index 000000000..83c0dcfe2 --- /dev/null +++ b/account_payment_sale/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Sale 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_sale/__openerp__.py b/account_payment_sale/__openerp__.py new file mode 100644 index 000000000..b6cf3b2cb --- /dev/null +++ b/account_payment_sale/__openerp__.py @@ -0,0 +1,48 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Sale 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 Sale', + 'version': '1.0', + 'category': 'Banking addons', + 'license': 'AGPL-3', + 'summary': "Adds Bank Account and Payment Type on Sale Orders", + 'description': """ +Account Payment Sale +==================== + +This modules adds 2 fields on sale orders : *Bank Account* and *Payment Type*. These fields are copied from partner to sale order and then from sale order to customer invoice. + +This module is similar to the *sale_payment* module ; the main difference is that it doesn't depend on the *account_payment_extension* module (it's not the only module to conflict with *account_payment_extension* ; all the SEPA modules in the banking addons conflict with *account_payment_extension*, cf banking-addons-70/account_banking_payment_export/__openerp__.py). + +Please contact Alexis de Lattre from Akretion for any help or question about this module. + """, + 'author': 'Akretion', + 'website': 'http://www.akretion.com', + 'depends': ['sale', 'account_payment_partner'], + 'conflicts': ['sale_payment'], + 'data': [ + 'view/sale.xml', + ], + 'installable': True, + 'active': False, +} diff --git a/account_payment_sale/i18n/account_payment_sale.pot b/account_payment_sale/i18n/account_payment_sale.pot new file mode 100644 index 000000000..3bb6dd99d --- /dev/null +++ b/account_payment_sale/i18n/account_payment_sale.pot @@ -0,0 +1,37 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_payment_sale +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-02-24 23:07+0000\n" +"PO-Revision-Date: 2014-02-24 23:07+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_sale +#: field:sale.order,payment_mode_type:0 +msgid "Payment Type" +msgstr "" + +#. module: account_payment_sale +#: model:ir.model,name:account_payment_sale.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: account_payment_sale +#: help:sale.order,partner_bank_receivable:0 +msgid "Select the bank account of your company on which the customer should pay. This field is copied from the partner and will be copied to the customer invoice." +msgstr "" + +#. module: account_payment_sale +#: field:sale.order,partner_bank_receivable:0 +msgid "Receivable Bank Account" +msgstr "" + diff --git a/account_payment_sale/model/__init__.py b/account_payment_sale/model/__init__.py new file mode 100644 index 000000000..079ae1b71 --- /dev/null +++ b/account_payment_sale/model/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Sale 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 sale diff --git a/account_payment_sale/model/sale.py b/account_payment_sale/model/sale.py new file mode 100644 index 000000000..3dc8a5e3c --- /dev/null +++ b/account_payment_sale/model/sale.py @@ -0,0 +1,66 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Sale 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 sale_order(orm.Model): + _inherit = "sale.order" + + _columns = { + 'partner_bank_receivable': fields.many2one( + 'res.partner.bank', 'Receivable Bank Account', + help="Select the bank account of your company on which the " + "customer should pay. This field is copied from the partner " + "and will be copied to the customer invoice."), + 'payment_mode_type': fields.many2one( + 'payment.mode.type', 'Payment Type'), + } + + def onchange_partner_id(self, cr, uid, ids, part, context=None): + res = super(sale_order, self).onchange_partner_id( + cr, uid, ids, part, context=context) + if part: + partner = self.pool['res.partner'].browse( + cr, uid, part, context=context) + res['value'].update({ + 'partner_bank_receivable': + partner.partner_bank_receivable.id or False, + 'payment_mode_type': + partner.customer_payment_mode_type.id or False, + }) + else: + res['value'].update({ + 'partner_bank_receivable': False, + 'payment_mode_type': False, + }) + return res + + def _prepare_invoice(self, cr, uid, order, lines, context=None): + """Copy bank partner from sale order to invoice""" + invoice_vals = super(sale_order, self)._prepare_invoice( + cr, uid, order, lines, context=context) + invoice_vals.update({ + 'partner_bank_id': order.partner_bank_receivable.id or False, + 'payment_mode_type': order.payment_mode_type.id or False, + }) + return invoice_vals diff --git a/account_payment_sale/view/sale.xml b/account_payment_sale/view/sale.xml new file mode 100644 index 000000000..f54cf8c95 --- /dev/null +++ b/account_payment_sale/view/sale.xml @@ -0,0 +1,28 @@ + + + + + + + + + account_payment_sale.sale_order.form + sale.order + + + + + + + + + + + + diff --git a/account_payment_sale_stock/__init__.py b/account_payment_sale_stock/__init__.py new file mode 100644 index 000000000..c98702b99 --- /dev/null +++ b/account_payment_sale_stock/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Sale Stock 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_sale_stock/__openerp__.py b/account_payment_sale_stock/__openerp__.py new file mode 100644 index 000000000..1b45fbf1c --- /dev/null +++ b/account_payment_sale_stock/__openerp__.py @@ -0,0 +1,43 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Sale Stock 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 Sale Stock', + 'version': '1.0', + 'category': 'Banking addons', + 'license': 'AGPL-3', + 'summary': "Manage Payment Type and Bank Account when invoicing from picking", + 'description': """ +Account Payment Sale Stock +========================== + +This modules copies *Bank Account* and *Payment Type* from Sale Order to Invoice when the Invoice is generated from the Picking. + +Please contact Alexis de Lattre from Akretion for any help or question about this module. + """, + 'author': 'Akretion', + 'website': 'http://www.akretion.com', + 'depends': ['sale_stock', 'account_payment_sale'], + 'conflicts': ['account_payment_extension'], + 'data': [], + 'active': False, +} diff --git a/account_payment_sale_stock/model/__init__.py b/account_payment_sale_stock/model/__init__.py new file mode 100644 index 000000000..251e4ac06 --- /dev/null +++ b/account_payment_sale_stock/model/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Sale Stock 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 stock diff --git a/account_payment_sale_stock/model/stock.py b/account_payment_sale_stock/model/stock.py new file mode 100644 index 000000000..f307d0d5c --- /dev/null +++ b/account_payment_sale_stock/model/stock.py @@ -0,0 +1,42 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Sale Stock 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 stock_picking(orm.Model): + _inherit = "stock.picking" + + def _prepare_invoice( + self, cr, uid, picking, partner, inv_type, journal_id, + context=None): + """Copy bank partner and payment type from sale order to invoice""" + invoice_vals = super(stock_picking, self)._prepare_invoice( + cr, uid, picking, partner, inv_type, journal_id, context=context) + if picking.sale_id: + invoice_vals.update({ + 'partner_bank_id': + picking.sale_id.partner_bank_receivable.id or False, + 'payment_mode_type': + picking.sale_id.payment_mode_type.id or False, + }) + return invoice_vals From d5cb35de7341f2d60a8bfbdeaca0bec556353978 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 12 Mar 2014 23:18:33 +0100 Subject: [PATCH 02/11] Add missing utf-8 header Update state field on SEPA file objects and display it in tree+form views. Migrate form views to version 7.0 and simplify them. --- account_banking_pain_base/__openerp__.py | 1 + .../__openerp__.py | 1 + .../account_banking_sepa.py | 2 +- .../account_banking_sepa_view.xml | 33 +++++++++---------- .../__openerp__.py | 1 + .../account_banking_sdd.py | 2 +- .../account_banking_sdd_view.xml | 33 +++++++++---------- account_banking_sepa_direct_debit/company.py | 1 + 8 files changed, 36 insertions(+), 38 deletions(-) diff --git a/account_banking_pain_base/__openerp__.py b/account_banking_pain_base/__openerp__.py index 9803980d5..71c52d5d0 100644 --- a/account_banking_pain_base/__openerp__.py +++ b/account_banking_pain_base/__openerp__.py @@ -1,3 +1,4 @@ +# -*- encoding: utf-8 -*- ############################################################################## # # PAIN base module for OpenERP diff --git a/account_banking_sepa_credit_transfer/__openerp__.py b/account_banking_sepa_credit_transfer/__openerp__.py index 9b0521aea..cdffa6eab 100644 --- a/account_banking_sepa_credit_transfer/__openerp__.py +++ b/account_banking_sepa_credit_transfer/__openerp__.py @@ -1,3 +1,4 @@ +# -*- encoding: utf-8 -*- ############################################################################## # # SEPA Credit Transfer module for OpenERP diff --git a/account_banking_sepa_credit_transfer/account_banking_sepa.py b/account_banking_sepa_credit_transfer/account_banking_sepa.py index a54888bb9..99d5b022b 100644 --- a/account_banking_sepa_credit_transfer/account_banking_sepa.py +++ b/account_banking_sepa_credit_transfer/account_banking_sepa.py @@ -1,3 +1,4 @@ +# -*- encoding: utf-8 -*- ############################################################################## # # SEPA Credit Transfer module for OpenERP @@ -81,7 +82,6 @@ class banking_export_sepa(orm.Model): 'state': fields.selection([ ('draft', 'Draft'), ('sent', 'Sent'), - ('done', 'Reconciled'), ], 'State', readonly=True), } diff --git a/account_banking_sepa_credit_transfer/account_banking_sepa_view.xml b/account_banking_sepa_credit_transfer/account_banking_sepa_view.xml index 8bf13cf1d..a5896c757 100644 --- a/account_banking_sepa_credit_transfer/account_banking_sepa_view.xml +++ b/account_banking_sepa_credit_transfer/account_banking_sepa_view.xml @@ -11,28 +11,24 @@ account.banking.export.sepa.form banking.export.sepa -
+ +
+ +
- - - - - - - - + + + + + + + + + - - - - - - - - - +
@@ -48,6 +44,7 @@ + diff --git a/account_banking_sepa_direct_debit/__openerp__.py b/account_banking_sepa_direct_debit/__openerp__.py index cd603fc03..611127a84 100644 --- a/account_banking_sepa_direct_debit/__openerp__.py +++ b/account_banking_sepa_direct_debit/__openerp__.py @@ -1,3 +1,4 @@ +# -*- encoding: utf-8 -*- ############################################################################## # # SEPA Direct Debit module for OpenERP diff --git a/account_banking_sepa_direct_debit/account_banking_sdd.py b/account_banking_sepa_direct_debit/account_banking_sdd.py index d0edb5e90..cbf0d0d10 100644 --- a/account_banking_sepa_direct_debit/account_banking_sdd.py +++ b/account_banking_sepa_direct_debit/account_banking_sdd.py @@ -1,3 +1,4 @@ +# -*- encoding: utf-8 -*- ############################################################################## # # SEPA Direct Debit module for OpenERP @@ -89,7 +90,6 @@ class banking_export_sdd(orm.Model): 'state': fields.selection([ ('draft', 'Draft'), ('sent', 'Sent'), - ('done', 'Reconciled'), ], 'State', readonly=True), } diff --git a/account_banking_sepa_direct_debit/account_banking_sdd_view.xml b/account_banking_sepa_direct_debit/account_banking_sdd_view.xml index f89ec7389..f74b60353 100644 --- a/account_banking_sepa_direct_debit/account_banking_sdd_view.xml +++ b/account_banking_sepa_direct_debit/account_banking_sdd_view.xml @@ -11,28 +11,24 @@ account.banking.export.sdd.form banking.export.sdd -
+ +
+ +
- - - - - - - - + + + + + + + + + - - - - - - - - - +
@@ -48,6 +44,7 @@ + diff --git a/account_banking_sepa_direct_debit/company.py b/account_banking_sepa_direct_debit/company.py index 5dd960224..6d54ba8e6 100644 --- a/account_banking_sepa_direct_debit/company.py +++ b/account_banking_sepa_direct_debit/company.py @@ -1,3 +1,4 @@ +# -*- encoding: utf-8 -*- ############################################################################## # # SEPA Direct Debit module for OpenERP From 58393f8b0faa745eab32aa1afb962c0dbdc9d349 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 17 Mar 2014 12:08:41 +0100 Subject: [PATCH 03/11] File account_banking_payment/model/account_payment.py is now PEP-8 compliant Introduce _prepare_* functions in the function action_sent(), to make inheritance easier. Add support for payment lines with move_line_id = False (for example, when you make an advance payment for a supplier order). --- .../model/account_payment.py | 175 ++++++++++-------- 1 file changed, 101 insertions(+), 74 deletions(-) diff --git a/account_banking_payment/model/account_payment.py b/account_banking_payment/model/account_payment.py index 0f4763af3..8c7374047 100644 --- a/account_banking_payment/model/account_payment.py +++ b/account_banking_payment/model/account_payment.py @@ -3,7 +3,7 @@ # # Copyright (C) 2009 EduSense BV (). # (C) 2011 - 2013 Therp BV (). -# +# # All other contributions are (C) by their respective contributors # # All Rights Reserved @@ -63,11 +63,11 @@ class payment_order(orm.Model): ), 'state': fields.selection([ ('draft', 'Draft'), - ('open','Confirmed'), - ('cancel','Cancelled'), + ('open', 'Confirmed'), + ('cancel', 'Cancelled'), ('sent', 'Sent'), ('rejected', 'Rejected'), - ('done','Done'), + ('done', 'Done'), ], 'State', select=True ), 'line_ids': fields.one2many( @@ -81,7 +81,7 @@ class payment_order(orm.Model): }, ), 'user_id': fields.many2one( - 'res.users','User', required=True, + 'res.users', 'User', required=True, states={ 'sent': [('readonly', True)], 'rejected': [('readonly', True)], @@ -98,18 +98,19 @@ class payment_order(orm.Model): 'rejected': [('readonly', True)], 'done': [('readonly', True)] }, - help=("Choose an option for the Payment Order:'Fixed' stands for a " - "date specified by you.'Directly' stands for the direct " + help=("Choose an option for the Payment Order:'Fixed' stands for " + "a date specified by you.'Directly' stands for the direct " "execution.'Due date' stands for the scheduled date of " "execution." - ) + ) ), 'date_sent': fields.date('Send date', readonly=True), } def _write_payment_lines(self, cr, uid, ids, **kwargs): ''' - ORM method for setting attributes of corresponding payment.line objects. + ORM method for setting attributes of corresponding payment.line + objects. Note that while this is ORM compliant, it is also very ineffecient due to the absence of filters on writes and hence the requirement to filter on the client(=OpenERP server) side. @@ -143,7 +144,7 @@ class payment_order(orm.Model): cr, uid, ids, *args ) - def debit_reconcile_transfer(self, cr, uid, payment_order_id, + def debit_reconcile_transfer(self, cr, uid, payment_order_id, amount, currency, context=None): """ During import of bank statements, create the reconcile on the transfer @@ -163,10 +164,10 @@ class payment_order(orm.Model): if line.account_id.type == 'other' and not line.reconcile_id: line_ids.append(line.id) if self.pool.get('res.currency').is_zero( - cr, uid, currency, - move_line_obj.get_balance(cr, uid, line_ids) - amount): + cr, uid, currency, + move_line_obj.get_balance(cr, uid, line_ids) - amount): reconcile_id = self.pool.get('account.move.reconcile').create( - cr, uid, + cr, uid, {'type': 'auto', 'line_id': [(6, 0, line_ids)]}, context) # set direct debit order to finished state @@ -175,8 +176,9 @@ class payment_order(orm.Model): uid, 'payment.order', payment_order_id, 'done', cr) return reconcile_id - def debit_unreconcile_transfer(self, cr, uid, payment_order_id, reconcile_id, - amount, currency, context=None): + def debit_unreconcile_transfer( + self, cr, uid, payment_order_id, reconcile_id, amount, currency, + context=None): """ Due to a cancelled bank statements import, unreconcile the move on the transfer account. Delegate the conditions to the workflow. @@ -194,12 +196,12 @@ class payment_order(orm.Model): if state != 'sent': raise orm.except_orm( _("Cannot unreconcile"), - _("Cannot unreconcile payment order: "+ + _("Cannot unreconcile payment order: " "Workflow will not allow it.")) return True def test_undo_done(self, cr, uid, ids, context=None): - """ + """ Called from the workflow. Used to unset done state on payment orders that were reconciled with bank transfers which are being cancelled. @@ -213,14 +215,68 @@ class payment_order(orm.Model): for order in self.browse(cr, uid, ids, context=context): for order_line in order.line_ids: if order_line.transit_move_line_id.move_id: - for line in order_line.transit_move_line_id.move_id.line_id: + for line in \ + order_line.transit_move_line_id.move_id.line_id: if (line.account_id.type == 'other' and line.reconcile_id): return False return True - + + def _prepare_transfer_move( + self, cr, uid, order, line, labels, context=None): + vals = { + 'journal_id': order.mode.transfer_journal_id.id, + 'name': '%s %s' % (labels[order.payment_order_type], + line.move_line_id + and line.move_line_id.move_id.name + or line.communication), + 'ref': '%s %s' % (order.payment_order_type[:3].upper(), + line.move_line_id + and line.move_line_id.move_id.name + or line.communication), + } + return vals + + def _prepare_move_line_transfer_account( + self, cr, uid, order, line, move_id, labels, context=None): + vals = { + 'name': _('%s for %s') % ( + labels[order.payment_order_type], + line.move_line_id and (line.move_line_id.invoice + and line.move_line_id.invoice.number + or line.move_line_id.name) + or line.communication), + 'move_id': move_id, + 'partner_id': False, + 'account_id': order.mode.transfer_account_id.id, + 'credit': (order.payment_order_type == 'payment' + and line.amount or 0.0), + 'debit': (order.payment_order_type == 'debit' + and line.amount or 0.0), + 'date': fields.date.context_today( + self, cr, uid, context=context), + } + return vals + + def _update_move_line_partner_account( + self, cr, uid, order, line, vals, context=None): + vals.update({ + 'partner_id': line.partner_id.id, + 'account_id': (line.move_line_id + and line.move_line_id.account_id.id + or False), + # if not line.move_line_id, the field 'account_id' must be set by + # another module that inherit this function, like for example in + # the module purchase_payment_order + 'credit': (order.payment_order_type == 'debit' + and line.amount or 0.0), + 'debit': (order.payment_order_type == 'payment' + and line.amount or 0.0), + }) + return vals + def action_sent(self, cr, uid, ids, context=None): - """ + """ Create the moves that pay off the move lines from the debit order. This happens when the debit order file is generated. @@ -233,63 +289,35 @@ class payment_order(orm.Model): 'debit': _('Direct debit order'), } for order in self.browse(cr, uid, ids, context=context): - if not order.mode.transfer_journal_id or not order.mode.transfer_account_id: + if not order.mode.transfer_journal_id \ + or not order.mode.transfer_account_id: continue for line in order.line_ids: # basic checks - if not line.move_line_id: + if line.move_line_id and line.move_line_id.reconcile_id: raise orm.except_orm( _('Error'), - _('No move line provided for line %s') % line.name) - if line.move_line_id.reconcile_id: - raise orm.except_orm( - _('Error'), - _('Move line %s has already been paid/reconciled') % - line.move_line_id.name - ) + _('Move line %s has already been paid/reconciled') + % line.move_line_id.name) - move_id = account_move_obj.create(cr, uid, { - 'journal_id': order.mode.transfer_journal_id.id, - 'name': '%s %s' % (labels[order.payment_order_type], - line.move_line_id.move_id.name), - 'ref': '%s%s' % (order.payment_order_type[:3].upper(), - line.move_line_id.move_id.name), - }, context=context) + move_id = account_move_obj.create( + cr, uid, self._prepare_transfer_move( + cr, uid, order, line, labels, context=context), + context=context) # TODO: take multicurrency into account - - # create the debit move line on the transfer account - vals = { - 'name': _('%s for %s') % ( - labels[order.payment_order_type], - line.move_line_id.invoice and - line.move_line_id.invoice.number or - line.move_line_id.name), - 'move_id': move_id, - 'partner_id': False, - 'account_id': order.mode.transfer_account_id.id, - 'credit': (order.payment_order_type == 'payment' - and line.amount or 0.0), - 'debit': (order.payment_order_type == 'debit' - and line.amount or 0.0), - 'date': fields.date.context_today( - self, cr, uid, context=context), - } - transfer_move_line_id = account_move_line_obj.create( - cr, uid, vals, context=context) - # create the debit move line on the receivable account - vals.update({ - 'partner_id': line.partner_id.id, - 'account_id': line.move_line_id.account_id.id, - 'credit': (order.payment_order_type == 'debit' - and line.amount or 0.0), - 'debit': (order.payment_order_type == 'payment' - and line.amount or 0.0), - }) + # create the debit move line on the transfer account + ml_vals = self._prepare_move_line_transfer_account( + cr, uid, order, line, move_id, labels, context=context) + account_move_line_obj.create(cr, uid, ml_vals, context=context) + + # create the debit move line on the partner account + self._update_move_line_partner_account( + cr, uid, order, line, ml_vals, context=context) reconcile_move_line_id = account_move_line_obj.create( - cr, uid, vals, context=context) - + cr, uid, ml_vals, context=context) + # register the debit move line on the payment line # and call reconciliation on it payment_line_obj.write( @@ -297,16 +325,15 @@ class payment_order(orm.Model): {'transit_move_line_id': reconcile_move_line_id}, context=context) - payment_line_obj.debit_reconcile( - cr, uid, line.id, context=context) + if line.move_line_id: + payment_line_obj.debit_reconcile( + cr, uid, line.id, context=context) account_move_obj.post(cr, uid, [move_id], context=context) # State field is written by act_sent_wait self.write(cr, uid, ids, { - 'date_sent': fields.date.context_today( - self, cr, uid, context=context), - }, context=context) + 'date_sent': fields.date.context_today( + self, cr, uid, context=context), + }, context=context) return True - - From daf46a3cbec9e81f88b7a5b8d57da799aaffb556 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 18 Mar 2014 23:51:10 +0100 Subject: [PATCH 04/11] Add a hook, which is designed to be inherited. For example, it can be used to wake-up the workflow of purchase order (usefull in combination with the module 'purchase_payment_order') --- account_banking_payment/model/account_payment.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/account_banking_payment/model/account_payment.py b/account_banking_payment/model/account_payment.py index 8c7374047..1e2e31277 100644 --- a/account_banking_payment/model/account_payment.py +++ b/account_banking_payment/model/account_payment.py @@ -275,6 +275,10 @@ class payment_order(orm.Model): }) return vals + def action_sent_no_move_line_hook(self, cr, uid, pay_line, context=None): + """This function is designed to be inherited""" + return + def action_sent(self, cr, uid, ids, context=None): """ Create the moves that pay off the move lines from @@ -328,6 +332,9 @@ class payment_order(orm.Model): if line.move_line_id: payment_line_obj.debit_reconcile( cr, uid, line.id, context=context) + else: + self.action_sent_no_move_line_hook( + cr, uid, line, context=context) account_move_obj.post(cr, uid, [move_id], context=context) # State field is written by act_sent_wait From 608d775a6648866ffc618692842b0270c5615135 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Fri, 21 Mar 2014 15:40:35 +0100 Subject: [PATCH 05/11] [FIX] wrong model type in inherit. --- account_payment_partner/model/payment_order_create.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/account_payment_partner/model/payment_order_create.py b/account_payment_partner/model/payment_order_create.py index 0168f1ae4..777c4480a 100644 --- a/account_payment_partner/model/payment_order_create.py +++ b/account_payment_partner/model/payment_order_create.py @@ -23,7 +23,7 @@ from openerp.osv import orm -class payment_order_create(orm.Model): +class payment_order_create(orm.TransientModel): _inherit = 'payment.order.create' def extend_payment_order_domain( From a20665ba12bad67a34fbd1e00d541654c99a2d00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Valyi?= Date: Fri, 21 Mar 2014 16:50:25 -0300 Subject: [PATCH 06/11] [REF] wrapping module description lines to keep cool with the PEP-8 extremists --- account_payment_partner/__openerp__.py | 6 ++++-- account_payment_purchase/__openerp__.py | 13 ++++++++++--- account_payment_sale/__openerp__.py | 13 ++++++++++--- account_payment_sale_stock/__openerp__.py | 6 ++++-- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/account_payment_partner/__openerp__.py b/account_payment_partner/__openerp__.py index e67a7fc2b..25e312638 100644 --- a/account_payment_partner/__openerp__.py +++ b/account_payment_partner/__openerp__.py @@ -39,9 +39,11 @@ This module adds severals fields : * the *Payment Type* on Invoices. -On a Payment Order, in the wizard *Select Invoices to Pay*, the invoices will be filtered per Payment Type. +On a Payment Order, in the wizard *Select Invoices to Pay*, the invoices will +be filtered per Payment Type. -Please contact Alexis de Lattre from Akretion for any help or question about this module. +Please contact Alexis de Lattre from Akretion +for any help or question about this module. """, 'author': 'Akretion', 'website': 'http://www.akretion.com', diff --git a/account_payment_purchase/__openerp__.py b/account_payment_purchase/__openerp__.py index e2fc219eb..76a89589b 100644 --- a/account_payment_purchase/__openerp__.py +++ b/account_payment_purchase/__openerp__.py @@ -30,11 +30,18 @@ Account Payment Purchase ======================== -This modules adds 2 fields on purchase orders : *Bank Account* and *Payment Type*. These fields are copied from partner to purchase order and then from purchase order to supplier invoice. +This modules adds 2 fields on purchase orders : *Bank Account* and *Payment +Type*. These fields are copied from partner to purchase order and then from +purchase order to supplier invoice. -This module is similar to the *purchase_payment* module ; the main difference is that it doesn't depend on the *account_payment_extension* module (it's not the only module to conflict with *account_payment_extension* ; all the SEPA modules in the banking addons conflict with *account_payment_extension*, cf banking-addons-70/account_banking_payment_export/__openerp__.py). +This module is similar to the *purchase_payment* module ; the main difference +is that it doesn't depend on the *account_payment_extension* module (it's not +the only module to conflict with *account_payment_extension* ; all the SEPA +modules in the banking addons conflict with *account_payment_extension*, cf +banking-addons-70/account_banking_payment_export/__openerp__.py). -Please contact Alexis de Lattre from Akretion for any help or question about this module. +Please contact Alexis de Lattre from Akretion +for any help or question about this module. """, 'author': 'Akretion', 'website': 'http://www.akretion.com', diff --git a/account_payment_sale/__openerp__.py b/account_payment_sale/__openerp__.py index b6cf3b2cb..42ba67911 100644 --- a/account_payment_sale/__openerp__.py +++ b/account_payment_sale/__openerp__.py @@ -30,11 +30,18 @@ Account Payment Sale ==================== -This modules adds 2 fields on sale orders : *Bank Account* and *Payment Type*. These fields are copied from partner to sale order and then from sale order to customer invoice. +This modules adds 2 fields on sale orders : *Bank Account* and *Payment Type*. +These fields are copied from partner to sale order and then from sale order to +customer invoice. -This module is similar to the *sale_payment* module ; the main difference is that it doesn't depend on the *account_payment_extension* module (it's not the only module to conflict with *account_payment_extension* ; all the SEPA modules in the banking addons conflict with *account_payment_extension*, cf banking-addons-70/account_banking_payment_export/__openerp__.py). +This module is similar to the *sale_payment* module ; the main difference is +that it doesn't depend on the *account_payment_extension* module (it's not the +only module to conflict with *account_payment_extension* ; all the SEPA +modules in the banking addons conflict with *account_payment_extension*, cf +banking-addons-70/account_banking_payment_export/__openerp__.py). -Please contact Alexis de Lattre from Akretion for any help or question about this module. +Please contact Alexis de Lattre from Akretion +for any help or question about this module. """, 'author': 'Akretion', 'website': 'http://www.akretion.com', diff --git a/account_payment_sale_stock/__openerp__.py b/account_payment_sale_stock/__openerp__.py index 1b45fbf1c..a10b34c3d 100644 --- a/account_payment_sale_stock/__openerp__.py +++ b/account_payment_sale_stock/__openerp__.py @@ -30,9 +30,11 @@ Account Payment Sale Stock ========================== -This modules copies *Bank Account* and *Payment Type* from Sale Order to Invoice when the Invoice is generated from the Picking. +This modules copies *Bank Account* and *Payment Type* from Sale Order to +Invoice when the Invoice is generated from the Picking. -Please contact Alexis de Lattre from Akretion for any help or question about this module. +Please contact Alexis de Lattre from Akretion +for any help or question about this module. """, 'author': 'Akretion', 'website': 'http://www.akretion.com', From 58529679bf0469b380c5ea3ccf884d324a87afc7 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 10 Apr 2014 23:16:30 +0200 Subject: [PATCH 07/11] Add auto-install on account_payment_sale_stock. --- account_payment_sale_stock/__openerp__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/account_payment_sale_stock/__openerp__.py b/account_payment_sale_stock/__openerp__.py index a10b34c3d..80be52bbb 100644 --- a/account_payment_sale_stock/__openerp__.py +++ b/account_payment_sale_stock/__openerp__.py @@ -41,5 +41,6 @@ for any help or question about this module. 'depends': ['sale_stock', 'account_payment_sale'], 'conflicts': ['account_payment_extension'], 'data': [], + 'auto_install': True, 'active': False, } From 03153cff92db8c981533aa9aba11f849a7ae2f67 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 10 Apr 2014 23:55:18 +0200 Subject: [PATCH 08/11] As suggested by Stefan, display unactive payment.mode.types in tree view. --- account_banking_payment_export/view/payment_mode_type.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/account_banking_payment_export/view/payment_mode_type.xml b/account_banking_payment_export/view/payment_mode_type.xml index 45e99656c..a3bd21c25 100644 --- a/account_banking_payment_export/view/payment_mode_type.xml +++ b/account_banking_payment_export/view/payment_mode_type.xml @@ -37,6 +37,7 @@ + @@ -47,6 +48,7 @@ payment.mode.type form tree,form + {'active_test': False} Date: Sat, 12 Apr 2014 00:48:45 +0200 Subject: [PATCH 09/11] As suggested by Stefan: also select invoices with empty payment.mode.type. --- account_payment_partner/model/payment_order_create.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/account_payment_partner/model/payment_order_create.py b/account_payment_partner/model/payment_order_create.py index 777c4480a..e6d4f8f17 100644 --- a/account_payment_partner/model/payment_order_create.py +++ b/account_payment_partner/model/payment_order_create.py @@ -31,8 +31,9 @@ class payment_order_create(orm.TransientModel): super(payment_order_create, self).extend_payment_order_domain( cr, uid, payment_order, domain, context=context) domain += [ - '|', + '|', '|', ('invoice', '=', False), + ('invoice.payment_mode_type', '=', False), ('invoice.payment_mode_type', '=', payment_order.mode_type.id) ] return True From c27bba821f6109c39effce17642b8c668eea12d1 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 10 Jun 2014 01:25:34 +0200 Subject: [PATCH 10/11] Update to the new data-model decided during the Open Days 2014. Add demo data. --- .../demo/banking_demo.xml | 35 ++++++++++ account_payment_partner/__init__.py | 2 +- account_payment_partner/__openerp__.py | 18 +++-- account_payment_partner/demo/partner_demo.xml | 51 ++++++++++++++ .../i18n/account_payment_partner.pot | 68 ++++++++----------- account_payment_partner/model/__init__.py | 2 +- .../model/account_invoice.py | 26 +++---- account_payment_partner/model/partner.py | 29 +++----- .../model/payment_order_create.py | 6 +- .../view/account_invoice.xml | 8 +-- account_payment_partner/view/partner.xml | 7 +- account_payment_purchase/__openerp__.py | 4 +- .../i18n/account_payment_purchase.pot | 22 +++--- account_payment_purchase/model/purchase.py | 22 +++--- account_payment_purchase/view/purchase.xml | 4 +- account_payment_sale/__openerp__.py | 6 +- .../i18n/account_payment_sale.pot | 18 ++--- account_payment_sale/model/sale.py | 26 ++----- account_payment_sale/view/sale.xml | 6 +- account_payment_sale_stock/__openerp__.py | 6 +- account_payment_sale_stock/model/stock.py | 8 +-- 21 files changed, 206 insertions(+), 168 deletions(-) create mode 100644 account_payment_partner/demo/partner_demo.xml diff --git a/account_banking_payment_export/demo/banking_demo.xml b/account_banking_payment_export/demo/banking_demo.xml index 1b220f072..fd29e4c51 100644 --- a/account_banking_payment_export/demo/banking_demo.xml +++ b/account_banking_payment_export/demo/banking_demo.xml @@ -21,6 +21,15 @@ + + Société Générale + SOGEFRPPXXX + 1 avenue du Roi Fabien 1er + 75008 + Paris + + + FR76 4242 4242 4242 4242 4242 424 iban @@ -30,6 +39,15 @@ PSSTFRPPXXX + + FR20 1242 1242 1242 1242 1242 124 + iban + + + Société Générale + SOGEFRPPXXX + + FR66 1212 1212 1212 1212 1212 121 iban @@ -39,5 +57,22 @@ FTNOFRP1XXX + + Credit Trf Banque Postale + + + + + + + + Credit Trf Société Générale + + + + + + + diff --git a/account_payment_partner/__init__.py b/account_payment_partner/__init__.py index da25c5761..161123944 100644 --- a/account_payment_partner/__init__.py +++ b/account_payment_partner/__init__.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Account Partner Payment module for OpenERP +# Account Payment Partner module for OpenERP # Copyright (C) 2014 Akretion (http://www.akretion.com) # @author Alexis de Lattre # diff --git a/account_payment_partner/__openerp__.py b/account_payment_partner/__openerp__.py index 25e312638..4e0217c98 100644 --- a/account_payment_partner/__openerp__.py +++ b/account_payment_partner/__openerp__.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Account Partner Payment module for OpenERP +# Account Payment Partner module for OpenERP # Copyright (C) 2014 Akretion (http://www.akretion.com) # @author Alexis de Lattre # @@ -22,25 +22,23 @@ { - 'name': 'Account Partner Payment', + 'name': 'Account Payment Partner', 'version': '0.1', 'category': 'Banking addons', 'license': 'AGPL-3', - 'summary': 'Adds payment type and receivable bank account on partners', + 'summary': 'Adds payment mode on partners and invoices', 'description': """ -Account Partner Payment +Account Payment Partner ======================= This module adds severals fields : -* the *Supplier Payment Type* and *Customer Payment Type* on Partners, +* the *Supplier Payment Mode* and *Customer Payment Mode* on Partners, -* the *Receivable Bank Account* on Partners, - -* the *Payment Type* on Invoices. +* the *Payment Mode* on Invoices. On a Payment Order, in the wizard *Select Invoices to Pay*, the invoices will -be filtered per Payment Type. +be filtered per Payment Mode. Please contact Alexis de Lattre from Akretion for any help or question about this module. @@ -52,6 +50,6 @@ for any help or question about this module. 'view/partner.xml', 'view/account_invoice.xml', ], - 'demo': [], + '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 index 0e83b63de..ca26e532d 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: OpenERP Server 7.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-02-24 23:06+0000\n" -"PO-Revision-Date: 2014-02-24 23:06+0000\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" @@ -16,38 +16,8 @@ msgstr "" "Plural-Forms: \n" #. module: account_payment_partner -#: field:account.invoice,payment_mode_type:0 -msgid "Payment Type" -msgstr "" - -#. module: account_payment_partner -#: model:ir.model,name:account_payment_partner.model_payment_order_create -msgid "payment.order.create" -msgstr "" - -#. module: account_payment_partner -#: field:res.partner,supplier_payment_mode_type:0 -msgid "Supplier Payment Type" -msgstr "" - -#. module: account_payment_partner -#: help:res.partner,partner_bank_receivable:0 -msgid "Select the bank account of your company on which the customer should pay." -msgstr "" - -#. module: account_payment_partner -#: field:res.partner,partner_bank_receivable:0 -msgid "Receivable Bank Account" -msgstr "" - -#. module: account_payment_partner -#: help:res.partner,supplier_payment_mode_type:0 -msgid "Select the default payment type for this supplier." -msgstr "" - -#. module: account_payment_partner -#: field:res.partner,customer_payment_mode_type:0 -msgid "Customer Payment Type" +#: field:res.partner,customer_payment_mode:0 +msgid "Customer Payment Mode" msgstr "" #. module: account_payment_partner @@ -55,13 +25,33 @@ msgstr "" msgid "Invoice" msgstr "" -#. module: account_payment_partner -#: help:res.partner,customer_payment_mode_type:0 -msgid "Select the default payment type for this customer." -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 index 3fae22c2a..16ab8bc9e 100644 --- a/account_payment_partner/model/__init__.py +++ b/account_payment_partner/model/__init__.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Account Partner Payment module for OpenERP +# Account Payment Partner module for OpenERP # Copyright (C) 2014 Akretion (http://www.akretion.com) # @author Alexis de Lattre # diff --git a/account_payment_partner/model/account_invoice.py b/account_payment_partner/model/account_invoice.py index 1e34729df..9e02ea476 100644 --- a/account_payment_partner/model/account_invoice.py +++ b/account_payment_partner/model/account_invoice.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Account Partner Payment module for OpenERP +# Account Payment Partner module for OpenERP # Copyright (C) 2014 Akretion (http://www.akretion.com) # @author Alexis de Lattre # @@ -27,8 +27,8 @@ class account_invoice(orm.Model): _inherit = 'account.invoice' _columns = { - 'payment_mode_type': fields.many2one( - 'payment.mode.type', 'Payment Type'), + 'payment_mode_id': fields.many2one( + 'payment.mode', 'Payment Mode'), } def onchange_partner_id( @@ -40,14 +40,16 @@ class account_invoice(orm.Model): company_id=company_id) if partner_id: partner = self.pool['res.partner'].browse(cr, uid, partner_id) - # TODO what about refunds ? Should be really copy - # the payment type for refunds ? - if type and type in ('in_invoice', 'in_refund'): - res['value']['payment_mode_type'] = \ - partner.supplier_payment_mode_type.id or False - elif type and type in ('out_invoice', 'out_refund'): - res['value']['payment_mode_type'] = \ - partner.customer_payment_mode_type.id or False + 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.bank_id.id or False, + }) else: - res['value']['payment_mode_type'] = False + res['value']['payment_mode_id'] = False return res diff --git a/account_payment_partner/model/partner.py b/account_payment_partner/model/partner.py index caef3c0a5..4bfe4c787 100644 --- a/account_payment_partner/model/partner.py +++ b/account_payment_partner/model/partner.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Account Partner Payment module for OpenERP +# Account Payment Partner module for OpenERP # Copyright (C) 2014 Akretion (http://www.akretion.com) # @author Alexis de Lattre # @@ -27,27 +27,18 @@ class res_partner(orm.Model): _inherit = 'res.partner' _columns = { - 'supplier_payment_mode_type': fields.property( - 'payment.mode.type', type='many2one', relation='payment.mode.type', - string='Supplier Payment Type', view_load=True, - help="Select the default payment type for this supplier."), - 'customer_payment_mode_type': fields.property( - 'payment.mode.type', type='many2one', relation='payment.mode.type', - string='Customer Payment Type', view_load=True, - help="Select the default payment type for this customer."), - 'partner_bank_receivable': fields.property( - 'res.partner.bank', type='many2one', relation='res.partner.bank', - string='Receivable Bank Account', view_load=True, - help="Select the bank account of your company on which the " - "customer should pay."), + '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_type', - 'customer_payment_mode_type', - 'partner_bank_receivable', - ] + 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 index e6d4f8f17..ea8b1ccb3 100644 --- a/account_payment_partner/model/payment_order_create.py +++ b/account_payment_partner/model/payment_order_create.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Account Partner Payment module for OpenERP +# Account Payment Partner module for OpenERP # Copyright (C) 2014 Akretion (http://www.akretion.com) # @author Alexis de Lattre # @@ -33,7 +33,7 @@ class payment_order_create(orm.TransientModel): domain += [ '|', '|', ('invoice', '=', False), - ('invoice.payment_mode_type', '=', False), - ('invoice.payment_mode_type', '=', payment_order.mode_type.id) + ('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 index 85e0e9bf1..0bfd2d1f5 100644 --- a/account_payment_partner/view/account_invoice.xml +++ b/account_payment_partner/view/account_invoice.xml @@ -11,24 +11,24 @@ - account_partner_payment.invoice_form + account_payment_partner.invoice_form account.invoice - + - account_partner_payment.invoice_supplier_form + account_payment_partner.invoice_supplier_form account.invoice - + diff --git a/account_payment_partner/view/partner.xml b/account_payment_partner/view/partner.xml index 2273ef07a..02eb8cc0f 100644 --- a/account_payment_partner/view/partner.xml +++ b/account_payment_partner/view/partner.xml @@ -16,14 +16,11 @@ - - - diff --git a/account_payment_purchase/__openerp__.py b/account_payment_purchase/__openerp__.py index 76a89589b..c8d28debb 100644 --- a/account_payment_purchase/__openerp__.py +++ b/account_payment_purchase/__openerp__.py @@ -25,13 +25,13 @@ 'version': '1.0', 'category': 'Banking addons', 'license': 'AGPL-3', - 'summary': "Adds Bank Account and Payment Type on Purchase Orders", + 'summary': "Adds Bank Account and Payment Mode on Purchase Orders", 'description': """ Account Payment Purchase ======================== This modules adds 2 fields on purchase orders : *Bank Account* and *Payment -Type*. These fields are copied from partner to purchase order and then from +Mode*. These fields are copied from partner to purchase order and then from purchase order to supplier invoice. This module is similar to the *purchase_payment* module ; the main difference diff --git a/account_payment_purchase/i18n/account_payment_purchase.pot b/account_payment_purchase/i18n/account_payment_purchase.pot index 49f775a6e..17ed963d5 100644 --- a/account_payment_purchase/i18n/account_payment_purchase.pot +++ b/account_payment_purchase/i18n/account_payment_purchase.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: OpenERP Server 7.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-02-24 23:07+0000\n" -"PO-Revision-Date: 2014-02-24 23:07+0000\n" +"POT-Creation-Date: 2014-06-09 23:23+0000\n" +"PO-Revision-Date: 2014-06-09 23:23+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -16,8 +16,13 @@ msgstr "" "Plural-Forms: \n" #. module: account_payment_purchase -#: field:purchase.order,payment_mode_type:0 -msgid "Payment Type" +#: field:purchase.order,payment_mode_id:0 +msgid "Payment Mode" +msgstr "" + +#. module: account_payment_purchase +#: model:ir.model,name:account_payment_purchase.model_stock_picking +msgid "Picking List" msgstr "" #. module: account_payment_purchase @@ -26,17 +31,12 @@ msgid "Purchase Order" msgstr "" #. module: account_payment_purchase -#: help:purchase.order,supplier_partner_bank:0 +#: help:purchase.order,supplier_partner_bank_id:0 msgid "Select the bank account of your supplier on which your company should send the payment. This field is copied from the partner and will be copied to the supplier invoice." msgstr "" #. module: account_payment_purchase -#: field:purchase.order,supplier_partner_bank:0 +#: field:purchase.order,supplier_partner_bank_id:0 msgid "Supplier Bank Account" msgstr "" -#. module: account_payment_purchase -#: model:ir.model,name:account_payment_purchase.model_stock_picking -msgid "Picking List" -msgstr "" - diff --git a/account_payment_purchase/model/purchase.py b/account_payment_purchase/model/purchase.py index 639fdce6d..f397a6a61 100644 --- a/account_payment_purchase/model/purchase.py +++ b/account_payment_purchase/model/purchase.py @@ -27,13 +27,13 @@ class purchase_order(orm.Model): _inherit = "purchase.order" _columns = { - 'supplier_partner_bank': fields.many2one( + 'supplier_partner_bank_id': fields.many2one( 'res.partner.bank', 'Supplier Bank Account', help="Select the bank account of your supplier on which " "your company should send the payment. This field is copied " "from the partner and will be copied to the supplier invoice."), - 'payment_mode_type': fields.many2one( - 'payment.mode.type', 'Payment Type'), + 'payment_mode_id': fields.many2one( + 'payment.mode', 'Payment Mode'), } def _get_default_supplier_partner_bank( @@ -51,16 +51,16 @@ class purchase_order(orm.Model): partner = self.pool['res.partner'].browse( cr, uid, partner_id) res['value'].update({ - 'supplier_partner_bank': + 'supplier_partner_bank_id': self._get_default_supplier_partner_bank( cr, uid, partner), - 'payment_mode_type': - partner.supplier_payment_mode_type.id or False, + 'payment_mode_id': + partner.supplier_payment_mode.id or False, }) else: res['value'].update({ - 'supplier_partner_bank': False, - 'payment_mode_type': False, + 'supplier_partner_bank_id': False, + 'payment_mode_id': False, }) return res @@ -75,8 +75,8 @@ class purchase_order(orm.Model): if invoice.state == 'draft': invoice.write({ 'partner_bank_id': - order.supplier_partner_bank.id or False, - 'payment_mode_type': - order.payment_mode_type.id or False, + order.supplier_partner_bank_id.id or False, + 'payment_mode_id': + order.payment_mode_id.id or False, }, context=context) return res diff --git a/account_payment_purchase/view/purchase.xml b/account_payment_purchase/view/purchase.xml index 3875fefda..f6b2cffec 100644 --- a/account_payment_purchase/view/purchase.xml +++ b/account_payment_purchase/view/purchase.xml @@ -15,8 +15,8 @@ - - + diff --git a/account_payment_sale/__openerp__.py b/account_payment_sale/__openerp__.py index 42ba67911..4ed156a33 100644 --- a/account_payment_sale/__openerp__.py +++ b/account_payment_sale/__openerp__.py @@ -25,13 +25,13 @@ 'version': '1.0', 'category': 'Banking addons', 'license': 'AGPL-3', - 'summary': "Adds Bank Account and Payment Type on Sale Orders", + 'summary': "Adds Payment Mode on Sale Orders", 'description': """ Account Payment Sale ==================== -This modules adds 2 fields on sale orders : *Bank Account* and *Payment Type*. -These fields are copied from partner to sale order and then from sale order to +This modules adds one field on sale orders : *Payment Mode*. +This field is copied from partner to sale order and then from sale order to customer invoice. This module is similar to the *sale_payment* module ; the main difference is diff --git a/account_payment_sale/i18n/account_payment_sale.pot b/account_payment_sale/i18n/account_payment_sale.pot index 3bb6dd99d..75c88ad87 100644 --- a/account_payment_sale/i18n/account_payment_sale.pot +++ b/account_payment_sale/i18n/account_payment_sale.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: OpenERP Server 7.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-02-24 23:07+0000\n" -"PO-Revision-Date: 2014-02-24 23:07+0000\n" +"POT-Creation-Date: 2014-06-09 23:24+0000\n" +"PO-Revision-Date: 2014-06-09 23:24+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -16,8 +16,8 @@ msgstr "" "Plural-Forms: \n" #. module: account_payment_sale -#: field:sale.order,payment_mode_type:0 -msgid "Payment Type" +#: field:sale.order,payment_mode_id:0 +msgid "Payment Mode" msgstr "" #. module: account_payment_sale @@ -25,13 +25,3 @@ msgstr "" msgid "Sales Order" msgstr "" -#. module: account_payment_sale -#: help:sale.order,partner_bank_receivable:0 -msgid "Select the bank account of your company on which the customer should pay. This field is copied from the partner and will be copied to the customer invoice." -msgstr "" - -#. module: account_payment_sale -#: field:sale.order,partner_bank_receivable:0 -msgid "Receivable Bank Account" -msgstr "" - diff --git a/account_payment_sale/model/sale.py b/account_payment_sale/model/sale.py index 3dc8a5e3c..1c82e9d35 100644 --- a/account_payment_sale/model/sale.py +++ b/account_payment_sale/model/sale.py @@ -27,13 +27,8 @@ class sale_order(orm.Model): _inherit = "sale.order" _columns = { - 'partner_bank_receivable': fields.many2one( - 'res.partner.bank', 'Receivable Bank Account', - help="Select the bank account of your company on which the " - "customer should pay. This field is copied from the partner " - "and will be copied to the customer invoice."), - 'payment_mode_type': fields.many2one( - 'payment.mode.type', 'Payment Type'), + 'payment_mode_id': fields.many2one( + 'payment.mode', 'Payment Mode'), } def onchange_partner_id(self, cr, uid, ids, part, context=None): @@ -42,17 +37,10 @@ class sale_order(orm.Model): if part: partner = self.pool['res.partner'].browse( cr, uid, part, context=context) - res['value'].update({ - 'partner_bank_receivable': - partner.partner_bank_receivable.id or False, - 'payment_mode_type': - partner.customer_payment_mode_type.id or False, - }) + res['value']['payment_mode_id'] = \ + partner.customer_payment_mode.id or False, else: - res['value'].update({ - 'partner_bank_receivable': False, - 'payment_mode_type': False, - }) + res['value']['payment_mode_id'] = False return res def _prepare_invoice(self, cr, uid, order, lines, context=None): @@ -60,7 +48,7 @@ class sale_order(orm.Model): invoice_vals = super(sale_order, self)._prepare_invoice( cr, uid, order, lines, context=context) invoice_vals.update({ - 'partner_bank_id': order.partner_bank_receivable.id or False, - 'payment_mode_type': order.payment_mode_type.id or False, + 'payment_mode_id': order.payment_mode_id.id or False, + 'partner_bank_id': order.payment_mode_id.bank_id.id or False, }) return invoice_vals diff --git a/account_payment_sale/view/sale.xml b/account_payment_sale/view/sale.xml index f54cf8c95..016598e09 100644 --- a/account_payment_sale/view/sale.xml +++ b/account_payment_sale/view/sale.xml @@ -15,11 +15,7 @@ - - - + diff --git a/account_payment_sale_stock/__openerp__.py b/account_payment_sale_stock/__openerp__.py index 80be52bbb..a6e91fcde 100644 --- a/account_payment_sale_stock/__openerp__.py +++ b/account_payment_sale_stock/__openerp__.py @@ -25,13 +25,13 @@ 'version': '1.0', 'category': 'Banking addons', 'license': 'AGPL-3', - 'summary': "Manage Payment Type and Bank Account when invoicing from picking", + 'summary': "Manage Payment Mode when invoicing from picking", 'description': """ Account Payment Sale Stock ========================== -This modules copies *Bank Account* and *Payment Type* from Sale Order to -Invoice when the Invoice is generated from the Picking. +This modules copies *Payment Mode* from Sale Order to Invoice when the +Invoice is generated from the Picking. Please contact Alexis de Lattre from Akretion for any help or question about this module. diff --git a/account_payment_sale_stock/model/stock.py b/account_payment_sale_stock/model/stock.py index f307d0d5c..85286c9a1 100644 --- a/account_payment_sale_stock/model/stock.py +++ b/account_payment_sale_stock/model/stock.py @@ -29,14 +29,14 @@ class stock_picking(orm.Model): def _prepare_invoice( self, cr, uid, picking, partner, inv_type, journal_id, context=None): - """Copy bank partner and payment type from sale order to invoice""" + """Copy payment mode from sale order to invoice""" invoice_vals = super(stock_picking, self)._prepare_invoice( cr, uid, picking, partner, inv_type, journal_id, context=context) if picking.sale_id: invoice_vals.update({ 'partner_bank_id': - picking.sale_id.partner_bank_receivable.id or False, - 'payment_mode_type': - picking.sale_id.payment_mode_type.id or False, + picking.sale_id.payment_mode_id.bank_id.id or False, + 'payment_mode_id': + picking.sale_id.payment_mode_id.id or False, }) return invoice_vals From 07f26de30fa4a70582750be097d42986b18f9fea Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 23 Jun 2014 11:45:26 +0200 Subject: [PATCH 11/11] Suggested by Stefan Rijnhart : check for the payment_mode_id before asking its bank_id.id --- account_payment_partner/model/account_invoice.py | 1 + account_payment_sale/model/sale.py | 3 ++- account_payment_sale_stock/model/stock.py | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/account_payment_partner/model/account_invoice.py b/account_payment_partner/model/account_invoice.py index 9e02ea476..607cda29a 100644 --- a/account_payment_partner/model/account_invoice.py +++ b/account_payment_partner/model/account_invoice.py @@ -48,6 +48,7 @@ class account_invoice(orm.Model): '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: diff --git a/account_payment_sale/model/sale.py b/account_payment_sale/model/sale.py index 1c82e9d35..5951f96af 100644 --- a/account_payment_sale/model/sale.py +++ b/account_payment_sale/model/sale.py @@ -49,6 +49,7 @@ class sale_order(orm.Model): cr, uid, order, lines, context=context) invoice_vals.update({ 'payment_mode_id': order.payment_mode_id.id or False, - 'partner_bank_id': order.payment_mode_id.bank_id.id or False, + 'partner_bank_id': order.payment_mode_id and + order.payment_mode_id.bank_id.id or False, }) return invoice_vals diff --git a/account_payment_sale_stock/model/stock.py b/account_payment_sale_stock/model/stock.py index 85286c9a1..5ed4fbd4f 100644 --- a/account_payment_sale_stock/model/stock.py +++ b/account_payment_sale_stock/model/stock.py @@ -35,6 +35,7 @@ class stock_picking(orm.Model): if picking.sale_id: invoice_vals.update({ 'partner_bank_id': + picking.sale_id.payment_mode_id and picking.sale_id.payment_mode_id.bank_id.id or False, 'payment_mode_id': picking.sale_id.payment_mode_id.id or False,