diff --git a/openerp/addons/base/ir/ir_sequence.py b/openerp/addons/base/ir/ir_sequence.py index c4ea65caf6d..4267e92d54d 100644 --- a/openerp/addons/base/ir/ir_sequence.py +++ b/openerp/addons/base/ir/ir_sequence.py @@ -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'],)) diff --git a/openerp/addons/base/res/partner/partner.py b/openerp/addons/base/res/partner/partner.py index f7f2ad385e2..ee81d1d10b6 100644 --- a/openerp/addons/base/res/partner/partner.py +++ b/openerp/addons/base/res/partner/partner.py @@ -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 diff --git a/openerp/addons/base/res/partner/partner_view.xml b/openerp/addons/base/res/partner/partner_view.xml index 6a8fbe95f7c..763147fb47e 100644 --- a/openerp/addons/base/res/partner/partner_view.xml +++ b/openerp/addons/base/res/partner/partner_view.xml @@ -79,6 +79,7 @@
+ diff --git a/openerp/addons/base/res/res_security.xml b/openerp/addons/base/res/res_security.xml index df80f90373c..1708be790cb 100644 --- a/openerp/addons/base/res/res_security.xml +++ b/openerp/addons/base/res/res_security.xml @@ -16,6 +16,9 @@ + + + @@ -34,7 +37,6 @@ ['|',('company_id.child_ids','child_of',[user.company_id.id]),('company_id','child_of',[user.company_id.id])] - - + diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index ff0d17af47a..48d66f30e32 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -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