diff --git a/addons/account/account.py b/addons/account/account.py index 4b2766c53ac..9dc9e5ac2aa 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -906,7 +906,10 @@ class account_move(osv.osv): amount+= (line.debit - line.credit) return amount - def _centralise(self, cr, uid, move, mode): + def _centralise(self, cr, uid, move, mode, context=None): + if context is None: + context = {} + if mode=='credit': account_id = move.journal_id.default_debit_account_id.id mode2 = 'debit' @@ -929,8 +932,9 @@ class account_move(osv.osv): if res: line_id = res[0] else: + context.update({'journal_id': move.journal_id.id, 'period_id': move.period_id.id}) line_id = self.pool.get('account.move.line').create(cr, uid, { - 'name': _('Centralisation ') + mode, + 'name': _t(cr, None, 'selection', context.get('lang'), source=(mode.capitalize()+' Centralisation')) or (mode.capitalize()+' Centralisation'), 'centralisation': mode, 'account_id': account_id, 'move_id': move.id, @@ -939,7 +943,7 @@ class account_move(osv.osv): 'date': move.period_id.date_stop, 'debit': 0.0, 'credit': 0.0, - }, {'journal_id': move.journal_id.id, 'period_id': move.period_id.id}) + }, context) # find the first line of this move with the other mode # so that we can exclude it from our calculation @@ -1021,8 +1025,8 @@ class account_move(osv.osv): # continue if journal.centralisation: - self._centralise(cr, uid, move, 'debit') - self._centralise(cr, uid, move, 'credit') + self._centralise(cr, uid, move, 'debit', context=context) + self._centralise(cr, uid, move, 'credit', context=context) self.pool.get('account.move.line').write(cr, uid, line_draft_ids, { 'state': 'valid' }, context, check=False) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 8d9b905d6c3..e9484ff312d 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -679,7 +679,7 @@ class account_invoice(osv.osv): for i in line: i[2]['period_id'] = period_id - move_id = self.pool.get('account.move').create(cr, uid, move) + move_id = self.pool.get('account.move').create(cr, uid, move, context=context) new_move_name = self.pool.get('account.move').browse(cr, uid, move_id).name # make the invoice point to that move self.write(cr, uid, [inv.id], {'move_id': move_id,'period_id':period_id, 'move_name':new_move_name}) diff --git a/addons/sale/sale.py b/addons/sale/sale.py index a7814e110ac..8e4426fd02b 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -955,7 +955,7 @@ class sale_order_line(osv.osv): partner = partner_obj.browse(cr, uid, partner_id) result['tax_id'] = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, product_obj.taxes_id) if not flag: - result['name'] = product_obj.partner_ref + result['name'] = self.pool.get('product.product').name_get(cr, uid, [product_obj.id], context=context)[0][1] domain = {} if (not uom) and (not uos): result['product_uom'] = product_obj.uom_id.id