[MERGE] from trunk

bzr revid: rco@openerp.com-20110722150218-by322dfid2sz3k30
This commit is contained in:
Raphael Collet
2011-07-22 17:02:18 +02:00
8 changed files with 42 additions and 37 deletions
+3 -3
View File
@@ -75,15 +75,15 @@ class ir_sequence(osv.osv):
def get_id(self, cr, uid, sequence_id, test='id', context=None):
assert test in ('code','id')
company_id = self.pool.get('res.users').read(cr, uid, uid, ['company_id'], context=context)['company_id'][0] or None
company_ids = self.pool.get('res.company').search(cr, uid, [], context=context)
cr.execute('''SELECT id, number_next, prefix, suffix, padding
FROM ir_sequence
WHERE %s=%%s
AND active=true
AND (company_id = %%s or company_id is NULL)
AND (company_id in %%s or company_id is NULL)
ORDER BY company_id, id
FOR UPDATE NOWAIT''' % test,
(sequence_id, company_id))
(sequence_id, tuple(company_ids)))
res = cr.dictfetchone()
if res:
cr.execute('UPDATE ir_sequence SET number_next=number_next+number_increment WHERE id=%s AND active=true', (res['id'],))
+4 -2
View File
@@ -224,8 +224,10 @@ class res_partner(osv.osv):
return True
def address_get(self, cr, uid, ids, adr_pref=['default']):
cr.execute('select type,id from res_partner_address where partner_id IN %s',(tuple(ids),))
res = cr.fetchall()
address_obj = self.pool.get('res.partner.address')
address_ids = address_obj.search(cr, uid, [('partner_id', '=', ids)])
address_rec = address_obj.read(cr, uid, address_ids, ['type'])
res = list(tuple(addr.values()) for addr in address_rec)
adr = dict(res)
# get the id of the (first) default address if there is one,
# otherwise get the id of the first address in the list
@@ -79,6 +79,7 @@
<form string="Address">
<group colspan="4" col="6">
<field name="partner_id" colspan="2"/>
<field name="active"/>
<field name="company_id" groups="base.group_multi_company" widget="selection" colspan="2"/>
<newline/>
<field name="name"/>
+4 -2
View File
@@ -16,6 +16,9 @@
<field eval="[(6,0,[ref('group_partner_manager')])]" name="groups_id"/>
</record>
</data>
<data noupdate="1">
<!-- Record Rule For Company -->
@@ -34,7 +37,6 @@
<field eval="True" name="global"/>
<field name="domain_force">['|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id])]</field>
</record>
</data>
</openerp>
+27 -18
View File
@@ -1091,7 +1091,20 @@ class orm_template(object):
if line[i] and skip:
return False
continue
#set the mode for m2o, o2m, m2m : xml_id/id/name
if len(field) == len(prefix)+1:
mode = False
else:
mode = field[len(prefix)+1]
# TODO: improve this by using csv.csv_reader
def many_ids(line, relation, current_module, mode):
res = []
for db_id in line.split(config.get('csv_internal_sep')):
res.append(_get_id(relation, db_id, current_module, mode))
return [(6,0,res)]
# ID of the record using a XML ID
if field[len(prefix)]=='id':
try:
@@ -1111,10 +1124,13 @@ class orm_template(object):
if field[len(prefix)] in done:
continue
done[field[len(prefix)]] = True
relation_obj = self.pool.get(fields_def[field[len(prefix)]]['relation'])
relation = fields_def[field[len(prefix)]]['relation']
relation_obj = self.pool.get(relation)
newfd = relation_obj.fields_get( cr, uid, context=context )
pos = position
res = []
res = many_ids(line[i], relation, current_module, mode)
first = 0
while pos < len(datas):
res2 = process_liness(self, datas, prefix + [field[len(prefix)]], current_module, relation_obj._name, newfd, pos, first)
@@ -1124,30 +1140,23 @@ class orm_template(object):
nbrmax = max(nbrmax, pos)
warning += w2
first += 1
if data_res_id2:
res.append((4, data_res_id2))
if (not newrow) or not reduce(lambda x, y: x or y, newrow.values(), 0):
break
res.append( (data_res_id2 and 1 or 0, data_res_id2 or 0, newrow) )
elif fields_def[field[len(prefix)]]['type']=='many2one':
relation = fields_def[field[len(prefix)]]['relation']
if len(field) == len(prefix)+1:
mode = False
else:
mode = field[len(prefix)+1]
res = _get_id(relation, line[i], current_module, mode)
elif fields_def[field[len(prefix)]]['type']=='many2many':
relation = fields_def[field[len(prefix)]]['relation']
if len(field) == len(prefix)+1:
mode = False
else:
mode = field[len(prefix)+1]
# TODO: improve this by using csv.csv_reader
res = []
for db_id in line[i].split(config.get('csv_internal_sep')):
res.append( _get_id(relation, db_id, current_module, mode) )
res = [(6,0,res)]
res = many_ids(line[i], relation, current_module, mode)
elif fields_def[field[len(prefix)]]['type'] == 'integer':
res = line[i] and int(line[i]) or 0
@@ -1168,7 +1177,7 @@ class orm_template(object):
else:
res = line[i]
row[field[len(prefix)]] = res or False
result = (row, nbrmax, warning, data_res_id, xml_id)
@@ -1182,7 +1191,7 @@ class orm_template(object):
position = 0
while position<len(datas):
res = {}
(res, position, warning, res_id, xml_id) = \
process_liness(self, datas, [], current_module, self._name, fields_def, position=position)
if len(warning):
+2 -2
View File
@@ -56,15 +56,15 @@ class report_printscreen_list(report_int):
if not context:
context={}
datas['ids'] = ids
model = pool.get(datas['model'])
pool = pooler.get_pool(cr.dbname)
model = pool.get(datas['model'])
# title come from description of model which are specified in py file.
self.title = model._description
result = model.fields_view_get(cr, uid, view_type='form', context=context)
fields_order = self._parse_string(result['arch'])
rows = model.read(cr, uid, datas['ids'], result['fields'].keys() )
res = self._create_table(uid, datas['ids'], result['fields'], fields_order, rows, context, model._description)
self._create_table(uid, datas['ids'], result['fields'], fields_order, rows, context, model._description)
return (self.obj.get(), 'pdf')
-10
View File
@@ -231,16 +231,6 @@ class rml_parse(object):
self.lang_dict_called = False
for obj in self.objects:
obj._context['lang'] = lang
for table in obj._cache:
for id in obj._cache[table]:
self._lang_cache.setdefault(obj._context['lang'], {}).setdefault(table,
{}).update(obj._cache[table][id])
if lang in self._lang_cache \
and table in self._lang_cache[lang] \
and id in self._lang_cache[lang][table]:
obj._cache[table][id] = self._lang_cache[lang][table][id]
else:
obj._cache[table][id] = {'id': id}
def _get_lang_dict(self):
pool_lang = self.pool.get('res.lang')
+1
View File
@@ -275,6 +275,7 @@ def safe_eval(expr, globals_dict=None, locals_dict=None, mode="eval", nocopy=Fal
'map': map,
'abs': abs,
'min': min,
'max': max,
'reduce': reduce,
'filter': filter,
'round': round,