[FIX] Bugfix translations and float/int format in reports

bzr revid: fp@tinyerp.com-20090609231554-iug5t0i4wi5wjzc3
This commit is contained in:
Fabien Pinckaers 2009-06-10 01:15:54 +02:00
commit db8f650de3
13 changed files with 494 additions and 207 deletions

View File

@ -673,10 +673,10 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
# NOTE: Try to also load the modules that have been marked as uninstallable previously...
STATES_TO_LOAD = ['installed', 'to upgrade', 'uninstallable']
graph = create_graph(cr, ['base'], force)
has_updates = False
if update_module:
has_updates = load_module_graph(cr, graph, status, perform_checks=False, report=report)
has_updates = load_module_graph(cr, graph, status, perform_checks=(not update_module), report=report)
if update_module:
modobj = pool.get('ir.module.module')
logger.notifyChannel('init', netsvc.LOG_INFO, 'updating modules list')
if ('base' in tools.config['init']) or ('base' in tools.config['update']):

File diff suppressed because it is too large Load Diff

View File

@ -77,6 +77,12 @@ class maintenance_contract(osv.osv):
status = self.status(cr, uid)
if status['status'] != 'full':
raise osv.except_osv(_('Error'), _("Your can't submit bug reports due to uncovered modules: %s") % (', '.join(status['uncovered_modules']),))
dbmsg = _('This error occurs on database %s') % (cr.dbname,)
if not remarks:
remarks = dbmsg
else:
remarks += '\n\n-----\n' + dbmsg
valid_contracts = self._get_valid_contracts(cr, uid)
@ -161,7 +167,7 @@ class maintenance_contract_wizard(osv.osv_memory):
'state' : lambda *a: 'draft',
}
def action_validate(self, cr, uid, ids, context):
def action_validate(self, cr, uid, ids, context=None):
if not ids:
return False

View File

@ -30,7 +30,7 @@ email_send_form = '''<?xml version="1.0"?>
<newline/>
<field name="subject"/>
<newline/>
<field name="text" widget="text_html"/>
<field name="text"/>
</form>'''
email_send_fields = {

View File

@ -66,6 +66,8 @@
<rng:optional><rng:attribute name="colspan"/></rng:optional>
<rng:optional><rng:attribute name="string"/></rng:optional>
<rng:optional><rng:attribute name="angle"/></rng:optional>
<rng:optional><rng:attribute name="fill"/></rng:optional>
<rng:optional><rng:attribute name="help"/></rng:optional>
<rng:zeroOrMore>
<rng:text/>
</rng:zeroOrMore>
@ -308,6 +310,10 @@
<rng:ref name="group" />
<rng:element name="properties"><rng:empty/></rng:element>
<rng:element name="newline"><rng:empty/></rng:element>
<rng:ref name="image"/>
<rng:ref name="notebook"/>
<rng:ref name="hpaned"/>
<rng:ref name="vpaned"/>
</rng:choice>
</rng:zeroOrMore>
</rng:element>

View File

@ -100,6 +100,7 @@
<rng:optional><rng:attribute name="menu"/></rng:optional>
<rng:optional><rng:attribute name="keyword"/></rng:optional>
<rng:optional><rng:attribute name="rml"/></rng:optional>
<rng:optional><rng:attribute name="sxw"/></rng:optional>
<rng:optional><rng:attribute name="xml"/></rng:optional>
<rng:optional><rng:attribute name="xsl"/></rng:optional>
<rng:optional> <rng:attribute name="auto" /> </rng:optional>

View File

@ -184,13 +184,13 @@ class browse_record(object):
lang = self._context.get('lang', 'en_US') or 'en_US'
lang_obj_ids = self.pool.get('res.lang').search(self._cr, self._uid,[('code','=',lang)])
if not lang_obj_ids:
raise Exception(_('Language %s is not defined in your system !\nDefine it through the Administration menu.') % (lang,))
raise Exception(_('Language with code "%s" is not defined in your system !\nDefine it through the Administration menu.') % (lang,))
lang_obj = self.pool.get('res.lang').browse(self._cr, self._uid,lang_obj_ids[0])
for n, f in ffields:
if f._type in self._fields_process:
for d in datas:
d[n] = self._fields_process[f._type](d[n])
if d[n]:
if (d[n] is not None) and (d[n] is not False):
d[n].set_value(self._cr, self._uid, d[n], self, f, lang_obj)

View File

@ -47,6 +47,7 @@ class html2html(object):
new_node.append(new_child)
if len(child):
for n in new_child:
new_child.text = utils._process_text(self, child.text)
new_child.remove(n)
process_text(child, new_child)
else:
@ -58,8 +59,10 @@ class html2html(object):
output = cStringIO.StringIO(base64.decodestring(src))
img = ImageReader(output)
(width,height) = img.getSize()
new_child.set('width',str(width))
new_child.set('height',str(height))
if not new_child.get('width'):
new_child.set('width',str(width))
if not new_child.get('height') :
new_child.set('height',str(height))
else :
new_child.getparent().remove(new_child)
new_child.text = utils._process_text(self, child.text)

View File

@ -38,6 +38,7 @@ class odt2odt(object):
new_node.attrib.clear()
for child in utils._child_get(node, self):
new_child = copy.deepcopy(child)
new_child.text = utils._process_text(self, child.text)
new_node.append(new_child)
if len(child):
for n in new_child:

View File

@ -103,10 +103,10 @@ def _process_text(self, txt):
txt2 = eval(sps.pop(0),self.localcontext)
except:
txt2 = ''
if type(txt2) == type(0) or type(txt2) == type(0.0):
txt2 = str(txt2)
if type(txt2)==type('') or type(txt2)==type(u''):
result += txt2
elif (txt2 is not None) and (txt2 is not False):
result += str(txt2)
return result
def text_get(node):

View File

@ -72,8 +72,6 @@ rml2sxw = {
'para': 'p',
}
class _format(object):
def set_value(self, cr, uid, name, object, field, lang_obj):
self.object = object
@ -82,15 +80,15 @@ class _format(object):
self.lang_obj = lang_obj
class _float_format(float, _format):
def __init__(self,value):
super(_float_format, self).__init__()
self.val = value and str(value) or str(0.00)
self.val = value
def __str__(self):
digits = 2
if hasattr(self,'_field') and hasattr(self._field, 'digits') and self._field.digits:
digits = self._field.digits[1]
if hasattr(self, 'lang_obj'):
return self.lang_obj.format('%.' + str(digits) + 'f', self.name, True)
return self.val
@ -196,7 +194,7 @@ class rml_parse(object):
def removeParentNode(self, tag=None):
raise Exception('Skip')
def set_html_image(self,id,model=None,field=None):
def set_html_image(self,id,model=None,field=None,context=None):
if not id :
return ''
if not model:
@ -217,14 +215,6 @@ class rml_parse(object):
if not lang or self.default_lang.has_key(lang):
if not lang:
key = 'en_US'
self.lang_dict_called = False
self.localcontext['lang'] = lang
elif self.default_lang.has_key(lang):
key = lang
if self.default_lang.get(key,False):
self.lang_dict = self.default_lang.get(key,False).copy()
self.lang_dict_called = True
return True
self.localcontext['lang'] = lang
self.lang_dict_called = False
for obj in self.objects:

View File

@ -92,7 +92,6 @@ def init_db(cr):
state = 'uninstallable'
cr.execute('select nextval(\'ir_module_module_id_seq\')')
id = cr.fetchone()[0]
print info.get('name', False)
cr.execute('insert into ir_module_module \
(id, author, website, name, shortdesc, description, \
category_id, state, certificate) \

View File

@ -427,43 +427,44 @@ def trans_generate(lang, modules, dbname=None):
push_translation(module, 'view', encode(obj.model), 0, t)
elif model=='ir.actions.wizard':
service_name = 'wizard.'+encode(obj.wiz_name)
obj2 = netsvc.SERVICES[service_name]
for state_name, state_def in obj2.states.iteritems():
if 'result' in state_def:
result = state_def['result']
if result['type'] != 'form':
continue
name = "%s,%s" % (encode(obj.wiz_name), state_name)
def_params = {
'string': ('wizard_field', lambda s: [encode(s)]),
'selection': ('selection', lambda s: [encode(e[1]) for e in ((not callable(s)) and s or [])]),
'help': ('help', lambda s: [encode(s)]),
}
if netsvc.SERVICES.get(service_name):
obj2 = netsvc.SERVICES[service_name]
for state_name, state_def in obj2.states.iteritems():
if 'result' in state_def:
result = state_def['result']
if result['type'] != 'form':
continue
name = "%s,%s" % (encode(obj.wiz_name), state_name)
def_params = {
'string': ('wizard_field', lambda s: [encode(s)]),
'selection': ('selection', lambda s: [encode(e[1]) for e in ((not callable(s)) and s or [])]),
'help': ('help', lambda s: [encode(s)]),
}
# export fields
for field_name, field_def in result['fields'].iteritems():
res_name = name + ',' + field_name
for fn in def_params:
if fn in field_def:
transtype, modifier = def_params[fn]
for val in modifier(field_def[fn]):
push_translation(module, transtype, res_name, 0, val)
# export fields
for field_name, field_def in result['fields'].iteritems():
res_name = name + ',' + field_name
for fn in def_params:
if fn in field_def:
transtype, modifier = def_params[fn]
for val in modifier(field_def[fn]):
push_translation(module, transtype, res_name, 0, val)
# export arch
arch = result['arch']
if arch and not isinstance(arch, UpdateableStr):
d = xml.dom.minidom.parseString(arch)
for t in trans_parse_view(d.documentElement):
push_translation(module, 'wizard_view', name, 0, t)
# export arch
arch = result['arch']
if arch and not isinstance(arch, UpdateableStr):
d = xml.dom.minidom.parseString(arch)
for t in trans_parse_view(d.documentElement):
push_translation(module, 'wizard_view', name, 0, t)
# export button labels
for but_args in result['state']:
button_name = but_args[0]
button_label = but_args[1]
res_name = name + ',' + button_name
push_translation(module, 'wizard_button', res_name, 0, button_label)
# export button labels
for but_args in result['state']:
button_name = but_args[0]
button_label = but_args[1]
res_name = name + ',' + button_name
push_translation(module, 'wizard_button', res_name, 0, button_label)
elif model=='ir.model.fields':
field_name = encode(obj.name)