[Merge] merge stable/5.0 branch

bzr revid: hmo@tinyerp.com-20091104064434-fijc4n2motwgsu13
This commit is contained in:
Harry (Open ERP) 2009-11-04 12:14:34 +05:30
commit c436917517
9 changed files with 43 additions and 12 deletions

View File

@ -90,8 +90,9 @@ class ir_attachment(osv.osv):
result = {}
if context is None:
context = {}
context['bin_size'] = False
for i in self.browse(cr, uid, ids, context=context):
ctx = context.copy()
ctx['bin_size'] = False
for i in self.browse(cr, uid, ids, context=ctx):
result[i.id] = False
for format in ('png','jpg','jpeg','gif','bmp'):
if (i.datas_fname and i.datas_fname.lower() or '').endswith(format):

View File

@ -421,7 +421,8 @@ class ir_model_data(osv.osv):
_defaults = {
'date_init': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
'date_update': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
'noupdate': lambda *a: False
'noupdate': lambda *a: False,
'module': lambda *a: ''
}
_sql_constraints = [
('module_name_uniq', 'unique(name, module)', 'You can not have multiple records with the same id for the same module'),

View File

@ -106,6 +106,11 @@ class ir_rule(osv.osv):
for rule in self.browse(cr, uid, ids, context):
eval_user_data = {'user': self.pool.get('res.users').browse(cr, 1, uid),
'time':time}
if rule.operand.startswith('user.') and rule.operand.count('.') > 1:
#Need to check user.field.field1.field2(if field is False,it will break the chain)
op = rule.operand[5:]
rule.operand = rule.operand[:5+len(op[:op.find('.')])] +' and '+ rule.operand + ' or False'
if rule.domain_force:
res[rule.id] = eval(rule.domain_force, eval_user_data)
else:

View File

@ -24,7 +24,7 @@ from report import report_sxw
class ir_module_reference_print(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(ir_module_reference_print, self).__init__(cr, uid, name, context)
super(ir_module_reference_print, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'time': time,
'findobj': self._object_find,

View File

@ -163,9 +163,9 @@ class res_partner(osv.osv):
'customer': lambda *a: 1,
'category_id': _default_category,
}
def copy(self, cr, uid, id, default=None, context={}):
def copy(self, cr, uid, id, default={}, context={}):
name = self.read(cr, uid, [id], ['name'])[0]['name']
default.update({'name': name+' (copy)', 'events':[]})
default.update({'name': name+ _(' (copy)'), 'events':[]})
return super(res_partner, self).copy(cr, uid, id, default, context)
def _check_ean_key(self, cr, uid, ids):

View File

@ -26,7 +26,6 @@ import ir
from tools.misc import currency
from tools.translate import _
from tools import config
import mx.DateTime
from mx.DateTime import RelativeDateTime, now, DateTime, localtime
@ -68,7 +67,7 @@ class res_currency(osv.osv):
if currency.rounding == 0:
return 0.0
else:
return round(amount / currency.rounding, int(config['price_accuracy'])) * currency.rounding
return round(amount / currency.rounding) * currency.rounding
def is_zero(self, cr, uid, currency, amount):
return abs(self.round(cr, uid, currency, amount)) < currency.rounding

View File

@ -65,7 +65,6 @@ class expression(object):
res.extend([r[0] for r in cr.fetchall()])
return res
def __init__(self, exp):
# check if the expression is valid
if not reduce(lambda acc, val: acc and (self._is_operator(val) or self._is_leaf(val)), exp, True):

View File

@ -453,6 +453,16 @@ class orm_template(object):
elif field_type == 'boolean':
return False
return ''
def selection_field(in_field):
col_obj = self.pool.get(in_field.keys()[0])
if f[i] in col_obj._columns.keys():
return col_obj._columns[f[i]]
elif f[i] in col_obj._inherits.keys():
selection_field(col_obj._inherits)
else:
return False
lines = []
data = map(lambda x: '', range(len(fields)))
@ -478,6 +488,18 @@ class orm_template(object):
break
else:
r = r[f[i]]
# To display external name of selection field when its exported
if not context.get('import_comp',False):# Allow external name only if its not import compatible
cols = False
if f[i] in self._columns.keys():
cols = self._columns[f[i]]
elif f[i] in self._inherit_fields.keys():
cols = selection_field(self._inherits)
if cols and cols._type == 'selection':
sel_list = cols.selection
if type(sel_list) == type([]):
r = [x[1] for x in sel_list if r==x[0]][0]
if not r:
if f[i] in self._columns:
r = check_type(self._columns[f[i]]._type)
@ -1514,6 +1536,8 @@ class orm_memory(orm_template):
return result
def write(self, cr, user, ids, vals, context=None):
if not ids:
return True
vals2 = {}
upd_todo = []
for field in vals:
@ -1608,7 +1632,7 @@ class orm_memory(orm_template):
# get the default values from the context
for key in context or {}:
if key.startswith('default_'):
if key.startswith('default_') and (key[8:] in fieds_list):
value[key[8:]] = context[key]
return value
@ -2224,10 +2248,12 @@ class orm(orm_template):
select = [ids]
select = map(lambda x: isinstance(x,dict) and x['id'] or x, select)
result = self._read_flat(cr, user, select, fields, context, load)
for r in result:
for key, v in r.items():
if v == None:
r[key] = False
if isinstance(ids, (int, long, dict)):
return result and result[0] or False
return result

View File

@ -661,9 +661,9 @@ class cache(object):
self.fun_default_values = dict(zip(self.fun_arg_names[-len(argspec[3]):], argspec[3]))
def cached_result(self2, cr, *args, **kwargs):
if time.time()-self.timeout > self.lasttime:
if time.time()-int(self.timeout) > self.lasttime:
self.lasttime = time.time()
t = time.time()-self.timeout
t = time.time()-int(self.timeout)
old_keys = [key for key in self.cache if self.cache[key][1] < t]
for key in old_keys:
del self.cache[key]