|
@@ -0,0 +1,102 @@
|
|
|
+# -*- coding: utf-8 -*-
|
|
|
+
|
|
|
+from openerp import models, fields, api
|
|
|
+
|
|
|
+class AccountInvoice(models.Model):
|
|
|
+ _inherit = 'account.invoice'
|
|
|
+
|
|
|
+ @api.model
|
|
|
+ def getAccountInvoicePagare(self,domain):
|
|
|
+ AccountInvoice = self.env['account.invoice'].search(domain)
|
|
|
+ values = []
|
|
|
+ for invoice in AccountInvoice:
|
|
|
+ values.append({
|
|
|
+ # ID
|
|
|
+ 'id': invoice.id,
|
|
|
+ 'number': invoice.number,
|
|
|
+ 'origin': invoice.origin,
|
|
|
+ 'date_invoice': invoice.date_invoice,
|
|
|
+ 'user_name': invoice.user_id.name,
|
|
|
+ 'amount_untaxed': invoice.amount_untaxed,
|
|
|
+ 'amount_tax': invoice.amount_untaxed,
|
|
|
+ 'amount_total': invoice.amount_untaxed,
|
|
|
+ # PARTNER INFO
|
|
|
+ 'partner_id':[{
|
|
|
+ 'id': invoice.partner_id.id,
|
|
|
+ 'name': invoice.partner_id.name,
|
|
|
+ 'ruc': invoice.partner_id.ruc,
|
|
|
+ 'address': invoice.partner_id.street,
|
|
|
+ 'phone': invoice.partner_id.phone,
|
|
|
+ 'mobile': invoice.partner_id.mobile,
|
|
|
+ }],
|
|
|
+ # COMPANY INFO
|
|
|
+ 'company_id': [{
|
|
|
+ 'id':invoice.user_id.company_id.id,
|
|
|
+ 'name': invoice.user_id.company_id.name,
|
|
|
+ 'logo': invoice.user_id.company_id.logo,
|
|
|
+ 'phone': invoice.user_id.company_id.phone,
|
|
|
+ }],
|
|
|
+ # CURRENCY INFO
|
|
|
+ 'currency_id':[{
|
|
|
+ 'id': invoice.currency_id.id,
|
|
|
+ 'name': invoice.currency_id.name,
|
|
|
+ 'symbol': invoice.currency_id.symbol,
|
|
|
+ 'thousands_separator': invoice.currency_id.thousands_separator,
|
|
|
+ 'decimal_separator': invoice.currency_id.decimal_separator,
|
|
|
+ 'decimal_places': invoice.currency_id.decimal_places,
|
|
|
+ 'symbol_position': invoice.currency_id.symbol,
|
|
|
+ }],
|
|
|
+ })
|
|
|
+
|
|
|
+ return values
|
|
|
+
|
|
|
+ @api.model
|
|
|
+ def getAccountInvoicePagareQuota(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 = 1
|
|
|
+ x = len(AccountMoveLine)
|
|
|
+ values = []
|
|
|
+
|
|
|
+ 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 AccountInvoiceLine(models.Model):
|
|
|
+ _inherit = 'account.invoice.line'
|
|
|
+
|
|
|
+ @api.model
|
|
|
+ def getAccountInvoiceLinePagare(self,domain):
|
|
|
+ AccountInvoiceLine = self.env['account.invoice.line'].search(domain)
|
|
|
+ values = []
|
|
|
+ for line in AccountInvoiceLine:
|
|
|
+ values.append({
|
|
|
+ 'id': line.id,
|
|
|
+ 'name': line.name,
|
|
|
+ 'quantity': line.quantity,
|
|
|
+ 'price_unit': line.price_unit,
|
|
|
+ 'price_subtotal': line.price_subtotal,
|
|
|
+ })
|
|
|
+
|
|
|
+ return values
|