account_invoice_partner_bank_usability: ability to choose which bank account is selected by default on customer invoices
This commit is contained in:
@@ -1,23 +1,3 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
|
||||||
#
|
|
||||||
# Account Invoice Partner Bank Usability module for OpenERP
|
|
||||||
# Copyright (C) 2013 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 account_invoice
|
from . import account_invoice
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
# Account Invoice Partner Bank Usability module for OpenERP
|
# Account Invoice Partner Bank Usability module for Odoo
|
||||||
# Copyright (C) 2013 Akretion (http://www.akretion.com)
|
# Copyright (C) 2013-2016 Akretion (http://www.akretion.com)
|
||||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
@@ -26,20 +26,18 @@
|
|||||||
'version': '0.1',
|
'version': '0.1',
|
||||||
'category': 'Accounting & Finance',
|
'category': 'Accounting & Finance',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'summary': 'If the company has a single bank account, get the first one on the customer invoice',
|
'summary': 'Configure a bank account by default for customer invoices',
|
||||||
'description': """
|
'description': """
|
||||||
Account Invoice Partner Bank Usability
|
Account Invoice Partner Bank Usability
|
||||||
======================================
|
======================================
|
||||||
|
|
||||||
If the company has a single bank account, we set this single bank account by default on the customer invoice.
|
This module adds a configuration parameter on the company that allows you to choose which bank account of your company will be selected by default on customer invoices.
|
||||||
|
|
||||||
Please contact Alexis de Lattre from Akretion <alexis.delattre@akretion.com> for any help or question about this module.
|
This module has been written by Alexis de Lattre from Akretion <alexis.delattre@akretion.com>.
|
||||||
""",
|
""",
|
||||||
'author': 'Akretion',
|
'author': 'Akretion',
|
||||||
'website': 'http://www.akretion.com',
|
'website': 'http://www.akretion.com',
|
||||||
'depends': ['account'],
|
'depends': ['account'],
|
||||||
'data': [],
|
'data': ['company_view.xml'],
|
||||||
'images': [],
|
|
||||||
'installable': True,
|
'installable': True,
|
||||||
'active': False,
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
# Account Invoice Partner Bank Usability module for OpenERP
|
# Account Invoice Partner Bank Usability module for Odoo
|
||||||
# Copyright (C) 2013 Akretion (http://www.akretion.com)
|
# Copyright (C) 2013-2016 Akretion (http://www.akretion.com)
|
||||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
@@ -20,27 +20,29 @@
|
|||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
from openerp.osv import orm
|
from openerp import models, fields
|
||||||
|
|
||||||
|
|
||||||
class account_invoice(orm.Model):
|
class ResCompany(models.Model):
|
||||||
|
_inherit = 'res.company'
|
||||||
|
|
||||||
|
default_out_invoice_partner_bank_id = fields.Many2one(
|
||||||
|
'res.partner.bank',
|
||||||
|
string='Default Bank Account for Customer Invoices',
|
||||||
|
copy=False, ondelete='restrict',
|
||||||
|
help="This is the bank account of your company that will be selected "
|
||||||
|
"by default when you create a customer invoice.")
|
||||||
|
|
||||||
|
|
||||||
|
class AccountInvoice(models.Model):
|
||||||
_inherit = "account.invoice"
|
_inherit = "account.invoice"
|
||||||
|
|
||||||
def invoice_out_get_first_partner_bank(self, cr, uid, context=None):
|
def invoice_out_default_bank_account(self):
|
||||||
'''Get the first bank account of your company on customer invoice
|
partner_bank_id = False
|
||||||
if your company only has one bank account'''
|
if self._context.get('type') == 'out_invoice' or \
|
||||||
if context is None:
|
self._context.get('inv_type') == 'out_invoice':
|
||||||
context = {}
|
partner_bank_id = self.env.user.company_id.\
|
||||||
res_partner_bank_id = False
|
default_out_invoice_partner_bank_id.id or False
|
||||||
if context.get('type') == 'out_invoice' or \
|
return partner_bank_id
|
||||||
context.get('inv_type') == 'out_invoice':
|
|
||||||
cur_user = self.pool['res.users'].browse(
|
|
||||||
cr, uid, uid, context=context)
|
|
||||||
partner_banks = cur_user.company_id.partner_id.bank_ids
|
|
||||||
if partner_banks and len(partner_banks) == 1:
|
|
||||||
res_partner_bank_id = partner_banks[0].id
|
|
||||||
return res_partner_bank_id
|
|
||||||
|
|
||||||
_defaults = {
|
partner_bank_id = fields.Many2one(default=invoice_out_default_bank_account)
|
||||||
'partner_bank_id': invoice_out_get_first_partner_bank,
|
|
||||||
}
|
|
||||||
|
|||||||
26
account_invoice_partner_bank_usability/company_view.xml
Normal file
26
account_invoice_partner_bank_usability/company_view.xml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2016 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_company_form" model="ir.ui.view">
|
||||||
|
<field name="name">account_invoice_partner_bank_usability.company.form</field>
|
||||||
|
<field name="model">res.company</field>
|
||||||
|
<field name="inherit_id" ref="base.view_company_form" />
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<group name="account_grp" position="inside">
|
||||||
|
<field name="default_out_invoice_partner_bank_id"
|
||||||
|
domain="[('company_id', '=', id)]"/>
|
||||||
|
</group>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</openerp>
|
||||||
Reference in New Issue
Block a user