# -*- coding: utf-8 -*- from openerp import models, fields, api class AccountInvoice(models.Model): _inherit = 'account.invoice' @api.model def getAccountInvoiceQuoteAnalysis(self,domain): AccountInvoice = self.env['account.invoice'].search(domain) AccountMoveLine = self.env['account.move.line'].search([('move_id','=',AccountInvoice.number),('debit','>',0)],order='date_maturity') # i = len(AccountMoveLine) i = 1 x = len(AccountMoveLine) values = [] # futbolistasTup.sort(key=lambda futbolista: futbolista[0]) # AccountMoveLine.sort(key=lambda futbolista: date_maturity) # import web_pdb; web_pdb.set_trace() for line in AccountMoveLine: amount = 0 value = 0 state = 'No pagado' if(line.reconcile_ref != False): if(line.amount_residual == 0): state = 'Pagado' if(line.amount_residual > 0): value = line.debit - line.amount_residual state = 'Amortizado' values.append({ 'date': line.date_maturity, 'name': 'Cuota ' + str(i) + ' / ' + str(x), 'state': state, 'value': value, 'amount': line.debit, 'residual': line.amount_residual, }) i = i + 1 return values class ResCurrrency(models.Model): _inherit = 'res.currency' @api.model def getResCurrencyQuoteAnalysis(self,domain): AccountInvoice = self.env['account.invoice'].search(domain) ResCurrency = self.env['res.currency'].search([('id','=',AccountInvoice.currency_id.id)]) values = [] for currency in ResCurrency: values.append({ 'symbol': currency.symbol, 'decimal_separator': currency.decimal_separator, 'decimal_places': currency.decimal_places, 'thousands_separator': currency.thousands_separator, 'symbol_position': currency.symbol_position, }) return values