From d94f15af7ab03aa473f817ed83b3aa5ec4b972ef Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Wed, 10 Sep 2014 12:48:09 +0200 Subject: [PATCH] [MIG] Migration and enhancement of all modules involved in SEPA --- account_payment_sale/__init__.py | 23 ++++++++ account_payment_sale/__openerp__.py | 55 +++++++++++++++++++ .../i18n/account_payment_sale.pot | 27 +++++++++ account_payment_sale/i18n/nl.po | 28 ++++++++++ account_payment_sale/model/__init__.py | 23 ++++++++ account_payment_sale/model/sale.py | 55 +++++++++++++++++++ account_payment_sale/models/__init__.py | 24 ++++++++ account_payment_sale/models/sale_order.py | 50 +++++++++++++++++ account_payment_sale/models/stock_picking.py | 40 ++++++++++++++ account_payment_sale/view/sale.xml | 24 ++++++++ .../views/sale_order_view.xml | 24 ++++++++ 11 files changed, 373 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/i18n/nl.po create mode 100644 account_payment_sale/model/__init__.py create mode 100644 account_payment_sale/model/sale.py create mode 100644 account_payment_sale/models/__init__.py create mode 100644 account_payment_sale/models/sale_order.py create mode 100644 account_payment_sale/models/stock_picking.py create mode 100644 account_payment_sale/view/sale.xml create mode 100644 account_payment_sale/views/sale_order_view.xml diff --git a/account_payment_sale/__init__.py b/account_payment_sale/__init__.py new file mode 100644 index 000000000..11323c6e9 --- /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 models diff --git a/account_payment_sale/__openerp__.py b/account_payment_sale/__openerp__.py new file mode 100644 index 000000000..99266a10a --- /dev/null +++ b/account_payment_sale/__openerp__.py @@ -0,0 +1,55 @@ +# -*- 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 Payment Mode on Sale Orders", + 'description': """ +Account Payment Sale +==================== + +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 +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*. + """, + 'author': 'Akretion', + 'website': 'http://www.akretion.com', + 'contributors': ['Pedro M. Baeza '], + 'depends': [ + 'sale', + 'stock_account', + 'account_payment_partner' + ], + 'conflicts': ['sale_payment'], + 'data': [ + 'views/sale_order_view.xml', + ], + 'installable': True, +} 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..75c88ad87 --- /dev/null +++ b/account_payment_sale/i18n/account_payment_sale.pot @@ -0,0 +1,27 @@ +# 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-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" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_payment_sale +#: field:sale.order,payment_mode_id:0 +msgid "Payment Mode" +msgstr "" + +#. module: account_payment_sale +#: model:ir.model,name:account_payment_sale.model_sale_order +msgid "Sales Order" +msgstr "" + diff --git a/account_payment_sale/i18n/nl.po b/account_payment_sale/i18n/nl.po new file mode 100644 index 000000000..c5d7923f3 --- /dev/null +++ b/account_payment_sale/i18n/nl.po @@ -0,0 +1,28 @@ +# Dutch translation for banking-addons +# Copyright (c) 2014 Rosetta Contributors and Canonical Ltd 2014 +# This file is distributed under the same license as the banking-addons package. +# FIRST AUTHOR , 2014. +# +msgid "" +msgstr "" +"Project-Id-Version: banking-addons\n" +"Report-Msgid-Bugs-To: FULL NAME \n" +"POT-Creation-Date: 2014-06-09 23:24+0000\n" +"PO-Revision-Date: 2014-06-26 14:13+0000\n" +"Last-Translator: Erwin van der Ploeg (BAS Solutions) \n" +"Language-Team: Dutch \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Launchpad-Export-Date: 2014-06-27 07:13+0000\n" +"X-Generator: Launchpad (build 17077)\n" + +#. module: account_payment_sale +#: field:sale.order,payment_mode_id:0 +msgid "Payment Mode" +msgstr "Betaalwijze" + +#. module: account_payment_sale +#: model:ir.model,name:account_payment_sale.model_sale_order +msgid "Sales Order" +msgstr "Verkooporder" 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..5951f96af --- /dev/null +++ b/account_payment_sale/model/sale.py @@ -0,0 +1,55 @@ +# -*- 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 = { + 'payment_mode_id': fields.many2one( + 'payment.mode', 'Payment Mode'), + } + + 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']['payment_mode_id'] = \ + partner.customer_payment_mode.id or False, + else: + res['value']['payment_mode_id'] = 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({ + 'payment_mode_id': order.payment_mode_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/models/__init__.py b/account_payment_sale/models/__init__.py new file mode 100644 index 000000000..9de52dd65 --- /dev/null +++ b/account_payment_sale/models/__init__.py @@ -0,0 +1,24 @@ +# -*- 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_order +from . import stock_picking diff --git a/account_payment_sale/models/sale_order.py b/account_payment_sale/models/sale_order.py new file mode 100644 index 000000000..cd93e56d7 --- /dev/null +++ b/account_payment_sale/models/sale_order.py @@ -0,0 +1,50 @@ +# -*- 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 import models, fields, api + + +class SaleOrder(models.Model): + _inherit = "sale.order" + + payment_mode_id = fields.Many2one( + 'payment.mode', string='Payment Mode', + domain="[('payment_order_type', '=', 'debit')]") + + @api.multi + def onchange_partner_id(self, partner_id): + res = super(SaleOrder, self).onchange_partner_id(partner_id) + if partner_id: + partner = self.env['res.partner'].browse(partner_id) + res['value']['payment_mode_id'] = partner.customer_payment_mode.id + else: + res['value']['payment_mode_id'] = False + return res + + @api.model + def _prepare_invoice(self, order, lines): + """Copy bank partner from sale order to invoice""" + vals = super(SaleOrder, self)._prepare_invoice(order, lines) + vals['payment_mode_id'] = order.payment_mode_id.id, + vals['partner_bank_id'] = (order.payment_mode_id and + order.payment_mode_id.bank_id.id) + return vals diff --git a/account_payment_sale/models/stock_picking.py b/account_payment_sale/models/stock_picking.py new file mode 100644 index 000000000..f9d48f688 --- /dev/null +++ b/account_payment_sale/models/stock_picking.py @@ -0,0 +1,40 @@ +# -*- 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 import models, api + + +class StockPicking(models.Model): + _inherit = "stock.picking" + + @api.model + def _create_invoice_from_picking(self, picking, vals): + if picking: + # Search if this picking comes from a sale order + sale_order_obj = self.env['sale.order'] + sale_order = sale_order_obj.search( + [('picking_ids', 'in', picking.id)], limit=1) + if sale_order: + vals['partner_bank_id'] = sale_order.payment_mode_id.bank_id.id + vals['payment_mode_id'] = sale_order.payment_mode_id.id + return super(StockPicking, self)._create_invoice_from_picking(picking, + vals) diff --git a/account_payment_sale/view/sale.xml b/account_payment_sale/view/sale.xml new file mode 100644 index 000000000..016598e09 --- /dev/null +++ b/account_payment_sale/view/sale.xml @@ -0,0 +1,24 @@ + + + + + + + + + account_payment_sale.sale_order.form + sale.order + + + + + + + + + + diff --git a/account_payment_sale/views/sale_order_view.xml b/account_payment_sale/views/sale_order_view.xml new file mode 100644 index 000000000..016598e09 --- /dev/null +++ b/account_payment_sale/views/sale_order_view.xml @@ -0,0 +1,24 @@ + + + + + + + + + account_payment_sale.sale_order.form + sale.order + + + + + + + + + +