From 0d28bfddd6047ad3a3f5e6810d13c0b27312822b Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 25 Feb 2014 00:19:57 +0100 Subject: [PATCH] Add 4 new modules to handle payment type and bank accounts: - account_payment_partner - account_payment_sale - account_payment_sale_stock - account_payment_purchase Filter the selection of invoices per payment type. Add active field on payment.mode and payment.mode.type. Add menu entry for Payment Types. --- account_payment_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 ++++++++ 6 files changed, 225 insertions(+) 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 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 + + + + + + + + + + + +