bzr revid: fp@tinyerp.com-20091005122731-35fhj0xbqsoah5se
This commit is contained in:
Fabien Pinckaers
2009-10-05 14:27:31 +02:00
20 changed files with 107 additions and 182 deletions
+1
View File
@@ -1709,6 +1709,7 @@
<field name="arch" type="xml">
<form string="Fiscal Position Template">
<field name="name" select="1"/>
<field name="chart_template_id"/>
<newline/>
<field name="tax_ids" colspan="4">
<tree string="Taxes Mapping" editable="bottom">
@@ -161,6 +161,38 @@ class abstract_quality_check(object):
def add_quatation(self, x_no, y_no):
return x_no/y_no
def get_style(self):
# This function return style tag with specified styles for html pages
style = '''
<style>
.divstyle {
border:1px solid #aaaaaa;
background-color:#f9f9f9;
padding:5px;
}
.tablestyle
{
border:1px dashed gray;
}
.tdatastyle
{
border:0.5px solid gray;
}
.head
{
color: black;
background: none;
font-weight: normal;
margin: 0;
padding-top: .5em;
padding-bottom: .17em;
border-bottom: 1px solid #aaa;
}
}
</style> '''
return style
class module_quality_check(osv.osv):
_name = 'module.quality.check'
_columns = {
@@ -40,7 +40,6 @@ Test checks for fields, views, security rules, dependancy level
return None
def run_test(self, cr, uid, module_path):
pool = pooler.get_pool(cr.dbname)
module_name = module_path.split('/')[-1]
obj_list = self.get_objects(cr, uid, module_name)
@@ -184,24 +183,9 @@ Test checks for fields, views, security rules, dependancy level
def get_result_details(self, dict_obj):
res = ""
if dict_obj != {}:
str_html = '''<html><strong> Fields Result</strong><head>
<style>
.bstyle
{
border-width:2px;
border-style:dashed;
border-color: gray;
}
.btstyle
{
border-width:2px;
border-style:solid;
border-color: gray;
}
}
</style></head><body>'''
str_html = '''<html><strong> Fields Result</strong><head>%s</head><body>'''%(self.get_style())
res += str_html
header = ('<tr><th class="btstyle">%s</th><th class="btstyle">%s</th><th class="btstyle">%s</th></tr>', [_('Object Name'), _('Field name'), _('Suggestion')])
header = ('<tr><th class="tdatastyle">%s</th><th class="tdatastyle">%s</th><th class="tdatastyle">%s</th></tr>', [_('Object Name'), _('Field name'), _('Suggestion')])
if not self.error:
for key in dict_obj.keys():
data_list = []
@@ -211,34 +195,18 @@ Test checks for fields, views, security rules, dependancy level
for i in data_list:
count = count + 1
final_dict[key + str(count)] = i
res_str = '<table class="bstyle">' + self.format_html_table(header, data_list=final_dict) + '</table><br>'
res += res_str.replace('''<td''', '''<td class="btstyle" ''')
res_str = '<table class="tablestyle">' + self.format_html_table(header, data_list=final_dict) + '</table><br>'
res += res_str.replace('''<td''', '''<td class="tdatastyle" ''')
return res + '</body></html>'
return ""
def get_result_general(self, dict_obj, name=''):
str_html = '''<html><strong> %s Result</strong><head>
<style>
.bstyle
{
border-width:2px;
border-style:dashed;
border-color: gray;
}
.btstyle
{
border-width:2px;
border-style:solid;
border-color: gray;
}
}
</style></head><body><table class="bstyle">'''% (name)
header = ('<tr><th class="btstyle">%s</th><th class="btstyle">%s</th></tr>', [_('Object Name'), _('Suggestion')])
str_html = '''<html><strong> %s Result</strong><head>%s</head><body><table class="tablestyle">'''% (name, self.get_style())
header = ('<tr><th class="tdatastyle">%s</th><th class="tdatastyle">%s</th></tr>', [_('Object Name'), _('Suggestion')])
if not self.error:
res = str_html + self.format_html_table(header, data_list=dict_obj) + '</table></body></html>'
res = res.replace('''<td''', '''<td class="btstyle" ''')
res = res.replace('''<td''', '''<td class="tdatastyle" ''')
return res
return ""
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -271,27 +271,11 @@ PEP-8 Test , copyright of py files check, method can not call from loops
return ""
def get_result_general(self, dict_obj):
str_html = '''<html><strong>Result</strong><head>
<style>
.bstyle
{
border-width:2px;
border-style:dashed;
border-color: gray;
}
.btstyle
{
border-width:2px;
border-style:solid;
border-color: gray;
}
}
</style>
</head><body><table class="bstyle">'''
header = ('<tr><th class="btstyle">%s</th><th class="btstyle">%s</th><th class="btstyle">%s</th></tr>', [_('Object Name'), _('Line number'), _('Suggestion')])
str_html = '''<html><strong>Result</strong><head>%s</head><body><table class="tablestyle">'''%(self.get_style())
header = ('<tr><th class="tdatastyle">%s</th><th class="tdatastyle">%s</th><th class="tdatastyle">%s</th></tr>', [_('Object Name'), _('Line number'), _('Suggestion')])
if not self.error:
res = str_html + self.format_html_table(header, data_list=dict_obj) + '</table></body></html>'
res = res.replace('''<td''', '''<td class="btstyle" ''')
res = res.replace('''<td''', '''<td class="tdatastyle" ''')
return res
return ""
@@ -48,29 +48,7 @@ class quality_test(base_module_quality.abstract_quality_check):
score = 0.0
dict_py = {}
flag = False
self.result_details += '''<html><body><head>
<style>
.bstyle
{
border-width:2px;
border-style:dashed;
border-color: gray;
}
.btstyle
{
border-width:2px;
border-style:solid;
border-color: gray;
}
.head
{
color: black;background: none;font-weight: normal;margin: 0;padding-top: .5em;
padding-bottom: .17em; border-bottom: 1px solid #aaa;
}
}
</style>
'''
self.result_details += '''<html><body><head>%s</head>'''%(self.get_style())
for file_py in list_files:
if file_py.split('.')[-1] == 'py' and not file_py.endswith('__init__.py') and not file_py.endswith('__terp__.py'):
if not flag:
@@ -104,17 +82,18 @@ class quality_test(base_module_quality.abstract_quality_check):
dict_py[file_py] = [file_py, _("Unable to parse the result. Check the details.")]
replace_string = ''
replace_string += res
replace_string = replace_string.replace('''<div''', '''<div style="border:1px solid #aaaaaa;background-color:#f9f9f9;padding:5px;"''')
replace_string = replace_string.replace('''<div''', '''<div class="divstyle" ''')
replace_string = replace_string.replace('''<h1''', '''<h1 style="font-size:188%" class="head" ''')
replace_string = replace_string.replace('''<h2''', '''<h2 style="font-size:150%" class="head" ''')
replace_string = replace_string.replace('''<h3''', '''<h3 style="font-size:132%" class="head" ''')
replace_string = replace_string.replace('''<h4''', '''<h4 style="font-size:116%" class="head" ''')
replace_string = replace_string.replace('''<h5''', '''<h5 style="font-size:100%" class="head" ''')
replace_string = replace_string.replace('''<h6''', '''<h6 style="font-size:80%" class="head" ''')
replace_string = replace_string.replace('''<table''', '''<table class="bstyle" ''')
replace_string = replace_string.replace('''<th''', '''<th class="btstyle" ''')
replace_string = replace_string.replace('''<td''', '''<td class="btstyle" ''')
replace_string = replace_string.replace('''<table''', '''<table class="tablestyle" ''')
replace_string = replace_string.replace('''<th''', '''<th class="tdatastyle" ''')
replace_string = replace_string.replace('''<td''', '''<td class="tdatastyle" ''')
self.result_details += replace_string
if not flag:
self.error = True
self.result = _("No python file found")
@@ -133,5 +112,4 @@ class quality_test(base_module_quality.abstract_quality_check):
return self.format_table(header, data_list=dict_py)
return ""
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -125,26 +125,11 @@ This test checks the speed of the module. Note that at least 5 demo data is need
return ""
def get_result_details(self, dict_speed):
str_html = '''<html><head>
<style>
.bstyle
{
border-width:2px;
border-style:dashed;
border-color: gray;
}
.btstyle
{
border-width:2px;
border-style:solid;
border-color: gray;
}
}
</style></head><body><table class="bstyle">'''
header = ('<tr><th class="btstyle" >%s</th><th class="btstyle">%s</th><th class="btstyle">%s</th><th class="btstyle">%s</th><th class="btstyle">%s</th><th class="btstyle">%s</th></tr>', [_('Object Name'), _('N (Number of Records)'), _('1'), _('N/2'), _('N'), _('Reading Complexity')])
str_html = '''<html><head>%s</head><body><table class="tablestyle">'''%(self.get_style())
header = ('<tr><th class="tdatastyle" >%s</th><th class="tdatastyle">%s</th><th class="tdatastyle">%s</th><th class="tdatastyle">%s</th><th class="tdatastyle">%s</th><th class="tdatastyle">%s</th></tr>', [_('Object Name'), _('N (Number of Records)'), _('1'), _('N/2'), _('N'), _('Reading Complexity')])
if not self.error:
res = str_html + self.format_html_table(header, data_list=dict_speed) + '</table></body></html>'
res = res.replace('''<td''', '''<td class="btstyle" ''')
res = res.replace('''<td''', '''<td class="tdatastyle" ''')
return res
return ""
@@ -23,6 +23,7 @@ import os
from tools.translate import _
from base_module_quality import base_module_quality
import pooler
class quality_test(base_module_quality.abstract_quality_check):
@@ -135,7 +136,6 @@ This test checks if the module satisfy tiny structure
self.module_score += final_score
self.score = self.module_score / (self.count)
self.result = self.get_result({ module_name: [module_name, int(self.score*100)]})
# self.result_details += self.get_result_details(self.result_dict)
return None
def run_test(self, cr, uid, module_path):
@@ -170,28 +170,12 @@ This test checks if the module satisfy tiny structure
return score
def get_result_details(self, dict_struct):
str_html = '''<html><head>
<style>
.bstyle
{
border-width:2px;
border-style:dashed;
border-color: gray;
}
.btstyle
{
border-width:2px;
border-style:solid;
border-color: gray;
}
}
</style></head><body><table class="bstyle">'''
header = ('<tr><th class="btstyle">%s</th><th class="btstyle">%s</th></tr>', [_('File Name'), _('Feedback about structure of module')])
str_html = '''<html><head>%s</head><body><table class="tablestyle">'''%(self.get_style())
header = ('<tr><th class="tdatastyle">%s</th><th class="tdatastyle">%s</th></tr>', [_('File Name'), _('Feedback about structure of module')])
if not self.error:
res = str_html + self.format_html_table(header, data_list=dict_struct) + '</table></body></html>'
res = res.replace('''<td''', '''<td class="btstyle" ''')
res = res.replace('''<td''', '''<td class="tdatastyle" ''')
return res
return ""
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -26,7 +26,6 @@ import re
import tools
from tools.translate import _
from base_module_quality import base_module_quality
import pooler
class quality_test(base_module_quality.abstract_quality_check):
@@ -116,6 +115,7 @@ class quality_test(base_module_quality.abstract_quality_check):
if result_dict1 or result_dict1:
score = round((feel_good_factor) / float(feel_good_factor + feel_bad_factor), 2)
self.result_details += self.get_result_details(result_dict)
self.result_details += self.get_result_details(result_dict1)
return [_('__terp__.py file'), score]
@@ -137,26 +137,11 @@ class quality_test(base_module_quality.abstract_quality_check):
def get_result_details(self, dict_terp):
if dict_terp:
str_html = '''<html><head>
<style>
.bstyle
{
border-width:2px;
border-style:dashed;
border-color: gray;
}
.btstyle
{
border-width:2px;
border-style:solid;
border-color: gray;
}
}
</style></head><body><table class="bstyle">'''
header = ('<tr><th class="btstyle">%s</th><th class="btstyle">%s</th></tr>', [_('Tag Name'), _('Feed back About terp file of Module')])
str_html = '''<html><head>%s</head><body><table class="tablestyle">'''%(self.get_style())
header = ('<tr><th class="tdatastyle">%s</th><th class="tdatastyle">%s</th></tr>', [_('Tag Name'), _('Feed back About terp file of Module')])
if not self.error:
res = str_html + self.format_html_table(header, data_list=dict_terp) + '</table><newline/></body></html>'
res = res.replace('''<td''', '''<td class="btstyle" ''')
res = res.replace('''<td''', '''<td class="tdatastyle" ''')
return res
return ""
@@ -23,6 +23,4 @@
import module_quality_check
import quality_save_report
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -134,26 +134,11 @@ class quality_test(base_module_quality.abstract_quality_check):
return ""
def get_result_details(self, dict_wf):
str_html = '''<html><head>
<style>
.bstyle
{
border-width:2px;
border-style:dashed;
border-color: gray;
}
.btstyle
{
border-width:2px;
border-style:solid;
border-color: gray;
}
}
</style></head><body><table class="bstyle">'''
header = ('<tr><th class="btstyle">%s</th><th class="btstyle">%s</th></tr>', [_('Object Name'), _('Feed back About Workflow of Module')])
str_html = '''<html><head>%s</head><body><table class="tablestyle">'''%(self.get_style())
header = ('<tr><th class="tdatastyle">%s</th><th class="tdatastyle">%s</th></tr>', [_('Object Name'), _('Feed back About Workflow of Module')])
if not self.error:
res = str_html + self.format_html_table(header, data_list=dict_wf) + '</table><newline/></body></html>'
res = res.replace('''<td''', '''<td class="btstyle" ''')
res = res.replace('''<td''', '''<td class="tdatastyle" ''')
return res
return ""
@@ -107,7 +107,16 @@ class report_creator(osv.osv):
else:
temp_list.append('''<field name="%(name)s" select="1"/>''' % {'name':'field'+str(i)})
i+=1
arch += '''<%(view_type)s string="%(string)s" date_start="%(date_start)s" date_delay="%(date_delay)s" color="%(color)s">''' %set_dict
arch += '''<%(view_type)s string="%(string)s" date_start="%(date_start)s" ''' %set_dict
if set_dict.get('date_delay',False):
arch +=''' date_delay="%(date_delay)s" '''%set_dict
if set_dict.get('date_stop',False):
arch +=''' date_stop="%(date_stop)s" '''%set_dict
if set_dict.get('color',False):
arch +=''' color="%(color)s"'''%set_dict
arch += '''>'''
arch += ''.join(temp_list)
else:
arch += '<%s string="%s">\n' % (view_type, report.name)
@@ -375,7 +384,7 @@ class report_creator_field(osv.osv):
'report_id': fields.many2one('base_report_creator.report','Report', on_delete='cascade'),
'group_method': fields.selection([('group','Grouped'),('sum','Sum'),('min','Minimum'),('count','Count'),('max','Maximum'),('avg','Average')], 'Grouping Method', required=True),
'graph_mode': fields.selection([('','/'),('x','X Axis'),('y','Y Axis')], 'Graph Mode'),
'calendar_mode': fields.selection([('','/'),('date_start','Starting Date'),('date_end','Ending Date'),('date_delay','Delay'),('color','Uniq Colors')], 'Calendar Mode'),
'calendar_mode': fields.selection([('','/'),('date_start','Starting Date'),('date_end','Ending Date'),('date_delay','Delay'),('date_stop','End Date'),('color','Unique Colors')], 'Calendar Mode'),
}
_defaults = {
'group_method': lambda *args: 'group',
+5 -6
View File
@@ -651,11 +651,11 @@ class document_file(osv.osv):
def create(self, cr, uid, vals, context={}):
vals['title']=vals['name']
vals['parent_id'] = context.get('parent_id',False) or vals.get('parent_id',False)
# if not vals.get('res_id', False) and context.get('default_res_id',False):
# vals['res_id']=context.get('default_res_id',False)
# if not vals.get('res_model', False) and context.get('default_res_model',False):
# vals['res_model']=context.get('default_res_model',False)
vals['res_model'] = "report.document.user"
if not vals.get('res_id', False) and context.get('default_res_id',False):
vals['res_id']=context.get('default_res_id',False)
if not vals.get('res_model', False) and context.get('default_res_model',False):
vals['res_model']=context.get('default_res_model',False)
if vals.get('res_id', False) and vals.get('res_model',False):
obj_model=self.pool.get(vals['res_model'])
result = obj_model.read(cr, uid, [vals['res_id']], context=context)
@@ -695,7 +695,6 @@ class document_file(osv.osv):
res = content_index(base64.decodestring(datas), vals['datas_fname'], vals.get('content_type', None))
super(document_file,self).write(cr, uid, [result], {
'index_content' : res,
'res_id' : result
})
cr.commit()
except:
@@ -16,6 +16,7 @@
<field name="product_uom_id" on_change="on_change_unit_amount(product_id, unit_amount, product_uom_id)"/>
<field name="amount" sum="Total cost"/>
<field name="general_account_id"/>
<field name="journal_id"/>
</tree>
</field>
</record>
+12 -2
View File
@@ -81,8 +81,18 @@ product_pricelist_type()
class product_pricelist(osv.osv):
def _pricelist_type_get(self, cr, uid, context={}):
cr.execute('select key,name from product_pricelist_type order by name')
return cr.fetchall()
pricelist_type_obj = self.pool.get('product.pricelist.type')
pricelist_type_ids = pricelist_type_obj.search(cr, uid, [], order='name')
pricelist_types = pricelist_type_obj.read(cr, uid, pricelist_type_ids, ['key','name'], context=context)
res = []
for type in pricelist_types:
res.append((type['key'],type['name']))
return res
# cr.execute('select key,name from product_pricelist_type order by name')
# return cr.fetchall()
_name = "product.pricelist"
_description = "Pricelist"
_columns = {
+2 -1
View File
@@ -329,7 +329,8 @@ class purchase_order(osv.osv):
'journal_id': len(journal_ids) and journal_ids[0] or False,
'origin': o.name,
'invoice_line': il,
'fiscal_position': o.partner_id.property_account_position.id
'fiscal_position': o.partner_id.property_account_position.id,
'payment_term':o.partner_id.property_payment_term and o.partner_id.property_payment_term.id or False,
}
inv_id = self.pool.get('account.invoice').create(cr, uid, inv, {'type':'in_invoice'})
self.pool.get('account.invoice').button_compute(cr, uid, [inv_id], {'type':'in_invoice'}, set_total=True)
+1 -3
View File
@@ -215,10 +215,8 @@
<field name="type">tree</field>
<field name="arch" type="xml">
<tree colors="red:date_planned&lt;=current_date" string="Purchase Order Lines">
<field name="order_id"/>
<field name="date_order"/>
<field name="name"/>
<field name="date_planned"/>
<field name="partner_id"/>
<field name="product_id"/>
<field name="product_qty"/>
<field name="product_uom"/>
+2 -1
View File
@@ -37,6 +37,7 @@ merge_form = """<?xml version="1.0"?>
* their status is draft
* they belong to the same partner
* are going to the same location
* have the same pricelist
- lines will only be merged if:
* they are exactly the same except for the quantity and unit</label>
</form>
@@ -76,7 +77,7 @@ def _merge_orders(self, cr, uid, data, context):
# compute what the new orders should contain
new_orders = {}
for porder in [order for order in order_obj.browse(cr, uid, data['ids']) if order.state == 'draft']:
order_key = make_key(porder, ('partner_id', 'location_id'))
order_key = make_key(porder, ('partner_id', 'location_id', 'pricelist_id'))
new_order = new_orders.setdefault(order_key, ({}, []))
new_order[1].append(porder.id)
+1 -1
View File
@@ -47,7 +47,7 @@ class report_project_task_user(osv.osv):
t.user_id,
t.project_id,
sum(planned_hours) as hours_planned,
to_char(avg(date_close::abstime-t.create_date::timestamp), 'DD"d" HH12:MI:SS') as closing_days,
to_char(avg(date_close::abstime-t.create_date::timestamp), 'DD"d" HH24:MI:SS') as closing_days,
sum(w.hours) as hours_effective,
((sum(planned_hours)-sum(w.hours))/count(distinct t.id))::decimal(16,2) as hours_delay
from project_task t
+2
View File
@@ -1266,6 +1266,7 @@ class stock_move(osv.osv):
(0, 0, {
'name': move.name,
'quantity': move.product_qty,
'product_id': move.product_id and move.product_id.id or False,
'credit': amount,
'account_id': acc_src,
'ref': ref,
@@ -1273,6 +1274,7 @@ class stock_move(osv.osv):
'partner_id': partner_id}),
(0, 0, {
'name': move.name,
'product_id': move.product_id and move.product_id.id or False,
'quantity': move.product_qty,
'debit': amount,
'account_id': acc_dest,
+4
View File
@@ -620,6 +620,7 @@
<form string="Packing list">
<group col="6" colspan="4">
<field name="address_id" select="1"/>
<field name="type"/>
<field name="name" select="1" readonly="1"/>
<field name="min_date" select="1"/>
<field name="backorder_id" select="2" readonly="1"/>
@@ -811,6 +812,7 @@
<form string="Packing list">
<group col="6" colspan="4">
<field name="address_id" select="2"/>
<field name="type"/>
<field name="min_date" select="2"/>
<field name="name" select="1" readonly="1"/>
<field name="invoice_state"/>
@@ -991,6 +993,7 @@
<form string="Input Packing List">
<group colspan="4" col="6">
<field name="address_id" on_change="onchange_partner_in(address_id)" select="2" context="{'contact_display':'partner'}"/>
<field name="type"/>
<field name="origin" select="2"/>
<field name="invoice_state" select="2" string="Invoice Control"/>
<field name="name" readonly="1" select="1"/>
@@ -1245,6 +1248,7 @@
<field name="address_id" select="2" context="{'contact_display':'partner'}"/>
<newline/>
<field name="picking_id" select="2"/>
<newline/>
<field name="prodlot_id" select="2"
context="{'location_id':location_id, 'product_id':product_id}"
domain="[('product_id','=',product_id)]"