commit
f90988f325
|
@ -377,7 +377,7 @@ class actions_server(osv.osv):
|
|||
_sequence = 'ir_actions_id_seq'
|
||||
_order = 'sequence'
|
||||
_columns = {
|
||||
'name': fields.char('Action Name', required=True, size=64, help="Easy to Refer action by name e.g. One Sales Order -> Many Invoices"),
|
||||
'name': fields.char('Action Name', required=True, size=64, help="Easy to Refer action by name e.g. One Sales Order -> Many Invoices", translate=True),
|
||||
'condition' : fields.char('Condition', size=256, required=True, help="Condition that is to be tested before action is executed, e.g. object.list_price > object.cost_price"),
|
||||
'state': fields.selection([
|
||||
('client_action','Client Action'),
|
||||
|
|
|
@ -413,6 +413,9 @@ class ir_model_data(osv.osv):
|
|||
'date_update': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'noupdate': lambda *a: False
|
||||
}
|
||||
_sql_constraints = [
|
||||
('module_name_uniq', 'unique(name, module)', 'You can not have multiple records with the same id for the same module'),
|
||||
]
|
||||
|
||||
def __init__(self, pool, cr):
|
||||
osv.osv.__init__(self, pool, cr)
|
||||
|
@ -420,11 +423,13 @@ class ir_model_data(osv.osv):
|
|||
self.doinit = True
|
||||
self.unlink_mark = {}
|
||||
|
||||
def _get_id(self,cr, uid, module, xml_id):
|
||||
@tools.cache()
|
||||
def _get_id(self, cr, uid, module, xml_id):
|
||||
ids = self.search(cr, uid, [('module','=',module),('name','=', xml_id)])
|
||||
assert len(ids)==1, '%d reference(s) to %s.%s. You should have one and only one !' % (len(ids), module, xml_id)
|
||||
if not ids:
|
||||
raise Exception('No references to %s.%s' % (module, xml_id))
|
||||
# the sql constraints ensure us we have only one result
|
||||
return ids[0]
|
||||
_get_id = tools.cache(skiparg=2)(_get_id)
|
||||
|
||||
def _update_dummy(self,cr, uid, model, module, xml_id=False, store=True):
|
||||
if not xml_id:
|
||||
|
|
|
@ -94,7 +94,7 @@ class ir_translation(osv.osv):
|
|||
translations[res_id] = value
|
||||
return translations
|
||||
|
||||
def _set_ids(self, cr, uid, name, tt, lang, ids, value):
|
||||
def _set_ids(self, cr, uid, name, tt, lang, ids, value, src=None):
|
||||
# clear the caches
|
||||
tr = self._get_ids(cr, uid, name, tt, lang, ids)
|
||||
for res_id in tr:
|
||||
|
@ -117,6 +117,7 @@ class ir_translation(osv.osv):
|
|||
'name':name,
|
||||
'res_id':id,
|
||||
'value':value,
|
||||
'src':src,
|
||||
})
|
||||
return len(ids)
|
||||
|
||||
|
|
|
@ -201,18 +201,30 @@ class expression(object):
|
|||
if field.translate:
|
||||
if operator in ('like', 'ilike', 'not like', 'not ilike'):
|
||||
right = '%%%s%%' % right
|
||||
|
||||
operator = operator == '=like' and 'like' or operator
|
||||
|
||||
query1 = '( SELECT res_id' \
|
||||
' FROM ir_translation' \
|
||||
' WHERE name = %s' \
|
||||
' AND lang = %s' \
|
||||
' AND type = %s' \
|
||||
' AND value ' + operator + ' %s' \
|
||||
' AND type = %s'
|
||||
instr = ' %s'
|
||||
#Covering in,not in operators with operands (%s,%s) ,etc.
|
||||
if operator in ['in','not in']:
|
||||
instr = ','.join(['%s'] * len(right))
|
||||
query1 += ' AND value ' + operator + ' ' +" (" + instr + ")" \
|
||||
') UNION (' \
|
||||
' SELECT id' \
|
||||
' FROM "' + working_table._table + '"' \
|
||||
' WHERE "' + left + '" ' + operator + ' %s' \
|
||||
')'
|
||||
' WHERE "' + left + '" ' + operator + ' ' +" (" + instr + "))"
|
||||
else:
|
||||
query1 += ' AND value ' + operator + instr + \
|
||||
') UNION (' \
|
||||
' SELECT id' \
|
||||
' FROM "' + working_table._table + '"' \
|
||||
' WHERE "' + left + '" ' + operator + instr + ")"
|
||||
|
||||
query2 = [working_table._name + ',' + left,
|
||||
context.get('lang', False) or 'en_US',
|
||||
'model',
|
||||
|
|
|
@ -433,6 +433,16 @@ class orm_template(object):
|
|||
return browse_null()
|
||||
|
||||
def __export_row(self, cr, uid, row, fields, context=None):
|
||||
|
||||
def check_type(type,r):
|
||||
if type == 'float':
|
||||
return 0.0
|
||||
elif type == 'integer':
|
||||
return 0
|
||||
elif type == 'char':
|
||||
return ''
|
||||
return r
|
||||
|
||||
lines = []
|
||||
data = map(lambda x: '', range(len(fields)))
|
||||
done = []
|
||||
|
@ -444,6 +454,12 @@ class orm_template(object):
|
|||
while i < len(f):
|
||||
r = r[f[i]]
|
||||
if not r:
|
||||
if f[i] in self._columns:
|
||||
r = check_type(self._columns[f[i]]._type,r)
|
||||
elif f[i] in self._inherit_fields:
|
||||
r = check_type(self._inherit_fields[f[i]][2]._type,r)
|
||||
|
||||
data[fpos] = tools.ustr(r)
|
||||
break
|
||||
if isinstance(r, (browse_record_list, list)):
|
||||
first = True
|
||||
|
@ -1633,7 +1649,9 @@ class orm(orm_template):
|
|||
('int4', 'float', get_pg_type(f)[1], '::'+get_pg_type(f)[1]),
|
||||
('date', 'datetime', 'TIMESTAMP', '::TIMESTAMP'),
|
||||
]
|
||||
if f_pg_type == 'varchar' and f._type == 'char' and f_pg_size != f.size:
|
||||
# !!! Avoid reduction of varchar field !!!
|
||||
if f_pg_type == 'varchar' and f._type == 'char' and f_pg_size < f.size:
|
||||
# if f_pg_type == 'varchar' and f._type == 'char' and f_pg_size != f.size:
|
||||
logger.notifyChannel('orm', netsvc.LOG_INFO, "column '%s' in table '%s' changed size" % (k, self._table))
|
||||
cr.execute('ALTER TABLE "%s" RENAME COLUMN "%s" TO temp_change_size' % (self._table, k))
|
||||
cr.execute('ALTER TABLE "%s" ADD COLUMN "%s" VARCHAR(%d)' % (self._table, k, f.size))
|
||||
|
@ -2289,11 +2307,12 @@ class orm(orm_template):
|
|||
else:
|
||||
cr.execute('update "'+self._table+'" set '+string.join(upd0, ',')+' ' \
|
||||
'where id in ('+ids_str+')', upd1)
|
||||
|
||||
|
||||
if totranslate:
|
||||
for f in direct:
|
||||
if self._columns[f].translate:
|
||||
self.pool.get('ir.translation')._set_ids(cr, user, self._name+','+f, 'model', context['lang'], ids, vals[f])
|
||||
src_trans = self.pool.get(self._name).read(cr,user,ids,[f])
|
||||
self.pool.get('ir.translation')._set_ids(cr, user, self._name+','+f, 'model', context['lang'], ids, vals[f], src_trans[0][f])
|
||||
|
||||
# call the 'set' method of fields which are not classic_write
|
||||
upd_todo.sort(lambda x, y: self._columns[x].priority-self._columns[y].priority)
|
||||
|
|
|
@ -4,6 +4,7 @@ import re
|
|||
rml_parents = ['tr','story','section']
|
||||
html_parents = ['tr','body','div']
|
||||
sxw_parents = ['{http://openoffice.org/2000/table}table-row','{http://openoffice.org/2000/office}body','{http://openoffice.org/2000/text}section']
|
||||
odt_parents = ['{urn:oasis:names:tc:opendocument:xmlns:office:1.0}body','{urn:oasis:names:tc:opendocument:xmlns:table:1.0}table-row','{urn:oasis:names:tc:opendocument:xmlns:text:1.0}section']
|
||||
|
||||
class report(object):
|
||||
def preprocess_rml(self, root_node,type='pdf'):
|
||||
|
@ -37,7 +38,9 @@ class report(object):
|
|||
if len(txt.group(4)) > 1:
|
||||
return " "
|
||||
match = rml_parents
|
||||
if type in ['odt','sxw']:
|
||||
if type == 'odt':
|
||||
match = odt_parents
|
||||
if type == 'sxw':
|
||||
match = sxw_parents
|
||||
if type =='html2html':
|
||||
match = html_parents
|
||||
|
|
|
@ -24,28 +24,26 @@ from report.render.rml2pdf import utils
|
|||
from lxml import etree
|
||||
import copy
|
||||
|
||||
|
||||
class odt2odt(object):
|
||||
def __init__(self, odt, localcontext):
|
||||
self.localcontext = localcontext
|
||||
self.etree = odt
|
||||
self._node = None
|
||||
|
||||
|
||||
def render(self):
|
||||
def process_text(node,new_node):
|
||||
if new_node.tag in ['story','tr','section']:
|
||||
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:
|
||||
new_child.text = utils._process_text(self, child.text)
|
||||
new_child.tail = utils._process_text(self, child.tail)
|
||||
new_child.remove(n)
|
||||
process_text(child, new_child)
|
||||
else:
|
||||
new_child.text = utils._process_text(self, child.text)
|
||||
new_child.tail = utils._process_text(self, child.tail)
|
||||
self._node = copy.deepcopy(self.etree)
|
||||
for n in self._node:
|
||||
self._node.remove(n)
|
||||
|
@ -53,16 +51,6 @@ class odt2odt(object):
|
|||
return self._node
|
||||
|
||||
def parseNode(node, localcontext = {}):
|
||||
body = node.getchildren()[-1]
|
||||
elements = body.findall(localcontext['name_space']["text"]+"p")
|
||||
for pe in elements:
|
||||
e = pe.findall(localcontext['name_space']["text"]+"drop-down")
|
||||
for de in e:
|
||||
pp=de.getparent()
|
||||
for cnd in de.getchildren():
|
||||
if cnd.text:
|
||||
pe.append(cnd)
|
||||
pp.remove(de)
|
||||
r = odt2odt(node, localcontext)
|
||||
return r.render()
|
||||
|
||||
|
|
|
@ -573,7 +573,7 @@ class _rml_flowable(object):
|
|||
from reportlab.graphics.barcode import usps
|
||||
except Exception, e:
|
||||
return None
|
||||
args = utils.attr_get(node, [], {'ratio':'float','xdim':'unit','height':'unit','checksum':'bool','quiet':'bool'})
|
||||
args = utils.attr_get(node, [], {'ratio':'float','xdim':'unit','height':'unit','checksum':'int','quiet':'int','width':'unit','stop':'bool','bearers':'int','barWidth':'float','barHeight':'float'})
|
||||
codes = {
|
||||
'codabar': lambda x: common.Codabar(x, **args),
|
||||
'code11': lambda x: common.Code11(x, **args),
|
||||
|
|
|
@ -162,6 +162,8 @@ def attr_get(node, attrs, dict={}):
|
|||
res[key] = int(node.get(key))
|
||||
elif dict[key]=='unit':
|
||||
res[key] = unit_get(node.get(key))
|
||||
elif dict[key] == 'float' :
|
||||
res[key] = float(node.get(key))
|
||||
return res
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -305,7 +305,7 @@ class rml_parse(object):
|
|||
head_dom = etree.XML(rml_head)
|
||||
for tag in head_dom.getchildren():
|
||||
found = rml_dom.find('.//'+tag.tag)
|
||||
if len(found):
|
||||
if found and len(found):
|
||||
if tag.get('position'):
|
||||
found.append(tag)
|
||||
else :
|
||||
|
@ -464,10 +464,47 @@ class report_sxw(report_rml, preprocess.report):
|
|||
meta = etree.tostring(rml_dom_meta)
|
||||
|
||||
rml_dom = etree.XML(rml)
|
||||
body = rml_dom.getchildren()[-1]
|
||||
elements = []
|
||||
key1 = rml_parser.localcontext['name_space']["text"]+"p"
|
||||
key2 = rml_parser.localcontext['name_space']["text"]+"drop-down"
|
||||
for n in rml_dom.iterdescendants():
|
||||
if n.tag == key1:
|
||||
elements.append(n)
|
||||
if report_type == 'odt':
|
||||
for pe in elements:
|
||||
e = pe.findall(key2)
|
||||
for de in e:
|
||||
pp=de.getparent()
|
||||
if de.text or de.tail:
|
||||
pe.text = de.text or de.tail
|
||||
for cnd in de.getchildren():
|
||||
if cnd.text or cnd.tail:
|
||||
if pe.text:
|
||||
pe.text += cnd.text or cnd.tail
|
||||
else:
|
||||
pe.text = cnd.text or cnd.tail
|
||||
pp.remove(de)
|
||||
else:
|
||||
for pe in elements:
|
||||
e = pe.findall(key2)
|
||||
for de in e:
|
||||
pp = de.getparent()
|
||||
if de.text or de.tail:
|
||||
pe.text = de.text or de.tail
|
||||
for cnd in de:
|
||||
text = cnd.get("{http://openoffice.org/2000/text}value",False)
|
||||
if text:
|
||||
if pe.text and text.startswith('[['):
|
||||
pe.text += text
|
||||
elif text.startswith('[['):
|
||||
pe.text = text
|
||||
if de.getparent():
|
||||
pp.remove(de)
|
||||
|
||||
rml_dom = self.preprocess_rml(rml_dom,report_type)
|
||||
create_doc = self.generators[report_type]
|
||||
odt = etree.tostring(create_doc(rml_dom, rml_parser.localcontext))
|
||||
|
||||
sxw_z = zipfile.ZipFile(sxw_io, mode='a')
|
||||
sxw_z.writestr('content.xml', "<?xml version='1.0' encoding='UTF-8'?>" + \
|
||||
odt)
|
||||
|
|
|
@ -256,7 +256,11 @@ form: module.record_id""" % (xml_id,)
|
|||
if len(d_search):
|
||||
ids = self.pool.get(d_model).search(cr,self.uid,eval(d_search))
|
||||
if len(d_id):
|
||||
ids.append(self.id_get(cr, d_model, d_id))
|
||||
try:
|
||||
ids.append(self.id_get(cr, d_model, d_id))
|
||||
except:
|
||||
# d_id cannot be found. doesn't matter in this case
|
||||
pass
|
||||
if len(ids):
|
||||
self.pool.get(d_model).unlink(cr, self.uid, ids)
|
||||
self.pool.get('ir.model.data')._unlink(cr, self.uid, d_model, ids, direct=True)
|
||||
|
|
Loading…
Reference in New Issue