From ea9fe99e0929371142a6f70131d289b4c94509bf Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Tue, 26 Mar 2013 16:27:32 +0100 Subject: [PATCH 01/52] [REF] split sale_quick_payment in 2 modules: sale_payment method is the base and sale_quick_payment adds a wizard to pay a sale order --- __init__.py | 24 ++++ __openerp__.py | 50 +++++++ account_move.py | 30 +++++ migrations/0.1/post-migration.py | 35 +++++ payment_method.py | 34 +++++ payment_method_view.xml | 48 +++++++ sale.py | 216 +++++++++++++++++++++++++++++++ sale_view.xml | 46 +++++++ security/ir.model.access.csv | 3 + settings/sale.exception.csv | 3 + 10 files changed, 489 insertions(+) create mode 100644 __init__.py create mode 100644 __openerp__.py create mode 100644 account_move.py create mode 100644 migrations/0.1/post-migration.py create mode 100644 payment_method.py create mode 100644 payment_method_view.xml create mode 100644 sale.py create mode 100644 sale_view.xml create mode 100644 security/ir.model.access.csv create mode 100644 settings/sale.exception.csv diff --git a/__init__.py b/__init__.py new file mode 100644 index 00000000000..00cecfa5136 --- /dev/null +++ b/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +################################################################################# +# # +# sale_payment_method for OpenERP # +# Copyright (C) 2011 Akretion Sébastien BEAU # +# # +# 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 . # +# # +################################################################################# + +import sale +import payment_method +import account_move diff --git a/__openerp__.py b/__openerp__.py new file mode 100644 index 00000000000..98795ce86a4 --- /dev/null +++ b/__openerp__.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +############################################################################### +# # +# sale_payment_method for OpenERP # +# Copyright (C) 2011 Akretion Sébastien BEAU # +# # +# 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': 'Sale Payment Method', + 'version': '0.2', + 'category': 'Generic Modules/Others', + 'license': 'AGPL-3', + 'description': """ +Sale Payment Method +=================== + +This module adds low-levels features used for instance by modules: + +- Sale Automatic Workflow +- Sale Quick Payment + +It adds a payment method on the sales orders and allow to register +payments entries on sales orders. +""", + 'author': 'Akretion', + 'website': 'http://www.akretion.com/', + 'depends': ['sale_exceptions', + ], + 'data': ['sale_view.xml', + 'payment_method_view.xml', + 'security/ir.model.access.csv', + 'settings/sale.exception.csv', + ], + 'demo': [], + 'installable': True, +} diff --git a/account_move.py b/account_move.py new file mode 100644 index 00000000000..3659cd5ca29 --- /dev/null +++ b/account_move.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Guewen Baconnier +# Copyright 2013 Camptocamp SA +# +# 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_move(orm.Model): + _inherit = 'account.move' + + _columns = { + 'order_ids': fields.many2many('sale.order', string='Sales Orders'), + } diff --git a/migrations/0.1/post-migration.py b/migrations/0.1/post-migration.py new file mode 100644 index 00000000000..6c82cf6e92c --- /dev/null +++ b/migrations/0.1/post-migration.py @@ -0,0 +1,35 @@ +# -*- encoding: utf-8 -*- +############################################################################### +# +# sale_quick_payment for OpenERP +# Copyright (C) 2012-TODAY Akretion . +# All Rights Reserved +# @author Sébastien BEAU +# 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 . +# +############################################################################### + +""" r0.1: Migration 6.1 => 7.0.0.1 + migrate the field payment_id from one2many to payment_ids many2many +""" +__name__ = ("sale.order:: V7 change/rename the field payment_id into a" + "many2many with the name payment_ids") + +def migrate(cr, version): + cr.execute("INSERT INTO account_voucher_sale_order_rel" + "(sale_order_id, account_voucher_id) " + "(SELECT id, payment_id FROM " + " sale_order " + "WHERE payment_id IS NOT NULL )") + diff --git a/payment_method.py b/payment_method.py new file mode 100644 index 00000000000..e448fd4a23f --- /dev/null +++ b/payment_method.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +############################################################################### +# # +# sale_quick_payment for OpenERP # +# Copyright (C) 2011 Akretion Sébastien BEAU # +# # +# 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 fields, orm + + +class payment_method(orm.Model): + _name = "payment.method" + _description = "Payment Method" + + _columns = { + 'name': fields.char('Name', size=64), + 'journal_id': fields.many2one('account.journal', 'Journal'), + 'payment_term_id': fields.many2one('account.payment.term', + 'Payment Term'), + } diff --git a/payment_method_view.xml b/payment_method_view.xml new file mode 100644 index 00000000000..0336bbcf926 --- /dev/null +++ b/payment_method_view.xml @@ -0,0 +1,48 @@ + + + + + + + + sale_quick_payment.payment_method.view_form + payment.method + +
+

+ +

+ + + + +
+ + + sale_quick_payment.payment_method.view_tree + payment.method + + + + + + + + + + + + E-Commerce Payment Methods + payment.method + form + tree,form + + + + +
+
diff --git a/sale.py b/sale.py new file mode 100644 index 00000000000..a9a72b34fa0 --- /dev/null +++ b/sale.py @@ -0,0 +1,216 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Guewen Baconnier +# Copyright (C) 2011 Akretion Sébastien BEAU +# Copyright 2013 Camptocamp SA (Guewen Baconnier) +# +# 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, osv +from openerp.tools.translate import _ +from collections import Iterable +import decimal_precision as dp + + +class sale_order(orm.Model): + _inherit = 'sale.order' + + def _get_order_from_move(self, cr, uid, ids, context=None): + result = set() + move_obj = self.pool.get('account.move') + for move in move_obj.browse(cr, uid, ids, context=context): + for order in move.order_ids: + result.add(order.id) + return list(result) + + def _get_order_from_line(self, cr, uid, ids, context=None): + so_obj = self.pool.get('sale.order') + return so_obj._get_order(cr, uid, ids, context=context) + + def _amount_residual(self, cr, uid, ids, field_name, args, context=None): + res = {} + for order in self.browse(cr, uid, ids, context=context): + amount = order.amount_total + for move in order.payment_ids: + amount -= move.amount + res[order.id] = amount + return res + + _columns = { + 'payment_ids': fields.many2many('account.move', + string='Payments Entries'), + 'payment_method_id': fields.many2one('payment.method', + 'Payment Method', + ondelete='restrict'), + 'residual': fields.function( + _amount_residual, + digits_compute=dp.get_precision('Account'), + string='Balance', + store=False), + } + + def copy(self, cr, uid, id, default=None, context=None): + if default is None: + default = {} + default['payment_ids'] = False + return super(sale_order, self).copy(cr, uid, id, + default, context=context) + + def add_payment_with_terms(self, cr, uid, ids, journal_id, amount=None, + date=None, context=None): + """ Create the payment entries to pay a sale order, respecting + the payment terms. + If no amount is defined, it will pay the residual amount of the sale + order. """ + if isinstance(ids, Iterable): + assert len(ids) == 1, "one sale order at a time can be paid" + ids = ids[0] + sale = self.browse(cr, uid, ids, context=context) + if date is None: + date = sale.date_order + if amount is None: + amount = sale.residual + if sale.payment_term: + term_obj = self.pool.get('account.payment.term') + amounts = term_obj.compute(cr, uid, sale.payment_term.id, + amount, date_ref=date, + context=context) + else: + amounts = [(date, amount)] + + journal_obj = self.pool.get('account.journal') + journal = journal_obj.browse(cr, uid, journal_id, context=context) + # reversed is cosmetic, compute returns terms in the 'wrong' order + for date, amount in reversed(amounts): + self._add_payment(cr, uid, sale, journal, + amount, date, context=context) + return True + + def add_payment(self, cr, uid, ids, journal_id, amount, + date=None, context=None): + """ Generate payment move lines of a certain amount linked + with the sale order. """ + if isinstance(ids, Iterable): + assert len(ids) == 1, "one sale order at a time can be paid" + ids = ids[0] + journal_obj = self.pool.get('account.journal') + + sale = self.browse(cr, uid, ids, context=context) + if date is None: + date = sale.date_order + journal = journal_obj.browse(cr, uid, journal_id, context=context) + self._add_payment(cr, uid, sale, journal, amount, date, context=context) + return True + + def _add_payment(self, cr, uid, sale, journal, amount, date, context=None): + """ Generate move lines entries to pay the sale order. """ + move_obj = self.pool.get('account.move') + period_obj = self.pool.get('account.period') + period_id = period_obj.find(cr, uid, dt=date, context=context)[0] + period = period_obj.browse(cr, uid, period_id, context=context) + move_name = self._get_payment_move_name(cr, uid, journal, + period, context=context) + move_vals = self._prepare_payment_move(cr, uid, move_name, sale, + journal, period, date, + context=context) + move_lines = self._prepare_payment_move_line(cr, uid, move_name, sale, + journal, period, amount, + date, context=context) + + move_vals['line_id'] = [(0, 0, line) for line in move_lines] + move_obj.create(cr, uid, move_vals, context=context) + + def _get_payment_move_name(self, cr, uid, journal, period, context=None): + if context is None: + context = {} + seq_obj = self.pool.get('ir.sequence') + sequence = journal.sequence_id + + if not sequence: + raise osv.except_osv( + _('Configuration Error'), + _('Please define a sequence on the journal %s.') % + journal.name) + if not sequence.active: + raise osv.except_osv( + _('Configuration Error'), + _('Please activate the sequence of the journal %s.') % + journal.name) + + ctx = context.copy() + ctx['fiscalyear_id'] = period.fiscalyear_id.id + name = seq_obj.next_by_id(cr, uid, sequence.id, context=ctx) + return name + + def _prepare_payment_move(self, cr, uid, move_name, sale, journal, + period, date, context=None): + return {'name': move_name, + 'journal_id': journal.id, + 'date': date, + 'ref': sale.name, + 'period_id': period.id, + 'order_ids': [(4, sale.id)], + } + + def _prepare_payment_move_line(self, cr, uid, move_name, sale, journal, + period, amount, date, context=None): + """ """ + partner_obj = self.pool.get('res.partner') + currency_obj = self.pool.get('res.currency') + partner = partner_obj._find_accounting_partner(sale.partner_id) + + company = journal.company_id + + currency_id = False + amount_currency = 0.0 + if journal.currency and journal.currency.id != company.currency_id.id: + currency_id = journal.currency.id + amount_currency, amount = (amount, + currency_obj.compute(cr, uid, + currency_id, + company.currency_id.id, + amount, + context=context)) + + # payment line (bank / cash) + debit_line = { + 'name': move_name, + 'debit': amount, + 'credit': 0.0, + 'account_id': journal.default_credit_account_id.id, + 'journal_id': journal.id, + 'period_id': period.id, + 'partner_id': partner.id, + 'date': date, + 'amount_currency': amount_currency, + 'currency_id': currency_id, + } + + # payment line (receivable) + credit_line = { + 'name': move_name, + 'debit': 0.0, + 'credit': amount, + 'account_id': partner.property_account_receivable.id, + 'journal_id': journal.id, + 'period_id': period.id, + 'partner_id': partner.id, + 'date': date, + 'amount_currency': -amount_currency, + 'currency_id': currency_id, + } + return debit_line, credit_line diff --git a/sale_view.xml b/sale_view.xml new file mode 100644 index 00000000000..1ca7afb2816 --- /dev/null +++ b/sale_view.xml @@ -0,0 +1,46 @@ + + + + + + + + + + sale.order.view.form + sale.order + + + + + + + + + + + + + + + + + + + + sale.order.view.tree + sale.order + + + + + + + + + + diff --git a/security/ir.model.access.csv b/security/ir.model.access.csv new file mode 100644 index 00000000000..13bf2263dcc --- /dev/null +++ b/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_payment_method_user,sale_quick_payment_payment_method_user,model_payment_method,base.group_user,1,0,0,0 +access_payment_method_manager,sale_quick_payment_payment_method_manager,model_payment_method,base.group_sale_manager,1,1,1,1 diff --git a/settings/sale.exception.csv b/settings/sale.exception.csv new file mode 100644 index 00000000000..b0eecfc5f93 --- /dev/null +++ b/settings/sale.exception.csv @@ -0,0 +1,3 @@ +id,name,description,sequence,model,code +must_be_paid,Sale order must be paid before validation,The sale order must be paid before the validation. Please fix it,50,sale.order,"if order.residual > 0: + failed = True" From 3726efac29178930a2d71f395ef8abd71490aecd Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Tue, 26 Mar 2013 16:52:17 +0100 Subject: [PATCH 02/52] [REF] move dependency on sale_exceptions from sale_payment_method to sale_quick_payment --- __openerp__.py | 4 +--- settings/sale.exception.csv | 3 --- 2 files changed, 1 insertion(+), 6 deletions(-) delete mode 100644 settings/sale.exception.csv diff --git a/__openerp__.py b/__openerp__.py index 98795ce86a4..7686d871d1d 100644 --- a/__openerp__.py +++ b/__openerp__.py @@ -38,12 +38,10 @@ """, 'author': 'Akretion', 'website': 'http://www.akretion.com/', - 'depends': ['sale_exceptions', - ], + 'depends': [], 'data': ['sale_view.xml', 'payment_method_view.xml', 'security/ir.model.access.csv', - 'settings/sale.exception.csv', ], 'demo': [], 'installable': True, diff --git a/settings/sale.exception.csv b/settings/sale.exception.csv deleted file mode 100644 index b0eecfc5f93..00000000000 --- a/settings/sale.exception.csv +++ /dev/null @@ -1,3 +0,0 @@ -id,name,description,sequence,model,code -must_be_paid,Sale order must be paid before validation,The sale order must be paid before the validation. Please fix it,50,sale.order,"if order.residual > 0: - failed = True" From 162d68112aab0fe966c760caecf2484829970ded Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Tue, 26 Mar 2013 17:23:00 +0100 Subject: [PATCH 03/52] [FIX] missing dependency on sale --- __openerp__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/__openerp__.py b/__openerp__.py index 7686d871d1d..f24908a9636 100644 --- a/__openerp__.py +++ b/__openerp__.py @@ -38,7 +38,8 @@ """, 'author': 'Akretion', 'website': 'http://www.akretion.com/', - 'depends': [], + 'depends': ['sale', + ], 'data': ['sale_view.xml', 'payment_method_view.xml', 'security/ir.model.access.csv', From 3fd045def161ff6aa43e7a7e85c46cbddfc9bb90 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Wed, 27 Mar 2013 13:47:36 +0100 Subject: [PATCH 04/52] [IMP] the workflow to use is set by an onchange when the payment method is changed --- payment_method_view.xml | 6 ++++-- sale.py | 10 ++++++++++ sale_view.xml | 3 ++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/payment_method_view.xml b/payment_method_view.xml index 0336bbcf926..17f360099f9 100644 --- a/payment_method_view.xml +++ b/payment_method_view.xml @@ -16,8 +16,10 @@

- - + + + + diff --git a/sale.py b/sale.py index a9a72b34fa0..b0f9b4079fd 100644 --- a/sale.py +++ b/sale.py @@ -214,3 +214,13 @@ def _prepare_payment_move_line(self, cr, uid, move_name, sale, journal, 'currency_id': currency_id, } return debit_line, credit_line + + def onchange_payment_method_id(self, cr, uid, ids, payment_method_id, context=None): + if not payment_method_id: + return {} + result = {} + method_obj = self.pool.get('payment.method') + method = method_obj.browse(cr, uid, payment_method_id, context=context) + if method.payment_term_id: + result['payment_term'] = method.payment_term_id.id + return {'value': result} diff --git a/sale_view.xml b/sale_view.xml index 1ca7afb2816..acb9d38fee1 100644 --- a/sale_view.xml +++ b/sale_view.xml @@ -18,7 +18,8 @@ - + From 739e4876bb25f83e6138ea1490dde378983807f4 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Wed, 27 Mar 2013 16:13:35 +0100 Subject: [PATCH 05/52] [CHG] move the part of the view which displays the payments from sale_payment_method to sale_quick_payment --- sale_view.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/sale_view.xml b/sale_view.xml index acb9d38fee1..6f2e961dcb0 100644 --- a/sale_view.xml +++ b/sale_view.xml @@ -20,9 +20,6 @@ - - - From 6c4172d1dc269ccdd16172f5abbf2f8733038c78 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Thu, 28 Mar 2013 09:33:41 +0100 Subject: [PATCH 06/52] [IMP] rename add_payment_with_terms to automatic_payment, use the payment method to generate the payment lines --- sale.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/sale.py b/sale.py index b0f9b4079fd..960fcdfddb9 100644 --- a/sale.py +++ b/sale.py @@ -70,8 +70,7 @@ def copy(self, cr, uid, id, default=None, context=None): return super(sale_order, self).copy(cr, uid, id, default, context=context) - def add_payment_with_terms(self, cr, uid, ids, journal_id, amount=None, - date=None, context=None): + def automatic_payment(self, cr, uid, ids, amount=None, context=None): """ Create the payment entries to pay a sale order, respecting the payment terms. If no amount is defined, it will pay the residual amount of the sale @@ -80,8 +79,22 @@ def add_payment_with_terms(self, cr, uid, ids, journal_id, amount=None, assert len(ids) == 1, "one sale order at a time can be paid" ids = ids[0] sale = self.browse(cr, uid, ids, context=context) - if date is None: - date = sale.date_order + method = sale.payment_method_id + if not method: + raise osv.except_osv( + _('Configuration Error'), + _("An automatic payment can not be created for the sale " + "order %s because it has no payment method.") % sale.name) + + if not method.journal_id: + raise osv.except_osv( + _('Configuration Error'), + _("An automatic payment should be created for the sale order %s " + "but the payment method '%s' has no journal defined.") % + (sale.name, method.name)) + + journal = method.journal_id + date = sale.date_order if amount is None: amount = sale.residual if sale.payment_term: @@ -92,8 +105,6 @@ def add_payment_with_terms(self, cr, uid, ids, journal_id, amount=None, else: amounts = [(date, amount)] - journal_obj = self.pool.get('account.journal') - journal = journal_obj.browse(cr, uid, journal_id, context=context) # reversed is cosmetic, compute returns terms in the 'wrong' order for date, amount in reversed(amounts): self._add_payment(cr, uid, sale, journal, From 48e04d2b66bdfdd82911e582d169234cd87edb2c Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Thu, 28 Mar 2013 11:06:54 +0100 Subject: [PATCH 07/52] [FIX] typo --- __openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__openerp__.py b/__openerp__.py index f24908a9636..37d07f208c6 100644 --- a/__openerp__.py +++ b/__openerp__.py @@ -28,7 +28,7 @@ Sale Payment Method =================== -This module adds low-levels features used for instance by modules: +This module adds low-level features used for instance by modules: - Sale Automatic Workflow - Sale Quick Payment From b6ff5acaedefcb8be2f1fb98076c3a38b91111ef Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Wed, 3 Apr 2013 09:33:59 +0200 Subject: [PATCH 08/52] [IMP] improve the view of payment methods to be more helpful --- payment_method.py | 17 +++++++++++++---- payment_method_view.xml | 18 ++++++++++++++++-- sale.py | 2 +- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/payment_method.py b/payment_method.py index e448fd4a23f..fc76a039b57 100644 --- a/payment_method.py +++ b/payment_method.py @@ -3,6 +3,7 @@ # # # sale_quick_payment for OpenERP # # Copyright (C) 2011 Akretion Sébastien BEAU # +# Copyright 2013 Camptocamp SA (Guewen Baconnier) # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU Affero General Public License as # @@ -27,8 +28,16 @@ class payment_method(orm.Model): _description = "Payment Method" _columns = { - 'name': fields.char('Name', size=64), - 'journal_id': fields.many2one('account.journal', 'Journal'), - 'payment_term_id': fields.many2one('account.payment.term', - 'Payment Term'), + 'name': fields.char('Name', + help="The name of the method on the backend"), + 'journal_id': fields.many2one( + 'account.journal', + 'Journal', + help="If a journal a selected, when a payment is recorded " + "on a backend, payment entries will be created in this " + "journal. "), + 'payment_term_id': fields.many2one( + 'account.payment.term', + 'Payment Term', + help="Default payment term of a sale order using this method."), } diff --git a/payment_method_view.xml b/payment_method_view.xml index 17f360099f9..cd0c6018fe1 100644 --- a/payment_method_view.xml +++ b/payment_method_view.xml @@ -16,8 +16,22 @@

- - + + + + + +

+ When the E-commerce backend will receive a payment for a sale order, + payment entries will be generated in the selected journal. +

+

+ Even if the E-commerce backend receives a payment for a sale order, + no payment entries will be generated. +

+
+
+ diff --git a/sale.py b/sale.py index 960fcdfddb9..b3de3ec70bd 100644 --- a/sale.py +++ b/sale.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- ############################################################################## # -# Author: Guewen Baconnier +# Author: Guewen Baconnier, Sébastien Beau # Copyright (C) 2011 Akretion Sébastien BEAU # Copyright 2013 Camptocamp SA (Guewen Baconnier) # From 4ad6fce39f2e683fc650c5bd0909481786c7e7fe Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Wed, 17 Apr 2013 10:49:35 +0200 Subject: [PATCH 09/52] [FIX] rename 'E-Commerce Payment Methods' to 'Payment Methods' because it is too long to be displayed in the menus --- payment_method_view.xml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/payment_method_view.xml b/payment_method_view.xml index cd0c6018fe1..f233e68d0bb 100644 --- a/payment_method_view.xml +++ b/payment_method_view.xml @@ -12,7 +12,7 @@ sale_quick_payment.payment_method.view_form payment.method -
+

@@ -42,7 +42,7 @@ sale_quick_payment.payment_method.view_tree payment.method - + @@ -50,9 +50,8 @@ - - E-Commerce Payment Methods + Payment Methods payment.method form tree,form From 4daff6b7083784fbec6e7a700a5070262a326010 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Thu, 2 May 2013 09:15:04 +0200 Subject: [PATCH 10/52] [ADD] sale_payment_method: french translation --- i18n/fr_FR.po | 142 +++++++++++++++++++++++++++++++++++ i18n/sale_payment_method.pot | 141 ++++++++++++++++++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 i18n/fr_FR.po create mode 100644 i18n/sale_payment_method.pot diff --git a/i18n/fr_FR.po b/i18n/fr_FR.po new file mode 100644 index 00000000000..5c156c737af --- /dev/null +++ b/i18n/fr_FR.po @@ -0,0 +1,142 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * sale_payment_method +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-05-02 07:06+0000\n" +"PO-Revision-Date: 2013-05-02 07: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: sale_payment_method +#: view:sale.order:0 +msgid "Automation Information" +msgstr "Informations d'automatisation" + +#. module: sale_payment_method +#: help:payment.method,journal_id:0 +msgid "If a journal a selected, when a payment is recorded on a backend, payment entries will be created in this journal. " +msgstr "Si un journal est sélectionné, lorsqu'un paiement est enregistré sur le backend, des lignes de paiement seront générées dans ce journal." + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "Even if the E-commerce backend receives a payment for a sale order,\n" +" no payment entries will be generated." +msgstr "Même si le backend e-commerce reçoit un payment pour un bon de commande, aucune ligne de paiement ne sera générée." + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "Default Values" +msgstr "Valeurs par défaut" + +#. module: sale_payment_method +#: model:ir.model,name:sale_payment_method.model_payment_method +#: field:sale.order,payment_method_id:0 +msgid "Payment Method" +msgstr "Méthode de paiement" + +#. module: sale_payment_method +#: view:sale.order:0 +msgid "View Automatic Payment" +msgstr "Voir les paiements automatiques" + +#. module: sale_payment_method +#: help:sale.order,payment_exists:0 +msgid "It indicates that sales order has at least one payment." +msgstr "Indique que la commande a reçu au moins un paiement." + +#. module: sale_payment_method +#: field:payment.method,journal_id:0 +msgid "Journal" +msgstr "Journal" + +#. module: sale_payment_method +#: model:ir.actions.act_window,name:sale_payment_method.act_payment_method_form +#: model:ir.ui.menu,name:sale_payment_method.menu_action_paymetn_method_form +msgid "Payment Methods " +msgstr "Méthodes de paiement" + +#. module: sale_payment_method +#: field:account.move,order_ids:0 +msgid "Sales Orders" +msgstr "Bons de commande" + +#. module: sale_payment_method +#: view:sale.order:0 +msgid "Other Information" +msgstr "Autres informations" + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "Payment Methods" +msgstr "Méthodes de paiement" + +#. module: sale_payment_method +#: field:payment.method,name:0 +msgid "Name" +msgstr "Nom" + +#. module: sale_payment_method +#: field:sale.order,payment_ids:0 +msgid "Payments Entries" +msgstr "Écritures de paiement" + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "When the E-commerce backend will receive a payment for a sale order,\n" +" payment entries will be generated in the selected journal." +msgstr "Lorsque le backend e-commerce reçoit un paiement pour la commande,\n" +" des écritures de paiement sont générées dans le journal sélectionné." + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "Journal for payment" +msgstr "Journal pour le paiement" + +#. module: sale_payment_method +#: field:sale.order,residual:0 +msgid "Balance" +msgstr "Solde" + +#. module: sale_payment_method +#: model:ir.model,name:sale_payment_method.model_account_move +msgid "Account Entry" +msgstr "Ecriture" + +#. module: sale_payment_method +#: help:payment.method,payment_term_id:0 +msgid "Default payment term of a sale order using this method." +msgstr "Condition de règlement par défaut pour les commandes utilisant cette méthode." + +#. module: sale_payment_method +#: field:payment.method,payment_term_id:0 +msgid "Payment Term" +msgstr "Condition de règlement" + +#. module: sale_payment_method +#: view:sale.order:0 +msgid "Create Invoice" +msgstr "Créer la facture" + +#. module: sale_payment_method +#: help:payment.method,name:0 +msgid "The name of the method on the backend" +msgstr "Nom de la méthode sur le backend" + +#. module: sale_payment_method +#: model:ir.model,name:sale_payment_method.model_sale_order +msgid "Sales Order" +msgstr "Bon de commande" + +#. module: sale_payment_method +#: field:sale.order,payment_exists:0 +msgid "Has automatic payment" +msgstr "A un paiement automatique" + diff --git a/i18n/sale_payment_method.pot b/i18n/sale_payment_method.pot new file mode 100644 index 00000000000..ef54c2b57de --- /dev/null +++ b/i18n/sale_payment_method.pot @@ -0,0 +1,141 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * sale_payment_method +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-05-02 07:06+0000\n" +"PO-Revision-Date: 2013-05-02 07: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: sale_payment_method +#: view:sale.order:0 +msgid "Automation Information" +msgstr "" + +#. module: sale_payment_method +#: help:payment.method,journal_id:0 +msgid "If a journal a selected, when a payment is recorded on a backend, payment entries will be created in this journal. " +msgstr "" + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "Even if the E-commerce backend receives a payment for a sale order,\n" +" no payment entries will be generated." +msgstr "" + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "Default Values" +msgstr "" + +#. module: sale_payment_method +#: model:ir.model,name:sale_payment_method.model_payment_method +#: field:sale.order,payment_method_id:0 +msgid "Payment Method" +msgstr "" + +#. module: sale_payment_method +#: view:sale.order:0 +msgid "View Automatic Payment" +msgstr "" + +#. module: sale_payment_method +#: help:sale.order,payment_exists:0 +msgid "It indicates that sales order has at least one payment." +msgstr "" + +#. module: sale_payment_method +#: field:payment.method,journal_id:0 +msgid "Journal" +msgstr "" + +#. module: sale_payment_method +#: model:ir.actions.act_window,name:sale_payment_method.act_payment_method_form +#: model:ir.ui.menu,name:sale_payment_method.menu_action_paymetn_method_form +msgid "Payment Methods " +msgstr "" + +#. module: sale_payment_method +#: field:account.move,order_ids:0 +msgid "Sales Orders" +msgstr "" + +#. module: sale_payment_method +#: view:sale.order:0 +msgid "Other Information" +msgstr "" + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "Payment Methods" +msgstr "" + +#. module: sale_payment_method +#: field:payment.method,name:0 +msgid "Name" +msgstr "" + +#. module: sale_payment_method +#: field:sale.order,payment_ids:0 +msgid "Payments Entries" +msgstr "" + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "When the E-commerce backend will receive a payment for a sale order,\n" +" payment entries will be generated in the selected journal." +msgstr "" + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "Journal for payment" +msgstr "" + +#. module: sale_payment_method +#: field:sale.order,residual:0 +msgid "Balance" +msgstr "" + +#. module: sale_payment_method +#: model:ir.model,name:sale_payment_method.model_account_move +msgid "Account Entry" +msgstr "" + +#. module: sale_payment_method +#: help:payment.method,payment_term_id:0 +msgid "Default payment term of a sale order using this method." +msgstr "" + +#. module: sale_payment_method +#: field:payment.method,payment_term_id:0 +msgid "Payment Term" +msgstr "" + +#. module: sale_payment_method +#: view:sale.order:0 +msgid "Create Invoice" +msgstr "" + +#. module: sale_payment_method +#: help:payment.method,name:0 +msgid "The name of the method on the backend" +msgstr "" + +#. module: sale_payment_method +#: model:ir.model,name:sale_payment_method.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: sale_payment_method +#: field:sale.order,payment_exists:0 +msgid "Has automatic payment" +msgstr "" + From 50a2d5c86647c8d877f3e6ec1002290b12ee18e3 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Thu, 2 May 2013 09:27:51 +0200 Subject: [PATCH 11/52] [ADD] sale_payment_method: button on the sale order to open the automatic payments, prevent cancellation of a sale order with automatic payments --- sale.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ sale_view.xml | 9 +++++++++ 2 files changed, 57 insertions(+) diff --git a/sale.py b/sale.py index b3de3ec70bd..63f73146253 100644 --- a/sale.py +++ b/sale.py @@ -50,6 +50,12 @@ def _amount_residual(self, cr, uid, ids, field_name, args, context=None): res[order.id] = amount return res + def _payment_exists(self, cursor, user, ids, name, arg, context=None): + res = {} + for sale in self.browse(cursor, user, ids, context=context): + res[sale.id] = bool(sale.payment_ids) + return res + _columns = { 'payment_ids': fields.many2many('account.move', string='Payments Entries'), @@ -61,6 +67,11 @@ def _amount_residual(self, cr, uid, ids, field_name, args, context=None): digits_compute=dp.get_precision('Account'), string='Balance', store=False), + 'payment_exists': fields.function( + _payment_exists, + string='Has automatic payment', + type='boolean', + help="It indicates that sales order has at least one payment."), } def copy(self, cr, uid, id, default=None, context=None): @@ -235,3 +246,40 @@ def onchange_payment_method_id(self, cr, uid, ids, payment_method_id, context=No if method.payment_term_id: result['payment_term'] = method.payment_term_id.id return {'value': result} + + def action_view_payments(self, cr, uid, ids, context=None): + """ Return an action to display the payment linked + with the sale order """ + + mod_obj = self.pool.get('ir.model.data') + act_obj = self.pool.get('ir.actions.act_window') + + payment_ids = [] + for so in self.browse(cr, uid, ids, context=context): + payment_ids += [move.id for move in so.payment_ids] + + ref = mod_obj.get_object_reference(cr, uid, 'account', + 'action_move_journal_line') + action_id = False + if ref: + __, action_id = ref + action = act_obj.read(cr, uid, [action_id], context=context)[0] + + # choose the view_mode accordingly + if len(payment_ids) > 1: + action['domain'] = str([('id', 'in', payment_ids)]) + else: + ref = mod_obj.get_object_reference(cr, uid, 'account', + 'view_move_form') + action['views'] = [(ref[1] if ref else False, 'form')] + action['res_id'] = payment_ids[0] if payment_ids else False + return action + + def action_cancel(self, cr, uid, ids, context=None): + for sale in self.browse(cr, uid, ids, context=context): + if sale.payment_ids: + raise osv.except_osv( + _('Cannot cancel this sales order!'), + _('Automatic payment entries are linked ' + 'with the sale order.')) + return super(sale_order, self).action_cancel(cr, uid, ids, context=context) diff --git a/sale_view.xml b/sale_view.xml index 6f2e961dcb0..6bef050b2a1 100644 --- a/sale_view.xml +++ b/sale_view.xml @@ -26,6 +26,15 @@ + + From 0a1a7d45f7aad571eeea776d23a9d8a1abc5e09a Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Wed, 25 Sep 2013 11:09:39 +0200 Subject: [PATCH 12/52] [FIX] fr_FR.po files not loaded, should be named fr.po --- i18n/{fr_FR.po => fr.po} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename i18n/{fr_FR.po => fr.po} (100%) diff --git a/i18n/fr_FR.po b/i18n/fr.po similarity index 100% rename from i18n/fr_FR.po rename to i18n/fr.po From 4c27d7e9ccd6ed320b72c10029f3b64d55f2da8b Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Thu, 26 Sep 2013 10:41:34 +0200 Subject: [PATCH 13/52] [CHG] removed the trailing # in the headers --- __init__.py | 38 ++++++++++++++++---------------- __openerp__.py | 38 ++++++++++++++++---------------- migrations/0.1/post-migration.py | 4 ++-- payment_method.py | 38 ++++++++++++++++---------------- 4 files changed, 59 insertions(+), 59 deletions(-) diff --git a/__init__.py b/__init__.py index 00cecfa5136..09822dfa9c8 100644 --- a/__init__.py +++ b/__init__.py @@ -1,23 +1,23 @@ # -*- coding: utf-8 -*- -################################################################################# -# # -# sale_payment_method for OpenERP # -# Copyright (C) 2011 Akretion Sébastien BEAU # -# # -# 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 . # -# # -################################################################################# +############################################################################## +# +# sale_payment_method for OpenERP +# Copyright (C) 2011 Akretion Sébastien BEAU +# +# 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 . +# +############################################################################## import sale import payment_method diff --git a/__openerp__.py b/__openerp__.py index 37d07f208c6..9cbefb4cc4c 100644 --- a/__openerp__.py +++ b/__openerp__.py @@ -1,23 +1,23 @@ # -*- coding: utf-8 -*- -############################################################################### -# # -# sale_payment_method for OpenERP # -# Copyright (C) 2011 Akretion Sébastien BEAU # -# # -# 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 . # -# # -############################################################################### +############################################################################## +# +# sale_payment_method for OpenERP +# Copyright (C) 2011 Akretion Sébastien BEAU +# +# 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': 'Sale Payment Method', diff --git a/migrations/0.1/post-migration.py b/migrations/0.1/post-migration.py index 6c82cf6e92c..458da9849f2 100644 --- a/migrations/0.1/post-migration.py +++ b/migrations/0.1/post-migration.py @@ -1,5 +1,5 @@ # -*- encoding: utf-8 -*- -############################################################################### +############################################################################## # # sale_quick_payment for OpenERP # Copyright (C) 2012-TODAY Akretion . @@ -18,7 +18,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################### +############################################################################## """ r0.1: Migration 6.1 => 7.0.0.1 migrate the field payment_id from one2many to payment_ids many2many diff --git a/payment_method.py b/payment_method.py index fc76a039b57..e28e38ab99b 100644 --- a/payment_method.py +++ b/payment_method.py @@ -1,24 +1,24 @@ # -*- coding: utf-8 -*- -############################################################################### -# # -# sale_quick_payment for OpenERP # -# Copyright (C) 2011 Akretion Sébastien BEAU # +############################################################################## +# +# sale_quick_payment for OpenERP +# Copyright (C) 2011 Akretion Sébastien BEAU # Copyright 2013 Camptocamp SA (Guewen Baconnier) -# # -# 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 . # -# # -############################################################################### +# +# 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 fields, orm From 7887f44e336e0dd23be620d3348425dc02516f6e Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Thu, 26 Sep 2013 10:42:06 +0200 Subject: [PATCH 14/52] [FIX] use explicit relative import --- __init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/__init__.py b/__init__.py index 09822dfa9c8..6f10dd35c1b 100644 --- a/__init__.py +++ b/__init__.py @@ -19,6 +19,6 @@ # ############################################################################## -import sale -import payment_method -import account_move +from . import sale +from . import payment_method +from . import account_move From 978ec56f1e3f458566646946d8882f22bfb718f4 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Thu, 26 Sep 2013 10:43:15 +0200 Subject: [PATCH 15/52] [FIX] misleading module name --- payment_method_view.xml | 2 +- sale_view.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/payment_method_view.xml b/payment_method_view.xml index f233e68d0bb..c6d90639e05 100644 --- a/payment_method_view.xml +++ b/payment_method_view.xml @@ -1,6 +1,6 @@ diff --git a/sale_view.xml b/sale_view.xml index 6bef050b2a1..2b62a9083ec 100644 --- a/sale_view.xml +++ b/sale_view.xml @@ -1,6 +1,6 @@ From 145445145a1c4840fdcd1f1ceda7b4c382b48f11 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Thu, 26 Sep 2013 10:44:33 +0200 Subject: [PATCH 16/52] [FIX] misleading module name in views names --- payment_method_view.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/payment_method_view.xml b/payment_method_view.xml index c6d90639e05..2aa85fc6e99 100644 --- a/payment_method_view.xml +++ b/payment_method_view.xml @@ -9,7 +9,7 @@ - sale_quick_payment.payment_method.view_form + sale_payment_method.payment_method.view_form payment.method @@ -39,7 +39,7 @@ - sale_quick_payment.payment_method.view_tree + sale_payment_method.payment_method.view_tree payment.method From 78003f8d046b274c92daf0e38c3ddcbf5e5dbc30 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Thu, 26 Sep 2013 10:48:27 +0200 Subject: [PATCH 17/52] [FIX] imports --- sale.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sale.py b/sale.py index 63f73146253..b5ca8acad93 100644 --- a/sale.py +++ b/sale.py @@ -23,7 +23,7 @@ from openerp.osv import orm, fields, osv from openerp.tools.translate import _ from collections import Iterable -import decimal_precision as dp +import openerp.addons.decimal_precision as dp class sale_order(orm.Model): From 72c5aa87c02cb53202d1b4678adf3e4f2f15575d Mon Sep 17 00:00:00 2001 From: Sebastien Beau Date: Thu, 19 Sep 2013 18:11:10 -0700 Subject: [PATCH 18/52] [IMP] sale_payment_method add the possibility to add the description when adding a payment --- sale.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sale.py b/sale.py index b5ca8acad93..aa13f1e5915 100644 --- a/sale.py +++ b/sale.py @@ -123,7 +123,7 @@ def automatic_payment(self, cr, uid, ids, amount=None, context=None): return True def add_payment(self, cr, uid, ids, journal_id, amount, - date=None, context=None): + date=None, description=None, context=None): """ Generate payment move lines of a certain amount linked with the sale order. """ if isinstance(ids, Iterable): @@ -135,16 +135,16 @@ def add_payment(self, cr, uid, ids, journal_id, amount, if date is None: date = sale.date_order journal = journal_obj.browse(cr, uid, journal_id, context=context) - self._add_payment(cr, uid, sale, journal, amount, date, context=context) + self._add_payment(cr, uid, sale, journal, amount, date, description, context=context) return True - def _add_payment(self, cr, uid, sale, journal, amount, date, context=None): + def _add_payment(self, cr, uid, sale, journal, amount, date, description, context=None): """ Generate move lines entries to pay the sale order. """ move_obj = self.pool.get('account.move') period_obj = self.pool.get('account.period') period_id = period_obj.find(cr, uid, dt=date, context=context)[0] period = period_obj.browse(cr, uid, period_id, context=context) - move_name = self._get_payment_move_name(cr, uid, journal, + move_name = description or self._get_payment_move_name(cr, uid, journal, period, context=context) move_vals = self._prepare_payment_move(cr, uid, move_name, sale, journal, period, date, From d442872c402e03f2298449e5b1dd51ef46cc0647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Beau?= Date: Sat, 10 Aug 2013 18:15:06 +0200 Subject: [PATCH 19/52] [REF] start to refactor sale_payment_method, the aim is to link the sale order to the move line and not the move. Indeed when we import a bank statement and we used the module account_bank_statement_one_move we have 1 one with X customer payment. So we have no choice the sale must be linked to the move lines --- account_move.py | 6 +++--- sale.py | 27 +++++++++++++++++++-------- sale_view.xml | 25 +++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 11 deletions(-) diff --git a/account_move.py b/account_move.py index 3659cd5ca29..0b35ca34de6 100644 --- a/account_move.py +++ b/account_move.py @@ -22,9 +22,9 @@ from openerp.osv import orm, fields -class account_move(orm.Model): - _inherit = 'account.move' +class account_move_line(orm.Model): + _inherit = 'account.move.line' _columns = { - 'order_ids': fields.many2many('sale.order', string='Sales Orders'), + 'sale_ids': fields.many2many('sale.order', string='Sales Orders'), } diff --git a/sale.py b/sale.py index aa13f1e5915..02f27c9e2ed 100644 --- a/sale.py +++ b/sale.py @@ -41,13 +41,17 @@ def _get_order_from_line(self, cr, uid, ids, context=None): so_obj = self.pool.get('sale.order') return so_obj._get_order(cr, uid, ids, context=context) - def _amount_residual(self, cr, uid, ids, field_name, args, context=None): + def _get_amount(self, cr, uid, ids, fields, args, context=None): res = {} for order in self.browse(cr, uid, ids, context=context): - amount = order.amount_total - for move in order.payment_ids: - amount -= move.amount - res[order.id] = amount + #TODO add support when payment is linked to many order + paid_amount = 0 + for line in order.payment_ids: + paid_amount = line.debit - line.credit + res[order.id] = { + 'amount_paid': paid_amount, + 'residual': order.amount_total - paid_amount, + } return res def _payment_exists(self, cursor, user, ids, name, arg, context=None): @@ -57,16 +61,23 @@ def _payment_exists(self, cursor, user, ids, name, arg, context=None): return res _columns = { - 'payment_ids': fields.many2many('account.move', + 'payment_ids': fields.many2many('account.move.line', string='Payments Entries'), 'payment_method_id': fields.many2one('payment.method', 'Payment Method', ondelete='restrict'), 'residual': fields.function( - _amount_residual, + _get_amount, digits_compute=dp.get_precision('Account'), string='Balance', - store=False), + store=False, + multi='payment'), + 'amount_paid': fields.function( + _get_amount, + digits_compute=dp.get_precision('Account'), + string='Amount Paid', + store=False, + multi='payment'), 'payment_exists': fields.function( _payment_exists, string='Has automatic payment', diff --git a/sale_view.xml b/sale_view.xml index 2b62a9083ec..738e7628103 100644 --- a/sale_view.xml +++ b/sale_view.xml @@ -49,5 +49,30 @@ + + sale.order.view.tree + sale.order + + + + + + + + + + + + sale.order + + + + + + + + + + From b48d9d2d7c6eb972cce2cf3f55ce475b1d3d7cf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Beau?= Date: Sun, 1 Sep 2013 18:28:01 +0200 Subject: [PATCH 20/52] [FIX] fix bug to due previous refactor, compute correctly the amount paid, link the payment with the sale order, and improve the payment view --- sale.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sale.py b/sale.py index 02f27c9e2ed..d3dfe8aac4b 100644 --- a/sale.py +++ b/sale.py @@ -47,7 +47,7 @@ def _get_amount(self, cr, uid, ids, fields, args, context=None): #TODO add support when payment is linked to many order paid_amount = 0 for line in order.payment_ids: - paid_amount = line.debit - line.credit + paid_amount += line.credit - line.debit res[order.id] = { 'amount_paid': paid_amount, 'residual': order.amount_total - paid_amount, @@ -196,7 +196,6 @@ def _prepare_payment_move(self, cr, uid, move_name, sale, journal, 'date': date, 'ref': sale.name, 'period_id': period.id, - 'order_ids': [(4, sale.id)], } def _prepare_payment_move_line(self, cr, uid, move_name, sale, journal, @@ -245,6 +244,7 @@ def _prepare_payment_move_line(self, cr, uid, move_name, sale, journal, 'date': date, 'amount_currency': -amount_currency, 'currency_id': currency_id, + 'sale_ids': [(4, sale.id)], } return debit_line, credit_line From 5307f7a2b63a00b627531c15fd57c61206f5d2b3 Mon Sep 17 00:00:00 2001 From: Arthur Vuillard Date: Thu, 5 Dec 2013 15:46:55 +0100 Subject: [PATCH 21/52] Add multicompany support for payment methods --- __openerp__.py | 1 + payment_method.py | 13 +++++++++++++ payment_method_view.xml | 1 + security/rules.xml | 13 +++++++++++++ 4 files changed, 28 insertions(+) create mode 100644 security/rules.xml diff --git a/__openerp__.py b/__openerp__.py index 9cbefb4cc4c..47a0ee28870 100644 --- a/__openerp__.py +++ b/__openerp__.py @@ -43,6 +43,7 @@ 'data': ['sale_view.xml', 'payment_method_view.xml', 'security/ir.model.access.csv', + 'security/rules.xml', ], 'demo': [], 'installable': True, diff --git a/payment_method.py b/payment_method.py index e28e38ab99b..5fb131e8299 100644 --- a/payment_method.py +++ b/payment_method.py @@ -40,4 +40,17 @@ class payment_method(orm.Model): 'account.payment.term', 'Payment Term', help="Default payment term of a sale order using this method."), + 'company_id': fields.many2one( + 'res.company', + 'Company', + ), + } + + def _default_company_id(self, cr, uid, context): + company_model = self.pool.get('res.company') + return company_model._company_default_get(cr, uid, 'payment.method', + context=context) + + _defaults = { + 'company_id': _default_company_id, } diff --git a/payment_method_view.xml b/payment_method_view.xml index 2aa85fc6e99..b69236cd868 100644 --- a/payment_method_view.xml +++ b/payment_method_view.xml @@ -18,6 +18,7 @@ + diff --git a/security/rules.xml b/security/rules.xml new file mode 100644 index 00000000000..b66174aa14b --- /dev/null +++ b/security/rules.xml @@ -0,0 +1,13 @@ + + + + + + Payment method multi-company + + + ['|','|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id]),('company_id','=',False)] + + + + From 451899da881dc9b0ff711f56cb9399121752d922 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Tue, 14 Jan 2014 13:49:52 +0100 Subject: [PATCH 22/52] [FIX] description is not required in the method and it has been added recently so it is less likely to make code crash if it is optional --- sale.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sale.py b/sale.py index d3dfe8aac4b..9f5f9023735 100644 --- a/sale.py +++ b/sale.py @@ -149,7 +149,7 @@ def add_payment(self, cr, uid, ids, journal_id, amount, self._add_payment(cr, uid, sale, journal, amount, date, description, context=context) return True - def _add_payment(self, cr, uid, sale, journal, amount, date, description, context=None): + def _add_payment(self, cr, uid, sale, journal, amount, date, description=None, context=None): """ Generate move lines entries to pay the sale order. """ move_obj = self.pool.get('account.move') period_obj = self.pool.get('account.period') From 610a5f0f9aece9ac1f1922dfd547120d813e712d Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Wed, 15 Jan 2014 09:44:10 +0100 Subject: [PATCH 23/52] [FIX] the 'View Automatic Payments' button still except moves but 'payment_ids' are move lines. We want to display the moves so we get them from the lines. --- sale.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sale.py b/sale.py index 9f5f9023735..9ac2e4d331f 100644 --- a/sale.py +++ b/sale.py @@ -265,9 +265,12 @@ def action_view_payments(self, cr, uid, ids, context=None): mod_obj = self.pool.get('ir.model.data') act_obj = self.pool.get('ir.actions.act_window') - payment_ids = [] + move_ids = set() for so in self.browse(cr, uid, ids, context=context): - payment_ids += [move.id for move in so.payment_ids] + # payment_ids are move lines, we want to display the moves + move_ids |= set([move_line.move_id.id for move_line + in so.payment_ids]) + move_ids = list(move_ids) ref = mod_obj.get_object_reference(cr, uid, 'account', 'action_move_journal_line') @@ -277,13 +280,13 @@ def action_view_payments(self, cr, uid, ids, context=None): action = act_obj.read(cr, uid, [action_id], context=context)[0] # choose the view_mode accordingly - if len(payment_ids) > 1: - action['domain'] = str([('id', 'in', payment_ids)]) + if len(move_ids) > 1: + action['domain'] = str([('id', 'in', move_ids)]) else: ref = mod_obj.get_object_reference(cr, uid, 'account', 'view_move_form') action['views'] = [(ref[1] if ref else False, 'form')] - action['res_id'] = payment_ids[0] if payment_ids else False + action['res_id'] = move_ids[0] if move_ids else False return action def action_cancel(self, cr, uid, ids, context=None): From fd89dffb72425378bd70a9c771763eb918c40c3e Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (Acsone)" Date: Fri, 14 Feb 2014 09:08:29 +0100 Subject: [PATCH 24/52] [FIX] No migration is required if not previous version --- migrations/0.1/post-migration.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/migrations/0.1/post-migration.py b/migrations/0.1/post-migration.py index 458da9849f2..aa945de084e 100644 --- a/migrations/0.1/post-migration.py +++ b/migrations/0.1/post-migration.py @@ -27,9 +27,10 @@ "many2many with the name payment_ids") def migrate(cr, version): - cr.execute("INSERT INTO account_voucher_sale_order_rel" - "(sale_order_id, account_voucher_id) " - "(SELECT id, payment_id FROM " - " sale_order " - "WHERE payment_id IS NOT NULL )") + if version: + cr.execute("INSERT INTO account_voucher_sale_order_rel" + "(sale_order_id, account_voucher_id) " + "(SELECT id, payment_id FROM " + " sale_order " + "WHERE payment_id IS NOT NULL )") From 9e3fa606189a11806e8e6e32bd9036e58472f12a Mon Sep 17 00:00:00 2001 From: Jan-Philipp Fischer Date: Thu, 13 Mar 2014 11:23:20 +0100 Subject: [PATCH 25/52] [FIX] name field on payment_method should be required --- payment_method.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/payment_method.py b/payment_method.py index 5fb131e8299..29e6143bf77 100644 --- a/payment_method.py +++ b/payment_method.py @@ -29,7 +29,8 @@ class payment_method(orm.Model): _columns = { 'name': fields.char('Name', - help="The name of the method on the backend"), + help="The name of the method on the backend", + required=True), 'journal_id': fields.many2one( 'account.journal', 'Journal', From 24e77c87f90679358e8ef6ff86dcea9042f64bec Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 14 Mar 2014 11:21:30 +0100 Subject: [PATCH 26/52] [FIX] No migration is required if not previous version --- __openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__openerp__.py b/__openerp__.py index 47a0ee28870..83c59ca848f 100644 --- a/__openerp__.py +++ b/__openerp__.py @@ -21,7 +21,7 @@ { 'name': 'Sale Payment Method', - 'version': '0.2', + 'version': '0.2.1', 'category': 'Generic Modules/Others', 'license': 'AGPL-3', 'description': """ From 6bff0c7b08e123ad88401392d5f999493fd3abda Mon Sep 17 00:00:00 2001 From: Alberto Garcia Date: Tue, 24 Jun 2014 11:57:29 +0200 Subject: [PATCH 27/52] Tranlations es for modules --- i18n/es.po | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 i18n/es.po diff --git a/i18n/es.po b/i18n/es.po new file mode 100644 index 00000000000..25bed888626 --- /dev/null +++ b/i18n/es.po @@ -0,0 +1,143 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * sale_payment_method +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-05-02 07:06+0000\n" +"PO-Revision-Date: 2014-06-24 11:55+0100\n" +"Last-Translator: Alberto Garcia \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" + +#. module: sale_payment_method +#: view:sale.order:0 +msgid "Automation Information" +msgstr "Información Automática" + +#. module: sale_payment_method +#: help:payment.method,journal_id:0 +msgid "If a journal a selected, when a payment is recorded on a backend, payment entries will be created in this journal. " +msgstr "Si un diario es sleccionado, cuando un pago es registrado en el backend, las entradas de los pagos serán creadas en ese diario" + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "" +"Even if the E-commerce backend receives a payment for a sale order,\n" +" no payment entries will be generated." +msgstr "Incluso si el E-commerce backend recibe un pago de un pedido de venta," + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "Default Values" +msgstr "Valores por defecto" + +#. module: sale_payment_method +#: model:ir.model,name:sale_payment_method.model_payment_method +#: field:sale.order,payment_method_id:0 +msgid "Payment Method" +msgstr "Método de pago" + +#. module: sale_payment_method +#: view:sale.order:0 +msgid "View Automatic Payment" +msgstr "Ver Pago Automático" + +#. module: sale_payment_method +#: help:sale.order,payment_exists:0 +msgid "It indicates that sales order has at least one payment." +msgstr "Esto indica que el pedido de venta tiene al menos un pago." + +#. module: sale_payment_method +#: field:payment.method,journal_id:0 +msgid "Journal" +msgstr "Diario" + +#. module: sale_payment_method +#: model:ir.actions.act_window,name:sale_payment_method.act_payment_method_form +#: model:ir.ui.menu,name:sale_payment_method.menu_action_paymetn_method_form +msgid "Payment Methods " +msgstr "Métodos de Pago" + +#. module: sale_payment_method +#: field:account.move,order_ids:0 +msgid "Sales Orders" +msgstr "Pedidos de venta" + +#. module: sale_payment_method +#: view:sale.order:0 +msgid "Other Information" +msgstr "Otra información" + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "Payment Methods" +msgstr "Métodos de pago" + +#. module: sale_payment_method +#: field:payment.method,name:0 +msgid "Name" +msgstr "Nombre" + +#. module: sale_payment_method +#: field:sale.order,payment_ids:0 +msgid "Payments Entries" +msgstr "Entradas de pagos" + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "" +"When the E-commerce backend will receive a payment for a sale order,\n" +" payment entries will be generated in the selected journal." +msgstr "Cuando el E-commerce backend recibe un pago para un pedido de venta," + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "Journal for payment" +msgstr "Diario de pago" + +#. module: sale_payment_method +#: field:sale.order,residual:0 +msgid "Balance" +msgstr "Balance" + +#. module: sale_payment_method +#: model:ir.model,name:sale_payment_method.model_account_move +msgid "Account Entry" +msgstr "Apunte Contable" + +#. module: sale_payment_method +#: help:payment.method,payment_term_id:0 +msgid "Default payment term of a sale order using this method." +msgstr "Forma de pago por defecto de un pedido de venta usado por este método." + +#. module: sale_payment_method +#: field:payment.method,payment_term_id:0 +msgid "Payment Term" +msgstr "Modo de pago" + +#. module: sale_payment_method +#: view:sale.order:0 +msgid "Create Invoice" +msgstr "Crear Factura" + +#. module: sale_payment_method +#: help:payment.method,name:0 +msgid "The name of the method on the backend" +msgstr "El nombre del método en el backend" + +#. module: sale_payment_method +#: model:ir.model,name:sale_payment_method.model_sale_order +msgid "Sales Order" +msgstr "Pediso de Ventas" + +#. module: sale_payment_method +#: field:sale.order,payment_exists:0 +msgid "Has automatic payment" +msgstr "Tiene pago automático" + From b712f1bb5625311cb9fbdbe794401aa35c681cc9 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Mon, 7 Jul 2014 15:41:15 +0200 Subject: [PATCH 28/52] set the flag 'installable' to False on the modules --- __openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__openerp__.py b/__openerp__.py index 83c59ca848f..898682d664a 100644 --- a/__openerp__.py +++ b/__openerp__.py @@ -46,5 +46,5 @@ 'security/rules.xml', ], 'demo': [], - 'installable': True, + 'installable': False, } From 9c3589c78924cb2ec3e87b65588906be74d133b1 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Mon, 7 Jul 2014 15:41:44 +0200 Subject: [PATCH 29/52] move modules to migrate in __unported__ --- __init__.py | 24 --- __openerp__.py | 50 ------ account_move.py | 30 ---- i18n/es.po | 143 --------------- i18n/fr.po | 142 --------------- i18n/sale_payment_method.pot | 141 --------------- migrations/0.1/post-migration.py | 36 ---- payment_method.py | 57 ------ payment_method_view.xml | 64 ------- sale.py | 299 ------------------------------- sale_view.xml | 78 -------- security/ir.model.access.csv | 3 - security/rules.xml | 13 -- 13 files changed, 1080 deletions(-) delete mode 100644 __init__.py delete mode 100644 __openerp__.py delete mode 100644 account_move.py delete mode 100644 i18n/es.po delete mode 100644 i18n/fr.po delete mode 100644 i18n/sale_payment_method.pot delete mode 100644 migrations/0.1/post-migration.py delete mode 100644 payment_method.py delete mode 100644 payment_method_view.xml delete mode 100644 sale.py delete mode 100644 sale_view.xml delete mode 100644 security/ir.model.access.csv delete mode 100644 security/rules.xml diff --git a/__init__.py b/__init__.py deleted file mode 100644 index 6f10dd35c1b..00000000000 --- a/__init__.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# sale_payment_method for OpenERP -# Copyright (C) 2011 Akretion Sébastien BEAU -# -# 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 -from . import payment_method -from . import account_move diff --git a/__openerp__.py b/__openerp__.py deleted file mode 100644 index 898682d664a..00000000000 --- a/__openerp__.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# sale_payment_method for OpenERP -# Copyright (C) 2011 Akretion Sébastien BEAU -# -# 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': 'Sale Payment Method', - 'version': '0.2.1', - 'category': 'Generic Modules/Others', - 'license': 'AGPL-3', - 'description': """ -Sale Payment Method -=================== - -This module adds low-level features used for instance by modules: - -- Sale Automatic Workflow -- Sale Quick Payment - -It adds a payment method on the sales orders and allow to register -payments entries on sales orders. -""", - 'author': 'Akretion', - 'website': 'http://www.akretion.com/', - 'depends': ['sale', - ], - 'data': ['sale_view.xml', - 'payment_method_view.xml', - 'security/ir.model.access.csv', - 'security/rules.xml', - ], - 'demo': [], - 'installable': False, -} diff --git a/account_move.py b/account_move.py deleted file mode 100644 index 0b35ca34de6..00000000000 --- a/account_move.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Author: Guewen Baconnier -# Copyright 2013 Camptocamp SA -# -# 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_move_line(orm.Model): - _inherit = 'account.move.line' - - _columns = { - 'sale_ids': fields.many2many('sale.order', string='Sales Orders'), - } diff --git a/i18n/es.po b/i18n/es.po deleted file mode 100644 index 25bed888626..00000000000 --- a/i18n/es.po +++ /dev/null @@ -1,143 +0,0 @@ -# Translation of OpenERP Server. -# This file contains the translation of the following modules: -# * sale_payment_method -# -msgid "" -msgstr "" -"Project-Id-Version: OpenERP Server 7.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-05-02 07:06+0000\n" -"PO-Revision-Date: 2014-06-24 11:55+0100\n" -"Last-Translator: Alberto Garcia \n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: \n" - -#. module: sale_payment_method -#: view:sale.order:0 -msgid "Automation Information" -msgstr "Información Automática" - -#. module: sale_payment_method -#: help:payment.method,journal_id:0 -msgid "If a journal a selected, when a payment is recorded on a backend, payment entries will be created in this journal. " -msgstr "Si un diario es sleccionado, cuando un pago es registrado en el backend, las entradas de los pagos serán creadas en ese diario" - -#. module: sale_payment_method -#: view:payment.method:0 -msgid "" -"Even if the E-commerce backend receives a payment for a sale order,\n" -" no payment entries will be generated." -msgstr "Incluso si el E-commerce backend recibe un pago de un pedido de venta," - -#. module: sale_payment_method -#: view:payment.method:0 -msgid "Default Values" -msgstr "Valores por defecto" - -#. module: sale_payment_method -#: model:ir.model,name:sale_payment_method.model_payment_method -#: field:sale.order,payment_method_id:0 -msgid "Payment Method" -msgstr "Método de pago" - -#. module: sale_payment_method -#: view:sale.order:0 -msgid "View Automatic Payment" -msgstr "Ver Pago Automático" - -#. module: sale_payment_method -#: help:sale.order,payment_exists:0 -msgid "It indicates that sales order has at least one payment." -msgstr "Esto indica que el pedido de venta tiene al menos un pago." - -#. module: sale_payment_method -#: field:payment.method,journal_id:0 -msgid "Journal" -msgstr "Diario" - -#. module: sale_payment_method -#: model:ir.actions.act_window,name:sale_payment_method.act_payment_method_form -#: model:ir.ui.menu,name:sale_payment_method.menu_action_paymetn_method_form -msgid "Payment Methods " -msgstr "Métodos de Pago" - -#. module: sale_payment_method -#: field:account.move,order_ids:0 -msgid "Sales Orders" -msgstr "Pedidos de venta" - -#. module: sale_payment_method -#: view:sale.order:0 -msgid "Other Information" -msgstr "Otra información" - -#. module: sale_payment_method -#: view:payment.method:0 -msgid "Payment Methods" -msgstr "Métodos de pago" - -#. module: sale_payment_method -#: field:payment.method,name:0 -msgid "Name" -msgstr "Nombre" - -#. module: sale_payment_method -#: field:sale.order,payment_ids:0 -msgid "Payments Entries" -msgstr "Entradas de pagos" - -#. module: sale_payment_method -#: view:payment.method:0 -msgid "" -"When the E-commerce backend will receive a payment for a sale order,\n" -" payment entries will be generated in the selected journal." -msgstr "Cuando el E-commerce backend recibe un pago para un pedido de venta," - -#. module: sale_payment_method -#: view:payment.method:0 -msgid "Journal for payment" -msgstr "Diario de pago" - -#. module: sale_payment_method -#: field:sale.order,residual:0 -msgid "Balance" -msgstr "Balance" - -#. module: sale_payment_method -#: model:ir.model,name:sale_payment_method.model_account_move -msgid "Account Entry" -msgstr "Apunte Contable" - -#. module: sale_payment_method -#: help:payment.method,payment_term_id:0 -msgid "Default payment term of a sale order using this method." -msgstr "Forma de pago por defecto de un pedido de venta usado por este método." - -#. module: sale_payment_method -#: field:payment.method,payment_term_id:0 -msgid "Payment Term" -msgstr "Modo de pago" - -#. module: sale_payment_method -#: view:sale.order:0 -msgid "Create Invoice" -msgstr "Crear Factura" - -#. module: sale_payment_method -#: help:payment.method,name:0 -msgid "The name of the method on the backend" -msgstr "El nombre del método en el backend" - -#. module: sale_payment_method -#: model:ir.model,name:sale_payment_method.model_sale_order -msgid "Sales Order" -msgstr "Pediso de Ventas" - -#. module: sale_payment_method -#: field:sale.order,payment_exists:0 -msgid "Has automatic payment" -msgstr "Tiene pago automático" - diff --git a/i18n/fr.po b/i18n/fr.po deleted file mode 100644 index 5c156c737af..00000000000 --- a/i18n/fr.po +++ /dev/null @@ -1,142 +0,0 @@ -# Translation of OpenERP Server. -# This file contains the translation of the following modules: -# * sale_payment_method -# -msgid "" -msgstr "" -"Project-Id-Version: OpenERP Server 7.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-05-02 07:06+0000\n" -"PO-Revision-Date: 2013-05-02 07: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: sale_payment_method -#: view:sale.order:0 -msgid "Automation Information" -msgstr "Informations d'automatisation" - -#. module: sale_payment_method -#: help:payment.method,journal_id:0 -msgid "If a journal a selected, when a payment is recorded on a backend, payment entries will be created in this journal. " -msgstr "Si un journal est sélectionné, lorsqu'un paiement est enregistré sur le backend, des lignes de paiement seront générées dans ce journal." - -#. module: sale_payment_method -#: view:payment.method:0 -msgid "Even if the E-commerce backend receives a payment for a sale order,\n" -" no payment entries will be generated." -msgstr "Même si le backend e-commerce reçoit un payment pour un bon de commande, aucune ligne de paiement ne sera générée." - -#. module: sale_payment_method -#: view:payment.method:0 -msgid "Default Values" -msgstr "Valeurs par défaut" - -#. module: sale_payment_method -#: model:ir.model,name:sale_payment_method.model_payment_method -#: field:sale.order,payment_method_id:0 -msgid "Payment Method" -msgstr "Méthode de paiement" - -#. module: sale_payment_method -#: view:sale.order:0 -msgid "View Automatic Payment" -msgstr "Voir les paiements automatiques" - -#. module: sale_payment_method -#: help:sale.order,payment_exists:0 -msgid "It indicates that sales order has at least one payment." -msgstr "Indique que la commande a reçu au moins un paiement." - -#. module: sale_payment_method -#: field:payment.method,journal_id:0 -msgid "Journal" -msgstr "Journal" - -#. module: sale_payment_method -#: model:ir.actions.act_window,name:sale_payment_method.act_payment_method_form -#: model:ir.ui.menu,name:sale_payment_method.menu_action_paymetn_method_form -msgid "Payment Methods " -msgstr "Méthodes de paiement" - -#. module: sale_payment_method -#: field:account.move,order_ids:0 -msgid "Sales Orders" -msgstr "Bons de commande" - -#. module: sale_payment_method -#: view:sale.order:0 -msgid "Other Information" -msgstr "Autres informations" - -#. module: sale_payment_method -#: view:payment.method:0 -msgid "Payment Methods" -msgstr "Méthodes de paiement" - -#. module: sale_payment_method -#: field:payment.method,name:0 -msgid "Name" -msgstr "Nom" - -#. module: sale_payment_method -#: field:sale.order,payment_ids:0 -msgid "Payments Entries" -msgstr "Écritures de paiement" - -#. module: sale_payment_method -#: view:payment.method:0 -msgid "When the E-commerce backend will receive a payment for a sale order,\n" -" payment entries will be generated in the selected journal." -msgstr "Lorsque le backend e-commerce reçoit un paiement pour la commande,\n" -" des écritures de paiement sont générées dans le journal sélectionné." - -#. module: sale_payment_method -#: view:payment.method:0 -msgid "Journal for payment" -msgstr "Journal pour le paiement" - -#. module: sale_payment_method -#: field:sale.order,residual:0 -msgid "Balance" -msgstr "Solde" - -#. module: sale_payment_method -#: model:ir.model,name:sale_payment_method.model_account_move -msgid "Account Entry" -msgstr "Ecriture" - -#. module: sale_payment_method -#: help:payment.method,payment_term_id:0 -msgid "Default payment term of a sale order using this method." -msgstr "Condition de règlement par défaut pour les commandes utilisant cette méthode." - -#. module: sale_payment_method -#: field:payment.method,payment_term_id:0 -msgid "Payment Term" -msgstr "Condition de règlement" - -#. module: sale_payment_method -#: view:sale.order:0 -msgid "Create Invoice" -msgstr "Créer la facture" - -#. module: sale_payment_method -#: help:payment.method,name:0 -msgid "The name of the method on the backend" -msgstr "Nom de la méthode sur le backend" - -#. module: sale_payment_method -#: model:ir.model,name:sale_payment_method.model_sale_order -msgid "Sales Order" -msgstr "Bon de commande" - -#. module: sale_payment_method -#: field:sale.order,payment_exists:0 -msgid "Has automatic payment" -msgstr "A un paiement automatique" - diff --git a/i18n/sale_payment_method.pot b/i18n/sale_payment_method.pot deleted file mode 100644 index ef54c2b57de..00000000000 --- a/i18n/sale_payment_method.pot +++ /dev/null @@ -1,141 +0,0 @@ -# Translation of OpenERP Server. -# This file contains the translation of the following modules: -# * sale_payment_method -# -msgid "" -msgstr "" -"Project-Id-Version: OpenERP Server 7.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-05-02 07:06+0000\n" -"PO-Revision-Date: 2013-05-02 07: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: sale_payment_method -#: view:sale.order:0 -msgid "Automation Information" -msgstr "" - -#. module: sale_payment_method -#: help:payment.method,journal_id:0 -msgid "If a journal a selected, when a payment is recorded on a backend, payment entries will be created in this journal. " -msgstr "" - -#. module: sale_payment_method -#: view:payment.method:0 -msgid "Even if the E-commerce backend receives a payment for a sale order,\n" -" no payment entries will be generated." -msgstr "" - -#. module: sale_payment_method -#: view:payment.method:0 -msgid "Default Values" -msgstr "" - -#. module: sale_payment_method -#: model:ir.model,name:sale_payment_method.model_payment_method -#: field:sale.order,payment_method_id:0 -msgid "Payment Method" -msgstr "" - -#. module: sale_payment_method -#: view:sale.order:0 -msgid "View Automatic Payment" -msgstr "" - -#. module: sale_payment_method -#: help:sale.order,payment_exists:0 -msgid "It indicates that sales order has at least one payment." -msgstr "" - -#. module: sale_payment_method -#: field:payment.method,journal_id:0 -msgid "Journal" -msgstr "" - -#. module: sale_payment_method -#: model:ir.actions.act_window,name:sale_payment_method.act_payment_method_form -#: model:ir.ui.menu,name:sale_payment_method.menu_action_paymetn_method_form -msgid "Payment Methods " -msgstr "" - -#. module: sale_payment_method -#: field:account.move,order_ids:0 -msgid "Sales Orders" -msgstr "" - -#. module: sale_payment_method -#: view:sale.order:0 -msgid "Other Information" -msgstr "" - -#. module: sale_payment_method -#: view:payment.method:0 -msgid "Payment Methods" -msgstr "" - -#. module: sale_payment_method -#: field:payment.method,name:0 -msgid "Name" -msgstr "" - -#. module: sale_payment_method -#: field:sale.order,payment_ids:0 -msgid "Payments Entries" -msgstr "" - -#. module: sale_payment_method -#: view:payment.method:0 -msgid "When the E-commerce backend will receive a payment for a sale order,\n" -" payment entries will be generated in the selected journal." -msgstr "" - -#. module: sale_payment_method -#: view:payment.method:0 -msgid "Journal for payment" -msgstr "" - -#. module: sale_payment_method -#: field:sale.order,residual:0 -msgid "Balance" -msgstr "" - -#. module: sale_payment_method -#: model:ir.model,name:sale_payment_method.model_account_move -msgid "Account Entry" -msgstr "" - -#. module: sale_payment_method -#: help:payment.method,payment_term_id:0 -msgid "Default payment term of a sale order using this method." -msgstr "" - -#. module: sale_payment_method -#: field:payment.method,payment_term_id:0 -msgid "Payment Term" -msgstr "" - -#. module: sale_payment_method -#: view:sale.order:0 -msgid "Create Invoice" -msgstr "" - -#. module: sale_payment_method -#: help:payment.method,name:0 -msgid "The name of the method on the backend" -msgstr "" - -#. module: sale_payment_method -#: model:ir.model,name:sale_payment_method.model_sale_order -msgid "Sales Order" -msgstr "" - -#. module: sale_payment_method -#: field:sale.order,payment_exists:0 -msgid "Has automatic payment" -msgstr "" - diff --git a/migrations/0.1/post-migration.py b/migrations/0.1/post-migration.py deleted file mode 100644 index aa945de084e..00000000000 --- a/migrations/0.1/post-migration.py +++ /dev/null @@ -1,36 +0,0 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# sale_quick_payment for OpenERP -# Copyright (C) 2012-TODAY Akretion . -# All Rights Reserved -# @author Sébastien BEAU -# 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 . -# -############################################################################## - -""" r0.1: Migration 6.1 => 7.0.0.1 - migrate the field payment_id from one2many to payment_ids many2many -""" -__name__ = ("sale.order:: V7 change/rename the field payment_id into a" - "many2many with the name payment_ids") - -def migrate(cr, version): - if version: - cr.execute("INSERT INTO account_voucher_sale_order_rel" - "(sale_order_id, account_voucher_id) " - "(SELECT id, payment_id FROM " - " sale_order " - "WHERE payment_id IS NOT NULL )") - diff --git a/payment_method.py b/payment_method.py deleted file mode 100644 index 29e6143bf77..00000000000 --- a/payment_method.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# sale_quick_payment for OpenERP -# Copyright (C) 2011 Akretion Sébastien BEAU -# Copyright 2013 Camptocamp SA (Guewen Baconnier) -# -# 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 fields, orm - - -class payment_method(orm.Model): - _name = "payment.method" - _description = "Payment Method" - - _columns = { - 'name': fields.char('Name', - help="The name of the method on the backend", - required=True), - 'journal_id': fields.many2one( - 'account.journal', - 'Journal', - help="If a journal a selected, when a payment is recorded " - "on a backend, payment entries will be created in this " - "journal. "), - 'payment_term_id': fields.many2one( - 'account.payment.term', - 'Payment Term', - help="Default payment term of a sale order using this method."), - 'company_id': fields.many2one( - 'res.company', - 'Company', - ), - } - - def _default_company_id(self, cr, uid, context): - company_model = self.pool.get('res.company') - return company_model._company_default_get(cr, uid, 'payment.method', - context=context) - - _defaults = { - 'company_id': _default_company_id, - } diff --git a/payment_method_view.xml b/payment_method_view.xml deleted file mode 100644 index b69236cd868..00000000000 --- a/payment_method_view.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - sale_payment_method.payment_method.view_form - payment.method - - -

- -

- - - - - - -

- When the E-commerce backend will receive a payment for a sale order, - payment entries will be generated in the selected journal. -

-

- Even if the E-commerce backend receives a payment for a sale order, - no payment entries will be generated. -

-
-
- - - - -
-
- - - sale_payment_method.payment_method.view_tree - payment.method - - - - - - - - - - - Payment Methods - payment.method - form - tree,form - - - - -
-
diff --git a/sale.py b/sale.py deleted file mode 100644 index 9ac2e4d331f..00000000000 --- a/sale.py +++ /dev/null @@ -1,299 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Author: Guewen Baconnier, Sébastien Beau -# Copyright (C) 2011 Akretion Sébastien BEAU -# Copyright 2013 Camptocamp SA (Guewen Baconnier) -# -# 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, osv -from openerp.tools.translate import _ -from collections import Iterable -import openerp.addons.decimal_precision as dp - - -class sale_order(orm.Model): - _inherit = 'sale.order' - - def _get_order_from_move(self, cr, uid, ids, context=None): - result = set() - move_obj = self.pool.get('account.move') - for move in move_obj.browse(cr, uid, ids, context=context): - for order in move.order_ids: - result.add(order.id) - return list(result) - - def _get_order_from_line(self, cr, uid, ids, context=None): - so_obj = self.pool.get('sale.order') - return so_obj._get_order(cr, uid, ids, context=context) - - def _get_amount(self, cr, uid, ids, fields, args, context=None): - res = {} - for order in self.browse(cr, uid, ids, context=context): - #TODO add support when payment is linked to many order - paid_amount = 0 - for line in order.payment_ids: - paid_amount += line.credit - line.debit - res[order.id] = { - 'amount_paid': paid_amount, - 'residual': order.amount_total - paid_amount, - } - return res - - def _payment_exists(self, cursor, user, ids, name, arg, context=None): - res = {} - for sale in self.browse(cursor, user, ids, context=context): - res[sale.id] = bool(sale.payment_ids) - return res - - _columns = { - 'payment_ids': fields.many2many('account.move.line', - string='Payments Entries'), - 'payment_method_id': fields.many2one('payment.method', - 'Payment Method', - ondelete='restrict'), - 'residual': fields.function( - _get_amount, - digits_compute=dp.get_precision('Account'), - string='Balance', - store=False, - multi='payment'), - 'amount_paid': fields.function( - _get_amount, - digits_compute=dp.get_precision('Account'), - string='Amount Paid', - store=False, - multi='payment'), - 'payment_exists': fields.function( - _payment_exists, - string='Has automatic payment', - type='boolean', - help="It indicates that sales order has at least one payment."), - } - - def copy(self, cr, uid, id, default=None, context=None): - if default is None: - default = {} - default['payment_ids'] = False - return super(sale_order, self).copy(cr, uid, id, - default, context=context) - - def automatic_payment(self, cr, uid, ids, amount=None, context=None): - """ Create the payment entries to pay a sale order, respecting - the payment terms. - If no amount is defined, it will pay the residual amount of the sale - order. """ - if isinstance(ids, Iterable): - assert len(ids) == 1, "one sale order at a time can be paid" - ids = ids[0] - sale = self.browse(cr, uid, ids, context=context) - method = sale.payment_method_id - if not method: - raise osv.except_osv( - _('Configuration Error'), - _("An automatic payment can not be created for the sale " - "order %s because it has no payment method.") % sale.name) - - if not method.journal_id: - raise osv.except_osv( - _('Configuration Error'), - _("An automatic payment should be created for the sale order %s " - "but the payment method '%s' has no journal defined.") % - (sale.name, method.name)) - - journal = method.journal_id - date = sale.date_order - if amount is None: - amount = sale.residual - if sale.payment_term: - term_obj = self.pool.get('account.payment.term') - amounts = term_obj.compute(cr, uid, sale.payment_term.id, - amount, date_ref=date, - context=context) - else: - amounts = [(date, amount)] - - # reversed is cosmetic, compute returns terms in the 'wrong' order - for date, amount in reversed(amounts): - self._add_payment(cr, uid, sale, journal, - amount, date, context=context) - return True - - def add_payment(self, cr, uid, ids, journal_id, amount, - date=None, description=None, context=None): - """ Generate payment move lines of a certain amount linked - with the sale order. """ - if isinstance(ids, Iterable): - assert len(ids) == 1, "one sale order at a time can be paid" - ids = ids[0] - journal_obj = self.pool.get('account.journal') - - sale = self.browse(cr, uid, ids, context=context) - if date is None: - date = sale.date_order - journal = journal_obj.browse(cr, uid, journal_id, context=context) - self._add_payment(cr, uid, sale, journal, amount, date, description, context=context) - return True - - def _add_payment(self, cr, uid, sale, journal, amount, date, description=None, context=None): - """ Generate move lines entries to pay the sale order. """ - move_obj = self.pool.get('account.move') - period_obj = self.pool.get('account.period') - period_id = period_obj.find(cr, uid, dt=date, context=context)[0] - period = period_obj.browse(cr, uid, period_id, context=context) - move_name = description or self._get_payment_move_name(cr, uid, journal, - period, context=context) - move_vals = self._prepare_payment_move(cr, uid, move_name, sale, - journal, period, date, - context=context) - move_lines = self._prepare_payment_move_line(cr, uid, move_name, sale, - journal, period, amount, - date, context=context) - - move_vals['line_id'] = [(0, 0, line) for line in move_lines] - move_obj.create(cr, uid, move_vals, context=context) - - def _get_payment_move_name(self, cr, uid, journal, period, context=None): - if context is None: - context = {} - seq_obj = self.pool.get('ir.sequence') - sequence = journal.sequence_id - - if not sequence: - raise osv.except_osv( - _('Configuration Error'), - _('Please define a sequence on the journal %s.') % - journal.name) - if not sequence.active: - raise osv.except_osv( - _('Configuration Error'), - _('Please activate the sequence of the journal %s.') % - journal.name) - - ctx = context.copy() - ctx['fiscalyear_id'] = period.fiscalyear_id.id - name = seq_obj.next_by_id(cr, uid, sequence.id, context=ctx) - return name - - def _prepare_payment_move(self, cr, uid, move_name, sale, journal, - period, date, context=None): - return {'name': move_name, - 'journal_id': journal.id, - 'date': date, - 'ref': sale.name, - 'period_id': period.id, - } - - def _prepare_payment_move_line(self, cr, uid, move_name, sale, journal, - period, amount, date, context=None): - """ """ - partner_obj = self.pool.get('res.partner') - currency_obj = self.pool.get('res.currency') - partner = partner_obj._find_accounting_partner(sale.partner_id) - - company = journal.company_id - - currency_id = False - amount_currency = 0.0 - if journal.currency and journal.currency.id != company.currency_id.id: - currency_id = journal.currency.id - amount_currency, amount = (amount, - currency_obj.compute(cr, uid, - currency_id, - company.currency_id.id, - amount, - context=context)) - - # payment line (bank / cash) - debit_line = { - 'name': move_name, - 'debit': amount, - 'credit': 0.0, - 'account_id': journal.default_credit_account_id.id, - 'journal_id': journal.id, - 'period_id': period.id, - 'partner_id': partner.id, - 'date': date, - 'amount_currency': amount_currency, - 'currency_id': currency_id, - } - - # payment line (receivable) - credit_line = { - 'name': move_name, - 'debit': 0.0, - 'credit': amount, - 'account_id': partner.property_account_receivable.id, - 'journal_id': journal.id, - 'period_id': period.id, - 'partner_id': partner.id, - 'date': date, - 'amount_currency': -amount_currency, - 'currency_id': currency_id, - 'sale_ids': [(4, sale.id)], - } - return debit_line, credit_line - - def onchange_payment_method_id(self, cr, uid, ids, payment_method_id, context=None): - if not payment_method_id: - return {} - result = {} - method_obj = self.pool.get('payment.method') - method = method_obj.browse(cr, uid, payment_method_id, context=context) - if method.payment_term_id: - result['payment_term'] = method.payment_term_id.id - return {'value': result} - - def action_view_payments(self, cr, uid, ids, context=None): - """ Return an action to display the payment linked - with the sale order """ - - mod_obj = self.pool.get('ir.model.data') - act_obj = self.pool.get('ir.actions.act_window') - - move_ids = set() - for so in self.browse(cr, uid, ids, context=context): - # payment_ids are move lines, we want to display the moves - move_ids |= set([move_line.move_id.id for move_line - in so.payment_ids]) - move_ids = list(move_ids) - - ref = mod_obj.get_object_reference(cr, uid, 'account', - 'action_move_journal_line') - action_id = False - if ref: - __, action_id = ref - action = act_obj.read(cr, uid, [action_id], context=context)[0] - - # choose the view_mode accordingly - if len(move_ids) > 1: - action['domain'] = str([('id', 'in', move_ids)]) - else: - ref = mod_obj.get_object_reference(cr, uid, 'account', - 'view_move_form') - action['views'] = [(ref[1] if ref else False, 'form')] - action['res_id'] = move_ids[0] if move_ids else False - return action - - def action_cancel(self, cr, uid, ids, context=None): - for sale in self.browse(cr, uid, ids, context=context): - if sale.payment_ids: - raise osv.except_osv( - _('Cannot cancel this sales order!'), - _('Automatic payment entries are linked ' - 'with the sale order.')) - return super(sale_order, self).action_cancel(cr, uid, ids, context=context) diff --git a/sale_view.xml b/sale_view.xml deleted file mode 100644 index 738e7628103..00000000000 --- a/sale_view.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - sale.order.view.form - sale.order - - - - - - - - - - - - - - - - - - - sale.order.view.tree - sale.order - - - - - - - - - - sale.order.view.tree - sale.order - - - - - - - - - - - - sale.order - - - - - - - - - - - - diff --git a/security/ir.model.access.csv b/security/ir.model.access.csv deleted file mode 100644 index 13bf2263dcc..00000000000 --- a/security/ir.model.access.csv +++ /dev/null @@ -1,3 +0,0 @@ -id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_payment_method_user,sale_quick_payment_payment_method_user,model_payment_method,base.group_user,1,0,0,0 -access_payment_method_manager,sale_quick_payment_payment_method_manager,model_payment_method,base.group_sale_manager,1,1,1,1 diff --git a/security/rules.xml b/security/rules.xml deleted file mode 100644 index b66174aa14b..00000000000 --- a/security/rules.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - Payment method multi-company - - - ['|','|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id]),('company_id','=',False)] - - - - From f26e9dac76c8d6f0e25c135aecf57c41110a2ae7 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Mon, 7 Jul 2014 16:50:21 +0200 Subject: [PATCH 30/52] Fix flake8 errors --- migrations/0.1/post-migration.py | 2 +- payment_method.py | 4 ++-- sale.py | 15 ++++++++------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/migrations/0.1/post-migration.py b/migrations/0.1/post-migration.py index aa945de084e..3e243cf6077 100644 --- a/migrations/0.1/post-migration.py +++ b/migrations/0.1/post-migration.py @@ -26,6 +26,7 @@ __name__ = ("sale.order:: V7 change/rename the field payment_id into a" "many2many with the name payment_ids") + def migrate(cr, version): if version: cr.execute("INSERT INTO account_voucher_sale_order_rel" @@ -33,4 +34,3 @@ def migrate(cr, version): "(SELECT id, payment_id FROM " " sale_order " "WHERE payment_id IS NOT NULL )") - diff --git a/payment_method.py b/payment_method.py index 29e6143bf77..70d70b00364 100644 --- a/payment_method.py +++ b/payment_method.py @@ -40,7 +40,7 @@ class payment_method(orm.Model): 'payment_term_id': fields.many2one( 'account.payment.term', 'Payment Term', - help="Default payment term of a sale order using this method."), + help="Default payment term of a sale order using this method."), 'company_id': fields.many2one( 'res.company', 'Company', @@ -53,5 +53,5 @@ def _default_company_id(self, cr, uid, context): context=context) _defaults = { - 'company_id': _default_company_id, + 'company_id': _default_company_id, } diff --git a/sale.py b/sale.py index 9ac2e4d331f..00a4d5525e4 100644 --- a/sale.py +++ b/sale.py @@ -44,14 +44,14 @@ def _get_order_from_line(self, cr, uid, ids, context=None): def _get_amount(self, cr, uid, ids, fields, args, context=None): res = {} for order in self.browse(cr, uid, ids, context=context): - #TODO add support when payment is linked to many order + # TODO add support when payment is linked to many order paid_amount = 0 - for line in order.payment_ids: + for line in order.payment_ids: paid_amount += line.credit - line.debit res[order.id] = { - 'amount_paid': paid_amount, - 'residual': order.amount_total - paid_amount, - } + 'amount_paid': paid_amount, + 'residual': order.amount_total - paid_amount, + } return res def _payment_exists(self, cursor, user, ids, name, arg, context=None): @@ -155,8 +155,9 @@ def _add_payment(self, cr, uid, sale, journal, amount, date, description=None, c period_obj = self.pool.get('account.period') period_id = period_obj.find(cr, uid, dt=date, context=context)[0] period = period_obj.browse(cr, uid, period_id, context=context) - move_name = description or self._get_payment_move_name(cr, uid, journal, - period, context=context) + move_name = description or self._get_payment_move_name( + cr, uid, journal, + period, context=context) move_vals = self._prepare_payment_move(cr, uid, move_name, sale, journal, period, date, context=context) From 731f367d57f18733c3c3bc3e1daa74c1b007079a Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 22 Aug 2014 12:27:11 +0200 Subject: [PATCH 31/52] Shorten long lines with > 79 chars --- sale.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/sale.py b/sale.py index 00a4d5525e4..586fa9e3215 100644 --- a/sale.py +++ b/sale.py @@ -111,8 +111,8 @@ def automatic_payment(self, cr, uid, ids, amount=None, context=None): if not method.journal_id: raise osv.except_osv( _('Configuration Error'), - _("An automatic payment should be created for the sale order %s " - "but the payment method '%s' has no journal defined.") % + _("An automatic payment should be created for the sale order" + " %s but the payment method '%s' has no journal defined.") % (sale.name, method.name)) journal = method.journal_id @@ -146,10 +146,12 @@ def add_payment(self, cr, uid, ids, journal_id, amount, if date is None: date = sale.date_order journal = journal_obj.browse(cr, uid, journal_id, context=context) - self._add_payment(cr, uid, sale, journal, amount, date, description, context=context) + self._add_payment(cr, uid, sale, journal, amount, date, description, + context=context) return True - def _add_payment(self, cr, uid, sale, journal, amount, date, description=None, context=None): + def _add_payment(self, cr, uid, sale, journal, amount, date, + description=None, context=None): """ Generate move lines entries to pay the sale order. """ move_obj = self.pool.get('account.move') period_obj = self.pool.get('account.period') @@ -212,12 +214,12 @@ def _prepare_payment_move_line(self, cr, uid, move_name, sale, journal, amount_currency = 0.0 if journal.currency and journal.currency.id != company.currency_id.id: currency_id = journal.currency.id - amount_currency, amount = (amount, - currency_obj.compute(cr, uid, - currency_id, - company.currency_id.id, - amount, - context=context)) + company_amount = currency_obj.compute(cr, uid, + currency_id, + company.currency_id.id, + amount, + context=context) + amount_currency, amount = amount, company_amount # payment line (bank / cash) debit_line = { @@ -249,7 +251,8 @@ def _prepare_payment_move_line(self, cr, uid, move_name, sale, journal, } return debit_line, credit_line - def onchange_payment_method_id(self, cr, uid, ids, payment_method_id, context=None): + def onchange_payment_method_id(self, cr, uid, ids, payment_method_id, + context=None): if not payment_method_id: return {} result = {} @@ -297,4 +300,5 @@ def action_cancel(self, cr, uid, ids, context=None): _('Cannot cancel this sales order!'), _('Automatic payment entries are linked ' 'with the sale order.')) - return super(sale_order, self).action_cancel(cr, uid, ids, context=context) + return super(sale_order, self).action_cancel(cr, uid, ids, + context=context) From aefcf424a6701186571a86237da734099be4a4af Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Thu, 20 Nov 2014 10:46:13 +0100 Subject: [PATCH 32/52] Redefining name 'fields' from outer scope --- sale.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sale.py b/sale.py index 586fa9e3215..b6cb4744780 100644 --- a/sale.py +++ b/sale.py @@ -41,7 +41,7 @@ def _get_order_from_line(self, cr, uid, ids, context=None): so_obj = self.pool.get('sale.order') return so_obj._get_order(cr, uid, ids, context=context) - def _get_amount(self, cr, uid, ids, fields, args, context=None): + def _get_amount(self, cr, uid, ids, name, args, context=None): res = {} for order in self.browse(cr, uid, ids, context=context): # TODO add support when payment is linked to many order From 3c23c1a2172abd69244f918151514bb93c647324 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Thu, 12 Feb 2015 14:56:16 +0100 Subject: [PATCH 33/52] Move sale_payment_method in root folder --- __init__.py | 24 +++ __openerp__.py | 50 ++++++ account_move.py | 27 +++ i18n/es.po | 143 +++++++++++++++ i18n/fr.po | 142 +++++++++++++++ i18n/sale_payment_method.pot | 141 +++++++++++++++ migrations/0.1/post-migration.py | 36 ++++ payment_method.py | 50 ++++++ payment_method_view.xml | 57 ++++++ sale.py | 300 +++++++++++++++++++++++++++++++ sale_view.xml | 67 +++++++ security/ir.model.access.csv | 3 + security/rules.xml | 13 ++ 13 files changed, 1053 insertions(+) create mode 100644 __init__.py create mode 100644 __openerp__.py create mode 100644 account_move.py create mode 100644 i18n/es.po create mode 100644 i18n/fr.po create mode 100644 i18n/sale_payment_method.pot create mode 100644 migrations/0.1/post-migration.py create mode 100644 payment_method.py create mode 100644 payment_method_view.xml create mode 100644 sale.py create mode 100644 sale_view.xml create mode 100644 security/ir.model.access.csv create mode 100644 security/rules.xml diff --git a/__init__.py b/__init__.py new file mode 100644 index 00000000000..6f10dd35c1b --- /dev/null +++ b/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# sale_payment_method for OpenERP +# Copyright (C) 2011 Akretion Sébastien BEAU +# +# 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 +from . import payment_method +from . import account_move diff --git a/__openerp__.py b/__openerp__.py new file mode 100644 index 00000000000..68fc8cb8db4 --- /dev/null +++ b/__openerp__.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# sale_payment_method for OpenERP +# Copyright (C) 2011 Akretion Sébastien BEAU +# +# 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': 'Sale Payment Method', + 'version': '0.2.1', + 'category': 'Generic Modules/Others', + 'license': 'AGPL-3', + 'description': """ +Sale Payment Method +=================== + +This module adds low-level features used for instance by modules: + +- Sale Automatic Workflow +- Sale Quick Payment + +It adds a payment method on the sales orders and allow to register +payments entries on sales orders. +""", + 'author': "Akretion,Odoo Community Association (OCA)", + 'website': 'http://www.akretion.com/', + 'depends': ['sale', + ], + 'data': ['sale_view.xml', + 'payment_method_view.xml', + 'security/ir.model.access.csv', + 'security/rules.xml', + ], + 'demo': [], + 'installable': True, +} diff --git a/account_move.py b/account_move.py new file mode 100644 index 00000000000..fa0f5f57cf7 --- /dev/null +++ b/account_move.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Guewen Baconnier +# Copyright 2013 Camptocamp SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from openerp import models, fields + + +class AccountMoveLine(models.Model): + _inherit = 'account.move.line' + + sale_ids = fields.Many2many('sale.order', string='Sales Orders') diff --git a/i18n/es.po b/i18n/es.po new file mode 100644 index 00000000000..25bed888626 --- /dev/null +++ b/i18n/es.po @@ -0,0 +1,143 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * sale_payment_method +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-05-02 07:06+0000\n" +"PO-Revision-Date: 2014-06-24 11:55+0100\n" +"Last-Translator: Alberto Garcia \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" + +#. module: sale_payment_method +#: view:sale.order:0 +msgid "Automation Information" +msgstr "Información Automática" + +#. module: sale_payment_method +#: help:payment.method,journal_id:0 +msgid "If a journal a selected, when a payment is recorded on a backend, payment entries will be created in this journal. " +msgstr "Si un diario es sleccionado, cuando un pago es registrado en el backend, las entradas de los pagos serán creadas en ese diario" + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "" +"Even if the E-commerce backend receives a payment for a sale order,\n" +" no payment entries will be generated." +msgstr "Incluso si el E-commerce backend recibe un pago de un pedido de venta," + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "Default Values" +msgstr "Valores por defecto" + +#. module: sale_payment_method +#: model:ir.model,name:sale_payment_method.model_payment_method +#: field:sale.order,payment_method_id:0 +msgid "Payment Method" +msgstr "Método de pago" + +#. module: sale_payment_method +#: view:sale.order:0 +msgid "View Automatic Payment" +msgstr "Ver Pago Automático" + +#. module: sale_payment_method +#: help:sale.order,payment_exists:0 +msgid "It indicates that sales order has at least one payment." +msgstr "Esto indica que el pedido de venta tiene al menos un pago." + +#. module: sale_payment_method +#: field:payment.method,journal_id:0 +msgid "Journal" +msgstr "Diario" + +#. module: sale_payment_method +#: model:ir.actions.act_window,name:sale_payment_method.act_payment_method_form +#: model:ir.ui.menu,name:sale_payment_method.menu_action_paymetn_method_form +msgid "Payment Methods " +msgstr "Métodos de Pago" + +#. module: sale_payment_method +#: field:account.move,order_ids:0 +msgid "Sales Orders" +msgstr "Pedidos de venta" + +#. module: sale_payment_method +#: view:sale.order:0 +msgid "Other Information" +msgstr "Otra información" + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "Payment Methods" +msgstr "Métodos de pago" + +#. module: sale_payment_method +#: field:payment.method,name:0 +msgid "Name" +msgstr "Nombre" + +#. module: sale_payment_method +#: field:sale.order,payment_ids:0 +msgid "Payments Entries" +msgstr "Entradas de pagos" + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "" +"When the E-commerce backend will receive a payment for a sale order,\n" +" payment entries will be generated in the selected journal." +msgstr "Cuando el E-commerce backend recibe un pago para un pedido de venta," + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "Journal for payment" +msgstr "Diario de pago" + +#. module: sale_payment_method +#: field:sale.order,residual:0 +msgid "Balance" +msgstr "Balance" + +#. module: sale_payment_method +#: model:ir.model,name:sale_payment_method.model_account_move +msgid "Account Entry" +msgstr "Apunte Contable" + +#. module: sale_payment_method +#: help:payment.method,payment_term_id:0 +msgid "Default payment term of a sale order using this method." +msgstr "Forma de pago por defecto de un pedido de venta usado por este método." + +#. module: sale_payment_method +#: field:payment.method,payment_term_id:0 +msgid "Payment Term" +msgstr "Modo de pago" + +#. module: sale_payment_method +#: view:sale.order:0 +msgid "Create Invoice" +msgstr "Crear Factura" + +#. module: sale_payment_method +#: help:payment.method,name:0 +msgid "The name of the method on the backend" +msgstr "El nombre del método en el backend" + +#. module: sale_payment_method +#: model:ir.model,name:sale_payment_method.model_sale_order +msgid "Sales Order" +msgstr "Pediso de Ventas" + +#. module: sale_payment_method +#: field:sale.order,payment_exists:0 +msgid "Has automatic payment" +msgstr "Tiene pago automático" + diff --git a/i18n/fr.po b/i18n/fr.po new file mode 100644 index 00000000000..5c156c737af --- /dev/null +++ b/i18n/fr.po @@ -0,0 +1,142 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * sale_payment_method +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-05-02 07:06+0000\n" +"PO-Revision-Date: 2013-05-02 07: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: sale_payment_method +#: view:sale.order:0 +msgid "Automation Information" +msgstr "Informations d'automatisation" + +#. module: sale_payment_method +#: help:payment.method,journal_id:0 +msgid "If a journal a selected, when a payment is recorded on a backend, payment entries will be created in this journal. " +msgstr "Si un journal est sélectionné, lorsqu'un paiement est enregistré sur le backend, des lignes de paiement seront générées dans ce journal." + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "Even if the E-commerce backend receives a payment for a sale order,\n" +" no payment entries will be generated." +msgstr "Même si le backend e-commerce reçoit un payment pour un bon de commande, aucune ligne de paiement ne sera générée." + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "Default Values" +msgstr "Valeurs par défaut" + +#. module: sale_payment_method +#: model:ir.model,name:sale_payment_method.model_payment_method +#: field:sale.order,payment_method_id:0 +msgid "Payment Method" +msgstr "Méthode de paiement" + +#. module: sale_payment_method +#: view:sale.order:0 +msgid "View Automatic Payment" +msgstr "Voir les paiements automatiques" + +#. module: sale_payment_method +#: help:sale.order,payment_exists:0 +msgid "It indicates that sales order has at least one payment." +msgstr "Indique que la commande a reçu au moins un paiement." + +#. module: sale_payment_method +#: field:payment.method,journal_id:0 +msgid "Journal" +msgstr "Journal" + +#. module: sale_payment_method +#: model:ir.actions.act_window,name:sale_payment_method.act_payment_method_form +#: model:ir.ui.menu,name:sale_payment_method.menu_action_paymetn_method_form +msgid "Payment Methods " +msgstr "Méthodes de paiement" + +#. module: sale_payment_method +#: field:account.move,order_ids:0 +msgid "Sales Orders" +msgstr "Bons de commande" + +#. module: sale_payment_method +#: view:sale.order:0 +msgid "Other Information" +msgstr "Autres informations" + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "Payment Methods" +msgstr "Méthodes de paiement" + +#. module: sale_payment_method +#: field:payment.method,name:0 +msgid "Name" +msgstr "Nom" + +#. module: sale_payment_method +#: field:sale.order,payment_ids:0 +msgid "Payments Entries" +msgstr "Écritures de paiement" + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "When the E-commerce backend will receive a payment for a sale order,\n" +" payment entries will be generated in the selected journal." +msgstr "Lorsque le backend e-commerce reçoit un paiement pour la commande,\n" +" des écritures de paiement sont générées dans le journal sélectionné." + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "Journal for payment" +msgstr "Journal pour le paiement" + +#. module: sale_payment_method +#: field:sale.order,residual:0 +msgid "Balance" +msgstr "Solde" + +#. module: sale_payment_method +#: model:ir.model,name:sale_payment_method.model_account_move +msgid "Account Entry" +msgstr "Ecriture" + +#. module: sale_payment_method +#: help:payment.method,payment_term_id:0 +msgid "Default payment term of a sale order using this method." +msgstr "Condition de règlement par défaut pour les commandes utilisant cette méthode." + +#. module: sale_payment_method +#: field:payment.method,payment_term_id:0 +msgid "Payment Term" +msgstr "Condition de règlement" + +#. module: sale_payment_method +#: view:sale.order:0 +msgid "Create Invoice" +msgstr "Créer la facture" + +#. module: sale_payment_method +#: help:payment.method,name:0 +msgid "The name of the method on the backend" +msgstr "Nom de la méthode sur le backend" + +#. module: sale_payment_method +#: model:ir.model,name:sale_payment_method.model_sale_order +msgid "Sales Order" +msgstr "Bon de commande" + +#. module: sale_payment_method +#: field:sale.order,payment_exists:0 +msgid "Has automatic payment" +msgstr "A un paiement automatique" + diff --git a/i18n/sale_payment_method.pot b/i18n/sale_payment_method.pot new file mode 100644 index 00000000000..ef54c2b57de --- /dev/null +++ b/i18n/sale_payment_method.pot @@ -0,0 +1,141 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * sale_payment_method +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-05-02 07:06+0000\n" +"PO-Revision-Date: 2013-05-02 07: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: sale_payment_method +#: view:sale.order:0 +msgid "Automation Information" +msgstr "" + +#. module: sale_payment_method +#: help:payment.method,journal_id:0 +msgid "If a journal a selected, when a payment is recorded on a backend, payment entries will be created in this journal. " +msgstr "" + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "Even if the E-commerce backend receives a payment for a sale order,\n" +" no payment entries will be generated." +msgstr "" + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "Default Values" +msgstr "" + +#. module: sale_payment_method +#: model:ir.model,name:sale_payment_method.model_payment_method +#: field:sale.order,payment_method_id:0 +msgid "Payment Method" +msgstr "" + +#. module: sale_payment_method +#: view:sale.order:0 +msgid "View Automatic Payment" +msgstr "" + +#. module: sale_payment_method +#: help:sale.order,payment_exists:0 +msgid "It indicates that sales order has at least one payment." +msgstr "" + +#. module: sale_payment_method +#: field:payment.method,journal_id:0 +msgid "Journal" +msgstr "" + +#. module: sale_payment_method +#: model:ir.actions.act_window,name:sale_payment_method.act_payment_method_form +#: model:ir.ui.menu,name:sale_payment_method.menu_action_paymetn_method_form +msgid "Payment Methods " +msgstr "" + +#. module: sale_payment_method +#: field:account.move,order_ids:0 +msgid "Sales Orders" +msgstr "" + +#. module: sale_payment_method +#: view:sale.order:0 +msgid "Other Information" +msgstr "" + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "Payment Methods" +msgstr "" + +#. module: sale_payment_method +#: field:payment.method,name:0 +msgid "Name" +msgstr "" + +#. module: sale_payment_method +#: field:sale.order,payment_ids:0 +msgid "Payments Entries" +msgstr "" + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "When the E-commerce backend will receive a payment for a sale order,\n" +" payment entries will be generated in the selected journal." +msgstr "" + +#. module: sale_payment_method +#: view:payment.method:0 +msgid "Journal for payment" +msgstr "" + +#. module: sale_payment_method +#: field:sale.order,residual:0 +msgid "Balance" +msgstr "" + +#. module: sale_payment_method +#: model:ir.model,name:sale_payment_method.model_account_move +msgid "Account Entry" +msgstr "" + +#. module: sale_payment_method +#: help:payment.method,payment_term_id:0 +msgid "Default payment term of a sale order using this method." +msgstr "" + +#. module: sale_payment_method +#: field:payment.method,payment_term_id:0 +msgid "Payment Term" +msgstr "" + +#. module: sale_payment_method +#: view:sale.order:0 +msgid "Create Invoice" +msgstr "" + +#. module: sale_payment_method +#: help:payment.method,name:0 +msgid "The name of the method on the backend" +msgstr "" + +#. module: sale_payment_method +#: model:ir.model,name:sale_payment_method.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: sale_payment_method +#: field:sale.order,payment_exists:0 +msgid "Has automatic payment" +msgstr "" + diff --git a/migrations/0.1/post-migration.py b/migrations/0.1/post-migration.py new file mode 100644 index 00000000000..3e243cf6077 --- /dev/null +++ b/migrations/0.1/post-migration.py @@ -0,0 +1,36 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# sale_quick_payment for OpenERP +# Copyright (C) 2012-TODAY Akretion . +# All Rights Reserved +# @author Sébastien BEAU +# 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 . +# +############################################################################## + +""" r0.1: Migration 6.1 => 7.0.0.1 + migrate the field payment_id from one2many to payment_ids many2many +""" +__name__ = ("sale.order:: V7 change/rename the field payment_id into a" + "many2many with the name payment_ids") + + +def migrate(cr, version): + if version: + cr.execute("INSERT INTO account_voucher_sale_order_rel" + "(sale_order_id, account_voucher_id) " + "(SELECT id, payment_id FROM " + " sale_order " + "WHERE payment_id IS NOT NULL )") diff --git a/payment_method.py b/payment_method.py new file mode 100644 index 00000000000..8ffb2e0aaab --- /dev/null +++ b/payment_method.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# sale_quick_payment for OpenERP +# Copyright (C) 2011 Akretion Sébastien BEAU +# Copyright 2013 Camptocamp SA (Guewen Baconnier) +# +# 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, fields + + +class PaymentMethod(models.Model): + _name = "payment.method" + _description = "Payment Method" + + @api.model + def _default_company_id(self): + company_model = self.env['res.company'] + return company_model._company_default_get('payment.method') + + name = fields.Char('Name', help="The name of the method on the backend") + journal_id = fields.Many2one( + 'account.journal', + 'Journal', + help="If a journal a selected, when a payment is recorded " + "on a backend, payment entries will be created in this " + "journal.") + payment_term_id = fields.Many2one( + 'account.payment.term', + 'Payment Term', + help="Default payment term of a sale order using this method.") + + company_id = fields.Many2one( + 'res.company', + 'Company', + default=_default_company_id + ) diff --git a/payment_method_view.xml b/payment_method_view.xml new file mode 100644 index 00000000000..8d9d2557d54 --- /dev/null +++ b/payment_method_view.xml @@ -0,0 +1,57 @@ + + + + + sale_payment_method.payment_method.view_form + payment.method + +
+

+ +

+ + + + + + +

+ When the E-commerce backend will receive a payment for a sale order, + payment entries will be generated in the selected journal. +

+

+ Even if the E-commerce backend receives a payment for a sale order, + no payment entries will be generated. +

+
+
+ + + +
+
+
+ + + sale_payment_method.payment_method.view_tree + payment.method + + + + + + + + + + + Payment Methods + payment.method + form + tree,form + + + + +
+
diff --git a/sale.py b/sale.py new file mode 100644 index 00000000000..72197405f5a --- /dev/null +++ b/sale.py @@ -0,0 +1,300 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author: Guewen Baconnier, Sébastien Beau +# Copyright (C) 2011 Akretion Sébastien BEAU +# Copyright 2013 Camptocamp SA (Guewen Baconnier) +# +# 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 osv, api, models, fields +from openerp.tools.translate import _ +from collections import Iterable +import openerp.addons.decimal_precision as dp + + +class SaleOrder(models.Model): + _inherit = 'sale.order' + + def _get_order_from_move(self, cr, uid, ids, context=None): + result = set() + move_obj = self.pool.get('account.move') + for move in move_obj.browse(cr, uid, ids, context=context): + for order in move.order_ids: + result.add(order.id) + return list(result) + + def _get_order_from_line(self, cr, uid, ids, context=None): + so_obj = self.pool.get('sale.order') + return so_obj._get_order(cr, uid, ids, context=context) + + @api.one + @api.depends('amount_total', 'payment_ids.credit', 'payment_ids.debit') + def _get_amount(self): + paid_amount = 0 + for line in self.payment_ids: + paid_amount += line.credit - line.debit + self.amount_paid = paid_amount + self.residual = self.amount_total - paid_amount + + @api.one + @api.depends('payment_ids') + def _payment_exists(self): + self.payment_exists = bool(self.payment_ids) + + payment_ids = fields.Many2many( + 'account.move.line', + string='Payments Entries') + + payment_method_id = fields.Many2one( + 'payment.method', + 'Payment Method', + ondelete='restrict') + + residual = fields.Float( + compute=_get_amount, + digits_compute=dp.get_precision('Account'), + string='Balance', + store=False) + + amount_paid = fields.Float( + compute=_get_amount, + digits_compute=dp.get_precision('Account'), + string='Amount Paid', + store=False) + + payment_exists = fields.Boolean( + compute=_payment_exists, + string='Has automatic payment', + help="It indicates that sales order has at least one payment.") + + @api.one + def copy(self, default=None): + if default is None: + default = {} + default['payment_ids'] = False + return super(SaleOrder, self).copy(default=default) + + def automatic_payment(self, cr, uid, ids, amount=None, context=None): + """ Create the payment entries to pay a sale order, respecting + the payment terms. + If no amount is defined, it will pay the residual amount of the sale + order. """ + if isinstance(ids, Iterable): + assert len(ids) == 1, "one sale order at a time can be paid" + ids = ids[0] + sale = self.browse(cr, uid, ids, context=context) + method = sale.payment_method_id + if not method: + raise osv.except_osv( + _('Configuration Error'), + _("An automatic payment can not be created for the sale " + "order %s because it has no payment method.") % sale.name) + + if not method.journal_id: + raise osv.except_osv( + _('Configuration Error'), + _("An automatic payment should be created for the sale order" + " %s but the payment method '%s' has no journal defined.") % + (sale.name, method.name)) + + journal = method.journal_id + date = sale.date_order + if amount is None: + amount = sale.residual + if sale.payment_term: + term_obj = self.pool.get('account.payment.term') + amounts = term_obj.compute(cr, uid, sale.payment_term.id, + amount, date_ref=date, + context=context) + else: + amounts = [(date, amount)] + + # reversed is cosmetic, compute returns terms in the 'wrong' order + for date, amount in reversed(amounts): + self._add_payment(cr, uid, sale, journal, + amount, date, context=context) + return True + + def add_payment(self, cr, uid, ids, journal_id, amount, + date=None, description=None, context=None): + """ Generate payment move lines of a certain amount linked + with the sale order. """ + if isinstance(ids, Iterable): + assert len(ids) == 1, "one sale order at a time can be paid" + ids = ids[0] + journal_obj = self.pool.get('account.journal') + + sale = self.browse(cr, uid, ids, context=context) + if date is None: + date = sale.date_order + journal = journal_obj.browse(cr, uid, journal_id, context=context) + self._add_payment(cr, uid, sale, journal, amount, date, description, + context=context) + return True + + def _add_payment(self, cr, uid, sale, journal, amount, date, + description=None, context=None): + """ Generate move lines entries to pay the sale order. """ + move_obj = self.pool.get('account.move') + period_obj = self.pool.get('account.period') + period_id = period_obj.find(cr, uid, dt=date, context=context)[0] + period = period_obj.browse(cr, uid, period_id, context=context) + move_name = description or self._get_payment_move_name( + cr, uid, journal, + period, context=context) + move_vals = self._prepare_payment_move(cr, uid, move_name, sale, + journal, period, date, + context=context) + move_lines = self._prepare_payment_move_line(cr, uid, move_name, sale, + journal, period, amount, + date, context=context) + + move_vals['line_id'] = [(0, 0, line) for line in move_lines] + move_obj.create(cr, uid, move_vals, context=context) + + def _get_payment_move_name(self, cr, uid, journal, period, context=None): + if context is None: + context = {} + seq_obj = self.pool.get('ir.sequence') + sequence = journal.sequence_id + + if not sequence: + raise osv.except_osv( + _('Configuration Error'), + _('Please define a sequence on the journal %s.') % + journal.name) + if not sequence.active: + raise osv.except_osv( + _('Configuration Error'), + _('Please activate the sequence of the journal %s.') % + journal.name) + + ctx = context.copy() + ctx['fiscalyear_id'] = period.fiscalyear_id.id + name = seq_obj.next_by_id(cr, uid, sequence.id, context=ctx) + return name + + def _prepare_payment_move(self, cr, uid, move_name, sale, journal, + period, date, context=None): + return {'name': move_name, + 'journal_id': journal.id, + 'date': date, + 'ref': sale.name, + 'period_id': period.id, + } + + def _prepare_payment_move_line(self, cr, uid, move_name, sale, journal, + period, amount, date, context=None): + """ """ + partner_obj = self.pool.get('res.partner') + currency_obj = self.pool.get('res.currency') + partner = partner_obj._find_accounting_partner(sale.partner_id) + + company = journal.company_id + + currency_id = False + amount_currency = 0.0 + if journal.currency and journal.currency.id != company.currency_id.id: + currency_id = journal.currency.id + company_amount = currency_obj.compute(cr, uid, + currency_id, + company.currency_id.id, + amount, + context=context) + amount_currency, amount = amount, company_amount + + # payment line (bank / cash) + debit_line = { + 'name': move_name, + 'debit': amount, + 'credit': 0.0, + 'account_id': journal.default_credit_account_id.id, + 'journal_id': journal.id, + 'period_id': period.id, + 'partner_id': partner.id, + 'date': date, + 'amount_currency': amount_currency, + 'currency_id': currency_id, + } + + # payment line (receivable) + credit_line = { + 'name': move_name, + 'debit': 0.0, + 'credit': amount, + 'account_id': partner.property_account_receivable.id, + 'journal_id': journal.id, + 'period_id': period.id, + 'partner_id': partner.id, + 'date': date, + 'amount_currency': -amount_currency, + 'currency_id': currency_id, + 'sale_ids': [(4, sale.id)], + } + return debit_line, credit_line + + def onchange_payment_method_id(self, cr, uid, ids, payment_method_id, + context=None): + if not payment_method_id: + return {} + result = {} + method_obj = self.pool.get('payment.method') + method = method_obj.browse(cr, uid, payment_method_id, context=context) + if method.payment_term_id: + result['payment_term'] = method.payment_term_id.id + return {'value': result} + + def action_view_payments(self, cr, uid, ids, context=None): + """ Return an action to display the payment linked + with the sale order """ + + mod_obj = self.pool.get('ir.model.data') + act_obj = self.pool.get('ir.actions.act_window') + + move_ids = set() + for so in self.browse(cr, uid, ids, context=context): + # payment_ids are move lines, we want to display the moves + move_ids |= set([move_line.move_id.id for move_line + in so.payment_ids]) + move_ids = list(move_ids) + + ref = mod_obj.get_object_reference(cr, uid, 'account', + 'action_move_journal_line') + action_id = False + if ref: + __, action_id = ref + action = act_obj.read(cr, uid, [action_id], context=context)[0] + + # choose the view_mode accordingly + if len(move_ids) > 1: + action['domain'] = str([('id', 'in', move_ids)]) + else: + ref = mod_obj.get_object_reference(cr, uid, 'account', + 'view_move_form') + action['views'] = [(ref[1] if ref else False, 'form')] + action['res_id'] = move_ids[0] if move_ids else False + return action + + def action_cancel(self, cr, uid, ids, context=None): + for sale in self.browse(cr, uid, ids, context=context): + if sale.payment_ids: + raise osv.except_osv( + _('Cannot cancel this sales order!'), + _('Automatic payment entries are linked ' + 'with the sale order.')) + return super(SaleOrder, self).action_cancel( + cr, uid, ids, context=context) diff --git a/sale_view.xml b/sale_view.xml new file mode 100644 index 00000000000..a14b08e3886 --- /dev/null +++ b/sale_view.xml @@ -0,0 +1,67 @@ + + + + + sale.order.view.form + sale.order + + + + + + + + + + + + + + + + + + + sale.order.view.tree + sale.order + + + + + + + + + + sale.order.view.tree + sale.order + + + + + + + + + + + + sale.order + + + + + + + + + + diff --git a/security/ir.model.access.csv b/security/ir.model.access.csv new file mode 100644 index 00000000000..13bf2263dcc --- /dev/null +++ b/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_payment_method_user,sale_quick_payment_payment_method_user,model_payment_method,base.group_user,1,0,0,0 +access_payment_method_manager,sale_quick_payment_payment_method_manager,model_payment_method,base.group_sale_manager,1,1,1,1 diff --git a/security/rules.xml b/security/rules.xml new file mode 100644 index 00000000000..b66174aa14b --- /dev/null +++ b/security/rules.xml @@ -0,0 +1,13 @@ + + + + + + Payment method multi-company + + + ['|','|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id]),('company_id','=',False)] + + + + From 00761dad430afd5acda377511336316073cb11ff Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 13 Feb 2015 10:16:32 +0100 Subject: [PATCH 34/52] Better definition of fields Name is required, use named arguments. --- account_move.py | 3 ++- payment_method.py | 26 ++++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/account_move.py b/account_move.py index fa0f5f57cf7..291bc309211 100644 --- a/account_move.py +++ b/account_move.py @@ -24,4 +24,5 @@ class AccountMoveLine(models.Model): _inherit = 'account.move.line' - sale_ids = fields.Many2many('sale.order', string='Sales Orders') + sale_ids = fields.Many2many(comodel_name='sale.order', + string='Sales Orders') diff --git a/payment_method.py b/payment_method.py index 8ffb2e0aaab..062ee0fa097 100644 --- a/payment_method.py +++ b/payment_method.py @@ -31,20 +31,22 @@ def _default_company_id(self): company_model = self.env['res.company'] return company_model._company_default_get('payment.method') - name = fields.Char('Name', help="The name of the method on the backend") + name = fields.Char(required=True, + help="The name of the method on the backend") journal_id = fields.Many2one( - 'account.journal', - 'Journal', + comodel_name='account.journal', + string='Journal', help="If a journal a selected, when a payment is recorded " - "on a backend, payment entries will be created in this " - "journal.") + "on a backend, payment entries will be created in this " + "journal.", + ) payment_term_id = fields.Many2one( - 'account.payment.term', - 'Payment Term', - help="Default payment term of a sale order using this method.") - + comodel_name='account.payment.term', + string='Payment Term', + help="Default payment term of a sale order using this method.", + ) company_id = fields.Many2one( - 'res.company', - 'Company', - default=_default_company_id + comodel_name='res.company', + string='Company', + default=_default_company_id, ) From 7abe2060f08843d672473ab161219b4ba9102ac4 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 13 Feb 2015 10:20:38 +0100 Subject: [PATCH 35/52] Use exceptions.Warning instead of osv.except_osv --- sale.py | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/sale.py b/sale.py index 72197405f5a..2ecd11d1c83 100644 --- a/sale.py +++ b/sale.py @@ -20,7 +20,7 @@ # ############################################################################## -from openerp import osv, api, models, fields +from openerp import api, models, fields, exceptions from openerp.tools.translate import _ from collections import Iterable import openerp.addons.decimal_precision as dp @@ -99,17 +99,17 @@ def automatic_payment(self, cr, uid, ids, amount=None, context=None): sale = self.browse(cr, uid, ids, context=context) method = sale.payment_method_id if not method: - raise osv.except_osv( - _('Configuration Error'), + raise exceptions.Warning( _("An automatic payment can not be created for the sale " - "order %s because it has no payment method.") % sale.name) + "order %s because it has no payment method.") % sale.name + ) if not method.journal_id: - raise osv.except_osv( - _('Configuration Error'), + raise exceptions.Warning( _("An automatic payment should be created for the sale order" " %s but the payment method '%s' has no journal defined.") % - (sale.name, method.name)) + (sale.name, method.name) + ) journal = method.journal_id date = sale.date_order @@ -173,15 +173,11 @@ def _get_payment_move_name(self, cr, uid, journal, period, context=None): sequence = journal.sequence_id if not sequence: - raise osv.except_osv( - _('Configuration Error'), - _('Please define a sequence on the journal %s.') % - journal.name) + raise exceptions.Warning(_('Please define a sequence on the ' + 'journal %s.') % journal.name) if not sequence.active: - raise osv.except_osv( - _('Configuration Error'), - _('Please activate the sequence of the journal %s.') % - journal.name) + raise exceptions.Warning(_('Please activate the sequence of the ' + 'journal %s.') % journal.name) ctx = context.copy() ctx['fiscalyear_id'] = period.fiscalyear_id.id @@ -292,9 +288,8 @@ def action_view_payments(self, cr, uid, ids, context=None): def action_cancel(self, cr, uid, ids, context=None): for sale in self.browse(cr, uid, ids, context=context): if sale.payment_ids: - raise osv.except_osv( - _('Cannot cancel this sales order!'), - _('Automatic payment entries are linked ' - 'with the sale order.')) + raise exceptions.Warning(_('Cannot cancel this sales order ' + 'because automatic payment entries ' + 'are linked with it.')) return super(SaleOrder, self).action_cancel( cr, uid, ids, context=context) From 9ce00d017ea309cb39eb6c6bf341fb51394d853d Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 13 Feb 2015 10:23:12 +0100 Subject: [PATCH 36/52] Remove unused methods --- sale.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/sale.py b/sale.py index 2ecd11d1c83..4ddf20a6673 100644 --- a/sale.py +++ b/sale.py @@ -29,18 +29,6 @@ class SaleOrder(models.Model): _inherit = 'sale.order' - def _get_order_from_move(self, cr, uid, ids, context=None): - result = set() - move_obj = self.pool.get('account.move') - for move in move_obj.browse(cr, uid, ids, context=context): - for order in move.order_ids: - result.add(order.id) - return list(result) - - def _get_order_from_line(self, cr, uid, ids, context=None): - so_obj = self.pool.get('sale.order') - return so_obj._get_order(cr, uid, ids, context=context) - @api.one @api.depends('amount_total', 'payment_ids.credit', 'payment_ids.debit') def _get_amount(self): From 0f4dc1d50195abf1c2c3e88b932a4dd38271ed17 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 13 Feb 2015 10:50:08 +0100 Subject: [PATCH 37/52] Migrate to new API --- sale.py | 244 +++++++++++++++++++++++--------------------------------- 1 file changed, 102 insertions(+), 142 deletions(-) diff --git a/sale.py b/sale.py index 4ddf20a6673..2f808ae566f 100644 --- a/sale.py +++ b/sale.py @@ -20,9 +20,7 @@ # ############################################################################## -from openerp import api, models, fields, exceptions -from openerp.tools.translate import _ -from collections import Iterable +from openerp import api, models, fields, exceptions, _ import openerp.addons.decimal_precision as dp @@ -31,135 +29,130 @@ class SaleOrder(models.Model): @api.one @api.depends('amount_total', 'payment_ids.credit', 'payment_ids.debit') - def _get_amount(self): - paid_amount = 0 - for line in self.payment_ids: - paid_amount += line.credit - line.debit + def _compute_amount(self): + paid_amount = sum(line.credit - line.debit + for line in self.payment_ids) self.amount_paid = paid_amount self.residual = self.amount_total - paid_amount @api.one @api.depends('payment_ids') - def _payment_exists(self): + def _compute_payment_exists(self): self.payment_exists = bool(self.payment_ids) payment_ids = fields.Many2many( - 'account.move.line', - string='Payments Entries') - + comodel_name='account.move.line', + string='Payments Entries', + domain=[('account_id.type', '=', 'receivable')], + ) payment_method_id = fields.Many2one( - 'payment.method', - 'Payment Method', - ondelete='restrict') - + comodel_name='payment.method', + string='Payment Method', + ondelete='restrict', + ) residual = fields.Float( - compute=_get_amount, + compute='_compute_amount', digits_compute=dp.get_precision('Account'), string='Balance', - store=False) - + store=False, + ) amount_paid = fields.Float( - compute=_get_amount, + compute='_compute_amount', digits_compute=dp.get_precision('Account'), string='Amount Paid', - store=False) - + store=False, + ) payment_exists = fields.Boolean( - compute=_payment_exists, + compute='_compute_payment_exists', string='Has automatic payment', - help="It indicates that sales order has at least one payment.") + help="It indicates that sales order has at least one payment.", + ) - @api.one + @api.multi + def action_cancel(self): + for sale in self: + if sale.payment_ids: + raise exceptions.Warning(_('Cannot cancel this sales order ' + 'because automatic payment entries ' + 'are linked with it.')) + return super(SaleOrder, self).action_cancel() + + @api.multi def copy(self, default=None): + self.ensure_one() if default is None: default = {} - default['payment_ids'] = False + default.setdefault('payment_ids', False) return super(SaleOrder, self).copy(default=default) - def automatic_payment(self, cr, uid, ids, amount=None, context=None): + @api.multi + def automatic_payment(self, amount=None): """ Create the payment entries to pay a sale order, respecting the payment terms. If no amount is defined, it will pay the residual amount of the sale - order. """ - if isinstance(ids, Iterable): - assert len(ids) == 1, "one sale order at a time can be paid" - ids = ids[0] - sale = self.browse(cr, uid, ids, context=context) - method = sale.payment_method_id + order. + """ + self.ensure_one() + method = self.payment_method_id if not method: raise exceptions.Warning( _("An automatic payment can not be created for the sale " - "order %s because it has no payment method.") % sale.name + "order %s because it has no payment method.") % self.name ) if not method.journal_id: raise exceptions.Warning( _("An automatic payment should be created for the sale order" " %s but the payment method '%s' has no journal defined.") % - (sale.name, method.name) + (self.name, method.name) ) journal = method.journal_id - date = sale.date_order + date = self.date_order if amount is None: - amount = sale.residual - if sale.payment_term: - term_obj = self.pool.get('account.payment.term') - amounts = term_obj.compute(cr, uid, sale.payment_term.id, - amount, date_ref=date, - context=context) + amount = self.residual + if self.payment_term: + amounts = self.payment_term.compute(amount, date_ref=date) else: amounts = [(date, amount)] # reversed is cosmetic, compute returns terms in the 'wrong' order for date, amount in reversed(amounts): - self._add_payment(cr, uid, sale, journal, - amount, date, context=context) + self._add_payment(journal, amount, date) return True - def add_payment(self, cr, uid, ids, journal_id, amount, - date=None, description=None, context=None): + @api.multi + def add_payment(self, journal_id, amount, date=None, description=None): """ Generate payment move lines of a certain amount linked - with the sale order. """ - if isinstance(ids, Iterable): - assert len(ids) == 1, "one sale order at a time can be paid" - ids = ids[0] - journal_obj = self.pool.get('account.journal') - - sale = self.browse(cr, uid, ids, context=context) + with the sale order. + """ + self.ensure_one() + journal_model = self.env['account.journal'] if date is None: - date = sale.date_order - journal = journal_obj.browse(cr, uid, journal_id, context=context) - self._add_payment(cr, uid, sale, journal, amount, date, description, - context=context) + date = self.date_order + journal = journal_model.browse(journal_id) + self._add_payment(journal, amount, date, description) return True - def _add_payment(self, cr, uid, sale, journal, amount, date, - description=None, context=None): + @api.multi + def _add_payment(self, journal, amount, date, description=None): """ Generate move lines entries to pay the sale order. """ - move_obj = self.pool.get('account.move') - period_obj = self.pool.get('account.period') - period_id = period_obj.find(cr, uid, dt=date, context=context)[0] - period = period_obj.browse(cr, uid, period_id, context=context) - move_name = description or self._get_payment_move_name( - cr, uid, journal, - period, context=context) - move_vals = self._prepare_payment_move(cr, uid, move_name, sale, - journal, period, date, - context=context) - move_lines = self._prepare_payment_move_line(cr, uid, move_name, sale, - journal, period, amount, - date, context=context) + move_model = self.env['account.move'] + period_model = self.env['account.period'] + period_id = period_model.find(dt=date) + period = period_model.browse(period_id) + move_name = description or self._get_payment_move_name(journal, period) + move_vals = self._prepare_payment_move(move_name, journal, + period, date) + move_lines = self._prepare_payment_move_line(move_name, journal, + period, amount, date) move_vals['line_id'] = [(0, 0, line) for line in move_lines] - move_obj.create(cr, uid, move_vals, context=context) + move_model.create(move_vals) - def _get_payment_move_name(self, cr, uid, journal, period, context=None): - if context is None: - context = {} - seq_obj = self.pool.get('ir.sequence') + @api.model + def _get_payment_move_name(self, journal, period): sequence = journal.sequence_id - if not sequence: raise exceptions.Warning(_('Please define a sequence on the ' 'journal %s.') % journal.name) @@ -167,38 +160,30 @@ def _get_payment_move_name(self, cr, uid, journal, period, context=None): raise exceptions.Warning(_('Please activate the sequence of the ' 'journal %s.') % journal.name) - ctx = context.copy() - ctx['fiscalyear_id'] = period.fiscalyear_id.id - name = seq_obj.next_by_id(cr, uid, sequence.id, context=ctx) + sequence = sequence.with_context(fiscalyear_id=period.fiscalyear_id.id) + name = sequence.next_by_id() return name - def _prepare_payment_move(self, cr, uid, move_name, sale, journal, - period, date, context=None): + @api.multi + def _prepare_payment_move(self, move_name, journal, period, date): return {'name': move_name, 'journal_id': journal.id, 'date': date, - 'ref': sale.name, + 'ref': self.name, 'period_id': period.id, } - def _prepare_payment_move_line(self, cr, uid, move_name, sale, journal, - period, amount, date, context=None): - """ """ - partner_obj = self.pool.get('res.partner') - currency_obj = self.pool.get('res.currency') - partner = partner_obj._find_accounting_partner(sale.partner_id) - + @api.multi + def _prepare_payment_move_line(self, move_name, journal, period, + amount, date): + partner = self.partner_id.commercial_partner_id company = journal.company_id - currency_id = False + currency = False amount_currency = 0.0 - if journal.currency and journal.currency.id != company.currency_id.id: - currency_id = journal.currency.id - company_amount = currency_obj.compute(cr, uid, - currency_id, - company.currency_id.id, - amount, - context=context) + if journal.currency and journal.currency != company.currency_id: + currency = journal.currency + company_amount = currency.compute(amount, company.currency_id) amount_currency, amount = amount, company_amount # payment line (bank / cash) @@ -212,7 +197,7 @@ def _prepare_payment_move_line(self, cr, uid, move_name, sale, journal, 'partner_id': partner.id, 'date': date, 'amount_currency': amount_currency, - 'currency_id': currency_id, + 'currency_id': currency.id, } # payment line (receivable) @@ -226,58 +211,33 @@ def _prepare_payment_move_line(self, cr, uid, move_name, sale, journal, 'partner_id': partner.id, 'date': date, 'amount_currency': -amount_currency, - 'currency_id': currency_id, - 'sale_ids': [(4, sale.id)], + 'currency_id': currency.id, + 'sale_ids': [(4, self.id)], } return debit_line, credit_line - def onchange_payment_method_id(self, cr, uid, ids, payment_method_id, - context=None): - if not payment_method_id: + @api.onchange('payment_method_id') + def onchange_payment_method_id_set_payment_term(self): + if not self.payment_method_id: return {} - result = {} - method_obj = self.pool.get('payment.method') - method = method_obj.browse(cr, uid, payment_method_id, context=context) + method = self.payment_method_id if method.payment_term_id: - result['payment_term'] = method.payment_term_id.id - return {'value': result} + self.payment_term = method.payment_term_id.id - def action_view_payments(self, cr, uid, ids, context=None): + @api.multi + def action_view_payments(self): """ Return an action to display the payment linked with the sale order """ + self.ensure_one() - mod_obj = self.pool.get('ir.model.data') - act_obj = self.pool.get('ir.actions.act_window') - - move_ids = set() - for so in self.browse(cr, uid, ids, context=context): - # payment_ids are move lines, we want to display the moves - move_ids |= set([move_line.move_id.id for move_line - in so.payment_ids]) - move_ids = list(move_ids) - - ref = mod_obj.get_object_reference(cr, uid, 'account', - 'action_move_journal_line') - action_id = False - if ref: - __, action_id = ref - action = act_obj.read(cr, uid, [action_id], context=context)[0] + moves = self.mapped('payment_ids.move_id') - # choose the view_mode accordingly - if len(move_ids) > 1: - action['domain'] = str([('id', 'in', move_ids)]) + xmlid = ('account', 'action_move_journal_line') + action = self.env['ir.actions.act_window'].for_xml_id(*xmlid) + if len(moves) > 1: + action['domain'] = str([('id', 'in', moves.ids)]) else: - ref = mod_obj.get_object_reference(cr, uid, 'account', - 'view_move_form') - action['views'] = [(ref[1] if ref else False, 'form')] - action['res_id'] = move_ids[0] if move_ids else False + ref = self.env.ref('account.view_move_form') + action['views'] = [(ref.id, 'form')] + action['res_id'] = moves.ids or False return action - - def action_cancel(self, cr, uid, ids, context=None): - for sale in self.browse(cr, uid, ids, context=context): - if sale.payment_ids: - raise exceptions.Warning(_('Cannot cancel this sales order ' - 'because automatic payment entries ' - 'are linked with it.')) - return super(SaleOrder, self).action_cancel( - cr, uid, ids, context=context) From f58cbfb9d21bf91fc491273b7fa35ce5fa0d8578 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 13 Feb 2015 11:09:58 +0100 Subject: [PATCH 38/52] Add Readme --- README.rst | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++ __openerp__.py | 14 +----------- 2 files changed, 62 insertions(+), 13 deletions(-) create mode 100644 README.rst diff --git a/README.rst b/README.rst new file mode 100644 index 00000000000..516fce7cad3 --- /dev/null +++ b/README.rst @@ -0,0 +1,61 @@ +Sale Payment Method +=================== + +It adds a payment method on the sales orders and allow to register +payments entries on sales orders. + +This module is low level and works well with the following modules: +* **Sale Automatic Worflow** and **Sale Payment Method - Automatic Workflow** + the payments created with this module will be automatically reconciled + with the invoices of the sales orders. +* Sale Quick Payment: allows to create the payments with a button on the + sales orders. + +Also, the e-commerce connectors such as the **Magento Connector** or +**Prestashop Connector** use it to create the external payments. + +Installation +============ + +Nothing special is required. + +Configuration +============= + +The payment methods can be configured in **Sales > Configuration > +Sales > Payment Methods**. + +Usage +===== + +A new field on sales orders allow to select the payment method used on +this sales order. + +Known issues / Roadmap +====================== + + * It accepts only one method per sale order. + +Credits +======= + +Contributors +------------ + +* Guewen Baconnier +* Sébastien Beau +* Arthur Vuillard +* Jan-Philipp Fischer + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. diff --git a/__openerp__.py b/__openerp__.py index 68fc8cb8db4..76f3908a868 100644 --- a/__openerp__.py +++ b/__openerp__.py @@ -24,18 +24,6 @@ 'version': '0.2.1', 'category': 'Generic Modules/Others', 'license': 'AGPL-3', - 'description': """ -Sale Payment Method -=================== - -This module adds low-level features used for instance by modules: - -- Sale Automatic Workflow -- Sale Quick Payment - -It adds a payment method on the sales orders and allow to register -payments entries on sales orders. -""", 'author': "Akretion,Odoo Community Association (OCA)", 'website': 'http://www.akretion.com/', 'depends': ['sale', @@ -47,4 +35,4 @@ ], 'demo': [], 'installable': True, -} + } From 7995dd0039e0d493a6970a34564adc04f8b86721 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 13 Feb 2015 11:14:09 +0100 Subject: [PATCH 39/52] Move the field payment_method in 'Other Informations' The page automation_information is now created in sale_automatic_workflow the field will be moved in this tab when the other module is installed (with a link module) --- sale_view.xml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/sale_view.xml b/sale_view.xml index a14b08e3886..e45cbbb8fa0 100644 --- a/sale_view.xml +++ b/sale_view.xml @@ -6,14 +6,10 @@ sale.order - - - - - - - + + + + From d66b8495cc35359a54d31b90e73fb6d17d5f2d33 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 13 Feb 2015 11:59:03 +0100 Subject: [PATCH 40/52] Corrections after tests with erppeek --- sale.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/sale.py b/sale.py index 2f808ae566f..689a171851c 100644 --- a/sale.py +++ b/sale.py @@ -108,11 +108,11 @@ def automatic_payment(self, amount=None): ) journal = method.journal_id - date = self.date_order + date = self.date_order[:10] if amount is None: amount = self.residual if self.payment_term: - amounts = self.payment_term.compute(amount, date_ref=date) + amounts = self.payment_term.compute(amount, date_ref=date)[0] else: amounts = [(date, amount)] @@ -139,8 +139,7 @@ def _add_payment(self, journal, amount, date, description=None): """ Generate move lines entries to pay the sale order. """ move_model = self.env['account.move'] period_model = self.env['account.period'] - period_id = period_model.find(dt=date) - period = period_model.browse(period_id) + period = period_model.find(dt=date) move_name = description or self._get_payment_move_name(journal, period) move_vals = self._prepare_payment_move(move_name, journal, period, date) @@ -161,7 +160,11 @@ def _get_payment_move_name(self, journal, period): 'journal %s.') % journal.name) sequence = sequence.with_context(fiscalyear_id=period.fiscalyear_id.id) - name = sequence.next_by_id() + # next_by_id not compatible with new api + sequence_model = self.pool['ir.sequence'] + name = sequence_model.next_by_id(self.env.cr, self.env.uid, + sequence.id, + context=self.env.context) return name @api.multi @@ -179,7 +182,7 @@ def _prepare_payment_move_line(self, move_name, journal, period, partner = self.partner_id.commercial_partner_id company = journal.company_id - currency = False + currency = self.env['res.currency'].browse() amount_currency = 0.0 if journal.currency and journal.currency != company.currency_id: currency = journal.currency @@ -239,5 +242,5 @@ def action_view_payments(self): else: ref = self.env.ref('account.view_move_form') action['views'] = [(ref.id, 'form')] - action['res_id'] = moves.ids or False + action['res_id'] = moves.id if moves else False return action From f5dc40c663f1e9a5a25fb1fed61fe5b189884034 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 13 Feb 2015 14:50:17 +0100 Subject: [PATCH 41/52] Fix pep8 in __openerp__ --- __openerp__.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/__openerp__.py b/__openerp__.py index 76f3908a868..d450a48cd6f 100644 --- a/__openerp__.py +++ b/__openerp__.py @@ -19,20 +19,19 @@ # ############################################################################## -{ - 'name': 'Sale Payment Method', - 'version': '0.2.1', - 'category': 'Generic Modules/Others', - 'license': 'AGPL-3', - 'author': "Akretion,Odoo Community Association (OCA)", - 'website': 'http://www.akretion.com/', - 'depends': ['sale', - ], - 'data': ['sale_view.xml', - 'payment_method_view.xml', - 'security/ir.model.access.csv', - 'security/rules.xml', +{'name': 'Sale Payment Method', + 'version': '0.2.1', + 'category': 'Generic Modules/Others', + 'license': 'AGPL-3', + 'author': "Akretion,Odoo Community Association (OCA)", + 'website': 'http://www.akretion.com/', + 'depends': ['sale', ], - 'demo': [], - 'installable': True, + 'data': ['sale_view.xml', + 'payment_method_view.xml', + 'security/ir.model.access.csv', + 'security/rules.xml', + ], + 'demo': [], + 'installable': True, } From 226a174869867cf77a4a5f412484be294fd3f15b Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Fri, 13 Feb 2015 14:57:29 +0100 Subject: [PATCH 42/52] Update translations --- i18n/fr.po | 204 +++++++++++++++++++++++------------ i18n/sale_payment_method.pot | 145 ++++++++++++++++--------- 2 files changed, 232 insertions(+), 117 deletions(-) diff --git a/i18n/fr.po b/i18n/fr.po index 5c156c737af..00e9940398a 100644 --- a/i18n/fr.po +++ b/i18n/fr.po @@ -1,56 +1,102 @@ # Translation of OpenERP Server. # This file contains the translation of the following modules: -# * sale_payment_method +# * sale_payment_method # msgid "" msgstr "" "Project-Id-Version: OpenERP Server 7.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-05-02 07:06+0000\n" +"POT-Creation-Date: 2015-02-13 13:51+0000\n" "PO-Revision-Date: 2013-05-02 07:06+0000\n" "Last-Translator: <>\n" "Language-Team: \n" +"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" #. module: sale_payment_method -#: view:sale.order:0 -msgid "Automation Information" -msgstr "Informations d'automatisation" +#: code:addons/sale_payment_method/sale.py:99 +#, python-format +msgid "" +"An automatic payment can not be created for the sale order %s because it has " +"no payment method." +msgstr "Aucun paiement automatique ne peut être créé pour la commande %s parce " +"qu'elle n'a pas de méthode de paiement." #. module: sale_payment_method -#: help:payment.method,journal_id:0 -msgid "If a journal a selected, when a payment is recorded on a backend, payment entries will be created in this journal. " -msgstr "Si un journal est sélectionné, lorsqu'un paiement est enregistré sur le backend, des lignes de paiement seront générées dans ce journal." +#: code:addons/sale_payment_method/sale.py:105 +#, python-format +msgid "" +"An automatic payment should be created for the sale order %s but the payment " +"method '%s' has no journal defined." +msgstr "Un paiement automatique doit être généré pour la commande %s mais la " +"méthode de paiement '%s' n'a aucun journal séléctionné." #. module: sale_payment_method -#: view:payment.method:0 -msgid "Even if the E-commerce backend receives a payment for a sale order,\n" -" no payment entries will be generated." -msgstr "Même si le backend e-commerce reçoit un payment pour un bon de commande, aucune ligne de paiement ne sera générée." +#: code:addons/sale_payment_method/sale.py:75 +#, python-format +msgid "" +"Cannot cancel this sales order because automatic payment entries are linked " +"with it." +msgstr "Impossible d'annuler cette commande parce que des paiement automatiques " +"y sont liés." + +#. module: sale_payment_method +#: view:payment.method:sale_payment_method.payment_method_view_form +#: field:payment.method,company_id:0 +msgid "Company" +msgstr "Société" + +#. module: sale_payment_method +#: view:sale.order:sale_payment_method.sale_order_view_form +msgid "Create Invoice" +msgstr "Créer la facture" #. module: sale_payment_method -#: view:payment.method:0 +#: field:payment.method,create_uid:0 +msgid "Created by" +msgstr "" + +#. module: sale_payment_method +#: field:payment.method,create_date:0 +msgid "Created on" +msgstr "" + +#. module: sale_payment_method +#: view:payment.method:sale_payment_method.payment_method_view_form msgid "Default Values" msgstr "Valeurs par défaut" #. module: sale_payment_method -#: model:ir.model,name:sale_payment_method.model_payment_method -#: field:sale.order,payment_method_id:0 -msgid "Payment Method" -msgstr "Méthode de paiement" +#: help:payment.method,payment_term_id:0 +msgid "Default payment term of a sale order using this method." +msgstr "" +"Condition de règlement par défaut pour les commandes utilisant cette méthode." #. module: sale_payment_method -#: view:sale.order:0 -msgid "View Automatic Payment" -msgstr "Voir les paiements automatiques" +#: view:payment.method:sale_payment_method.payment_method_view_form +msgid "" +"Even if the E-commerce backend receives a payment for a sale order,\n" +" no payment entries will be generated." +msgstr "" +"Même si le backend e-commerce reçoit un payment pour un bon de commande, " +"aucune ligne de paiement ne sera générée." #. module: sale_payment_method -#: help:sale.order,payment_exists:0 -msgid "It indicates that sales order has at least one payment." -msgstr "Indique que la commande a reçu au moins un paiement." +#: field:payment.method,id:0 +msgid "ID" +msgstr "" + +#. module: sale_payment_method +#: help:payment.method,journal_id:0 +msgid "" +"If a journal a selected, when a payment is recorded on a backend, payment " +"entries will be created in this journal." +msgstr "" +"Si un journal est sélectionné, lorsqu'un paiement est enregistré sur le " +"backend, des lignes de paiement seront générées dans ce journal." #. module: sale_payment_method #: field:payment.method,journal_id:0 @@ -58,25 +104,24 @@ msgid "Journal" msgstr "Journal" #. module: sale_payment_method -#: model:ir.actions.act_window,name:sale_payment_method.act_payment_method_form -#: model:ir.ui.menu,name:sale_payment_method.menu_action_paymetn_method_form -msgid "Payment Methods " -msgstr "Méthodes de paiement" +#: model:ir.model,name:sale_payment_method.model_account_move_line +msgid "Journal Items" +msgstr "Pièces comptables" #. module: sale_payment_method -#: field:account.move,order_ids:0 -msgid "Sales Orders" -msgstr "Bons de commande" +#: view:payment.method:sale_payment_method.payment_method_view_form +msgid "Journal for payment" +msgstr "Journal pour le paiement" #. module: sale_payment_method -#: view:sale.order:0 -msgid "Other Information" -msgstr "Autres informations" +#: field:payment.method,write_uid:0 +msgid "Last Updated by" +msgstr "" #. module: sale_payment_method -#: view:payment.method:0 -msgid "Payment Methods" -msgstr "Méthodes de paiement" +#: field:payment.method,write_date:0 +msgid "Last Updated on" +msgstr "" #. module: sale_payment_method #: field:payment.method,name:0 @@ -84,46 +129,59 @@ msgid "Name" msgstr "Nom" #. module: sale_payment_method -#: field:sale.order,payment_ids:0 -msgid "Payments Entries" -msgstr "Écritures de paiement" +#: view:sale.order:sale_payment_method.view_sales_order_filter +msgid "Order With Payment" +msgstr "Commande avec paiement" #. module: sale_payment_method -#: view:payment.method:0 -msgid "When the E-commerce backend will receive a payment for a sale order,\n" -" payment entries will be generated in the selected journal." -msgstr "Lorsque le backend e-commerce reçoit un paiement pour la commande,\n" -" des écritures de paiement sont générées dans le journal sélectionné." +#: model:ir.model,name:sale_payment_method.model_payment_method +#: field:sale.order,payment_method_id:0 +msgid "Payment Method" +msgstr "Méthode de paiement" #. module: sale_payment_method -#: view:payment.method:0 -msgid "Journal for payment" -msgstr "Journal pour le paiement" +#: view:payment.method:sale_payment_method.payment_method_view_form +#: view:payment.method:sale_payment_method.payment_method_view_tree +msgid "Payment Methods" +msgstr "Méthodes de paiement" #. module: sale_payment_method -#: field:sale.order,residual:0 -msgid "Balance" -msgstr "Solde" +#: model:ir.actions.act_window,name:sale_payment_method.act_payment_method_form +#: model:ir.ui.menu,name:sale_payment_method.menu_action_paymetn_method_form +msgid "Payment Methods " +msgstr "Méthodes de paiement" #. module: sale_payment_method -#: model:ir.model,name:sale_payment_method.model_account_move -msgid "Account Entry" -msgstr "Ecriture" +#: field:payment.method,payment_term_id:0 +msgid "Payment Term" +msgstr "Condition de règlement" #. module: sale_payment_method -#: help:payment.method,payment_term_id:0 -msgid "Default payment term of a sale order using this method." -msgstr "Condition de règlement par défaut pour les commandes utilisant cette méthode." +#: field:sale.order,payment_ids:0 +msgid "Payments Entries" +msgstr "Écritures de paiement" #. module: sale_payment_method -#: field:payment.method,payment_term_id:0 -msgid "Payment Term" -msgstr "Condition de règlement" +#: code:addons/sale_payment_method/sale.py:159 +#, python-format +msgid "Please activate the sequence of the journal %s." +msgstr "Veuillez activer la séquence sur le journal %s." #. module: sale_payment_method -#: view:sale.order:0 -msgid "Create Invoice" -msgstr "Créer la facture" +#: code:addons/sale_payment_method/sale.py:156 +#, python-format +msgid "Please define a sequence on the journal %s." +msgstr "Veuillez définir une séquence sur le journal %s." + +#. module: sale_payment_method +#: model:ir.model,name:sale_payment_method.model_sale_order +msgid "Sales Order" +msgstr "Bon de commande" + +#. module: sale_payment_method +#: field:account.move.line,sale_ids:0 +msgid "Sales Orders" +msgstr "Bons de commande" #. module: sale_payment_method #: help:payment.method,name:0 @@ -131,12 +189,22 @@ msgid "The name of the method on the backend" msgstr "Nom de la méthode sur le backend" #. module: sale_payment_method -#: model:ir.model,name:sale_payment_method.model_sale_order -msgid "Sales Order" -msgstr "Bon de commande" +#: view:sale.order:sale_payment_method.sale_order_view_form +msgid "View Automatic Payment" +msgstr "Voir les paiements automatiques" #. module: sale_payment_method -#: field:sale.order,payment_exists:0 -msgid "Has automatic payment" -msgstr "A un paiement automatique" +#: view:payment.method:sale_payment_method.payment_method_view_form +msgid "" +"When the E-commerce backend will receive a payment for a sale order,\n" +" payment entries will be generated in the " +"selected journal." +msgstr "" +"Lorsque le backend e-commerce reçoit un paiement pour la commande,\n" +" des écritures de paiement sont générées dans " +"le journal sélectionné." +#. module: sale_payment_method +#: view:sale.order:sale_payment_method.view_sales_order_filter +msgid "With Payment" +msgstr "Avec paiement" diff --git a/i18n/sale_payment_method.pot b/i18n/sale_payment_method.pot index ef54c2b57de..5fbcd185f80 100644 --- a/i18n/sale_payment_method.pot +++ b/i18n/sale_payment_method.pot @@ -1,13 +1,13 @@ -# Translation of OpenERP Server. +# Translation of Odoo Server. # This file contains the translation of the following modules: # * sale_payment_method # msgid "" msgstr "" -"Project-Id-Version: OpenERP Server 7.0\n" +"Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-05-02 07:06+0000\n" -"PO-Revision-Date: 2013-05-02 07:06+0000\n" +"POT-Creation-Date: 2015-02-13 13:51+0000\n" +"PO-Revision-Date: 2015-02-13 13:51+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -16,40 +16,68 @@ msgstr "" "Plural-Forms: \n" #. module: sale_payment_method -#: view:sale.order:0 -msgid "Automation Information" +#: code:addons/sale_payment_method/sale.py:99 +#, python-format +msgid "An automatic payment can not be created for the sale order %s because it has no payment method." msgstr "" #. module: sale_payment_method -#: help:payment.method,journal_id:0 -msgid "If a journal a selected, when a payment is recorded on a backend, payment entries will be created in this journal. " +#: code:addons/sale_payment_method/sale.py:105 +#, python-format +msgid "An automatic payment should be created for the sale order %s but the payment method '%s' has no journal defined." msgstr "" #. module: sale_payment_method -#: view:payment.method:0 -msgid "Even if the E-commerce backend receives a payment for a sale order,\n" -" no payment entries will be generated." +#: code:addons/sale_payment_method/sale.py:75 +#, python-format +msgid "Cannot cancel this sales order because automatic payment entries are linked with it." +msgstr "" + +#. module: sale_payment_method +#: view:payment.method:sale_payment_method.payment_method_view_form +#: field:payment.method,company_id:0 +msgid "Company" +msgstr "" + +#. module: sale_payment_method +#: view:sale.order:sale_payment_method.sale_order_view_form +msgid "Create Invoice" msgstr "" #. module: sale_payment_method -#: view:payment.method:0 +#: field:payment.method,create_uid:0 +msgid "Created by" +msgstr "" + +#. module: sale_payment_method +#: field:payment.method,create_date:0 +msgid "Created on" +msgstr "" + +#. module: sale_payment_method +#: view:payment.method:sale_payment_method.payment_method_view_form msgid "Default Values" msgstr "" #. module: sale_payment_method -#: model:ir.model,name:sale_payment_method.model_payment_method -#: field:sale.order,payment_method_id:0 -msgid "Payment Method" +#: help:payment.method,payment_term_id:0 +msgid "Default payment term of a sale order using this method." msgstr "" #. module: sale_payment_method -#: view:sale.order:0 -msgid "View Automatic Payment" +#: view:payment.method:sale_payment_method.payment_method_view_form +msgid "Even if the E-commerce backend receives a payment for a sale order,\n" +" no payment entries will be generated." +msgstr "" + +#. module: sale_payment_method +#: field:payment.method,id:0 +msgid "ID" msgstr "" #. module: sale_payment_method -#: help:sale.order,payment_exists:0 -msgid "It indicates that sales order has at least one payment." +#: help:payment.method,journal_id:0 +msgid "If a journal a selected, when a payment is recorded on a backend, payment entries will be created in this journal." msgstr "" #. module: sale_payment_method @@ -58,24 +86,23 @@ msgid "Journal" msgstr "" #. module: sale_payment_method -#: model:ir.actions.act_window,name:sale_payment_method.act_payment_method_form -#: model:ir.ui.menu,name:sale_payment_method.menu_action_paymetn_method_form -msgid "Payment Methods " +#: model:ir.model,name:sale_payment_method.model_account_move_line +msgid "Journal Items" msgstr "" #. module: sale_payment_method -#: field:account.move,order_ids:0 -msgid "Sales Orders" +#: view:payment.method:sale_payment_method.payment_method_view_form +msgid "Journal for payment" msgstr "" #. module: sale_payment_method -#: view:sale.order:0 -msgid "Other Information" +#: field:payment.method,write_uid:0 +msgid "Last Updated by" msgstr "" #. module: sale_payment_method -#: view:payment.method:0 -msgid "Payment Methods" +#: field:payment.method,write_date:0 +msgid "Last Updated on" msgstr "" #. module: sale_payment_method @@ -84,44 +111,58 @@ msgid "Name" msgstr "" #. module: sale_payment_method -#: field:sale.order,payment_ids:0 -msgid "Payments Entries" +#: view:sale.order:sale_payment_method.view_sales_order_filter +msgid "Order With Payment" msgstr "" #. module: sale_payment_method -#: view:payment.method:0 -msgid "When the E-commerce backend will receive a payment for a sale order,\n" -" payment entries will be generated in the selected journal." +#: model:ir.model,name:sale_payment_method.model_payment_method +#: field:sale.order,payment_method_id:0 +msgid "Payment Method" msgstr "" #. module: sale_payment_method -#: view:payment.method:0 -msgid "Journal for payment" +#: view:payment.method:sale_payment_method.payment_method_view_form +#: view:payment.method:sale_payment_method.payment_method_view_tree +msgid "Payment Methods" msgstr "" #. module: sale_payment_method -#: field:sale.order,residual:0 -msgid "Balance" +#: model:ir.actions.act_window,name:sale_payment_method.act_payment_method_form +#: model:ir.ui.menu,name:sale_payment_method.menu_action_paymetn_method_form +msgid "Payment Methods " msgstr "" #. module: sale_payment_method -#: model:ir.model,name:sale_payment_method.model_account_move -msgid "Account Entry" +#: field:payment.method,payment_term_id:0 +msgid "Payment Term" msgstr "" #. module: sale_payment_method -#: help:payment.method,payment_term_id:0 -msgid "Default payment term of a sale order using this method." +#: field:sale.order,payment_ids:0 +msgid "Payments Entries" msgstr "" #. module: sale_payment_method -#: field:payment.method,payment_term_id:0 -msgid "Payment Term" +#: code:addons/sale_payment_method/sale.py:159 +#, python-format +msgid "Please activate the sequence of the journal %s." msgstr "" #. module: sale_payment_method -#: view:sale.order:0 -msgid "Create Invoice" +#: code:addons/sale_payment_method/sale.py:156 +#, python-format +msgid "Please define a sequence on the journal %s." +msgstr "" + +#. module: sale_payment_method +#: model:ir.model,name:sale_payment_method.model_sale_order +msgid "Sales Order" +msgstr "" + +#. module: sale_payment_method +#: field:account.move.line,sale_ids:0 +msgid "Sales Orders" msgstr "" #. module: sale_payment_method @@ -130,12 +171,18 @@ msgid "The name of the method on the backend" msgstr "" #. module: sale_payment_method -#: model:ir.model,name:sale_payment_method.model_sale_order -msgid "Sales Order" +#: view:sale.order:sale_payment_method.sale_order_view_form +msgid "View Automatic Payment" +msgstr "" + +#. module: sale_payment_method +#: view:payment.method:sale_payment_method.payment_method_view_form +msgid "When the E-commerce backend will receive a payment for a sale order,\n" +" payment entries will be generated in the selected journal." msgstr "" #. module: sale_payment_method -#: field:sale.order,payment_exists:0 -msgid "Has automatic payment" +#: view:sale.order:sale_payment_method.view_sales_order_filter +msgid "With Payment" msgstr "" From 5aea69d4ab8256afa54c037e09d2f9c04cc55d15 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Thu, 19 Feb 2015 08:03:01 +0100 Subject: [PATCH 43/52] Typo in a help message --- i18n/es.po | 2 +- i18n/fr.po | 2 +- i18n/sale_payment_method.pot | 2 +- payment_method.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/i18n/es.po b/i18n/es.po index 25bed888626..04e22014ebe 100644 --- a/i18n/es.po +++ b/i18n/es.po @@ -22,7 +22,7 @@ msgstr "Información Automática" #. module: sale_payment_method #: help:payment.method,journal_id:0 -msgid "If a journal a selected, when a payment is recorded on a backend, payment entries will be created in this journal. " +msgid "If a journal is selected, when a payment is recorded on a backend, payment entries will be created in this journal. " msgstr "Si un diario es sleccionado, cuando un pago es registrado en el backend, las entradas de los pagos serán creadas en ese diario" #. module: sale_payment_method diff --git a/i18n/fr.po b/i18n/fr.po index 00e9940398a..a554e06574b 100644 --- a/i18n/fr.po +++ b/i18n/fr.po @@ -92,7 +92,7 @@ msgstr "" #. module: sale_payment_method #: help:payment.method,journal_id:0 msgid "" -"If a journal a selected, when a payment is recorded on a backend, payment " +"If a journal is selected, when a payment is recorded on a backend, payment " "entries will be created in this journal." msgstr "" "Si un journal est sélectionné, lorsqu'un paiement est enregistré sur le " diff --git a/i18n/sale_payment_method.pot b/i18n/sale_payment_method.pot index 5fbcd185f80..71ea66b516c 100644 --- a/i18n/sale_payment_method.pot +++ b/i18n/sale_payment_method.pot @@ -77,7 +77,7 @@ msgstr "" #. module: sale_payment_method #: help:payment.method,journal_id:0 -msgid "If a journal a selected, when a payment is recorded on a backend, payment entries will be created in this journal." +msgid "If a journal is selected, when a payment is recorded on a backend, payment entries will be created in this journal." msgstr "" #. module: sale_payment_method diff --git a/payment_method.py b/payment_method.py index 062ee0fa097..7de13940841 100644 --- a/payment_method.py +++ b/payment_method.py @@ -36,7 +36,7 @@ def _default_company_id(self): journal_id = fields.Many2one( comodel_name='account.journal', string='Journal', - help="If a journal a selected, when a payment is recorded " + help="If a journal is selected, when a payment is recorded " "on a backend, payment entries will be created in this " "journal.", ) From 0e30a2c3d00efad066ef5abd5b5226bf3639b14c Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Thu, 19 Feb 2015 08:21:43 +0100 Subject: [PATCH 44/52] Method returns 2 move lines, add a final 's' Keep the original method with a deprecation warning to help people eventually inheriting this method to not lose their minds when migrating their code. --- sale.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sale.py b/sale.py index 689a171851c..9f8dd7393c2 100644 --- a/sale.py +++ b/sale.py @@ -20,9 +20,12 @@ # ############################################################################## +import logging from openerp import api, models, fields, exceptions, _ import openerp.addons.decimal_precision as dp +_logger = logging.getLogger(__name__) + class SaleOrder(models.Model): _inherit = 'sale.order' @@ -143,8 +146,8 @@ def _add_payment(self, journal, amount, date, description=None): move_name = description or self._get_payment_move_name(journal, period) move_vals = self._prepare_payment_move(move_name, journal, period, date) - move_lines = self._prepare_payment_move_line(move_name, journal, - period, amount, date) + move_lines = self._prepare_payment_move_lines(move_name, journal, + period, amount, date) move_vals['line_id'] = [(0, 0, line) for line in move_lines] move_model.create(move_vals) @@ -179,6 +182,15 @@ def _prepare_payment_move(self, move_name, journal, period, date): @api.multi def _prepare_payment_move_line(self, move_name, journal, period, amount, date): + # to remove in v9 + _logger.warning('Deprecated: _prepare_payment_move_line has been ' + 'deprecated in favor of _prepare_payment_move_lines') + return self._prepare_payment_move_lines(move_name, journal, period, + amount, date) + + @api.multi + def _prepare_payment_move_lines(self, move_name, journal, period, + amount, date): partner = self.partner_id.commercial_partner_id company = journal.company_id From dc4d96b66269ea4ad6502bc1c3850cc56849d182 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Thu, 12 Mar 2015 11:20:18 +0100 Subject: [PATCH 45/52] Useless dict returned --- sale.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sale.py b/sale.py index 9f8dd7393c2..9d0cb3d15f2 100644 --- a/sale.py +++ b/sale.py @@ -234,7 +234,7 @@ def _prepare_payment_move_lines(self, move_name, journal, period, @api.onchange('payment_method_id') def onchange_payment_method_id_set_payment_term(self): if not self.payment_method_id: - return {} + return method = self.payment_method_id if method.payment_term_id: self.payment_term = method.payment_term_id.id From 9b459c12e40ecd3f29d4100bb7b5564c8dd4ec11 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Thu, 12 Mar 2015 11:21:03 +0100 Subject: [PATCH 46/52] str() not needed --- sale.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sale.py b/sale.py index 9d0cb3d15f2..e0d7e238c7e 100644 --- a/sale.py +++ b/sale.py @@ -250,7 +250,7 @@ def action_view_payments(self): xmlid = ('account', 'action_move_journal_line') action = self.env['ir.actions.act_window'].for_xml_id(*xmlid) if len(moves) > 1: - action['domain'] = str([('id', 'in', moves.ids)]) + action['domain'] = [('id', 'in', moves.ids)] else: ref = self.env.ref('account.view_move_form') action['views'] = [(ref.id, 'form')] From da7669c9e3468c2aa856cacdf3daa6ab1374764a Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Thu, 12 Mar 2015 11:26:11 +0100 Subject: [PATCH 47/52] Add comments on the currency conversion --- sale.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sale.py b/sale.py index e0d7e238c7e..a0a693ffd42 100644 --- a/sale.py +++ b/sale.py @@ -195,8 +195,13 @@ def _prepare_payment_move_lines(self, move_name, journal, period, company = journal.company_id currency = self.env['res.currency'].browse() + # if the lines are not in a different currency, + # the amount_currency stays at 0.0 amount_currency = 0.0 if journal.currency and journal.currency != company.currency_id: + # when the journal have a currency, we have to convert + # the amount to the currency of the company and set + # the journal's currency on the lines currency = journal.currency company_amount = currency.compute(amount, company.currency_id) amount_currency, amount = amount, company_amount From 1388143a469b73b636c620bbd57dcaf3bd2c5378 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Thu, 12 Mar 2015 11:28:43 +0100 Subject: [PATCH 48/52] Use copy=False on the field rather than copy method --- sale.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/sale.py b/sale.py index a0a693ffd42..b32874213e6 100644 --- a/sale.py +++ b/sale.py @@ -47,6 +47,7 @@ def _compute_payment_exists(self): comodel_name='account.move.line', string='Payments Entries', domain=[('account_id.type', '=', 'receivable')], + copy=False, ) payment_method_id = fields.Many2one( comodel_name='payment.method', @@ -80,14 +81,6 @@ def action_cancel(self): 'are linked with it.')) return super(SaleOrder, self).action_cancel() - @api.multi - def copy(self, default=None): - self.ensure_one() - if default is None: - default = {} - default.setdefault('payment_ids', False) - return super(SaleOrder, self).copy(default=default) - @api.multi def automatic_payment(self, amount=None): """ Create the payment entries to pay a sale order, respecting From 1469e5231bd4e18b5228316ff1b91bf7d47208f5 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Mon, 23 Mar 2015 09:15:34 +0100 Subject: [PATCH 49/52] Remove the field sale_order.payment_exists The computed field was used to hide the button 'View Automatic Payment' when the sales order has at least one payment. It is now using only a condition on payment_ids, thanks to @hbrunn for the correct definition: [('payment_ids', '=', [[6, False, []]])] --- i18n/es.po | 5 ----- sale.py | 10 ---------- sale_view.xml | 4 ++-- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/i18n/es.po b/i18n/es.po index 04e22014ebe..a6f6fff34c2 100644 --- a/i18n/es.po +++ b/i18n/es.po @@ -48,11 +48,6 @@ msgstr "Método de pago" msgid "View Automatic Payment" msgstr "Ver Pago Automático" -#. module: sale_payment_method -#: help:sale.order,payment_exists:0 -msgid "It indicates that sales order has at least one payment." -msgstr "Esto indica que el pedido de venta tiene al menos un pago." - #. module: sale_payment_method #: field:payment.method,journal_id:0 msgid "Journal" diff --git a/sale.py b/sale.py index b32874213e6..1e0f88ff30a 100644 --- a/sale.py +++ b/sale.py @@ -38,11 +38,6 @@ def _compute_amount(self): self.amount_paid = paid_amount self.residual = self.amount_total - paid_amount - @api.one - @api.depends('payment_ids') - def _compute_payment_exists(self): - self.payment_exists = bool(self.payment_ids) - payment_ids = fields.Many2many( comodel_name='account.move.line', string='Payments Entries', @@ -66,11 +61,6 @@ def _compute_payment_exists(self): string='Amount Paid', store=False, ) - payment_exists = fields.Boolean( - compute='_compute_payment_exists', - string='Has automatic payment', - help="It indicates that sales order has at least one payment.", - ) @api.multi def action_cancel(self): diff --git a/sale_view.xml b/sale_view.xml index e45cbbb8fa0..59e37da70ed 100644 --- a/sale_view.xml +++ b/sale_view.xml @@ -15,11 +15,11 @@ From 59bea19f1df6d6c3bbec0507b7c4b10368911a8a Mon Sep 17 00:00:00 2001 From: Matt Choplin Date: Tue, 28 Apr 2015 15:40:51 +0100 Subject: [PATCH 50/52] [FIX] a Many2one in the new api is expecting a recordset --- payment_method.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/payment_method.py b/payment_method.py index 7de13940841..43f140b93e5 100644 --- a/payment_method.py +++ b/payment_method.py @@ -29,7 +29,8 @@ class PaymentMethod(models.Model): @api.model def _default_company_id(self): company_model = self.env['res.company'] - return company_model._company_default_get('payment.method') + return company_model.browse( + company_model._company_default_get('payment.method')) name = fields.Char(required=True, help="The name of the method on the backend") From 41b93a947f7fe95517edfa01965783fda9b88c78 Mon Sep 17 00:00:00 2001 From: Matt Choplin Date: Tue, 28 Apr 2015 17:53:21 +0100 Subject: [PATCH 51/52] add returns decorator --- payment_method.py | 1 + 1 file changed, 1 insertion(+) diff --git a/payment_method.py b/payment_method.py index 43f140b93e5..e58e0ff0fdd 100644 --- a/payment_method.py +++ b/payment_method.py @@ -27,6 +27,7 @@ class PaymentMethod(models.Model): _description = "Payment Method" @api.model + @api.returns('res.company') def _default_company_id(self): company_model = self.env['res.company'] return company_model.browse( From 1fd0d198d7875fc1be6acd7164f67d9e27c6cd3a Mon Sep 17 00:00:00 2001 From: Benoit Guillot Date: Wed, 24 Jun 2015 22:02:35 +0200 Subject: [PATCH 52/52] [IMP] move file --- README.rst => sale_payment_method/README.rst | 0 __init__.py => sale_payment_method/__init__.py | 0 __openerp__.py => sale_payment_method/__openerp__.py | 0 account_move.py => sale_payment_method/account_move.py | 0 {i18n => sale_payment_method/i18n}/es.po | 0 {i18n => sale_payment_method/i18n}/fr.po | 0 {i18n => sale_payment_method/i18n}/sale_payment_method.pot | 0 .../migrations}/0.1/post-migration.py | 0 payment_method.py => sale_payment_method/payment_method.py | 0 .../payment_method_view.xml | 0 sale.py => sale_payment_method/sale.py | 0 sale_view.xml => sale_payment_method/sale_view.xml | 0 {security => sale_payment_method/security}/ir.model.access.csv | 0 {security => sale_payment_method/security}/rules.xml | 0 14 files changed, 0 insertions(+), 0 deletions(-) rename README.rst => sale_payment_method/README.rst (100%) rename __init__.py => sale_payment_method/__init__.py (100%) rename __openerp__.py => sale_payment_method/__openerp__.py (100%) rename account_move.py => sale_payment_method/account_move.py (100%) rename {i18n => sale_payment_method/i18n}/es.po (100%) rename {i18n => sale_payment_method/i18n}/fr.po (100%) rename {i18n => sale_payment_method/i18n}/sale_payment_method.pot (100%) rename {migrations => sale_payment_method/migrations}/0.1/post-migration.py (100%) rename payment_method.py => sale_payment_method/payment_method.py (100%) rename payment_method_view.xml => sale_payment_method/payment_method_view.xml (100%) rename sale.py => sale_payment_method/sale.py (100%) rename sale_view.xml => sale_payment_method/sale_view.xml (100%) rename {security => sale_payment_method/security}/ir.model.access.csv (100%) rename {security => sale_payment_method/security}/rules.xml (100%) diff --git a/README.rst b/sale_payment_method/README.rst similarity index 100% rename from README.rst rename to sale_payment_method/README.rst diff --git a/__init__.py b/sale_payment_method/__init__.py similarity index 100% rename from __init__.py rename to sale_payment_method/__init__.py diff --git a/__openerp__.py b/sale_payment_method/__openerp__.py similarity index 100% rename from __openerp__.py rename to sale_payment_method/__openerp__.py diff --git a/account_move.py b/sale_payment_method/account_move.py similarity index 100% rename from account_move.py rename to sale_payment_method/account_move.py diff --git a/i18n/es.po b/sale_payment_method/i18n/es.po similarity index 100% rename from i18n/es.po rename to sale_payment_method/i18n/es.po diff --git a/i18n/fr.po b/sale_payment_method/i18n/fr.po similarity index 100% rename from i18n/fr.po rename to sale_payment_method/i18n/fr.po diff --git a/i18n/sale_payment_method.pot b/sale_payment_method/i18n/sale_payment_method.pot similarity index 100% rename from i18n/sale_payment_method.pot rename to sale_payment_method/i18n/sale_payment_method.pot diff --git a/migrations/0.1/post-migration.py b/sale_payment_method/migrations/0.1/post-migration.py similarity index 100% rename from migrations/0.1/post-migration.py rename to sale_payment_method/migrations/0.1/post-migration.py diff --git a/payment_method.py b/sale_payment_method/payment_method.py similarity index 100% rename from payment_method.py rename to sale_payment_method/payment_method.py diff --git a/payment_method_view.xml b/sale_payment_method/payment_method_view.xml similarity index 100% rename from payment_method_view.xml rename to sale_payment_method/payment_method_view.xml diff --git a/sale.py b/sale_payment_method/sale.py similarity index 100% rename from sale.py rename to sale_payment_method/sale.py diff --git a/sale_view.xml b/sale_payment_method/sale_view.xml similarity index 100% rename from sale_view.xml rename to sale_payment_method/sale_view.xml diff --git a/security/ir.model.access.csv b/sale_payment_method/security/ir.model.access.csv similarity index 100% rename from security/ir.model.access.csv rename to sale_payment_method/security/ir.model.access.csv diff --git a/security/rules.xml b/sale_payment_method/security/rules.xml similarity index 100% rename from security/rules.xml rename to sale_payment_method/security/rules.xml