コード例 #1
0
 def _get_total_in_list(self, cr, uid, ids, name, args, context={}):
     res={}
     for obj in self.browse(cr, uid, ids, context):
         total_amount_vnd=0
         total_amount_usd=0
         
         for objl in obj.detail_ids:                          
             total_amount_vnd+=objl.opening_balance + objl.request_adv - objl.return_adv 
             total_amount_usd+=objl.opening_balance_usd + objl.request_adv_usd - objl.return_adv_usd
         
         nego_vnd=False
         if total_amount_vnd<0:
             nego_vnd = True
         
         nego_usd=False
         if total_amount_usd<0:
             nego_usd = True
         
         amount_in_word_vnd_vn = amount_to_text(abs(total_amount_vnd),'vn', u' \u0111\u1ed3ng').capitalize()
         amount_in_word_vnd_en = amount_to_text(abs(total_amount_vnd),"en","dongs").capitalize()
         
         amount_in_word_usd_vn = amount_to_text(abs(total_amount_usd),'vn'," dollar").capitalize()
         amount_in_word_usd_en = amount_to_text(abs(total_amount_usd),'en'," dollar").capitalize()
         res[obj.id]={'total_amount_vnd':total_amount_vnd,
                      'amount_in_word_vnd_vn': ('(%s)' if nego_vnd else '%s')  % amount_in_word_vnd_vn,
                      'amount_in_word_vnd_en':('(%s)' if nego_vnd else '%s')  % amount_in_word_vnd_en,
                      
                      'total_amount_usd':total_amount_usd,
                      'amount_in_word_usd_vn':('(%s)' if nego_usd else '%s') % amount_in_word_usd_vn,
                      'amount_in_word_usd_en':('(%s)' if nego_usd else '%s') % amount_in_word_usd_en                         
                      }            
     return res
コード例 #2
0
 def _voucher_amount_to_word(self, cr, uid, ids, name, args, context={}):
     res = {}
     for x in self.browse(cr,uid,ids, context=context):
         reimbursement_amount=x.reimbursement_amount if x.reimbursement_amount>=0 else 0
         if x.currency_id.name=='USD':
             amount_to_word_vn = amount_to_text(reimbursement_amount,'vn',u" \u0111\xf4la",decimal="cents").capitalize()
             amount_to_word_en = amount_to_text(reimbursement_amount,'en'," dollar").capitalize()
         elif x.currency_id.name=='VND':
             amount_to_word_vn = amount_to_text(reimbursement_amount,'vn', u' \u0111\u1ed3ng').capitalize()  # + x.currency_id.name
             amount_to_word_en = amount_to_text(reimbursement_amount,"en","dongs").capitalize()
         else:
             amount_to_word_vn =amount_to_text(reimbursement_amount,'vn'," " + x.currency_id.name).capitalize()
             amount_to_word_en =amount_to_text(reimbursement_amount,'en'," "+ x.currency_id.name).capitalize() 
         res[x.id] = {'total_voucher_amount_to_word_vn':amount_to_word_vn,
                      'total_voucher_amount_to_word_en':amount_to_word_en}
     return res