From 3fa1e69ffd6284d0fa32ba68d3d1911cc36d1153 Mon Sep 17 00:00:00 2001 From: "Jay (Open ERP)" Date: Mon, 17 May 2010 18:47:13 +0530 Subject: [REF] bzr revid: jvo@tinyerp.com-20100517131713-kh7s2n85elr52xjf --- addons/analytic_user_function/analytic_user_function.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/analytic_user_function/analytic_user_function.py') diff --git a/addons/analytic_user_function/analytic_user_function.py b/addons/analytic_user_function/analytic_user_function.py index c5c2af729a0..fe238d373be 100644 --- a/addons/analytic_user_function/analytic_user_function.py +++ b/addons/analytic_user_function/analytic_user_function.py @@ -100,7 +100,7 @@ class hr_analytic_timesheet(osv.osv): 'for this product: "%s" (id:%d)') % \ (r.product_id.name, r.product_id.id,)) # Compute based on pricetype - amount_unit=self.on_change_unit_amount(cr, uid, ids, + amount_unit = self.on_change_unit_amount(cr, uid, ids, r.product_id.id, unit_amount, r.product_id.uom_id.id)['value']['amount'] amount = unit_amount * amount_unit @@ -136,7 +136,7 @@ class hr_analytic_timesheet(osv.osv): 'for this product: "%s" (id:%d)') % \ (r.product_id.name, r.product_id.id,)) # Compute based on pricetype - amount_unit=self.on_change_unit_amount(cr, uid, ids, + amount_unit = self.on_change_unit_amount(cr, uid, ids, r.product_id.id, unit_amount, r.product_id.uom_id.id)['value']['amount'] amount = unit_amount * amount_unit -- cgit v1.2.3 From bf8d2a73c06154918874220b8bfb1251dc614088 Mon Sep 17 00:00:00 2001 From: vra Date: Wed, 16 Jun 2010 17:21:39 +0530 Subject: [IMP][REF] Sql-injection changes, remove print statement, some space improvement. bzr revid: vra@tinyerp.com-20100616115139-cql5oiqf622spa6p --- .../analytic_user_function.py | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'addons/analytic_user_function/analytic_user_function.py') diff --git a/addons/analytic_user_function/analytic_user_function.py b/addons/analytic_user_function/analytic_user_function.py index fe238d373be..2f5152faea6 100644 --- a/addons/analytic_user_function/analytic_user_function.py +++ b/addons/analytic_user_function/analytic_user_function.py @@ -28,9 +28,9 @@ class analytic_user_funct_grid(osv.osv): _name="analytic_user_funct_grid" _description= "Relation table between users and products on a analytic account" _columns={ - 'user_id': fields.many2one("res.users","User",required=True,), - 'product_id': fields.many2one("product.product","Product",required=True,), - 'account_id': fields.many2one("account.analytic.account", "Analytic Account",required=True,), + 'user_id': fields.many2one("res.users", "User", required=True,), + 'product_id': fields.many2one("product.product", "Product", required=True,), + 'account_id': fields.many2one("account.analytic.account", "Analytic Account", required=True,), } analytic_user_funct_grid() @@ -53,15 +53,15 @@ class hr_analytic_timesheet(osv.osv): # Look in account, if no value for the user => look in parent until there is no more parent to look # Take the first found... if nothing found => return False - def _get_related_user_account_recursiv(self,cr,uid,user_id,account_id): + def _get_related_user_account_recursiv(self, cr, uid, user_id, account_id): temp=self.pool.get('analytic_user_funct_grid').search(cr, uid, [('user_id', '=', user_id),('account_id', '=', account_id) ]) - account=self.pool.get('account.analytic.account').browse(cr,uid,account_id) + account=self.pool.get('account.analytic.account').browse(cr, uid, account_id) if temp: return temp else: if account.parent_id: - return self._get_related_user_account_recursiv(cr,uid,user_id,account.parent_id.id) + return self._get_related_user_account_recursiv(cr, uid, user_id, account.parent_id.id) else: return False @@ -74,19 +74,19 @@ class hr_analytic_timesheet(osv.osv): return res if not (user_id): - return super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids,account_id) + return super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids, account_id) #get the browse record related to user_id and account_id - temp = self._get_related_user_account_recursiv(cr,uid,user_id,account_id) + temp = self._get_related_user_account_recursiv(cr, uid, user_id, account_id) # temp = self.pool.get('analytic_user_funct_grid').search(cr, uid, [('user_id', '=', user_id),('account_id', '=', account_id) ]) if not temp: #if there isn't any record for this user_id and account_id - return super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids,account_id) + return super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids, account_id) else: #get the old values from super and add the value from the new relation analytic_user_funct_grid r = self.pool.get('analytic_user_funct_grid').browse(cr, uid, temp)[0] res.setdefault('value',{}) - res['value']= super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids,account_id)['value'] + res['value']= super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids, account_id)['value'] res['value']['product_id'] = r.product_id.id res['value']['product_uom_id'] = r.product_id.product_tmpl_id.uom_id.id @@ -108,19 +108,19 @@ class hr_analytic_timesheet(osv.osv): res ['value']['general_account_id']= a return res - def on_change_user_id(self, cr, uid, ids,user_id, account_id, unit_amount=0): + def on_change_user_id(self, cr, uid, ids, user_id, account_id, unit_amount=0): res = {} if not (user_id): #avoid a useless call to super return res #get the old values from super - res = super(hr_analytic_timesheet, self).on_change_user_id(cr, uid, ids,user_id) + res = super(hr_analytic_timesheet, self).on_change_user_id(cr, uid, ids, user_id) if account_id: #get the browse record related to user_id and account_id # temp = self.pool.get('analytic_user_funct_grid').search(cr, uid, [('user_id', '=', user_id),('account_id', '=', account_id) ]) - temp = self._get_related_user_account_recursiv(cr,uid,user_id,account_id) + temp = self._get_related_user_account_recursiv(cr, uid, user_id, account_id) if temp: #add the value from the new relation analytic_user_funct_grid r = self.pool.get('analytic_user_funct_grid').browse(cr, uid, temp)[0] -- cgit v1.2.3 From d5ad0b8ff144886a2a5b3766a297b72f59633184 Mon Sep 17 00:00:00 2001 From: "RHA (Open ERP)" <> Date: Thu, 19 Aug 2010 17:21:57 +0530 Subject: [CLEAN]: Removed commented codes, unnecessary spaces. bzr revid: uco@tinyerp.com-20100819115157-sfsmbnjdgpp4wl12 --- .../analytic_user_function.py | 27 ++++++++++------------ 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'addons/analytic_user_function/analytic_user_function.py') diff --git a/addons/analytic_user_function/analytic_user_function.py b/addons/analytic_user_function/analytic_user_function.py index 2f5152faea6..0bb9afc3386 100644 --- a/addons/analytic_user_function/analytic_user_function.py +++ b/addons/analytic_user_function/analytic_user_function.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # 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 . +# along with this program. If not, see . # ############################################################################## @@ -54,7 +54,7 @@ class hr_analytic_timesheet(osv.osv): # Look in account, if no value for the user => look in parent until there is no more parent to look # Take the first found... if nothing found => return False def _get_related_user_account_recursiv(self, cr, uid, user_id, account_id): - + temp=self.pool.get('analytic_user_funct_grid').search(cr, uid, [('user_id', '=', user_id),('account_id', '=', account_id) ]) account=self.pool.get('account.analytic.account').browse(cr, uid, account_id) if temp: @@ -64,21 +64,19 @@ class hr_analytic_timesheet(osv.osv): return self._get_related_user_account_recursiv(cr, uid, user_id, account.parent_id.id) else: return False - - + + def on_change_account_id(self, cr, uid, ids, account_id, user_id=False, unit_amount=0): - #{'value': {'to_invoice': False, 'amount': (-162.0,), 'product_id': 7, 'general_account_id': (5,)}} res = {} if not (account_id): #avoid a useless call to super - return res + return res if not (user_id): return super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids, account_id) #get the browse record related to user_id and account_id temp = self._get_related_user_account_recursiv(cr, uid, user_id, account_id) - # temp = self.pool.get('analytic_user_funct_grid').search(cr, uid, [('user_id', '=', user_id),('account_id', '=', account_id) ]) if not temp: #if there isn't any record for this user_id and account_id return super(hr_analytic_timesheet, self).on_change_account_id(cr, uid, ids, account_id) @@ -100,9 +98,9 @@ class hr_analytic_timesheet(osv.osv): 'for this product: "%s" (id:%d)') % \ (r.product_id.name, r.product_id.id,)) # Compute based on pricetype - amount_unit = self.on_change_unit_amount(cr, uid, ids, + amount_unit = self.on_change_unit_amount(cr, uid, ids, r.product_id.id, unit_amount, r.product_id.uom_id.id)['value']['amount'] - + amount = unit_amount * amount_unit res ['value']['amount']= - round(amount, 2) res ['value']['general_account_id']= a @@ -112,19 +110,18 @@ class hr_analytic_timesheet(osv.osv): res = {} if not (user_id): #avoid a useless call to super - return res + return res #get the old values from super res = super(hr_analytic_timesheet, self).on_change_user_id(cr, uid, ids, user_id) if account_id: #get the browse record related to user_id and account_id - # temp = self.pool.get('analytic_user_funct_grid').search(cr, uid, [('user_id', '=', user_id),('account_id', '=', account_id) ]) temp = self._get_related_user_account_recursiv(cr, uid, user_id, account_id) if temp: #add the value from the new relation analytic_user_funct_grid r = self.pool.get('analytic_user_funct_grid').browse(cr, uid, temp)[0] - res['value']['product_id'] = r.product_id.id + res['value']['product_id'] = r.product_id.id #the change of product has to impact the amount, uom and general_account_id a = r.product_id.product_tmpl_id.property_account_expense.id @@ -136,9 +133,9 @@ class hr_analytic_timesheet(osv.osv): 'for this product: "%s" (id:%d)') % \ (r.product_id.name, r.product_id.id,)) # Compute based on pricetype - amount_unit = self.on_change_unit_amount(cr, uid, ids, + amount_unit = self.on_change_unit_amount(cr, uid, ids, r.product_id.id, unit_amount, r.product_id.uom_id.id)['value']['amount'] - + amount = unit_amount * amount_unit res ['value']['amount']= - round(amount, 2) res ['value']['general_account_id']= a -- cgit v1.2.3 From 94fd910f3c02243b09e42a7df9c19ab5f2f9a479 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Tue, 5 Oct 2010 00:56:29 +0200 Subject: fix bzr revid: fp@tinyerp.com-20101004225629-vidur45sz7dmg9nn --- addons/analytic_user_function/analytic_user_function.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/analytic_user_function/analytic_user_function.py') diff --git a/addons/analytic_user_function/analytic_user_function.py b/addons/analytic_user_function/analytic_user_function.py index 0bb9afc3386..21fe0a7da29 100644 --- a/addons/analytic_user_function/analytic_user_function.py +++ b/addons/analytic_user_function/analytic_user_function.py @@ -99,7 +99,7 @@ class hr_analytic_timesheet(osv.osv): (r.product_id.name, r.product_id.id,)) # Compute based on pricetype amount_unit = self.on_change_unit_amount(cr, uid, ids, - r.product_id.id, unit_amount, r.product_id.uom_id.id)['value']['amount'] + r.product_id.id, unit_amount, False, r.product_id.uom_id.id)['value']['amount'] amount = unit_amount * amount_unit res ['value']['amount']= - round(amount, 2) @@ -134,7 +134,7 @@ class hr_analytic_timesheet(osv.osv): (r.product_id.name, r.product_id.id,)) # Compute based on pricetype amount_unit = self.on_change_unit_amount(cr, uid, ids, - r.product_id.id, unit_amount, r.product_id.uom_id.id)['value']['amount'] + r.product_id.id, unit_amount, False, r.product_id.uom_id.id)['value']['amount'] amount = unit_amount * amount_unit res ['value']['amount']= - round(amount, 2) -- cgit v1.2.3 From fa8bd9305df3ee312c0a6af2ad7a8347cfa27e86 Mon Sep 17 00:00:00 2001 From: vth Date: Mon, 11 Oct 2010 15:53:00 +0530 Subject: [REF] account bzr revid: vth@tinyerp.com-20101011102300-59rukbdh3ps9m2dm --- addons/analytic_user_function/analytic_user_function.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/analytic_user_function/analytic_user_function.py') diff --git a/addons/analytic_user_function/analytic_user_function.py b/addons/analytic_user_function/analytic_user_function.py index 21fe0a7da29..04f66fb8daa 100644 --- a/addons/analytic_user_function/analytic_user_function.py +++ b/addons/analytic_user_function/analytic_user_function.py @@ -40,7 +40,7 @@ class account_analytic_account(osv.osv): _inherit = "account.analytic.account" _columns = { - 'user_product_ids' : fields.one2many('analytic_user_funct_grid', 'account_id', 'Users/Products Rel.'), + 'user_product_ids': fields.one2many('analytic_user_funct_grid', 'account_id', 'Users/Products Rel.'), } account_analytic_account() -- cgit v1.2.3