From 82d239d7341233e5f7bcd2fee91791dc808447c7 Mon Sep 17 00:00:00 2001 From: Omar Date: Wed, 6 Feb 2013 23:10:41 +0100 Subject: [PATCH] [FIX] account_invoice_line_default_account: Correction of author name. (../account-financial-tools-6.1 rev 103) --- .../__openerp__.py | 4 ++-- .../model/account_invoice_line.py | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/account_invoice_line_default_account/__openerp__.py b/account_invoice_line_default_account/__openerp__.py index 400c161c2b4..b78051fc063 100644 --- a/account_invoice_line_default_account/__openerp__.py +++ b/account_invoice_line_default_account/__openerp__.py @@ -20,12 +20,12 @@ ############################################################################## { 'name': 'Account Invoice Line Default Account', - 'version': '6.1.r004', + 'version': '6.1.r005', 'depends': [ 'base', 'account' ], - 'author': 'Therp B.V.', + 'author': 'Therp BV', 'category': 'Accounting', 'description': '''When entering purchase invoices directly, the user has to select an account which will be used as a counterpart in the generated 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 95b96898f06..1ba4bfb987d 100644 --- a/account_invoice_line_default_account/model/account_invoice_line.py +++ b/account_invoice_line_default_account/model/account_invoice_line.py @@ -8,6 +8,7 @@ http://www.therp.nl ''' from openerp.osv import orm +from openerp.tools.translate import _ class account_invoice_line(orm.Model): @@ -22,7 +23,9 @@ def _account_id_default(self, cr, uid, context=None): partner_model = self.pool.get('res.partner') partner_obj = partner_model.browse( cr, uid, partner_id, context=context) - if partner_obj and partner_obj.property_account_expense: + assert partner_obj, ( + _('No object created for partner %d') % partner_id) + if partner_obj.property_account_expense: return partner_obj.property_account_expense.id return False @@ -35,11 +38,14 @@ def onchange_account_id( fposition_id, account_id): if (account_id and partner_id and (not product_id) and inv_type in ['in_invoice', 'in_refund']): - # We have an account_id, and is not from a product, so - # store it in partner automagically: + # We have a manually entered account_id (no product_id, so the + # 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_obj = partner_model.browse(cr, uid, partner_id) - if partner_obj and partner_obj.auto_update_account_expense: + assert partner_obj, ( + _('No object created for partner %d') % partner_id) + if partner_obj.auto_update_account_expense: old_account_id = ( partner_obj.property_account_expense and partner_obj.property_account_expense.id)