[FIX] sale: translate advance message on advance invoice

This commit is contained in:
Simon Lejeune 2014-10-13 17:07:13 +02:00
parent 98c6e7c3d5
commit 9c0e8f10e0
1 changed files with 7 additions and 4 deletions

View File

@ -58,6 +58,9 @@ class sale_advance_payment_inv(osv.osv_memory):
'product_id': _get_advance_product,
}
def _translate_advance(self, cr, uid, percentage=False, context=None):
return _("Advance of %s %%") if percentage else _("Advance of %s %s")
def onchange_method(self, cr, uid, ids, advance_payment_method, product_id, context=None):
if advance_payment_method == 'percentage':
return {'value': {'amount':0, 'product_id':False }}
@ -104,16 +107,17 @@ class sale_advance_payment_inv(osv.osv_memory):
if wizard.advance_payment_method == 'percentage':
inv_amount = sale.amount_total * wizard.amount / 100
if not res.get('name'):
res['name'] = _("Advance of %s %%") % (wizard.amount)
res['name'] = self._translate_advance(cr, uid, percentage=True, context=dict(context, lang=sale.partner_id.lang)) % (wizard.amount)
else:
inv_amount = wizard.amount
if not res.get('name'):
#TODO: should find a way to call formatLang() from rml_parse
symbol = sale.pricelist_id.currency_id.symbol
if sale.pricelist_id.currency_id.position == 'after':
res['name'] = _("Advance of %s %s") % (inv_amount, symbol)
symbol_order = (inv_amount, symbol)
else:
res['name'] = _("Advance of %s %s") % (symbol, inv_amount)
symbol_order = (symbol, inv_amount)
res['name'] = self._translate_advance(cr, uid, context=dict(context, lang=sale.partner_id.lang)) % symbol_order
# determine taxes
if res.get('invoice_line_tax_id'):
@ -159,7 +163,6 @@ class sale_advance_payment_inv(osv.osv_memory):
sale_obj.write(cr, uid, sale_id, {'invoice_ids': [(4, inv_id)]}, context=context)
return inv_id
def create_invoices(self, cr, uid, ids, context=None):
""" create invoices for the active sales orders """
sale_obj = self.pool.get('sale.order')