Beispiel #1
0
 def _amount_in_words(self):
     amount_in_words = amount_to_text_en.amount_to_text(math.floor(
         self.total_amount),
                                                        lang='en',
                                                        currency='')
     amount_in_words = amount_in_words.replace(' and Zero Cent',
                                               '') + ' Rupees'
     decimals = self.total_amount % 1
     if decimals >= 10**-2:
         amount_in_words += ' and ' + amount_to_text_en.amount_to_text(
             math.floor(decimals * 100), lang='en', currency='')
         amount_in_words = amount_in_words.replace(' and Zero Cent',
                                                   '') + ' Paise'
     amount_in_words += ' Only'
     self.amount_in_words = amount_in_words
 def get_net_total_words(self, obj):
     ptotal=0.00
     for line in obj.line_ids:
         if line.category_id.code.upper()=='NET':  
             ptotal = line.total
           
     return amount_to_text(ptotal, currency=obj.company_id.currency_id.name)
    def onchange_amount(self, cr, uid, ids, amount, rate, partner_id, journal_id, currency_id, ttype, date, payment_rate_currency_id, company_id, context=None):
        """ Inherited - add amount_in_word and allow_check_writting in returned value dictionary """
        if not context:
            context = {}
        default = super(account_voucher, self).onchange_amount(cr, uid, ids, amount, rate, partner_id, journal_id, currency_id, ttype, date, payment_rate_currency_id, company_id, context=context)
        if 'value' in default:
            amount = 'amount' in default['value'] and default['value']['amount'] or amount

            # Currency complete name is not available in res.currency model
            # Exceptions done here (EUR, USD, BRL) cover 75% of cases
            # For other currencies, display the currency code
            currency = self.pool['res.currency'].browse(cr, uid, currency_id, context=context)
            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
            #TODO : generic amount_to_text is not ready yet, otherwise language (and country) and currency can be passed
            #amount_in_word = amount_to_text(amount, context=context)
            amount_in_word = amount_to_text(amount, currency=currency_name)
            default['value'].update({'amount_in_word':amount_in_word})
            if journal_id:
                allow_check_writing = self.pool.get('account.journal').browse(cr, uid, journal_id, context=context).allow_check_writing
                default['value'].update({'allow_check':allow_check_writing})
        return default
Beispiel #4
0
    def get_net_total_words(self, obj):
        ptotal = 0.00
        for line in obj.line_ids:
            if line.category_id.code.upper() == 'NET':
                ptotal = line.total

        return amount_to_text(ptotal, currency=obj.company_id.currency_id.name)
Beispiel #5
0
 def _amount_to_word_en(self, cursor, user, ids, name, arg, context=None):
     res = {}
     minus = False
     amount_text = ""
     for obj in self.browse(cursor, user, ids, context=context):
         a = "Baht"
         b = "Satang"
         if obj.currency_id.name == "JYP":
             a = "Yen"
             b = "Sen"
         if obj.currency_id.name == "GBP":
             a = "Pound"
             b = "Penny"
         if obj.currency_id.name == "USD":
             a = "Dollar"
             b = "Cent"
         if obj.currency_id.name == "EUR":
             a = "Euro"
             b = "Cent"
         amount_total = self._get_amount_total(obj)
         if amount_total < 0:
             minus = True
             amount_total = -amount_total
         amount_text = (
             amount_to_text(amount_total, "en", a)
             .replace("and Zero Cent", "Only")
             .replace("Cent", b)
             .replace("Cents", b)
         )
         final_amount_text = (minus and "Minus " + amount_text or amount_text).lower()
         res[obj.id] = final_amount_text[:1].upper() + final_amount_text[1:]
     return res
 def _compute_amount_untaxed_text_en(self):
     for invoice in self:
         minus = False
         a = 'Baht'
         b = 'Satang'
         if invoice.currency_id.name == 'JYP':
             a = 'Yen'
             b = 'Sen'
         if invoice.currency_id.name == 'GBP':
             a = 'Pound'
             b = 'Penny'
         if invoice.currency_id.name == 'USD':
             a = 'Dollar'
             b = 'Cent'
         if invoice.currency_id.name == 'EUR':
             a = 'Euro'
             b = 'Cent'
         amount_untaxed = invoice.amount_untaxed
         if amount_untaxed < 0:
             minus = True
             amount_untaxed = -amount_untaxed
         amount_text = amount_to_text(
             amount_untaxed, 'en', a).replace(
                 'and Zero Cent', 'Only').replace(
                     'Cent', b).replace('Cents', b)
         final_amount_text = (minus and 'Minus ' +
                              amount_text or amount_text).lower()
         invoice.amount_untaxed_text_en = \
             final_amount_text[:1].upper() + final_amount_text[1:]
Beispiel #7
0
 def _amount_to_word_en(self, cursor, user, ids, name, arg, context=None):
     res = {}
     minus = False
     amount_text = ''
     for obj in self.browse(cursor, user, ids, context=context):
         a = 'Baht'
         b = 'Satang'
         if obj.currency_id.name == 'JYP':
             a = 'Yen'
             b = 'Sen'
         if obj.currency_id.name == 'GBP':
             a = 'Pound'
             b = 'Penny'
         if obj.currency_id.name == 'USD':
             a = 'Dollar'
             b = 'Cent'
         if obj.currency_id.name == 'EUR':
             a = 'Euro'
             b = 'Cent'   
         amount_total = self._get_amount_total(obj)
         if amount_total < 0:
             minus = True
             amount_total = -amount_total
         amount_text = amount_to_text(amount_total, 'en', a).replace('and Zero Cent', 'Only').replace('Cent', b).replace('Cents', b)
         res[obj.id] = minus and 'Minus ' + amount_text or amount_text
     return res
 def amount_to_text(self, amount, currency):
     convert_amount_in_words = amount_to_text_en.amount_to_text(amount,
                                                                lang='en',
                                                                currency='')
     convert_amount_in_words = convert_amount_in_words.replace(
         ' and Zero Cent', ' Only ')
     return convert_amount_in_words
Beispiel #9
0
 def get_amount_in_words(self,data):
     amount = self.pool.get('smsfee.receiptbook').browse(self.cr,self.uid,data).total_paybles        
     user_id = self.pool.get('res.users').browse(self.cr, self.uid,[self.uid])[0]
     cur = user_id.company_id.currency_id.name
     amt_en = amount_to_text_en.amount_to_text(amount,'en',cur);
     return_value=str(amt_en).replace('Cent','Paisa')
     return return_value
Beispiel #10
0
 def _amount_to_word_en(self, cursor, user, ids, name, arg, context=None):
     res = {}
     minus = False
     amount_text = ''
     for obj in self.browse(cursor, user, ids, context=context):
         a = 'Baht'
         b = 'Satang'
         if obj.currency_id.name == 'JYP':
             a = 'Yen'
             b = 'Sen'
         if obj.currency_id.name == 'GBP':
             a = 'Pound'
             b = 'Penny'
         if obj.currency_id.name == 'USD':
             a = 'Dollar'
             b = 'Cent'
         if obj.currency_id.name == 'EUR':
             a = 'Euro'
             b = 'Cent'
         amount_total = self._get_amount_total(obj)
         if amount_total < 0:
             minus = True
             amount_total = -amount_total
         amount_text = amount_to_text(amount_total, 'en', a).replace(
             'and Zero Cent', 'Only').replace('Cent',
                                              b).replace('Cents', b)
         final_amount_text = (minus and 'Minus ' + amount_text
                              or amount_text).lower()
         res[obj.id] = final_amount_text[:1].upper() + final_amount_text[1:]
     return res
    def onchange_amount(self,
                        cr,
                        uid,
                        ids,
                        amount,
                        rate,
                        partner_id,
                        journal_id,
                        currency_id,
                        ttype,
                        date,
                        payment_rate_currency_id,
                        company_id,
                        context=None):
        """ Inherited - add amount_in_word and allow_check_writting in returned value dictionary """
        if not context:
            context = {}
        default = super(account_voucher,
                        self).onchange_amount(cr,
                                              uid,
                                              ids,
                                              amount,
                                              rate,
                                              partner_id,
                                              journal_id,
                                              currency_id,
                                              ttype,
                                              date,
                                              payment_rate_currency_id,
                                              company_id,
                                              context=context)
        if 'value' in default:
            amount = 'amount' in default['value'] and default['value'][
                'amount'] or amount

            # Currency complete name is not available in res.currency model
            # Exceptions done here (EUR, USD, BRL) cover 75% of cases
            # For other currencies, display the currency code
            currency = self.pool['res.currency'].browse(cr,
                                                        uid,
                                                        currency_id,
                                                        context=context)
            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
            #TODO : generic amount_to_text is not ready yet, otherwise language (and country) and currency can be passed
            #amount_in_word = amount_to_text(amount, context=context)
            amount_in_word = amount_to_text(amount, currency=currency_name)
            default['value'].update({'amount_in_word': amount_in_word})
            if journal_id:
                allow_check_writing = self.pool.get('account.journal').browse(
                    cr, uid, journal_id, context=context).allow_check_writing
                default['value'].update({'allow_check': allow_check_writing})
        return default
 def get_amt_inwords(self, invoice, total,ttype):
     if ttype == 'words':
         amt_in_words = amount_to_text(total,'en',invoice.currency_id.name)
         if invoice.currency_id.name == 'INR':
             amt_in_words = amt_in_words.replace('INR','Rupees').replace('Cents','Paisa').replace('Cent','Paisa')
             return amt_in_words
     else:
         return total
 def _amount_word(self, obj):
     total = self._get_total(obj)
     if total == 0.0:
         return ' '
     else:
         amount = amount_to_text(total)
         word = str(amount)
         return word
 def get_amount_in_words(self):
     balance = self.total_in_amount - self.total_out_amount
     amount_in_words = amount_to_text_en.amount_to_text(balance,
                                                        currency='INR')
     amount_in_words1 = amount_in_words.replace('INR', 'Rupees')
     final_words = amount_in_words1.replace('Cents', 'Paisa')
     final_words = amount_in_words1.replace('Cent', 'Paisa')
     return final_words
 def _onchange_amount(self):
     if hasattr(super(account_payment, self), '_onchange_amount'):
         super(account_payment, self)._onchange_amount()
     check_amount_in_words = amount_to_text_en.amount_to_text(math.floor(self.amount), lang='en', currency='')
     check_amount_in_words = check_amount_in_words.replace(' and Zero Cent', '') # Ugh
     decimals = self.amount % 1
     if decimals >= 10**-2:
         check_amount_in_words += _(' and %s/100') % str(int(round(float_round(decimals*100, precision_rounding=1))))
     self.check_amount_in_words = check_amount_in_words
Beispiel #16
0
 def amount_to_text_en(self, amount, currency):
     convert_amount_in_words = amount_to_text_en.amount_to_text(amount, lang='en', currency=currency)        
     company_id = self.company_id and self.company_id.id
     if company_id ==6:
         convert_amount_in_words = convert_amount_in_words.replace('Cent', 'Halala')
     else:
         convert_amount_in_words = convert_amount_in_words.replace('Cent', 'Fill')
                           
     return convert_amount_in_words
    def _amount_to_text_report(self, num):
        ans = amount_to_text(num)
        # print ans
        ans = ans.replace("euro", "rupees")
        ans = ans.replace("Cents", "paisa")
        ans = ans.replace("Cent", "paisa")

        # print ans
        return ans
Beispiel #18
0
 def _onchange_amount(self):
     if hasattr(super(account_payment, self), '_onchange_amount'):
         super(account_payment, self)._onchange_amount()
     check_amount_in_words = amount_to_text_en.amount_to_text(math.floor(self.amount), lang='en', currency='')
     check_amount_in_words = check_amount_in_words.replace(' and Zero Cent', '') # Ugh
     decimals = self.amount % 1
     if decimals >= 10**-2:
         check_amount_in_words += _(' and %s/100') % str(int(round(float_round(decimals*100, precision_rounding=1))))
     self.check_amount_in_words = check_amount_in_words
Beispiel #19
0
 def _amount_in_words(self, cr, uid, ids, name, arg, context=None):
     res = {}
     for so in self.browse(cr, uid, ids, context=context):
         temp_text = amount_to_text(so.amount_total,
                                    currency=so.currency_id.name)
         #cut = temp_text.find('euro')
         #temp_text = temp_text[0:cut]
         #temp_text += 'Cartons Only'
         res[so.id] = temp_text
     return res
Beispiel #20
0
 def _onchange_amount(self):
     if hasattr(super(account_register_payments, self), '_onchange_amount'):
         super(account_register_payments, self)._onchange_amount()
     # TODO: merge, refactor and complete the amount_to_text and amount_to_text_en classes
     check_amount_in_words = amount_to_text_en.amount_to_text(math.floor(self.amount), lang='en', currency='')
     check_amount_in_words = check_amount_in_words.replace(' and Zero Cent', '') # Ugh
     decimals = self.amount % 1
     if decimals >= 10**-2:
         check_amount_in_words += _(' and %s/100') % str(int(round(float_round(decimals*100, precision_rounding=1))))
     self.check_amount_in_words = check_amount_in_words
def AmountToTextFractional(amountInt):
    amount_word = amount_to_text_en.amount_to_text(math.floor(amountInt),
                                                   lang='en',
                                                   currency='')
    amount_word = amount_word.replace(' and Zero Cent', '')
    decimals = amountInt % 1
    if decimals >= 10**-2:
        amount_word += _(' and %s/100') % str(
            int(round(float_round(decimals * 100, precision_rounding=1))))
    return amount_word
Beispiel #22
0
 def _amount_in_words(self, cr, uid, ids, name, arg, context=None):
     res = {}
     for order in self.browse(cr, uid, ids, context=context):
         a=''
         b=''
         if order.currency_id.name == 'INR':
             a = 'Rupees'
             b = ''
         res[order.id] = amount_to_text(order.roundoff_grand_total, 'en', a).replace('and Zero Cent', b).replace('and Zero Cent', b)
     return res
 def _onchange_amount(self):
     if hasattr(super(account_register_payments, self), '_onchange_amount'):
         super(account_register_payments, self)._onchange_amount()
     # TODO: merge, refactor and complete the amount_to_text and amount_to_text_en classes
     check_amount_in_words = amount_to_text_en.amount_to_text(math.floor(self.amount), lang='en', currency='')
     check_amount_in_words = check_amount_in_words.replace(' and Zero Cent', '') # Ugh
     decimals = self.amount % 1
     if decimals >= 10**-2:
         check_amount_in_words += _(' and %s/100') % str(int(round(float_round(decimals*100, precision_rounding=1))))
     self.check_amount_in_words = check_amount_in_words
Beispiel #24
0
 def _amount_total_in_words(self, cr, uid, ids, name, arg, context=None):
     res = {}
     for invoice in self.browse(cr, uid, ids, context=context):
         temp_text = amount_to_text(invoice.amount_total,
                                    currency=invoice.currency_id.name)
         #cut = temp_text.find('euro')
         #temp_text = temp_text[0:cut]
         #temp_text += 'Cartons Only'
         #print temp_text, invoice.currency_id.name
         res[invoice.id] = temp_text
     return res
 def convert(self,allocated_amt,amount,currency_id):
     if allocated_amt:
         amount= allocated_amt
     else:
         amount = amount
     amt_en =  amount_to_text_en.amount_to_text(amount,'en',currency_id.name) + ' ' + 'Only '
     amt_en = amt_en.replace(',',' ')
     amt_en = amt_en.replace('-',' ')
     if currency_id.name == 'AED':
         amt_en = amt_en.replace('Cent','Fil')
     return amt_en
 def _compute_amount_total(self):
     for letter in self:
         self._cr.execute("""
             select sum(amount_residual)
             from pabi_partner_dunning_letter_line
             where letter_id = %s
         """, (letter.id,))
         letter.amount_total = self._cr.fetchone()[0]
         letter.amount_total_text_en = amount_to_text(
             letter.amount_total, 'en', 'Baht').replace(
                 'and Zero Cent', 'Only').replace(
                     'Cent', 'Satang').replace('Cents', 'Satang')
 def _compute_amount_total(self):
     for letter in self:
         self._cr.execute("""
             select sum(amount_residual)
             from pabi_partner_dunning_letter_line
             where letter_id = %s
         """, (letter.id,))
         letter.amount_total = self._cr.fetchone()[0]
         letter.amount_total_text_en = amount_to_text(
             letter.amount_total, 'en', 'Baht').replace(
                 'and Zero Cent', 'Only').replace(
                     'Cent', 'Satang').replace('Cents', 'Satang')
Beispiel #28
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
Beispiel #29
0
 def convert(self, allocated_amt, amount, currency_id):
     if allocated_amt:
         amount = allocated_amt
     else:
         amount = amount
     amt_en = amount_to_text_en.amount_to_text(
         amount, 'en', currency_id.name) + ' ' + 'Only '
     amt_en = amt_en.replace(',', ' ')
     amt_en = amt_en.replace('-', ' ')
     if currency_id.name == 'AED':
         amt_en = amt_en.replace('Cent', 'Fil')
     return amt_en
Beispiel #30
0
 def convert(self, amount, currency_id):
     amount_in_word = ''
     currency_format =  self.pool.get('res.users').browse(self.cr, self.uid, self.uid).company_id.currency_format 
     if currency_format=='ar':
         if currency_id:
             currency = self.pool.get('res.currency').read(self.cr, self.uid, currency_id, ['units_name','cents_name'], context=self.context)
             amount_in_word = amount_to_text_ar(amount, currency_format, currency['units_name'], currency['cents_name'])
         else:
             amount_in_word = amount_to_text_ar(amount, currency_format)
     else: 
         amount_in_word = amount_to_text(amount)
     return amount_in_word
 def amount_to_text(self, amount, currency):
     '''
     The purpose of this function is to use payment amount change in word
     @param amount: pass Total payment of amount
     @param currency: pass which currency to pay
     @return: return amount in word
     @rtype : string
     '''
     amount_in_word = amount_to_text(amount)
     if currency == 'INR':
         amount_in_word = amount_in_word.replace("euro", "Rupees").replace("Cents", "Paise").replace("Cent", "Paise")
     return amount_in_word
 def _get_text_amount(self, amount, currency_id, lang):
     es_regex = re.compile('es.*')
     en_regex = re.compile('en.*')
     if es_regex.match(lang):
         from openerp.addons.l10n_cr_amount_to_text import amount_to_text
         return amount_to_text.number_to_text_es(
             amount, self._get_currency_name(currency_id, 'es'),
             join_dec=' Y ', separator=',', decimal_point='.')
     elif en_regex.match(lang):
         from openerp.tools import amount_to_text_en
         return amount_to_text_en.amount_to_text(
             amount, lang='en', currency=self._get_currency_name(
                 currency_id, 'en'))
Beispiel #33
0
 def _amount_total_text(self, cursor, user, ids, name, arg, context=None):
     res = {}
     for invoice in self.browse(cursor, user, ids, context=context):
         a = 'Baht'
         b = 'Satang'
         if invoice.currency_id.name == 'USD':
             a = 'Dollar'
             b = 'Cent'
         if invoice.currency_id.name == 'EUR':
             a = 'Euro'
             b = 'Cent'   
         res[invoice.id] = amount_to_text(invoice.amount_total, 'en', a).replace('Cent', b).replace('Cents', b)
     return res
Beispiel #34
0
    def onchange_amount(self,
                        cr,
                        uid,
                        ids,
                        amount,
                        rate,
                        partner_id,
                        journal_id,
                        currency_id,
                        ttype,
                        date,
                        payment_rate_currency_id,
                        company_id,
                        context=None):
        """ Inherited - add amount_in_word and allow_check_writting in returned value dictionary """

        if not context:
            context = {}
        default = super(account_voucher,
                        self).onchange_amount(cr,
                                              uid,
                                              ids,
                                              amount,
                                              rate,
                                              partner_id,
                                              journal_id,
                                              currency_id,
                                              ttype,
                                              date,
                                              payment_rate_currency_id,
                                              company_id,
                                              context=context)
        if 'value' in default:
            amount = 'amount' in default['value'] and default['value'][
                'amount'] or amount

            lang = context.get('lang')
            amount_in_word = ''
            if (lang and len(lang) >= 2 and lang[:2] == 'es'):
                amount_in_word = amount_to_text_ec().amount_to_text_cheque(
                    amount, '', '')
            else:
                amount_in_word = amount_to_text(amount)

            default['value'].update({'amount_in_word': amount_in_word})
            if journal_id:
                allow_check_writing = self.pool.get('account.journal').browse(
                    cr, uid, journal_id, context=context).allow_check_writing
                default['value'].update({'allow_check': allow_check_writing})

        return default
 def _get_text_amount(self, amount, currency_id):
     es_regex = re.compile('es.*')
     en_regex = re.compile('en.*')
     lang = self.localcontext.get('lang')
     if es_regex.match(lang):
         from openerp.addons.l10n_cr_amount_to_text import amount_to_text
         return amount_to_text.number_to_text_es(
             amount, '',
             join_dec=' Y ', separator=',', decimal_point='.')
     elif en_regex.match(lang):
         from openerp.tools import amount_to_text_en
         return amount_to_text_en.amount_to_text(
             amount, lang='en', currency='')
     else:
         raise Warning(_('Language not supported by this report.'))
Beispiel #36
0
 def _onchange_amount(self):
     print "changei in amount called------------------------", self.amount
     # TODO: merge, refactor and complete the amount_to_text and amount_to_text_en classes
     check_amount_in_words = amount_to_text_en.amount_to_text(math.floor(
         self.amount),
                                                              lang='en',
                                                              currency='')
     check_amount_in_words = check_amount_in_words.replace(
         ' and Zero Cent', '')  # Ugh
     decimals = self.amount % 1
     if decimals >= 10**-2:
         check_amount_in_words += _(' and %s/100 Fils') % str(
             int(round(float_round(decimals * 100, precision_rounding=1))))
     self.check_amount_in_words = check_amount_in_words + ' ' + 'Only'
     print "check_amount_in_words--------------", self.check_amount_in_words
 def _amount_to_text(self, cr, uid, amount, currency_id, context=None):
     # Currency complete name is not available in res.currency model
     # Exceptions done here (EUR, USD, BRL) cover 75% of cases
     # For other currencies, display the currency code
     currency = self.pool['res.currency'].browse(cr, uid, currency_id, context=context)
     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
     #TODO : generic amount_to_text is not ready yet, otherwise language (and country) and currency can be passed
     #amount_in_word = amount_to_text(amount, context=context)
     return amount_to_text(amount, currency=currency_name)
Beispiel #38
0
    def onchange_amount(self, cr, uid, ids, amount, rate, partner_id, journal_id, currency_id, ttype, date, payment_rate_currency_id, company_id, context=None):
        """ Inherited - add amount_in_word and allow_check_writting in returned value dictionary """
        if not context:
            context = {}
        default = super(account_voucher, self).onchange_amount(cr, uid, ids, amount, rate, partner_id, journal_id, currency_id, ttype, date, payment_rate_currency_id, company_id, context=context)
        if 'value' in default:
            amount = 'amount' in default['value'] and default['value']['amount'] or amount

            #TODO : generic amount_to_text is not ready yet, otherwise language (and country) and currency can be passed
            #amount_in_word = amount_to_text(amount, context=context)
            amount_in_word = amount_to_text(amount)
            default['value'].update({'amount_in_word':amount_in_word})
            if journal_id:
                allow_check_writing = self.pool.get('account.journal').browse(cr, uid, journal_id, context=context).allow_check_writing
                default['value'].update({'allow_check':allow_check_writing})
        return default
Beispiel #39
0
    def onchange_amount(self, cr, uid, ids, amount, rate, partner_id, journal_id, currency_id, ttype, date, payment_rate_currency_id, company_id, context=None):
        """ Inherited - add amount_in_word and allow_check_writting in returned value dictionary """
        if not context:
            context = {}
        default = super(account_voucher, self).onchange_amount(cr, uid, ids, amount, rate, partner_id, journal_id, currency_id, ttype, date, payment_rate_currency_id, company_id, context=context)
        if 'value' in default:
            amount = 'amount' in default['value'] and default['value']['amount'] or amount

            #TODO : generic amount_to_text is not ready yet, otherwise language (and country) and currency can be passed
            #amount_in_word = amount_to_text(amount, context=context)
            amount_in_word = amount_to_text(amount)
            default['value'].update({'amount_in_word':amount_in_word})
            if journal_id:
                allow_check_writing = self.pool.get('account.journal').browse(cr, uid, journal_id, context=context).allow_check_writing
                default['value'].update({'allow_check':allow_check_writing})
        return default
 def _amount_to_text(self, cr, uid, amount, currency_id, context=None):
     # Currency complete name is not available in res.currency model
     # Exceptions done here (EUR, USD, BRL) cover 75% of cases
     # For other currencies, display the currency code
     currency = self.pool['res.currency'].browse(cr, uid, currency_id, context=context)
     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
     #TODO : generic amount_to_text is not ready yet, otherwise language (and country) and currency can be passed
     #amount_in_word = amount_to_text(amount, context=context)
     return amount_to_text(amount, currency=currency_name)
Beispiel #41
0
def _amount_total_text(self, cursor, user, ids, name, arg, context=None):
    res = {}
    for order in self.browse(cursor, user, ids, context=context):
        a = ''
        b = ''
        if order.currency_id.name == 'THB':
            a = 'Baht'
            b = 'Satang'
        if order.currency_id.name == 'USD':
            a = 'Dollar'
            b = 'Cent'
        if order.currency_id.name == 'EUR':
            a = 'Euro'
            b = 'Cent'
        res[order.id] = amount_to_text(order.amount_total, 'en',
                                       a).replace('Cents',
                                                  b).replace('Cent', b)
    return res
Beispiel #42
0
    def onchange_price(self,
                       cr,
                       uid,
                       ids,
                       line_ids,
                       tax_id,
                       partner_id=False,
                       context=None):
        """
        Inherit method to update the text value of the check amount in the field 
        amount_in_word based on the language format of the currency.

        @return: dictionary of values of fields to be updated 
        """
        res = super(account_voucher,
                    self).onchange_price(cr,
                                         uid,
                                         ids,
                                         line_ids,
                                         tax_id,
                                         partner_id=partner_id,
                                         context=context)
        amount = res.get('value', {}).get('amount', 0)
        currency_format = self.pool.get('res.users').browse(
            cr, uid, uid).company_id.currency_format
        if currency_format == 'ar':
            currency_id = ids and self.browse(
                cr, uid, ids, context=context)[0].currency_id.id
            if currency_id:
                currency = self.pool.get('res.currency').read(
                    cr,
                    uid,
                    currency_id, ['units_name', 'cents_name'],
                    context=context)
                amount_in_word = amount_to_text_ar(
                    amount, currency_format, currency.get('units_name', ''),
                    currency.get('cents_name', ''))
            else:
                amount_in_word = amount_to_text_ar(amount, currency_format)
        else:
            amount_in_word = amount_to_text(amount)
        res.get('value', {}).update({'amount_in_word': amount_in_word})
        return res
Beispiel #43
0
    def onchange_partner_id_ratification(self,
                                         cr,
                                         uid,
                                         ids,
                                         partner_id,
                                         journal_id,
                                         ttype,
                                         price,
                                         context={}):
        """
        This metthod call when changing Ratification amount or partner.
        @param int partner_id: Ratification record Partner,
        @param int journal_id: Ratification record Journal,
        @param char ttype: Ratification record type,
        @param float price: Ratification record amount,            
        @return: dictionary conatins amount_in_word value
        """
        ratification_journal = self.pool.get('res.company').browse(
            cr, uid, uid, context=context).ratification_journal_id
        default = {'value': {}}
        context.update({'type': 'purchase'})
        default['value'][
            'journal_id'] = ratification_journal.id and ratification_journal.id or self._get_journal(
                cr, uid, context=context)
        if partner_id and ttype == 'ratification':
            default['value']['account_id'] = self.pool.get(
                'res.partner').browse(
                    cr, uid, partner_id,
                    context=context).property_account_payable.id
        amount = 'amount' in default['value'] and default['value'][
            'amount'] or price
        currency_format = self.pool.get('res.users').browse(
            cr, uid, uid, context=context).company_id.currency_format
        amount_in_word = currency_format == 'ar' and amount_to_text_ar(
            amount, currency_format) or amount_to_text(amount)

        default['value'].update({'amount_in_word': amount_in_word})
        if journal_id:  #TODO:
            allow_check_writing = self.pool.get('account.journal').browse(
                cr, uid, journal_id, context=context).allow_check_writing
            default['value'].update({'allow_check': allow_check_writing})
        return default
 def _amount_to_text(self, amount, currency_id, context=None):
     # Currency complete name is not available in res.currency model
     # Exceptions done here (EUR, USD, BRL) cover 75% of cases
     # For other currencies, display the currency code
     currency = self.pool['res.currency'].browse(self.cr, self.uid, currency_id, context=context)
     if currency.name.upper() == 'EUR':
         currency_name = 'Euro'
     elif currency.name.upper() == 'USD':
         currency_name = 'Dollars'
     elif currency.name.upper() == 'BRL':
         currency_name = 'reais'
     elif currency.name.upper() == 'INR':
         currency_name = 'Rupees'
     else:
         currency_name = currency.name
     amout_str = amount_to_text(amount, currency=currency_name)
     if currency.name.upper() == 'INR':
         amout_str = string.replace(amout_str, 'Cents', 'Paisa')
         amout_str = string.replace(amout_str, 'Cent', 'Paisa')
     return amout_str
 def onchange_amount(self, cr, uid, ids, amount, rate, partner_id, journal_id, currency_id, ttype, date, payment_rate_currency_id, company_id, context=None):
     """ 
     Inherited: add amount_in_word and allow_check_writing in @returned value dictionary 
     """
     if not context:
         context = {}
     default = super(account_voucher, self).onchange_amount(cr, uid, ids, amount, rate, partner_id, journal_id, currency_id, ttype, date, payment_rate_currency_id, company_id, context=context)
     if 'value' in default:
         amount = 'amount' in default['value'] and default['value']['amount'] or amount
         currency = self.pool.get('res.currency').browse(cr, uid, currency_id, context=context)
         language = 'en'
         if context.get('lang'):
             language = context.get('lang')[0:2]
         currency = currency.name.lower()
         amount_in_word = amount_to_text_en.amount_to_text(amount, lang=language, currency=currency)
         default['value'].update({'amount_in_word': amount_in_word})
         if journal_id:
             allow_check_writing = self.pool.get('account.journal').browse(cr, uid, journal_id, context=context).allow_check_writing
             default['value'].update({'allow_check': allow_check_writing})
     return default
 def convert(self):
     return amount_to_text_en.amount_to_text(self.amount, 'en', self.currency_id.name)
Beispiel #47
0
    def amt_word(self, amt,crny):
#        if crny and crny.upper() == 'USD':
#            crny = 'Dollars'
        amount = amount_to_text(amt,currency=crny)
        amount = amount.replace('USD','Dollars')
        return amount
Beispiel #48
0
 def amount_to_text(self, amount):
     amount_in_word = amount_to_text(amount)
     amount_in_word = amount_in_word.replace("euro", "Rupees").replace("Cents", "Paise").replace("Cent", "Paise")
     return amount_in_word
Beispiel #49
0
 def _compute_amount(self):
     self.amount_untaxed = sum(line.price_subtotal for line in self.invoice_line)
     self.amount_tax = sum(line.amount for line in self.tax_line)
     self.amount_total = self.amount_untaxed + self.amount_tax
     self.amount_word = amount_to_text_en.amount_to_text(float(self.amount_total))
     return super(account_invoice, self)._compute_amount()
 def amount_word(self):
     amount = amount_to_text(self.amount_total)
     word = str(amount) + ' Only'
     return word
Beispiel #51
0
 def convert(self, amount, cur):
     return amount_to_text_en.amount_to_text(amount, "en", cur)
Beispiel #52
0
 def convert(self, amount, cur):
     amt_en = amount_to_text_en.amount_to_text(amount, 'en', cur)
     return amt_en
 def convert(self, amount):
     return amount_to_text_en.amount_to_text(amount, 'en', 'Rupees')
 def convert(self, amount, obj):
     cur = obj
     var =  amount_to_text_en.amount_to_text(amount, 'en', cur).replace(cur, "")
     return var
 def get_amount(self, amt, row, bow):
     amount_in_word = amount_to_text_en.amount_to_text(amt, row, bow)
     return amount_in_word