示例#1
0
    def get_vouchers(self, cr, uid, context=None):
        retval = {}
        voucher_obj = self.pool.get('account.voucher')
        voucher_ids = context.get('active_ids')
        vouchers = voucher_obj.browse(cr, uid, voucher_ids, context=context)
        for voucher in vouchers:
            currency_obj = self.pool.get('res.currency')
            voucher_curr_id = voucher.currency_id.id
            company_obj = self.pool.get('res.company')
            user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
            company = company_obj.browse(cr, uid, user.company_id.id)
            default_curr_id = company.currency_id.id
            default_currency = currency_obj.browse(cr, uid, default_curr_id, context=context).symbol
            amount_default = currency_obj.compute(cr, uid, voucher_curr_id, default_curr_id,
                voucher.amount)
            retval[voucher] = {
                # Yup, hardcpoding lang for this one. It's only gonna be used
                # in French.
                'amount_text': amount_to_text(voucher.amount, lang='fr',
                    currency=voucher.currency_id.symbol),
                'amount_default': amount_default,
                'amount_text_default': amount_to_text(amount_default, lang='fr',
                    currency=default_currency),
                'default_currency': default_currency,
                'diff_currencies': voucher_curr_id != default_curr_id,

            }
        return retval
示例#2
0
 def get_vouchers(self, cr, uid, context=None):
     retval = {}
     voucher_obj = self.pool.get('account.voucher')
     voucher_ids = context.get('active_ids')
     vouchers = voucher_obj.browse(cr, uid, voucher_ids, context=context)
     for voucher in vouchers:
         currency_obj = self.pool.get('res.currency')
         voucher_curr_id = voucher.currency_id.id
         company_obj = self.pool.get('res.company')
         user = self.pool.get('res.users').browse(cr,
                                                  uid,
                                                  uid,
                                                  context=context)
         company = company_obj.browse(cr, uid, user.company_id.id)
         default_curr_id = company.currency_id.id
         default_currency = currency_obj.browse(cr,
                                                uid,
                                                default_curr_id,
                                                context=context).symbol
         amount_default = currency_obj.compute(cr, uid, voucher_curr_id,
                                               default_curr_id,
                                               voucher.amount)
         retval[voucher] = {
             # Yup, hardcpoding lang for this one. It's only gonna be used
             # in French.
             'amount_text':
             amount_to_text(voucher.amount,
                            lang='fr',
                            currency=voucher.currency_id.symbol),
             'amount_default':
             amount_default,
             'amount_text_default':
             amount_to_text(amount_default,
                            lang='fr',
                            currency=default_currency),
             'default_currency':
             default_currency,
             'diff_currencies':
             voucher_curr_id != default_curr_id,
         }
     return retval
示例#3
0
 def amount_to_text(self, nbr, lang='vi_VN', currency='USD'):
     if lang and ('vi' in lang or 'vn' in lang):
         text = amount_to_text_vn.amount_to_text(nbr, currency) + u' đồng'
     elif 'fr' in lang:
         text = amount_to_text_fr(nbr, currency)
     elif 'en' in lang:
         text = amount_to_text_en.amount_to_text(nbr, currency)
     else:
         text = amount_to_text(nbr, currency)
     if text:
         text = text[0].upper() + text[1:]
     return text
 def get_amount(self, voucher):
     currency = voucher.currency_id
     if currency.name.upper() == 'EUR':
         currency_name = 'Euro'
     elif currency.name.upper() == 'USD':
         currency_name = 'Dollars'
     elif currency.name.upper() == 'BRL':
         currency_name = 'reais'
     else:
         currency_name = currency.name
     # l'appel de la fonction est forcé en français
     # TODO utiliser le bon formatage selon la langue du client ou la langue de la société
     text = "**" + amount_to_text(abs(
         voucher.amount), voucher.partner_id.lang, currency_name).upper()
     text = string.ljust(text, 46, "*")
     text += " "
     text = string.ljust(text, 92, "*")
     return text
示例#5
0
 def _compute_text(self):
     self.amount_in_word = amount_to_text(self.amount_total,
                                          self.partner_id.lang,
                                          self.currency_id.symbol)
示例#6
0
 def amount_to_texto(self, amount_total, currency='INR'):
     return amount_to_text(self.amount_total, currency)