Add 4 new modules to handle payment type and bank accounts:

- account_payment_partner
- account_payment_sale
- account_payment_sale_stock
- account_payment_purchase

Filter the selection of invoices per payment type.
Add active field on payment.mode and payment.mode.type.
Add menu entry for Payment Types.
This commit is contained in:
Alexis de Lattre
2014-02-25 00:19:57 +01:00
committed by Enric Tobella
parent 1daf9009dd
commit 72fce1441b
9 changed files with 386 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Account Partner Payment module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import model

View File

@@ -0,0 +1,55 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Account Partner Payment module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Account Partner Payment',
'version': '0.1',
'category': 'Banking addons',
'license': 'AGPL-3',
'summary': 'Adds payment type and receivable bank account on partners',
'description': """
Account Partner Payment
=======================
This module adds severals fields :
* the *Supplier Payment Type* and *Customer Payment Type* on Partners,
* the *Receivable Bank Account* on Partners,
* the *Payment Type* on Invoices.
On a Payment Order, in the wizard *Select Invoices to Pay*, the invoices will be filtered per Payment Type.
Please contact Alexis de Lattre from Akretion <alexis.delattre@akretion.com> for any help or question about this module.
""",
'author': 'Akretion',
'website': 'http://www.akretion.com',
'depends': ['account_banking_payment_export'],
'data': [
'view/partner.xml',
'view/account_invoice.xml',
],
'demo': [],
'active': False,
}

View File

@@ -0,0 +1,67 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * account_payment_partner
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-02-24 23:06+0000\n"
"PO-Revision-Date: 2014-02-24 23:06+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: account_payment_partner
#: field:account.invoice,payment_mode_type:0
msgid "Payment Type"
msgstr ""
#. module: account_payment_partner
#: model:ir.model,name:account_payment_partner.model_payment_order_create
msgid "payment.order.create"
msgstr ""
#. module: account_payment_partner
#: field:res.partner,supplier_payment_mode_type:0
msgid "Supplier Payment Type"
msgstr ""
#. module: account_payment_partner
#: help:res.partner,partner_bank_receivable:0
msgid "Select the bank account of your company on which the customer should pay."
msgstr ""
#. module: account_payment_partner
#: field:res.partner,partner_bank_receivable:0
msgid "Receivable Bank Account"
msgstr ""
#. module: account_payment_partner
#: help:res.partner,supplier_payment_mode_type:0
msgid "Select the default payment type for this supplier."
msgstr ""
#. module: account_payment_partner
#: field:res.partner,customer_payment_mode_type:0
msgid "Customer Payment Type"
msgstr ""
#. module: account_payment_partner
#: model:ir.model,name:account_payment_partner.model_account_invoice
msgid "Invoice"
msgstr ""
#. module: account_payment_partner
#: help:res.partner,customer_payment_mode_type:0
msgid "Select the default payment type for this customer."
msgstr ""
#. module: account_payment_partner
#: model:ir.model,name:account_payment_partner.model_res_partner
msgid "Partner"
msgstr ""

View File

@@ -0,0 +1,25 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Account Partner Payment module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import partner
from . import account_invoice
from . import payment_order_create

View File

@@ -0,0 +1,53 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Account Partner Payment module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import orm, fields
class account_invoice(orm.Model):
_inherit = 'account.invoice'
_columns = {
'payment_mode_type': fields.many2one(
'payment.mode.type', 'Payment Type'),
}
def onchange_partner_id(
self, cr, uid, ids, type, partner_id, date_invoice=False,
payment_term=False, partner_bank_id=False, company_id=False):
res = super(account_invoice, self).onchange_partner_id(
cr, uid, ids, type, partner_id, date_invoice=date_invoice,
payment_term=payment_term, partner_bank_id=partner_bank_id,
company_id=company_id)
if partner_id:
partner = self.pool['res.partner'].browse(cr, uid, partner_id)
# TODO what about refunds ? Should be really copy
# the payment type for refunds ?
if type and type in ('in_invoice', 'in_refund'):
res['value']['payment_mode_type'] = \
partner.supplier_payment_mode_type.id or False
elif type and type in ('out_invoice', 'out_refund'):
res['value']['payment_mode_type'] = \
partner.customer_payment_mode_type.id or False
else:
res['value']['payment_mode_type'] = False
return res

View File

@@ -0,0 +1,53 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Account Partner Payment module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import orm, fields
class res_partner(orm.Model):
_inherit = 'res.partner'
_columns = {
'supplier_payment_mode_type': fields.property(
'payment.mode.type', type='many2one', relation='payment.mode.type',
string='Supplier Payment Type', view_load=True,
help="Select the default payment type for this supplier."),
'customer_payment_mode_type': fields.property(
'payment.mode.type', type='many2one', relation='payment.mode.type',
string='Customer Payment Type', view_load=True,
help="Select the default payment type for this customer."),
'partner_bank_receivable': fields.property(
'res.partner.bank', type='many2one', relation='res.partner.bank',
string='Receivable Bank Account', view_load=True,
help="Select the bank account of your company on which the "
"customer should pay."),
}
def _commercial_fields(self, cr, uid, context=None):
res = super(res_partner, self)._commercial_fields(
cr, uid, context=context)
res += [
'supplier_payment_mode_type',
'customer_payment_mode_type',
'partner_bank_receivable',
]
return res

View File

@@ -0,0 +1,38 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Account Partner Payment module for OpenERP
# Copyright (C) 2014 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.osv import orm
class payment_order_create(orm.Model):
_inherit = 'payment.order.create'
def extend_payment_order_domain(
self, cr, uid, payment_order, domain, context=None):
super(payment_order_create, self).extend_payment_order_domain(
cr, uid, payment_order, domain, context=context)
domain += [
'|',
('invoice', '=', False),
('invoice.payment_mode_type', '=', payment_order.mode_type.id)
]
return True

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 Akretion (http://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<record id="invoice_form" model="ir.ui.view">
<field name="name">account_partner_payment.invoice_form</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form" />
<field name="arch" type="xml">
<field name="partner_bank_id" position="after">
<field name="payment_mode_type"/>
</field>
</field>
</record>
<record id="invoice_supplier_form" model="ir.ui.view">
<field name="name">account_partner_payment.invoice_supplier_form</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_supplier_form" />
<field name="arch" type="xml">
<field name="partner_bank_id" position="after">
<field name="payment_mode_type"/>
</field>
</field>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 Akretion (http://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<record id="view_partner_property_form" model="ir.ui.view">
<field name="name">account_partner_payment.partner_form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="account.view_partner_property_form" />
<field name="arch" type="xml">
<field name="property_payment_term" position="after">
<field name="customer_payment_mode_type"
attrs="{'invisible': [('customer', '=', False)]}"/>
<field name="partner_bank_receivable"
domain="[('partner_id.ref_companies', 'in', [company_id])]"
attrs="{'invisible': [('customer', '=', False)]}" />
</field>
<field name="property_supplier_payment_term" position="after">
<field name="supplier_payment_mode_type"
attrs="{'invisible': [('supplier', '=', False)]}"/>
</field>
</field>
</record>
</data>
</openerp>