|
-
-
-
+ [[ repeatIn(adr_get(o, 'invoice'),'addr') ]]
|
[[ o.name ]]
- [[ adr_get(o, 'invoice')['name'] ]]
- [[ adr_get(o, 'invoice')['street'] ]]
- [[ adr_get(o, 'invoice')['zip'] ]] [[ adr_get(o, 'invoice')['city'] ]]
- [[ adr_get(o, 'invoice')['country_id'] and adr_get(o, 'invoice')['country_id'][1] ]]
+ [[ addr['name'] ]]
+ [[ addr['street'] ]]
+ [[ addr['zip'] ]] [[ addr['city'] ]]
+ [[ addr['country_id'] ]]
diff --git a/addons/base_module_quality/base_module_quality.py b/addons/base_module_quality/base_module_quality.py
index 30b40de1a87..d6dd19d3524 100644
--- a/addons/base_module_quality/base_module_quality.py
+++ b/addons/base_module_quality/base_module_quality.py
@@ -70,6 +70,9 @@ class abstract_quality_check(object):
#This variable is use to make result of test should have more weight (Some tests are more critical than others)
self.ponderation = 0.0
+ #Specify test got an error on module
+ self.error = False
+
self.tests = []
self.list_folders = os.listdir(config['addons_path']+'/base_module_quality/')
for item in self.list_folders:
@@ -138,7 +141,7 @@ class abstract_quality_check(object):
res_format['summary'] = data_list[0]
elif test=='terp':
res_format['summary'] = data_list[0]
- res_format['detail'] = data_list[1]
+ res_format['detail'] = data_list[1]
return res_format
def add_quatation(self, x, y):
diff --git a/addons/base_module_quality/method_test/method_test.py b/addons/base_module_quality/method_test/method_test.py
index 3d7f2650fad..57ca26c3295 100644
--- a/addons/base_module_quality/method_test/method_test.py
+++ b/addons/base_module_quality/method_test/method_test.py
@@ -48,7 +48,6 @@ class quality_test(base_module_quality.abstract_quality_check):
result = {}
ok_count = 0
ex_count = 0
- error = False
for obj in obj_list:
temp = []
try:
@@ -91,8 +90,8 @@ This test checks if the module classes are raising exception when calling basic
The module has to be installed before running this test.\n\n """
header_list = ""
- error = True
- self.result = self.format_table(test='method', header=header_list, data_list=[summary,result,error])
+ self.error = True
+ self.result = self.format_table(test='method', header=header_list, data_list=[summary,result,self.error])
return None
diff --git a/addons/base_module_quality/pylint_test/pylint_test.py b/addons/base_module_quality/pylint_test/pylint_test.py
index c25b884d8e9..a99c7256e3d 100644
--- a/addons/base_module_quality/pylint_test/pylint_test.py
+++ b/addons/base_module_quality/pylint_test/pylint_test.py
@@ -54,7 +54,6 @@ class quality_test(base_module_quality.abstract_quality_check):
score = 0.0
detail = ""
detail = "\n===Pylint Test===\n"
- error = False
for file in list_files:
if file.split('.')[-1] == 'py' and not file.endswith('__init__.py') and not file.endswith('__terp__.py'):
file_path = os.path.join(module_path, file)
@@ -89,8 +88,8 @@ This test checks if the module satisfies the current coding standard used by Ope
The module has to be installed before running this test.\n\n """
header_list = ""
- error = True
- self.result = self.format_table(test='pylint', data_list=[summary,detail,error])
+ self.error = True
+ self.result = self.format_table(test='pylint', data_list=[summary,detail,self.error])
return None
diff --git a/addons/base_module_quality/speed_test/speed_test.py b/addons/base_module_quality/speed_test/speed_test.py
index 7db0d572624..317bb12225b 100644
--- a/addons/base_module_quality/speed_test/speed_test.py
+++ b/addons/base_module_quality/speed_test/speed_test.py
@@ -55,7 +55,6 @@ class quality_test(base_module_quality.abstract_quality_check):
obj_ids = self.get_ids(cr, uid, obj_list)
detail = ""
list1 = []
- error = False
for obj in obj_ids:
obj_counter += 1
ids = obj_ids[obj]
@@ -110,8 +109,8 @@ This test checks the speed of the module.
The module has to be installed before running this test.\n\n """
header_list = ""
- error = True
- self.result = self.format_table(test='speed', header=header_list, data_list=[summary,list1, error])
+ self.error = True
+ self.result = self.format_table(test='speed', header=header_list, data_list=[summary,list1,self.error])
return None
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/base_module_quality/terp_test/__init__.py b/addons/base_module_quality/terp_test/__init__.py
new file mode 100644
index 00000000000..79850888f41
--- /dev/null
+++ b/addons/base_module_quality/terp_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/terp_test/terp_test.py b/addons/base_module_quality/terp_test/terp_test.py
new file mode 100644
index 00000000000..202c9705b6d
--- /dev/null
+++ b/addons/base_module_quality/terp_test/terp_test.py
@@ -0,0 +1,108 @@
+# -*- 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
+import tools
+
+from base_module_quality import base_module_quality
+import pooler
+import re
+
+class quality_test(base_module_quality.abstract_quality_check):
+
+ def __init__(self):
+ '''
+ This test checks the quality of __terp__.py file in the selected module.
+ '''
+ super(quality_test, self).__init__()
+ self.bool_installed_only = True
+ return None
+
+ def run_test(self, cr, uid, module_path, module_state):
+ no_terp = False
+ list_files = os.listdir(module_path)
+ for i in list_files:
+ path = os.path.join(module_path, i)
+ if os.path.isdir(path):
+ for j in os.listdir(path):
+ list_files.append(os.path.join(i, j))
+
+ n = 0
+ score = 0.0
+ feel_good_factor = 0
+ feel_bad_factor = 0
+ detail = "\n===TERP Test===\n"
+ summary = "\n===TERP Test===:\n"
+
+ if '__terp__.py' not in list_files:
+ no_terp = True
+
+ if no_terp:
+ summary += """
+The module does not contain the __terp__.py file.\n\n """
+ header_list = ""
+ self.error = True
+ self.result = self.format_table(test='terp', data_list=[summary, detail, self.error])
+ return None
+
+ terp_file = os.path.join(module_path,'__terp__.py')
+ res = eval(tools.file_open(terp_file).read())
+
+ terp_keys = ['category', 'name', 'description', 'author', 'website', 'update_xml', 'init_xml', 'depends', 'version', 'active', 'installable', 'demo_xml']
+
+ for key in terp_keys:
+ if key in res:
+ feel_good_factor += 1
+ if isinstance(res[key],(str,unicode)):
+ if not res[key]:
+ feel_bad_factor += 1
+ else:
+ if key == 'description' and res[key] and len(str(res[key]))>=25:
+ feel_good_factor += 1
+ if res['description'].count('\n') >= 4:# description contains minimum 5 lines
+ feel_good_factor += 1
+ if key == 'website':
+ ptrn = re.compile('https?://[\w\.]*') # reg ex matching on temporary basis.
+ result = ptrn.search(str(res[key]))
+ if result:
+ feel_good_factor += 1
+ else:
+ feel_bad_factor += 1
+
+ self.score = round((feel_good_factor * 10) / float(feel_good_factor + feel_bad_factor),2)
+# if not self.bool_installed_only or module_state=="installed":
+ summary += """
+This test checks if the module satisfies the current coding standard for __terp__.py file used by OpenERP.
+
+"""
+# else:
+# summary += """
+#The module has to be installed before running this test.\n\n """
+# header_list = ""
+# error = True
+
+ detail += "__terp__.py : "+ str(self.score) + "/10\n"
+ self.result = self.format_table(test='terp', data_list=[summary, detail, self.error])
+ return None
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/base_module_quality/wizard/module_quality_check.py b/addons/base_module_quality/wizard/module_quality_check.py
index 3bf863764ac..af8331ff40e 100644
--- a/addons/base_module_quality/wizard/module_quality_check.py
+++ b/addons/base_module_quality/wizard/module_quality_check.py
@@ -77,7 +77,8 @@ class wiz_quality_check(osv.osv_memory):
val = test.quality_test()
val.run_test(cr, uid, str(module_path), str(module_data[0].state))
string_ret += val.result['summary'] #summary tab
- string_ret += "Score: " + str(val.score) + "/10\n" #val.score = val.score * val.ponderation ???
+ if not val.error:
+ string_ret += "Score: " + str(val.score) + "/10\n" #val.score = val.score * val.ponderation ???
string_detail += val.result['detail'] # detail tab
score_sum += (val.add_quatation(val.score, 10) * val.ponderation)
ponderation_sum += val.ponderation
diff --git a/addons/hr_holidays/hr.py b/addons/hr_holidays/hr.py
index 0ec16766445..4e19e15f2ee 100644
--- a/addons/hr_holidays/hr.py
+++ b/addons/hr_holidays/hr.py
@@ -87,6 +87,31 @@ class hr_holidays(osv.osv):
}
_order = 'date_from desc'
+ def create(self, cr, uid, vals, *args, **kwargs):
+ id_holiday = super(hr_holidays, self).create(cr, uid, vals, *args, **kwargs)
+ self._create_log(cr, uid, [id_holiday])
+ return id_holiday
+
+ def _create_log(self, cr, uid, ids):
+ holidays_user_obj = self.pool.get('hr.holidays.per.user')
+ list_request = []
+ holidays_data = self.browse(cr, uid, ids[0])
+ datas = {
+ 'employee_id' : holidays_data.employee_id.id,
+ 'name' : holidays_data.state,
+ 'holiday_status' : holidays_data.holiday_status.id,
+ 'holiday_req_id' : holidays_data.id,
+ 'nb_holidays' : holidays_data.number_of_days
+ }
+ ids_log = self.pool.get('hr.holidays.log').create(cr, uid, datas)
+ ids_user_hdays = holidays_user_obj.search(cr, uid, [('employee_id', '=', holidays_data.employee_id.id),('holiday_status', '=', holidays_data.holiday_status.id)])
+ for hdays in holidays_user_obj.browse(cr, uid, ids_user_hdays):
+ for req in hdays.history:
+ list_request.append(req.id)
+ list_request.append(ids_log)
+ holidays_user_obj.write(cr, uid, ids_user_hdays, {'history' : [(6,0,list_request)]})
+ return True
+
def onchange_date_to(self, cr, uid, ids, date_from, date_to):
result = {}
if date_from:
@@ -108,19 +133,19 @@ class hr_holidays(osv.osv):
'state':'draft',
'manager_id': False
})
+ self._create_log(cr, uid, ids)
return True
def holidays_validate(self, cr, uid, ids, *args):
self.check_holidays(cr,uid,ids)
-
vals = {
'state':'validate',
}
ids2 = self.pool.get('hr.employee').search(cr, uid, [('user_id','=', uid)])
if ids2:
vals['manager_id'] = ids2[0]
-
self.write(cr, uid, ids, vals)
+ self._create_log(cr, uid, ids)
return True
def holidays_confirm(self, cr, uid, ids, *args):
@@ -132,6 +157,7 @@ class hr_holidays(osv.osv):
'state':'confirm',
'user_id': user,
})
+ self._create_log(cr, uid, ids)
return True
def holidays_refuse(self, cr, uid, ids, *args):
@@ -140,6 +166,7 @@ class hr_holidays(osv.osv):
'state':'refuse',
'manager_id':ids2[0]
})
+ self._create_log(cr, uid, ids)
return True
def holidays_cancel(self, cr, uid, ids, *args):
@@ -150,17 +177,22 @@ class hr_holidays(osv.osv):
obj_holidays_per_user=self.pool.get('hr.holidays.per.user').browse(cr, uid,holiday_id[0])
self.pool.get('hr.holidays.per.user').write(cr,uid,obj_holidays_per_user.id,{'leaves_taken':obj_holidays_per_user.leaves_taken - record.number_of_days})
if record.case_id:
- self.pool.get('crm.case').unlink(cr,uid,record.case_id.id)
+ if record.case_id.state <> 'draft':
+ raise osv.except_osv(_('Warning !'),
+ _('You can not cancel this holiday request. first You have to make its case in draft state.'))
+ else:
+ self.pool.get('crm.case').unlink(cr,uid,[record.case_id.id])
self.write(cr, uid, ids, {
'state':'cancel'
})
-
+ self._create_log(cr, uid, ids)
return True
def holidays_draft(self, cr, uid, ids, *args):
self.write(cr, uid, ids, {
'state':'draft'
})
+ self._create_log(cr, uid, ids)
return True
def check_holidays(self,cr,uid,ids):
@@ -212,9 +244,17 @@ class hr_holidays_per_user(osv.osv):
_description = "Holidays Per User"
def _get_remaining_leaves(self, cr, uid, ids, field_name, arg=None, context={}):
+ obj_holiday = self.pool.get('hr.holidays')
+ days = 0.0
result = {}
- for r in self.read(cr, uid, ids, ['max_leaves','leaves_taken']):
- result[r['id']] = r['max_leaves'] - r['leaves_taken']
+ for holiday_user in self.browse(cr, uid, ids):
+ ids_request = obj_holiday.search(cr, uid, [('employee_id', '=', holiday_user.employee_id.id),('state', '=', 'validate'),('holiday_status', '=', holiday_user.holiday_status.id)])
+ if ids_request:
+ holidays = obj_holiday.browse(cr, uid, ids_request)
+ for holiday in holidays:
+ days += holiday.number_of_days
+ days = holiday_user.max_leaves - days
+ result[holiday_user.id] = days
return result
_columns = {
@@ -226,6 +266,7 @@ class hr_holidays_per_user(osv.osv):
'active' : fields.boolean('Active'),
'notes' : fields.text('Notes'),
'remaining_leaves': fields.function(_get_remaining_leaves, method=True, string='Remaining Leaves', type='float'),
+ 'history' : fields.one2many('hr.holidays.log', 'holiday_user_id', 'History')
}
_defaults = {
'active' : lambda *a: True,
@@ -239,5 +280,23 @@ class hr_holidays_per_user(osv.osv):
hr_holidays_per_user()
+class holiday_user_log(osv.osv):
+ _name = 'hr.holidays.log'
+ _description = 'hr.holidays.log'
+ _order = "holiday_req_id desc"
+ _columns = {
+ 'name' : fields.char('Action', size=64, readonly=True),
+ 'holiday_req_id' : fields.char('Holiday Request ID', size=64),
+ 'nb_holidays' : fields.float('Number of Holidays Requested'),
+ 'employee_id' : fields.many2one('hr.employee', 'Employee', readonly=True),
+ 'holiday_status' : fields.many2one("hr.holidays.status", "Holiday's Status", readonly=True),
+ 'holiday_user_id' : fields.many2one('hr.holidays.per.user', 'Holidays user'),
+ 'date': fields.datetime('Date'),
+ }
+ _defaults = {
+ 'date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
+ }
+holiday_user_log()
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/hr_holidays/hr_view.xml b/addons/hr_holidays/hr_view.xml
index dcf73f3e9f9..cc940075097 100644
--- a/addons/hr_holidays/hr_view.xml
+++ b/addons/hr_holidays/hr_view.xml
@@ -8,7 +8,7 @@
hr.holidays
form
-
diff --git a/addons/sale/stock.py b/addons/sale/stock.py
index 0c6ec645150..9669366add3 100644
--- a/addons/sale/stock.py
+++ b/addons/sale/stock.py
@@ -158,6 +158,7 @@ class stock_picking(osv.osv):
price_unit = sale_line.price_unit
discount = sale_line.discount
tax_ids = sale_line.tax_id
+ tax_ids = map(lambda x: x.id, tax_ids)
account_analytic_id = self._get_account_analytic_invoice(cursor,
user, picking, sale_line)
|