user552403
user552403

Reputation: 306

Why does the code here create a non-used variable `context`?

https://github.com/odoo/odoo/blob/11.0/addons/sale/wizard/sale_make_invoice_advance.py#L79-L86

    context = {'lang': order.partner_id.lang}
    if self.advance_payment_method == 'percentage':
        amount = order.amount_untaxed * self.amount / 100
        name = _("Down payment of %s%%") % (self.amount,)
    else:
        amount = self.amount
        name = _('Down Payment')
    del context

I'm quite familiar with Python so I think the context has not been used in the code above. Am I correct?

Upvotes: 2

Views: 54

Answers (1)

user552403
user552403

Reputation: 306

After reading the code at https://github.com/odoo/odoo/blob/11.0/odoo/tools/translate.py#L387-L393

I've found the answer is: the underscore(_) function will use the context.lang setting for the translation. It will get the value of context from call stack.

Upvotes: 3

Related Questions