From 01304346e91c15e70c024191504684db8ec330b3 Mon Sep 17 00:00:00 2001 From: Jacques-Etienne Baudoux Date: Fri, 3 Jul 2015 15:10:09 +0200 Subject: [PATCH] [FIX] pep8, README.rst --- .../README.rst | 37 +++++++++++++++++++ .../__openerp__.py | 18 ++------- .../model/account_invoice_line.py | 17 +++++---- 3 files changed, 50 insertions(+), 22 deletions(-) create mode 100644 account_invoice_line_default_account/README.rst diff --git a/account_invoice_line_default_account/README.rst b/account_invoice_line_default_account/README.rst new file mode 100644 index 00000000000..2d59bd61a5e --- /dev/null +++ b/account_invoice_line_default_account/README.rst @@ -0,0 +1,37 @@ +Account Invoice Line default Account +==================================== + +When entering sales or purchase invoices directly, the user has to select an +account which will be used as a counterpart in the generated move lines. Each +supplier will mostly be linked to one account. For instance when ordering paper +from a supplier that deals in paper, the counterpart account will mostly be +something like 'office expenses'. The same principle has been applied for +customers. This module will add a default counterpart expense and income +account to a partner, comparable to the similiar field in product. When an +invoice is entered, withouth a product, the field from partner will be used as +default. Also when an account is entered on an invoice line (not automatically +selected for a product), the account will be automatically linked to the +partner as default expense or income account, unless explicitly disabled in the +partner record. + +Credits +======= + +Contributors +------------ + +* Jacques-Etienne Baudoux (BCIM sprl) + +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/account_invoice_line_default_account/__openerp__.py b/account_invoice_line_default_account/__openerp__.py index a04d23edc99..811454f1efa 100644 --- a/account_invoice_line_default_account/__openerp__.py +++ b/account_invoice_line_default_account/__openerp__.py @@ -3,7 +3,7 @@ # # OpenERP, Open Source Management Solution # This module copyright (C) 2012 Therp BV (). -# This module copyright (C) 2013 BCIM SPRL (). +# This module copyright (C) 2013-2015 BCIM SPRL (). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -21,25 +21,13 @@ ############################################################################## { 'name': 'Account Invoice Line Default Account', - 'version': '7.0.1.0', + 'version': '1.0', 'depends': [ 'account' ], - 'author': 'Therp BV', + 'author': 'Therp BV,BCIM,Odoo Community Association (OCA)', 'contributors': ['Jacques-Etienne Baudoux '], 'category': 'Accounting', - 'description': '''When entering sales or purchase invoices directly, the -user has to select an account which will be used as a counterpart in the -generated move lines. Each supplier will mostly be linked to one account. For -instance when ordering paper from a supplier that deals in paper, the -counterpart account will mostly be something like 'office expenses'. The sme -principle has been applied for customers. This module will add a default -counterpart expense and income account to a partner, comparable to the similiar -field in product. When an invoice is entered, withouth a product, the field -from partner will be used as default. Also when an account is entered on an -invoice line (not automatically selected for a product), the account will be -automatically linked to the partner as default expense or income account, unless -explicitly disabled in the partner record.''', 'data': [ 'view/res_partner.xml', 'view/account_invoice.xml', diff --git a/account_invoice_line_default_account/model/account_invoice_line.py b/account_invoice_line_default_account/model/account_invoice_line.py index 50a5f5b8669..90c9a903885 100644 --- a/account_invoice_line_default_account/model/account_invoice_line.py +++ b/account_invoice_line_default_account/model/account_invoice_line.py @@ -24,11 +24,13 @@ def _account_id_default(self, cr, uid, context=None): invoice_type = context.get('type') partner_model = self.pool.get('res.partner') if invoice_type in ['in_invoice', 'in_refund']: - partner = partner_model.read(cr, uid, partner_id, + partner = partner_model.read( + cr, uid, partner_id, ['property_account_expense'], context=context) return partner['property_account_expense'] elif invoice_type in ['out_invoice', 'out_refund']: - partner = partner_model.read(cr, uid, partner_id, + partner = partner_model.read( + cr, uid, partner_id, ['property_account_income'], context=context) return partner['property_account_income'] return False @@ -45,23 +47,24 @@ def onchange_account_id( # account_id is not the result of a product selection). # Store this account_id as future default in res_partner. partner_model = self.pool.get('res.partner') - partner = partner_model.read(cr, uid, partner_id, + partner = partner_model.read( + cr, uid, partner_id, ['auto_update_account_expense', 'property_account_expense', 'auto_update_account_income', 'property_account_income'], context=context) vals = {} if (inv_type in ['in_invoice', 'in_refund'] and - partner['auto_update_account_expense']): + partner['auto_update_account_expense']): if account_id != partner['property_account_expense']: # only write when something really changed vals.update({'property_account_expense': account_id}) elif (inv_type in ['out_invoice', 'out_refund'] and - partner['auto_update_account_income']): + partner['auto_update_account_income']): if account_id != partner['property_account_income']: # only write when something really changed vals.update({'property_account_income': account_id}) if vals: partner_model.write(cr, uid, partner_id, vals, context=context) return super(account_invoice_line, self).onchange_account_id( - cr, uid, ids, product_id, partner_id, inv_type, - fposition_id, account_id) + cr, uid, ids, product_id, partner_id, inv_type, + fposition_id, account_id)