diff --git a/account_payment_partner/__init__.py b/account_payment_partner/__init__.py new file mode 100644 index 000000000..fe47437f2 --- /dev/null +++ b/account_payment_partner/__init__.py @@ -0,0 +1,24 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Partner module for OpenERP +# Copyright (C) 2014 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import models +from . import wizard diff --git a/account_payment_partner/__openerp__.py b/account_payment_partner/__openerp__.py new file mode 100644 index 000000000..3f3a51f3f --- /dev/null +++ b/account_payment_partner/__openerp__.py @@ -0,0 +1,53 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Partner module for OpenERP +# Copyright (C) 2014 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + + +{ + 'name': 'Account Payment Partner', + 'version': '0.1', + 'category': 'Banking addons', + 'license': 'AGPL-3', + 'summary': 'Adds payment mode on partners and invoices', + 'description': """ +Account Payment Partner +======================= + +This module adds severals fields : + +* the *Supplier Payment Mode* and *Customer Payment Mode* on Partners, + +* the *Payment Mode* on Invoices. + +On a Payment Order, in the wizard *Select Invoices to Pay*, the invoices will +be filtered per Payment Mode. + """, + 'author': 'Akretion', + 'website': 'http://www.akretion.com', + 'contributors': ['Pedro M. Baeza '], + 'depends': ['account_banking_payment_export'], + 'data': [ + 'views/res_partner_view.xml', + 'views/account_invoice_view.xml', + ], + 'demo': ['demo/partner_demo.xml'], + 'installable': True, +} diff --git a/account_payment_partner/demo/partner_demo.xml b/account_payment_partner/demo/partner_demo.xml new file mode 100644 index 000000000..776058d44 --- /dev/null +++ b/account_payment_partner/demo/partner_demo.xml @@ -0,0 +1,51 @@ + + + + + + + + supplier_payment_mode_12 + + + + + + + + customer_payment_mode_12 + + + + + + + + + customer_payment_mode_2 + + + + + + + + + supplier_payment_mode_1 + + + + + + + + + diff --git a/account_payment_partner/i18n/account_payment_partner.pot b/account_payment_partner/i18n/account_payment_partner.pot new file mode 100644 index 000000000..ca26e532d --- /dev/null +++ b/account_payment_partner/i18n/account_payment_partner.pot @@ -0,0 +1,57 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * account_payment_partner +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-06-09 23:22+0000\n" +"PO-Revision-Date: 2014-06-09 23:22+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: account_payment_partner +#: field:res.partner,customer_payment_mode:0 +msgid "Customer Payment Mode" +msgstr "" + +#. module: account_payment_partner +#: model:ir.model,name:account_payment_partner.model_account_invoice +msgid "Invoice" +msgstr "" + +#. module: account_payment_partner +#: model:ir.model,name:account_payment_partner.model_res_partner +msgid "Partner" +msgstr "" + +#. module: account_payment_partner +#: field:account.invoice,payment_mode_id:0 +msgid "Payment Mode" +msgstr "" + +#. module: account_payment_partner +#: help:res.partner,customer_payment_mode:0 +msgid "Select the default payment mode for this customer." +msgstr "" + +#. module: account_payment_partner +#: help:res.partner,supplier_payment_mode:0 +msgid "Select the default payment mode for this supplier." +msgstr "" + +#. module: account_payment_partner +#: field:res.partner,supplier_payment_mode:0 +msgid "Supplier Payment Mode" +msgstr "" + +#. module: account_payment_partner +#: model:ir.model,name:account_payment_partner.model_payment_order_create +msgid "payment.order.create" +msgstr "" + diff --git a/account_payment_partner/i18n/nl.po b/account_payment_partner/i18n/nl.po new file mode 100644 index 000000000..4c90fe776 --- /dev/null +++ b/account_payment_partner/i18n/nl.po @@ -0,0 +1,58 @@ +# Dutch translation for banking-addons +# Copyright (c) 2014 Rosetta Contributors and Canonical Ltd 2014 +# This file is distributed under the same license as the banking-addons package. +# FIRST AUTHOR , 2014. +# +msgid "" +msgstr "" +"Project-Id-Version: banking-addons\n" +"Report-Msgid-Bugs-To: FULL NAME \n" +"POT-Creation-Date: 2014-06-09 23:22+0000\n" +"PO-Revision-Date: 2014-06-26 14:13+0000\n" +"Last-Translator: Erwin van der Ploeg (BAS Solutions) \n" +"Language-Team: Dutch \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Launchpad-Export-Date: 2014-06-27 07:13+0000\n" +"X-Generator: Launchpad (build 17077)\n" + +#. module: account_payment_partner +#: field:res.partner,customer_payment_mode:0 +msgid "Customer Payment Mode" +msgstr "Betaalwijze klant" + +#. module: account_payment_partner +#: model:ir.model,name:account_payment_partner.model_account_invoice +msgid "Invoice" +msgstr "Factuur" + +#. module: account_payment_partner +#: model:ir.model,name:account_payment_partner.model_res_partner +msgid "Partner" +msgstr "Relatie" + +#. module: account_payment_partner +#: field:account.invoice,payment_mode_id:0 +msgid "Payment Mode" +msgstr "Betaalwijze" + +#. module: account_payment_partner +#: help:res.partner,customer_payment_mode:0 +msgid "Select the default payment mode for this customer." +msgstr "Selecteer de standaard betaalwijze voor deze klant." + +#. module: account_payment_partner +#: help:res.partner,supplier_payment_mode:0 +msgid "Select the default payment mode for this supplier." +msgstr "Selecteer de standaard betaalwijze voor deze leverancier." + +#. module: account_payment_partner +#: field:res.partner,supplier_payment_mode:0 +msgid "Supplier Payment Mode" +msgstr "Betaalwijze leverancier" + +#. module: account_payment_partner +#: model:ir.model,name:account_payment_partner.model_payment_order_create +msgid "payment.order.create" +msgstr "payment.order.create" diff --git a/account_payment_partner/models/__init__.py b/account_payment_partner/models/__init__.py new file mode 100644 index 000000000..c2c7b405d --- /dev/null +++ b/account_payment_partner/models/__init__.py @@ -0,0 +1,24 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Partner module for OpenERP +# Copyright (C) 2014 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import res_partner +from . import account_invoice diff --git a/account_payment_partner/models/account_invoice.py b/account_payment_partner/models/account_invoice.py new file mode 100644 index 000000000..cbbd4b5b9 --- /dev/null +++ b/account_payment_partner/models/account_invoice.py @@ -0,0 +1,51 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Partner module for OpenERP +# Copyright (C) 2014 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp import models, fields, api + + +class AccountInvoice(models.Model): + _inherit = 'account.invoice' + + payment_mode_id = fields.Many2one('payment.mode', string="Payment Mode") + + @api.multi + def onchange_partner_id( + self, type, partner_id, date_invoice=False, + payment_term=False, partner_bank_id=False, company_id=False): + res = super(AccountInvoice, self).onchange_partner_id( + type, partner_id, date_invoice=date_invoice, + payment_term=payment_term, partner_bank_id=partner_bank_id, + company_id=company_id) + if partner_id: + partner = self.env['res.partner'].browse(partner_id) + if type == 'in_invoice': + res['value']['payment_mode_id'] = \ + partner.supplier_payment_mode.id + elif type == 'out_invoice': + res['value'].update({ + 'payment_mode_id': partner.customer_payment_mode.id, + 'partner_bank_id': partner.customer_payment_mode.bank_id.id + }) + else: + res['value']['payment_mode_id'] = False + return res diff --git a/account_payment_partner/models/partner.py b/account_payment_partner/models/partner.py new file mode 100644 index 000000000..4bfe4c787 --- /dev/null +++ b/account_payment_partner/models/partner.py @@ -0,0 +1,44 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Partner module for OpenERP +# Copyright (C) 2014 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.osv import orm, fields + + +class res_partner(orm.Model): + _inherit = 'res.partner' + + _columns = { + 'supplier_payment_mode': fields.property( + 'payment.mode', type='many2one', relation='payment.mode', + string='Supplier Payment Mode', view_load=True, + help="Select the default payment mode for this supplier."), + 'customer_payment_mode': fields.property( + 'payment.mode', type='many2one', relation='payment.mode', + string='Customer Payment Mode', view_load=True, + help="Select the default payment mode for this customer."), + } + + def _commercial_fields(self, cr, uid, context=None): + res = super(res_partner, self)._commercial_fields( + cr, uid, context=context) + res += ['supplier_payment_mode', 'customer_payment_mode'] + return res diff --git a/account_payment_partner/models/payment_order_create.py b/account_payment_partner/models/payment_order_create.py new file mode 100644 index 000000000..ea8b1ccb3 --- /dev/null +++ b/account_payment_partner/models/payment_order_create.py @@ -0,0 +1,39 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Partner module for OpenERP +# Copyright (C) 2014 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.osv import orm + + +class payment_order_create(orm.TransientModel): + _inherit = 'payment.order.create' + + def extend_payment_order_domain( + self, cr, uid, payment_order, domain, context=None): + super(payment_order_create, self).extend_payment_order_domain( + cr, uid, payment_order, domain, context=context) + domain += [ + '|', '|', + ('invoice', '=', False), + ('invoice.payment_mode_id', '=', False), + ('invoice.payment_mode_id', '=', payment_order.mode.id) + ] + return True diff --git a/account_payment_partner/models/res_partner.py b/account_payment_partner/models/res_partner.py new file mode 100644 index 000000000..c8762f7d5 --- /dev/null +++ b/account_payment_partner/models/res_partner.py @@ -0,0 +1,42 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Partner module for OpenERP +# Copyright (C) 2014 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp import models, fields, api + + +class ResPartner(models.Model): + _inherit = 'res.partner' + + supplier_payment_mode = fields.Many2one( + 'payment.mode', string='Supplier Payment Mode', company_dependent=True, + domain="[('payment_order_type', '=', 'payment')]", + help="Select the default payment mode for this supplier.") + customer_payment_mode = fields.Many2one( + 'payment.mode', string='Customer Payment Mode', company_dependent=True, + domain="[('payment_order_type', '=', 'debit')]", + help="Select the default payment mode for this customer.") + + @api.model + def _commercial_fields(self): + res = super(ResPartner, self)._commercial_fields() + res += ['supplier_payment_mode', 'customer_payment_mode'] + return res diff --git a/account_payment_partner/views/account_invoice.xml b/account_payment_partner/views/account_invoice.xml new file mode 100644 index 000000000..0bfd2d1f5 --- /dev/null +++ b/account_payment_partner/views/account_invoice.xml @@ -0,0 +1,38 @@ + + + + + + + + + + account_payment_partner.invoice_form + account.invoice + + + + + + + + + + + account_payment_partner.invoice_supplier_form + account.invoice + + + + + + + + + + + diff --git a/account_payment_partner/views/account_invoice_view.xml b/account_payment_partner/views/account_invoice_view.xml new file mode 100644 index 000000000..f4805fa89 --- /dev/null +++ b/account_payment_partner/views/account_invoice_view.xml @@ -0,0 +1,40 @@ + + + + + + + + + + account_payment_partner.invoice_form + account.invoice + + + + + + + + + + + account_payment_partner.invoice_supplier_form + account.invoice + + + + + + + + + + + diff --git a/account_payment_partner/views/partner.xml b/account_payment_partner/views/partner.xml new file mode 100644 index 000000000..02eb8cc0f --- /dev/null +++ b/account_payment_partner/views/partner.xml @@ -0,0 +1,31 @@ + + + + + + + + + + account_partner_payment.partner_form + res.partner + + + + + + + + + + + + + + diff --git a/account_payment_partner/views/res_partner_view.xml b/account_payment_partner/views/res_partner_view.xml new file mode 100644 index 000000000..3c6d670aa --- /dev/null +++ b/account_payment_partner/views/res_partner_view.xml @@ -0,0 +1,27 @@ + + + + + + + + + account_partner_payment.partner_form + res.partner + + + + + + + + + + + + + diff --git a/account_payment_partner/wizard/__init__.py b/account_payment_partner/wizard/__init__.py new file mode 100644 index 000000000..f7107a63f --- /dev/null +++ b/account_payment_partner/wizard/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Partner module for OpenERP +# Copyright (C) 2014 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from . import payment_order_create diff --git a/account_payment_partner/wizard/payment_order_create.py b/account_payment_partner/wizard/payment_order_create.py new file mode 100644 index 000000000..c26b7f9d9 --- /dev/null +++ b/account_payment_partner/wizard/payment_order_create.py @@ -0,0 +1,37 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Account Payment Partner module for OpenERP +# Copyright (C) 2014 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp import models, api + + +class PaymentOrderCreate(models.TransientModel): + _inherit = 'payment.order.create' + + @api.model + def extend_payment_order_domain(self, payment_order, domain): + res = super(PaymentOrderCreate, self).extend_payment_order_domain( + payment_order, domain) + domain += ['|', '|', + ('invoice', '=', False), + ('invoice.payment_mode_id', '=', False), + ('invoice.payment_mode_id', '=', payment_order.mode.id)] + return res