bzr revid: fp@tinyerp.com-20081231125851-53hamyjf54wi8p2x
This commit is contained in:
Fabien Pinckaers 2008-12-31 13:58:51 +01:00
commit 36c0818b59
15 changed files with 295 additions and 73 deletions

View File

@ -2070,10 +2070,12 @@ class wizard_multi_charts_accounts(osv.osv_memory):
#create the account_account for this bank journal
tmp = self.pool.get('res.partner.bank').name_get(cr, uid, [line.acc_no.id])[0][1]
dig = obj_multi.code_digits
print ">>>>",dig
print ">>>",ref_acc_bank.code.ljust(dig,'0')
vals={
'name': line.acc_no.bank and line.acc_no.bank.name+' '+tmp or tmp,
'currency_id': line.currency_id and line.currency_id.id or False,
'code': str(int(ref_acc_bank.code.ljust(dig,'0')) + current_num),
'code': str(ref_acc_bank.code.ljust(dig,'0') + str(current_num)),
'type': 'other',
'user_type': account_template.user_type and account_template.user_type.id or False,
'reconcile': True,

View File

@ -179,9 +179,9 @@
</field>
</group>
<group col="4" colspan="2">
<button colspan="2" name="button_reset_taxes" states="draft" string="Reset taxes" type="object"/>
<button colspan="2" name="button_reset_taxes" states="draft" string="Compute Taxes" type="object"/>
<field name="amount_untaxed"/>
<button colspan="2" name="button_compute" states="draft" string="Compute" type="object"/>
<label string="" colspan="2"/>
<field name="amount_tax"/>
<field name="reconciled"/>
<field name="amount_total"/>
@ -264,9 +264,9 @@
</field>
</group>
<group col="4" colspan="2">
<button colspan="2" name="button_reset_taxes" states="draft" string="Reset taxes" type="object"/>
<button colspan="2" name="button_reset_taxes" states="draft" string="Compute Taxes" type="object"/>
<field name="amount_untaxed"/>
<button colspan="2" name="button_compute" states="draft" string="Compute" type="object"/>
<label string="" colspan="2"/>
<field name="amount_tax"/>
<field name="reconciled"/>
<field name="amount_total"/>

View File

@ -382,30 +382,8 @@ class account_invoice(osv.osv):
return True
def button_compute(self, cr, uid, ids, context={}, set_total=False):
ait_obj = self.pool.get('account.invoice.tax')
cur_obj = self.pool.get('res.currency')
self.button_reset_taxes(cr, uid, ids, context)
for inv in self.browse(cr, uid, ids):
company_currency = inv.company_id.currency_id.id
compute_taxes = ait_obj.compute(cr, uid, inv.id)
if not inv.tax_line:
for tax in compute_taxes.values():
ait_obj.create(cr, uid, tax)
else:
tax_key = []
for tax in inv.tax_line:
if tax.manual:
continue
key = (tax.tax_code_id.id, tax.base_code_id.id, tax.account_id.id)
tax_key.append(key)
if not key in compute_taxes:
ait_obj.unlink(cr, uid, [tax.id])
continue
compute_taxes[key]['base'] = cur_obj.compute(cr, uid, inv.currency_id.id, company_currency, compute_taxes[key]['base'], context={'date': inv.date_invoice})
if abs(compute_taxes[key]['base'] - tax.base) > inv.company_id.currency_id.rounding:
ait_obj.write(cr, uid, [tax.id], compute_taxes[key])
for key in compute_taxes:
if not key in tax_key:
ait_obj.create(cr, uid, compute_taxes[key])
if set_total:
self.pool.get('account.invoice').write(cr, uid, [inv.id], {'check_total': inv.amount_total})
return True

View File

@ -38,11 +38,25 @@ class Overdue(report_sxw.rml_parse):
})
def _adr_get(self, partner, type):
res = []
res_partner = pooler.get_pool(self.cr.dbname).get('res.partner')
res_partner_address = pooler.get_pool(self.cr.dbname).get('res.partner.address')
addresses = res_partner.address_get(self.cr, self.uid, [partner.id], [type])
adr_id = addresses and addresses[type] or False
return adr_id and res_partner_address.read(self.cr, self.uid, [adr_id])[0] or False
result = {
'name': False,
'street': False,
'city' : False,
'zip' : False,
'country_id' : False,
}
if adr_id:
result = res_partner_address.read(self.cr, self.uid, [adr_id])
result[0]['country_id'] = result[0]['country_id'] and result[0]['country_id'][1] or False
return result
res.append(result)
return res
def _tel_get(self,partner):
if not partner:

View File

@ -90,16 +90,14 @@
<blockTable colWidths="286.0,224.0" style="Tableau2">
<tr>
<td>
<para style="P11">
<font color="white"> </font>
</para>
<para style="P7">[[ repeatIn(adr_get(o, 'invoice'),'addr') ]]</para>
</td>
<td>
<para style="P16">[[ o.name ]]</para>
<para style="P17">[[ adr_get(o, 'invoice')['name'] ]]</para>
<para style="P17">[[ adr_get(o, 'invoice')['street'] ]]</para>
<para style="P17">[[ adr_get(o, 'invoice')['zip'] ]] [[ adr_get(o, 'invoice')['city'] ]]</para>
<para style="P17">[[ adr_get(o, 'invoice')['country_id'] and adr_get(o, 'invoice')['country_id'][1] ]]</para>
<para style="P17">[[ addr['name'] ]]</para>
<para style="P17">[[ addr['street'] ]]</para>
<para style="P17">[[ addr['zip'] ]] [[ addr['city'] ]]</para>
<para style="P17">[[ addr['country_id'] ]]</para>
<para style="P17">
<font color="white"> </font>
</para>

View File

@ -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):

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -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/>.
#
##############################################################################
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,108 @@
# -*- 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 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:

View File

@ -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

View File

@ -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:

View File

@ -8,7 +8,7 @@
<field name="model">hr.holidays</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Employee holidays">
<form string="Employee Holidays">
<field name="name" select="1"/>
<field name="holiday_status" select="1"/>
<field name="date_from" select="1"/>
@ -17,8 +17,8 @@
<page string="General">
<field name="employee_id" select="1" />
<field name="number_of_days"/>
<field name="notes" colspan="4"/>
<field name="manager_id"/>
<field name="notes" colspan="4"/>
<newline/>
<field name="state" select="1" colspan="2"/>
<group colspan="2">
@ -36,10 +36,10 @@
<record model="ir.ui.view" id="view_holiday">
<field name="name">hr.holidays.tree</field>
<field name="model">hr.holidays</field>
<field name="model">hr.holidays</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Employee holidays">
<tree string="Employee Holidays">
<field name="name"/>
<field name="employee_id"/>
<field name="number_of_days" string="Number of Days"/>
@ -51,10 +51,40 @@
</field>
</record>
<!-- holidays log -->
<record model="ir.ui.view" id="holiday_log_form">
<field name="name">hr.holidays.log.form</field>
<field name="model">hr.holidays.log</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Log Holidays">
<field name="name" select="1"/>
<field name="employee_id" select="2"/>
<field name="holiday_status" select="1" />
</form>
</field>
</record>
<record model="ir.ui.view" id="holiday_log_tree">
<field name="name">>hr.holidays.log.tree</field>
<field name="model">hr.holidays.log</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Log Holidays">
<field name="holiday_req_id" />
<field name="date" />
<field name="employee_id" />
<field name="name" />
<field name="holiday_status" />
<field name="nb_holidays" />
</tree>
</field>
</record>
<!-- holidays status -->
<record model="ir.ui.view" id="edit_holiday_status_form">
<field name="name">hr.holidays.status.form</field>
<field name="model">hr.holidays.status</field>
<field name="model">hr.holidays.status</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Define holiday status">
@ -68,15 +98,15 @@
</record>
<record model="ir.ui.view" id="view_holiday_status_tree">
<field name="name">hr.holidays.status.tree</field>
<field name="model">hr.holidays.status</field>
<field name="model">hr.holidays.status</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Holiday status">
<field name="name"/>
<field name="color_name" />
<field name="section_id" />
<field name="limit" select="2"/>
<field name="active" select="2"/>
<field name="limit" />
<field name="active" />
</tree>
</field>
</record>
@ -98,17 +128,24 @@
<field name="model">hr.holidays.per.user</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Holidays Per Employee">
<field name="employee_id" select="1" />
<field name="holiday_status" select="1" />
<newline/>
<field name="max_leaves" select="2" colspan="2" />
<field name="leaves_taken" select="2" colspan="2" />
<newline/>
<field name="remaining_leaves" select="2" colspan="2" />
<field name="active" select="2"/>
<newline/>
<field name="notes" colspan="4" select="2"/>
<form string="Holidays Per Employee">
<notebook>
<page string="General Information">
<field name="employee_id" select="1" />
<field name="holiday_status" select="1" />
<newline/>
<field name="max_leaves" select="2" />
<field name="leaves_taken" select="2" />
<newline/>
<field name="remaining_leaves" select="2" colspan="2" />
<field name="active" select="2"/>
<newline/>
<field name="notes" colspan="4" select="2"/>
</page>
<page string="History" >
<field name="history" nolabel="1"/>
</page>
</notebook>
</form>
</field>
</record>
@ -122,7 +159,7 @@
<field name="holiday_status"/>
<field name="max_leaves"/>
<field name="remaining_leaves"/>
<field name="active" select="2"/>
<field name="active"/>
</tree>
</field>
</record>

View File

@ -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)