From 61caf30b11064086a58ef83cba8da1494b7986fc Mon Sep 17 00:00:00 2001 From: hmo-tinyerp <> Date: Fri, 19 Dec 2008 15:08:03 +0530 Subject: [PATCH 1/8] replaced '=like' with 'like' to search name of node' bzr revid: hmo-tinyerp-20081219093803-w242aqj3cyuwvmds --- addons/document/document.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/document/document.py b/addons/document/document.py index b8b053eb8b4..d6a87f374a8 100644 --- a/addons/document/document.py +++ b/addons/document/document.py @@ -107,7 +107,7 @@ class node_class(object): where.append( ('parent_id','=',self.object.id) ) where.append( ('res_id','=',False) ) if nodename: - where.append( (fobj._rec_name,'=like',nodename) ) + where.append( (fobj._rec_name,'like',nodename) ) ids = fobj.search(self.cr, self.uid, where+[ ('parent_id','=',self.object and self.object.id or False) ], context=self.context) if self.object and self.root and (self.object.type=='ressource'): ids += fobj.search(self.cr, self.uid, where+[ ('parent_id','=',False) ], context=self.context) @@ -118,7 +118,7 @@ class node_class(object): pool = pooler.get_pool(self.cr.dbname) where = [] if nodename: - where.append(('name','=like',nodename)) + where.append(('name','like',nodename)) if (self.object and self.object.type=='directory') or not self.object2: where.append(('parent_id','=',self.object and self.object.id or False)) else: @@ -144,7 +144,7 @@ class node_class(object): fobj = pool.get('ir.attachment') vargs = [('parent_id','=',False),('res_id','=',False)] if nodename: - vargs.append(('name','=like',nodename)) + vargs.append(('name','like',nodename)) file_ids=fobj.search(self.cr,self.uid,vargs) res = fobj.browse(self.cr, self.uid, file_ids, context=self.context) @@ -174,7 +174,7 @@ class node_class(object): for invalid in INVALID_CHARS: if nodename.find(INVALID_CHARS[invalid]) : nodename=nodename.replace(INVALID_CHARS[invalid],invalid) - where.append(('name','=like',nodename)) + where.append(('name','like',nodename)) ids = obj.search(self.cr, self.uid, where, self.context) res = obj.browse(self.cr, self.uid, ids,self.context) for r in res: @@ -290,7 +290,7 @@ class document_directory(osv.osv): def _get_childs(self, cr, uid, node, nodename=False, context={}): where = [] if nodename: - where.append(('name','=like',nodename)) + where.append(('name','like',nodename)) if object: where.append(('parent_id','=',object.id)) ids = self.search(cr, uid, where, context) From 732284076cf81a478ee1f75acf63690738f1bcfd Mon Sep 17 00:00:00 2001 From: hmo-tinyerp <> Date: Fri, 19 Dec 2008 16:00:32 +0530 Subject: [PATCH 2/8] now binary datas of file will not store in db. removed store=True in datas field of ir.attachment object bzr revid: hmo-tinyerp-20081219103032-fmodunl65i800ol8 --- addons/document/document.py | 82 +++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 44 deletions(-) diff --git a/addons/document/document.py b/addons/document/document.py index d6a87f374a8..75cbdeb2797 100644 --- a/addons/document/document.py +++ b/addons/document/document.py @@ -485,19 +485,15 @@ class document_file(osv.osv): _inherit = 'ir.attachment' def _data_get(self, cr, uid, ids, name, arg, context): result = {} - cr.execute('select id,store_method,datas,store_fname,link from ir_attachment where id in ('+','.join(map(str,ids))+')') - for id,m,d,r,l in cr.fetchall(): - if m=='db': - result[id] = d - elif m=='fs': - try: - path = os.path.join(os.getcwd(), 'filestore', cr.dbname) - value = file(os.path.join(path,r), 'rb').read() - result[id] = base64.encodestring(value) - except: - result[id]='' - else: - result[id] = '' + cr.execute('select id,store_fname,link from ir_attachment where id in ('+','.join(map(str,ids))+')') + for id,r,l in cr.fetchall(): + try: + path = os.path.join(os.getcwd(), 'filestore', cr.dbname) + value = file(os.path.join(path,r), 'rb').read() + result[id] = base64.encodestring(value) + except: + result[id]='' + if context.get('bin_size', False): result[id] = tools.human_size(len(result[id])) @@ -509,26 +505,24 @@ class document_file(osv.osv): def _data_set(self, cr, obj, id, name, value, uid=None, context={}): if not value: return True - if (not context) or context.get('store_method','fs')=='fs': - path = os.path.join(os.getcwd(), "filestore", cr.dbname) - if not os.path.isdir(path): - os.makedirs(path) - flag = None - # This can be improved - for dirs in os.listdir(path): - if os.path.isdir(os.path.join(path,dirs)) and len(os.listdir(os.path.join(path,dirs)))<4000: - flag = dirs - break - flag = flag or create_directory(path) - filename = random_name() - fname = os.path.join(path, flag, filename) - fp = file(fname,'wb') - v = base64.decodestring(value) - fp.write(v) - filesize = os.stat(fname).st_size - cr.execute('update ir_attachment set store_fname=%s,store_method=%s,file_size=%s where id=%s', (os.path.join(flag,filename),'fs',len(v),id)) - else: - cr.execute('update ir_attachment set datas=%s,store_method=%s where id=%s', (Binary(value),'db',id)) + #if (not context) or context.get('store_method','fs')=='fs': + path = os.path.join(os.getcwd(), "filestore", cr.dbname) + if not os.path.isdir(path): + os.makedirs(path) + flag = None + # This can be improved + for dirs in os.listdir(path): + if os.path.isdir(os.path.join(path,dirs)) and len(os.listdir(os.path.join(path,dirs)))<4000: + flag = dirs + break + flag = flag or create_directory(path) + filename = random_name() + fname = os.path.join(path, flag, filename) + fp = file(fname,'wb') + v = base64.decodestring(value) + fp.write(v) + filesize = os.stat(fname).st_size + cr.execute('update ir_attachment set store_fname=%s,store_method=%s,file_size=%s where id=%s', (os.path.join(flag,filename),'fs',len(v),id)) return True _columns = { @@ -543,7 +537,7 @@ class document_file(osv.osv): 'create_date': fields.datetime('Date Created', readonly=True), 'create_uid': fields.many2one('res.users', 'Creator', readonly=True), 'store_method': fields.selection([('db','Database'),('fs','Filesystem'),('link','Link')], "Storing Method"), - 'datas': fields.function(_data_get,method=True,store=True,fnct_inv=_data_set,string='File Content',type="binary"), + 'datas': fields.function(_data_get,method=True,fnct_inv=_data_set,string='File Content',type="binary"), 'store_fname': fields.char('Stored Filename', size=200), 'res_model': fields.char('Attached Model', size=64), #res_model 'res_id': fields.integer('Attached ID'), #res_id @@ -595,8 +589,8 @@ class document_file(osv.osv): cr.commit() try: for f in self.browse(cr, uid, ids, context=context): - if 'datas' not in vals: - vals['datas']=f.datas + #if 'datas' not in vals: + # vals['datas']=f.datas res = content_index(base64.decodestring(vals['datas']), f.datas_fname, f.file_type or None) super(document_file,self).write(cr, uid, ids, { 'index_content': res @@ -635,11 +629,11 @@ class document_file(osv.osv): vals['partner_id']=obj['partner_id'] datas=None - if vals.get('datas',False) and vals.get('link',False) : + if vals.get('link',False) : import urllib datas=base64.encodestring(urllib.urlopen(vals['link']).read()) else: - datas=vals['datas'] + datas=vals.get('datas',False) vals['file_size']= len(datas) if not self._check_duplication(cr,uid,vals): raise except_orm('ValidateError', 'File name must be unique!') @@ -657,12 +651,12 @@ class document_file(osv.osv): def unlink(self,cr, uid, ids, context={}): for f in self.browse(cr, uid, ids, context): - if f.store_method=='fs': - try: - path = os.path.join(os.getcwd(), cr.dbname, 'filestore',f.store_fname) - os.unlink(path) - except: - pass + #if f.store_method=='fs': + try: + path = os.path.join(os.getcwd(), cr.dbname, 'filestore',f.store_fname) + os.unlink(path) + except: + pass return super(document_file, self).unlink(cr, uid, ids, context) document_file() From 045b32b7b065d72a21ed4ec15d2ca70993b99283 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Fri, 19 Dec 2008 17:50:49 +0530 Subject: [PATCH 3/8] added method_test on base_module_quality bzr revid: mra@tinyerp.com-20081219122049-heky9f41aljdf142 --- .../method_test/__init__.py | 24 ++++++ .../method_test/method_test.py | 82 +++++++++++++++++++ .../wizard/module_quality_check.py | 28 ++----- 3 files changed, 113 insertions(+), 21 deletions(-) create mode 100644 addons/base_module_quality/method_test/__init__.py create mode 100644 addons/base_module_quality/method_test/method_test.py diff --git a/addons/base_module_quality/method_test/__init__.py b/addons/base_module_quality/method_test/__init__.py new file mode 100644 index 00000000000..79850888f41 --- /dev/null +++ b/addons/base_module_quality/method_test/__init__.py @@ -0,0 +1,24 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2008 Tiny SPRL (). All Rights Reserved +# $Id$ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/base_module_quality/method_test/method_test.py b/addons/base_module_quality/method_test/method_test.py new file mode 100644 index 00000000000..84f3f167247 --- /dev/null +++ b/addons/base_module_quality/method_test/method_test.py @@ -0,0 +1,82 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2008 Tiny SPRL (). All Rights Reserved +# $Id$ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## + + +import os +from tools import config + +from base_module_quality import base_module_quality +import pooler + +class quality_test(base_module_quality.abstract_quality_check): + + def __init__(self): + self.result = """ +Method Test: +------------ + + This test checks if the class method has exception or not. + + +""" + self.bool_installed_only = False + return None + + def run_test(self, module_path, module_name=None, cr=None, uid=None): + pool = pooler.get_pool(cr.dbname) + ids2 = pool.get('ir.model.data').search(cr, uid, [('module','=', module_name), ('model','=','ir.model')]) + obj_list = [] + for mod in pool.get('ir.model.data').browse(cr, uid, ids2): + object_name = mod.name.split('_') + object_name.pop(0) + object_name = '.'.join(object_name) + obj_list.append(str(object_name)) + result={} + self.result += "Module Name:" + module_name + '\n' + '===============\n' + for obj in obj_list: + temp=[] + try: + res = pool.get(obj).search(cr, uid, []) + temp.append('Ok') + except: + temp.append('Exception') + try: + res1 = pool.get(obj).fields_view_get(cr, uid,) + temp.append('Ok') + except: + temp.append('Exception') + try: + res2 = pool.get(obj).read(cr, uid, []) + temp.append('Ok') + except: + temp.append('Exception') + result[obj] = temp + self.result+=("%-40s %-12s \t %-16s %-12s")%('Object Name'.ljust(40),'search','fields_view_get','read') + self.result+='\n' + for res in result: + self.result+=("%-40s %-12s \t %-16s \t %-12s")%(res.ljust(40),result[res][0],result[res][1],result[res][2]) + self.result+="\n" + return None + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/base_module_quality/wizard/module_quality_check.py b/addons/base_module_quality/wizard/module_quality_check.py index 9a5ec9391dd..da067551e6d 100644 --- a/addons/base_module_quality/wizard/module_quality_check.py +++ b/addons/base_module_quality/wizard/module_quality_check.py @@ -30,29 +30,17 @@ import os #TODO: configure pylint #TODO: implement the speed test #TODO: implement the simple test -#TODO: add cheks: do the class quality_check inherits the class abstract_quality_check? +#TODO: add cheks: do the class quality_check inherits the class abstract_quality_check? #TODO: improve translability #To keep or not? to be discussed... -#~ form_check = ''' -#~
- #~ -#~ ''' - -#~ fields_check = { - #~ 'test': { - #~ 'string':'Tests', 'type':'selection', 'required':True, - #~ 'selection': [('pylint', 'Pylint'), ('othertest','other')], - #~ 'default': lambda *args: 'pylint' - #~ }, - #~ } view_form = """
- +
""" @@ -71,8 +59,8 @@ class wiz_quality_check(wizard.interface): from tools import config pool = pooler.get_pool(cr.dbname) module_data = pool.get('ir.module.module').browse(cr, uid, data['ids']) - list_folders = os.listdir(config['addons_path']+'/base_module_quality/') + module_name = module_data[0].name for item in list_folders: path = config['addons_path']+'/base_module_quality/'+item if os.path.exists(path+'/'+item+'.py') and item not in ['report', 'wizard', 'security']: @@ -83,18 +71,16 @@ class wiz_quality_check(wizard.interface): x2 = getattr(x, item) x3 = getattr(x2, item) val = x3.quality_test() - if not val.bool_installed_only or module_data[0].state == "installed": + if (not val.bool_installed_only or module_data[0].state == "installed") and item == 'method_test': + val.run_test(str(module_path), module_name, cr, uid) + elif not val.bool_installed_only or module_data[0].state == "installed" : val.run_test(str(module_path)) else: val.result += "The module has to be installed before running this test." - string_ret += val.result - print val.result_details return {'general_info':string_ret} - - states = { #To keep or not? to be discussed... @@ -107,8 +93,8 @@ class wiz_quality_check(wizard.interface): 'actions': [_check], 'result': {'type':'form', 'arch':view_form, 'fields':view_field, 'state':[('end','Ok')]}, }, + } - } wiz_quality_check('base.module.quality') # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From aee47aa5e2eddc8972f163d79e545d1fe6967324 Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Fri, 19 Dec 2008 18:42:35 +0530 Subject: [PATCH 4/8] now its possible to have the dynamic currency on the product label * add new field called company_id this will be appear on the form in extended view only lp bug: https://launchpad.net/bugs/309565 fixed bzr revid: mga@tinyerp.com-20081219131235-4ixr7lkboozsuofe --- addons/product/product.py | 6 +++++- addons/product/product_view.xml | 1 + addons/product/report/product_label.xml | 1 + addons/product/report/product_label.xsl | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/addons/product/product.py b/addons/product/product.py index 35d0bb4182e..06343eda249 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -271,8 +271,9 @@ class product_template(osv.osv): 'loc_rack': fields.char('Rack', size=16), 'loc_row': fields.char('Row', size=16), 'loc_case': fields.char('Case', size=16), + 'company_id': fields.many2one('res.company', 'Company'), } - + def _get_uom_id(self, cr, uid, *args): cr.execute('select id from product_uom order by id limit 1') res = cr.fetchone() @@ -284,6 +285,9 @@ class product_template(osv.osv): return False _defaults = { + 'company_id': lambda self, cr, uid, context: \ + self.pool.get('res.users').browse(cr, uid, uid, + context=context).company_id.id, 'type': lambda *a: 'product', 'list_price': lambda *a: 1, 'cost_method': lambda *a: 'standard', diff --git a/addons/product/product_view.xml b/addons/product/product_view.xml index fa9ff515aef..1aacaa39691 100644 --- a/addons/product/product_view.xml +++ b/addons/product/product_view.xml @@ -101,6 +101,7 @@ + diff --git a/addons/product/report/product_label.xml b/addons/product/report/product_label.xml index ba7d202cb81..beb8d22d6e2 100644 --- a/addons/product/report/product_label.xml +++ b/addons/product/report/product_label.xml @@ -6,5 +6,6 @@ + diff --git a/addons/product/report/product_label.xsl b/addons/product/report/product_label.xsl index 2df7e8d3e2c..f76cea07e94 100644 --- a/addons/product/report/product_label.xsl +++ b/addons/product/report/product_label.xsl @@ -66,7 +66,7 @@ - EUR + From d1b708e379c30bd0792ed56b953965ac6802a373 Mon Sep 17 00:00:00 2001 From: hmo-tinyerp <> Date: Fri, 19 Dec 2008 19:21:02 +0530 Subject: [PATCH 5/8] * add picking_id in list view & form view of stock move and can be able to cancel stock move line in packing form bzr revid: hmo-tinyerp-20081219135102-mrf5fl593gazsehc --- addons/stock/stock_view.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index 20aa537f08b..f8f3837e06b 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -553,6 +553,7 @@