From d25a59a0ca4d91bf23d59d27cc115e71284b2230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 22 May 2008 10:45:33 +0200 Subject: [PATCH] Improve default_company to return (id, name) to prevent one rpc request. --- account.py | 6 +++++- tax.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/account.py b/account.py index 3b1c8f450a..751beaa20f 100644 --- a/account.py +++ b/account.py @@ -251,9 +251,13 @@ class Account(OSV): return True def default_company(self, cursor, user, context=None): + company_obj = self.pool.get('company.company') if context is None: context = {} - return context.get('company', False) + if context.get('company'): + return company_obj.name_get(cursor, user, context['company'], + context=context)[0] + return False def default_type(self, cursor, user, context=None): type_obj = self.pool.get('account.account.type') diff --git a/tax.py b/tax.py index 4091283e6d..c465d84c46 100644 --- a/tax.py +++ b/tax.py @@ -313,9 +313,13 @@ class Tax(OSV): return 1 def default_company(self, cursor, user, context=None): + company_obj = self.pool.get('company.company') if context is None: context = {} - return context.get('company', False) + if context.get('company'): + return company_obj.name_get(cursor, user, context['company'], + context=context)[0] + return False def _process_tax(self, cursor, user, tax, price_unit, context=None): if tax.type == 'percentage':