base module quality
bzr revid: mra@tinyerp.com-20081205092733-60b9iki2gxtgiolp
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import wizard
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
{
|
||||
"name" : "Module Merger",
|
||||
"version" : "1.0",
|
||||
"author" : "Tiny",
|
||||
"website" : "http://tinyerp.com",
|
||||
"category" : "Generic Modules/Base",
|
||||
"description": """
|
||||
* The wizard asks a many2many of modules
|
||||
* And then generate a module which is the merge of all selected modules
|
||||
* The new module is provided as a .zip file
|
||||
|
||||
The merge will works in all situations:
|
||||
* Merging all .py files with the same name in the new module
|
||||
* merging all .xml files and take care of id's.
|
||||
""",
|
||||
"depends" : ["base"],
|
||||
"init_xml" : [ ],
|
||||
"demo_xml" : [ ],
|
||||
"update_xml" : [ "base_module_merge_wizard.xml" ],
|
||||
"installable": True
|
||||
}
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<wizard
|
||||
id="wizard_base_module_merger"
|
||||
string="Merge module"
|
||||
model="ir.module.module"
|
||||
multi="True"
|
||||
name="base_module_merge.module_merge"/>
|
||||
|
||||
|
||||
<menuitem
|
||||
parent="base.menu_management"
|
||||
type="wizard"
|
||||
action="wizard_base_module_merger"
|
||||
id="menu_wizard_base_module_merger"/>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -0,0 +1,25 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import base_module_merge
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -0,0 +1,302 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import wizard
|
||||
import osv
|
||||
import pooler
|
||||
import tools
|
||||
import os
|
||||
from xml.dom import minidom
|
||||
|
||||
info_start_form = '''<?xml version="1.0"?>
|
||||
<form string="Module Merging">
|
||||
<field name="modules_list" colspan="4"/>
|
||||
</form>'''
|
||||
|
||||
info_start_fields = {
|
||||
'modules_list': {'string':'Modules', 'type':'many2many','relation':'ir.module.module','help':'Select Modules which you want to merge in single module'},
|
||||
}
|
||||
|
||||
|
||||
intro_start_form = '''<?xml version="1.0"?>
|
||||
<form string="Module Recording">
|
||||
<separator string="Module Information" colspan="4"/>
|
||||
<field name="name"/>
|
||||
<field name="directory_name"/>
|
||||
<field name="version"/>
|
||||
<field name="author"/>
|
||||
<field name="website" colspan="4"/>
|
||||
<field name="category" colspan="4"/>
|
||||
<field name="data_kind"/>
|
||||
<newline/>
|
||||
<field name="description" colspan="4"/>
|
||||
</form>'''
|
||||
|
||||
intro_start_fields = {
|
||||
'name': {'string':'Module Name', 'type':'char', 'size':64, 'required':True},
|
||||
'directory_name': {'string':'Directory Name', 'type':'char', 'size':32, 'required':True},
|
||||
'version': {'string':'Version', 'type':'char', 'size':16, 'required':True},
|
||||
'author': {'string':'Author', 'type':'char', 'size':64, 'default': lambda *args: 'Tiny', 'required':True},
|
||||
'category': {'string':'Category', 'type':'char', 'size':64, 'default': lambda *args: 'Vertical Modules/Parametrization', 'required':True},
|
||||
'website': {'string':'Documentation URL', 'type':'char', 'size':64, 'default': lambda *args: 'http://tinyerp.com', 'required':True},
|
||||
'description': {'string':'Full Description', 'type':'text', 'required':True},
|
||||
'data_kind': {'string':'Type of Data', 'type':'selection', 'selection':[('demo','Demo Data'),('update','Normal Data')], 'required':True, 'default': lambda *args:'update'},
|
||||
}
|
||||
|
||||
intro_save_form = '''<?xml version="1.0"?>
|
||||
<form string="Module Recording">
|
||||
<separator string="Module successfully created !" colspan="4"/>
|
||||
<field name="module_filename"/>
|
||||
<newline/>
|
||||
<field name="module_file"/>
|
||||
<separator string="Information" colspan="4"/>
|
||||
<label string="If you think your module could interrest others people, we'd like you to publish it on TinyERP.com, in the 'Modules' section. You can do it through the website or using features of the 'base_module_publish' module." colspan="4" align="0.0"/>
|
||||
<label string="Thanks in advance for your contribution." colspan="4" align="0.0"/>
|
||||
</form>'''
|
||||
|
||||
intro_save_fields = {
|
||||
'module_file': {'string': 'Module .zip File', 'type':'binary', 'readonly':True},
|
||||
'module_filename': {'string': 'Filename', 'type':'char', 'size': 64, 'readonly':True},
|
||||
}
|
||||
import zipfile
|
||||
from zipfile import PyZipFile, ZIP_DEFLATED
|
||||
import StringIO
|
||||
import base64
|
||||
|
||||
class base_module_merge(wizard.interface):
|
||||
|
||||
def _zip_writestr(self,file_name,data):
|
||||
info = zipfile.ZipInfo(file_name)
|
||||
info.compress_type = zipfile.ZIP_DEFLATED
|
||||
info.external_attr = 2175008768
|
||||
self.archive.writestr(info,data)
|
||||
return True
|
||||
|
||||
def _remove_prefix_ref(self,fromurl,path):
|
||||
infile=tools.file_open(os.path.join(fromurl,path))
|
||||
xml=infile.read()
|
||||
mydom = minidom.parseString(xml)
|
||||
for child in mydom.getElementsByTagName("field"):
|
||||
for attr in child.attributes.keys():
|
||||
if attr=='ref':
|
||||
old=child.getAttribute(attr)
|
||||
if len(old.split('.')) > 1:
|
||||
if old.split('.')[0] in self.dependencies:
|
||||
child.setAttribute(attr,old.split('.')[1])
|
||||
return mydom.toxml()
|
||||
|
||||
def _parse_init(self,path,filename):
|
||||
res=[]
|
||||
path=os.path.join(path,filename)
|
||||
infile=open(path,'r')
|
||||
for i in infile:
|
||||
i=i.strip()
|
||||
if len(i)>0:
|
||||
if i[0]!="#":
|
||||
res.append( i.strip().split('\n')[0])
|
||||
infile.close()
|
||||
return res
|
||||
|
||||
def _zippy(self,archive, fromurl, path, src=True):
|
||||
if path!='':
|
||||
url = os.path.join(fromurl, path)
|
||||
else:
|
||||
url=fromurl
|
||||
if os.path.isdir(url):
|
||||
if path.split('/')[-1].startswith('.'):
|
||||
return False
|
||||
for fname in os.listdir(url):
|
||||
self._zippy(self.archive, fromurl, path and os.path.join(path, fname) or fname, src=src)
|
||||
else:
|
||||
if src:
|
||||
exclude = ['pyo', 'pyc']
|
||||
else:
|
||||
exclude = ['py','pyo','pyc']
|
||||
if (path.split('.')[-1] not in exclude):
|
||||
if os.path.basename(path)=='__init__.py':
|
||||
datas=self._parse_init(fromurl,path)
|
||||
if path in self.dict_init:
|
||||
self.dict_init[path]+=datas
|
||||
else:
|
||||
self.dict_init[path]=datas
|
||||
return True
|
||||
if os.path.basename(path)=='__terp__.py':
|
||||
terp_file=os.path.join(fromurl,path)
|
||||
terp_info=eval(tools.file_open(terp_file).read())
|
||||
self.init_xml+=terp_info['init_xml']
|
||||
self.demo_xml+=terp_info['demo_xml']
|
||||
self.update_xml+=terp_info['update_xml']
|
||||
return True
|
||||
try:
|
||||
info = self.archive.getinfo(path)
|
||||
except KeyError:
|
||||
if path.split('.')[-1] == 'xml':
|
||||
xml_doc=self._remove_prefix_ref(fromurl,path)
|
||||
xml_doc = xml_doc.encode("utf-8")
|
||||
self._zip_writestr(path, xml_doc)
|
||||
else:
|
||||
file_data=tools.file_open(os.path.join(fromurl, path)).read()
|
||||
self._zip_writestr(path, file_data)
|
||||
else:
|
||||
path2=os.path.split(fromurl)[-1]
|
||||
new_path=path2+'_'+os.path.split(path)[-1]
|
||||
if len(os.path.split(path))>1:
|
||||
new_path=os.path.join(os.path.split(path)[0],new_path)
|
||||
if path.split('.')[-1] == 'xml':
|
||||
xml_doc=self._remove_prefix_ref(fromurl,path)
|
||||
xml_doc = xml_doc.encode("utf-8")
|
||||
self._zip_writestr(new_path, xml_doc)
|
||||
if len(os.path.split(path))>1:
|
||||
terp_file=os.path.join(fromurl,'__terp__.py')
|
||||
terp_info=eval(tools.file_open(terp_file).read())
|
||||
if os.path.basename(path) in terp_info['init_xml']:
|
||||
print "in init_xml",new_path
|
||||
self.init_xml+=[os.path.basename(new_path)]
|
||||
elif os.path.basename(path) in terp_info['demo_xml']:
|
||||
print "in demo_xml",new_path
|
||||
self.demo_xml+=[os.path.basename(new_path)]
|
||||
elif os.path.basename(path) in terp_info['update_xml']:
|
||||
print "in update_xml",new_path
|
||||
self.update_xml+=[os.path.basename(new_path)]
|
||||
else:
|
||||
file_data=tools.file_open(os.path.join(fromurl, path)).read()
|
||||
self._zip_writestr(new_path, file_data)
|
||||
if new_path.split('.')[-1] == 'py':
|
||||
new_import='import '+os.path.basename(new_path).split('.')[0]
|
||||
if os.path.dirname(path)=='':
|
||||
dict_key='__init__.py'
|
||||
else:
|
||||
dict_key=os.path.join(os.path.dirname(path),'__init__.py')
|
||||
if dict_key in self.dict_init:
|
||||
self.dict_init[dict_key]+=[new_import]
|
||||
else:
|
||||
self.dict_init[dict_key]=[new_import]
|
||||
return True
|
||||
|
||||
def rec_depend(self,cr, uid, ids, data, context=None, level=50):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
dep_obj=pool.get('ir.module.module.dependency')
|
||||
if level<1:
|
||||
raise Exception, 'Recursion error in modules dependencies !'
|
||||
for module in pool.get('ir.module.module').browse(cr, uid, ids):
|
||||
dep_ids = dep_obj.search(cr, uid, [('module_id', '=', module.id)])
|
||||
if dep_ids:
|
||||
ids2 = []
|
||||
for dep in dep_obj.browse(cr, uid, dep_ids):
|
||||
dep_name=pool.get('ir.module.module').search(cr, uid, [('name','=',dep.name)])
|
||||
ids2.append(dep_name[0])
|
||||
self.rec_depend(cr, uid, ids2, data, context, level-1)
|
||||
if module.name not in data['form']['dependencies']:
|
||||
data['form']['dependencies'].append(module.name)
|
||||
return True
|
||||
|
||||
def _compute_dependencies(self, cr, uid, data, context):
|
||||
data['form']['dependencies']=[]
|
||||
self.rec_depend(cr,uid,data['form']['modules_list'][0][2],data,context)
|
||||
self.dependencies=data['form']['dependencies']
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
return {}
|
||||
|
||||
def _create_module(self, cr, uid, data, context):
|
||||
self.dict_init={}
|
||||
self.init_xml=[]
|
||||
self.demo_xml=[]
|
||||
self.update_xml=[]
|
||||
self.archname = StringIO.StringIO('wb')
|
||||
self.archive = zipfile.ZipFile(self.archname, "w", ZIP_DEFLATED)
|
||||
for module in self.dependencies:
|
||||
ad = tools.config['addons_path']
|
||||
url = os.path.join(ad, module)
|
||||
if not os.path.isdir(url):
|
||||
url=url+'.zip'
|
||||
self._zippy(self.archive, url, '', src=True)
|
||||
dname = data['form']['directory_name']
|
||||
data['form']['depen']=[]
|
||||
|
||||
data['form']['init_xml']=reduce(lambda l, x: x not in l and l.append(x) or l, self.init_xml, [])
|
||||
data['form']['demo_xml']=reduce(lambda l, x: x not in l and l.append(x) or l, self.demo_xml, [])
|
||||
data['form']['update_xml']=reduce(lambda l, x: x not in l and l.append(x) or l, self.update_xml, [])
|
||||
_terp = """{
|
||||
"name" : "%(name)s",
|
||||
"version" : "%(version)s",
|
||||
"author" : "%(author)s",
|
||||
"website" : "%(website)s",
|
||||
"category" : "%(category)s",
|
||||
"description":\"\"\"%(description)s\"\"\",
|
||||
"depends" : %(depen)s,
|
||||
"init_xml" : %(init_xml)s,
|
||||
"demo_xml" : %(demo_xml)s,
|
||||
"update_xml" : %(update_xml)s,
|
||||
"active": True,
|
||||
"installable": True
|
||||
} """ % data['form']
|
||||
for name,datastr in self.dict_init.items():
|
||||
self.dict_init[name]=reduce(lambda l, x: x not in l and l.append(x) or l, self.dict_init[name], [])
|
||||
init_data='\n'.join(self.dict_init[name])
|
||||
self._zip_writestr(name, init_data)
|
||||
self._zip_writestr('__terp__.py', _terp)
|
||||
self.archive.close()
|
||||
return {
|
||||
'module_file': base64.encodestring(self.archname.getvalue()),
|
||||
'module_filename': data['form']['directory_name']+'-'+data['form']['version']+'.zip'
|
||||
}
|
||||
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [],
|
||||
'result': {
|
||||
'type':'form',
|
||||
'arch':info_start_form,
|
||||
'fields': info_start_fields,
|
||||
'state':[
|
||||
('end', 'Cancel', 'gtk-cancel'),
|
||||
('info', 'Continue', 'gtk-ok'),
|
||||
]
|
||||
}
|
||||
},
|
||||
'info': {
|
||||
'actions': [_compute_dependencies],
|
||||
'result': {
|
||||
'type':'form',
|
||||
'arch':intro_start_form,
|
||||
'fields': intro_start_fields,
|
||||
'state':[
|
||||
('end', 'Cancel', 'gtk-cancel'),
|
||||
('save', 'Continue', 'gtk-ok'),
|
||||
]
|
||||
}
|
||||
},
|
||||
'save': {
|
||||
'actions': [_create_module],
|
||||
'result': {
|
||||
'type':'form',
|
||||
'arch':intro_save_form,
|
||||
'fields': intro_save_fields,
|
||||
'state':[
|
||||
('end', 'Close', 'gtk-ok'),
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
base_module_merge('base_module_merge.module_merge')
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
##############################################################################
|
||||
|
||||
import base_module_quality
|
||||
import wizard
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -23,13 +23,13 @@
|
||||
"name" : "Base module quality",
|
||||
"author" : "Tiny",
|
||||
"version" : "1.0",
|
||||
"depends" : ["base", "product"],
|
||||
"depends" : ["base",],
|
||||
"description": "Sample module to check the quality",
|
||||
"init_xml" : [],
|
||||
"update_xml" : ["base_module_quality_view.xml"],
|
||||
"update_xml" : ["base_module_quality_wizard.xml"],
|
||||
"category" : "Tiny Specific Modules/Base module quality",
|
||||
"active": False,
|
||||
"installable": False
|
||||
"installable": True
|
||||
}
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import netsvc
|
||||
from osv import fields, osv
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<wizard id="base_module_quality" model="ir.module.module" name="base.module.quality" string="Check the Quality of module"/>
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -0,0 +1,27 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import module_quality_check
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import wizard
|
||||
import pooler
|
||||
import osv
|
||||
import netsvc
|
||||
|
||||
import sys
|
||||
import tools
|
||||
import os
|
||||
import pylint
|
||||
|
||||
form_check = '''<?xml version="1.0"?>
|
||||
<form string="Quality check">
|
||||
<field name="test" />
|
||||
</form>'''
|
||||
|
||||
fields_check = {
|
||||
'test': {
|
||||
'string':'Tests', 'type':'selection', 'size':64, 'required':True,
|
||||
'selection': [('pylint', 'Pylint'), ('othertest','other')],
|
||||
'default': lambda *args: 'pylint'
|
||||
},
|
||||
}
|
||||
view_form = """<?xml version="1.0"?>
|
||||
<form string="Check quality">
|
||||
<group colspan="2" col="4">
|
||||
<field name="module_info" nolabel="1" colspan="4"/>
|
||||
</group>
|
||||
</form>"""
|
||||
|
||||
view_field = {
|
||||
"module_info": {'type': 'text', 'string': 'check quality',
|
||||
'readonly': True,},
|
||||
}
|
||||
|
||||
class wiz_quality_check(wizard.interface):
|
||||
|
||||
def _check(self, cr, uid, data, context):
|
||||
if data['form']['test'] == 'pylint':
|
||||
pool=pooler.get_pool(cr.dbname)
|
||||
module_data = pool.get('ir.module.module').browse(cr, uid, data['ids'])
|
||||
from pylint_test import pylint_test
|
||||
ad = tools.config['addons_path']
|
||||
url = os.path.join(ad, module_data[0].name)
|
||||
result = pylint_test._test_pylint(self, url)
|
||||
string_ret = ''
|
||||
for i in result:
|
||||
string_ret = string_ret + i + ':\n' + result[i]
|
||||
|
||||
return {'module_info':string_ret}
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [],
|
||||
'result': {'type':'form', 'arch':form_check, 'fields':fields_check, 'state':[('end','Cancel'),('do','Do Test')]}
|
||||
},
|
||||
'do': {
|
||||
'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:
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import pylint_test
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import netsvc
|
||||
from osv import fields, osv
|
||||
import os
|
||||
|
||||
def _test_pylint(self, url):
|
||||
list_files = os.listdir(url)
|
||||
dict_files = {}
|
||||
for file in list_files:
|
||||
if file.split('.')[-1] == 'py':
|
||||
save_file = file.split('.')[0]+".txt"
|
||||
file_path = os.path.join(url, file)
|
||||
a1 = os.system('pylint '+file_path+'>> '+save_file+' ')
|
||||
a2 = os.system('cat '+save_file+' | tail -4 >> temp.txt')
|
||||
fp = open('temp.txt','r')
|
||||
result = fp.read()
|
||||
fp.close()
|
||||
str_result = ''
|
||||
try:
|
||||
for line in result:
|
||||
str_result = str_result + line
|
||||
finally:
|
||||
fp = open('temp.txt','w')
|
||||
fp.write('')
|
||||
fp.close()
|
||||
if str_result.startswith('Global'):
|
||||
dict_files[file] = str_result
|
||||
return dict_files
|
||||
#
|
||||
#class res_partner_contact(osv.osv):
|
||||
# _name = "res.partner.contact"
|
||||
# _description = "res.partner.contact"
|
||||
#
|
||||
# def _title_get(self,cr, user, context={}):
|
||||
# obj = self.pool.get('res.partner.title')
|
||||
# ids = obj.search(cr, user, [])
|
||||
# res = obj.read(cr, user, ids, ['shortcut', 'name','domain'], context)
|
||||
# res = [(r['shortcut'], r['name']) for r in res if r['domain']=='contact']
|
||||
# return res
|
||||
#
|
||||
# _columns = {
|
||||
# 'name': fields.char('Last Name', size=30,required=True),
|
||||
# 'first_name': fields.char('First Name', size=30),
|
||||
# 'mobile':fields.char('Mobile',size=30),
|
||||
# 'title': fields.selection(_title_get, 'Title'),
|
||||
# 'website':fields.char('Website',size=120),
|
||||
# 'lang_id':fields.many2one('res.lang','Language'),
|
||||
# 'job_ids':fields.one2many('res.partner.job','contact_id','Functions and Addresses'),
|
||||
# 'country_id':fields.many2one('res.country','Nationality'),
|
||||
# 'birthdate':fields.date('Birth Date'),
|
||||
# 'active' : fields.boolean('Active'),
|
||||
# 'partner_id':fields.related('job_ids','address_id','partner_id',type='many2one', relation='res.partner', string='Main Employer'),
|
||||
# 'function_id':fields.related('job_ids','function_id',type='many2one', relation='res.partner.function', string='Main Job'),
|
||||
# }
|
||||
# _defaults = {
|
||||
# 'active' : lambda *a: True,
|
||||
# }
|
||||
# def name_get(self, cr, user, ids, context={}):
|
||||
# #will return name and first_name.......
|
||||
# if not len(ids):
|
||||
# return []
|
||||
# res = []
|
||||
# for r in self.read(cr, user, ids, ['name','first_name','title']):
|
||||
# addr = r['title'] and str(r['title'])+" " or ''
|
||||
# addr +=str(r['name'] or '')
|
||||
# if r['name'] and r['first_name']:
|
||||
# addr += ' '
|
||||
# addr += str(r['first_name'] or '')
|
||||
# res.append((r['id'], addr))
|
||||
# return res
|
||||
#res_partner_contact()
|
||||
#
|
||||
#class res_partner_address(osv.osv):
|
||||
#
|
||||
# #overriding of the name_get defined in base in order to remove the old contact name
|
||||
# def name_get(self, cr, user, ids, context={}):
|
||||
# if not len(ids):
|
||||
# return []
|
||||
# res = []
|
||||
# for r in self.read(cr, user, ids, ['zip','city','partner_id', 'street']):
|
||||
# if context.get('contact_display', 'contact')=='partner':
|
||||
# res.append((r['id'], r['partner_id'][1]))
|
||||
# else:
|
||||
# addr = str('')
|
||||
# addr += str(r['street'] or '') + ' ' + str(r['zip'] or '') + ' ' + str(r['city'] or '')
|
||||
# res.append((r['id'], addr.strip() or '/'))
|
||||
# return res
|
||||
#
|
||||
# _name = 'res.partner.address'
|
||||
# _inherit='res.partner.address'
|
||||
# _description ='Partner Address'
|
||||
# _columns = {
|
||||
# 'job_ids':fields.one2many('res.partner.job', 'address_id', 'Contacts'),
|
||||
# }
|
||||
#res_partner_address()
|
||||
#
|
||||
#class res_partner_job(osv.osv):
|
||||
#
|
||||
# def name_get(self, cr, uid, ids, context={}):
|
||||
# if not len(ids):
|
||||
# return []
|
||||
# res = []
|
||||
# for r in self.browse(cr, uid, ids):
|
||||
# res.append((r.id, self.pool.get('res.partner.contact').name_get(cr, uid, [r.contact_id.id])[0][1] +", "+ r.function_id.name))
|
||||
# return res
|
||||
#
|
||||
# def search(self, cr, user, args, offset=0, limit=None, order=None,
|
||||
# context=None, count=False):
|
||||
# for arg in args:
|
||||
# if arg[0]=='address_id':
|
||||
# self._order = 'sequence_partner'
|
||||
# if arg[0]=='contact_id':
|
||||
# self._order = 'sequence_contact'
|
||||
# return super(res_partner_job,self).search(cr, user, args, offset, limit, order, context, count)
|
||||
#
|
||||
# _name = 'res.partner.job'
|
||||
# _description ='Contact Job Title'
|
||||
# _order = 'sequence_contact'
|
||||
# _columns = {
|
||||
# 'name': fields.related('address_id','partner_id', type='many2one', relation='res.partner', string='Partner'),
|
||||
# 'address_id':fields.many2one('res.partner.address','Address'),
|
||||
# 'contact_id':fields.many2one('res.partner.contact','Contact', required=True, ondelete='cascade'),
|
||||
# 'function_id': fields.many2one('res.partner.function','Job Title'),
|
||||
# 'sequence_contact':fields.integer('Sequence',help='Order of importance of this address in the list of addresses of the linked contact'),
|
||||
# 'sequence_partner':fields.integer('Sequence',help='Order of importance of this job title in the list of job title of the linked partner'),
|
||||
# 'email': fields.char('E-Mail', size=240),
|
||||
# 'phone': fields.char('Phone', size=64),
|
||||
# 'date_start' : fields.date('Date Start'),
|
||||
# 'date_stop' : fields.date('Date Stop'),
|
||||
# 'state' : fields.selection([('past', 'Past'),('current', 'Current')], 'State', required=True),
|
||||
# }
|
||||
#
|
||||
# _defaults = {
|
||||
# 'sequence_contact' : lambda *a: 0,
|
||||
# 'state' : lambda *a: 'current',
|
||||
# }
|
||||
#res_partner_job()
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
Reference in New Issue
Block a user