123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- # -*- 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_total,
- 'comment': invoice.comment or "",
- # PARTNER INFO
- 'partner_id':[{
- 'id': invoice.partner_id.id,
- 'name': invoice.partner_id.name or "",
- 'ruc': invoice.partner_id.ruc or "",
- 'address': invoice.partner_id.street or "",
- 'city': invoice.partner_id.city or "",
- 'barrio': invoice.partner_id.street2 or "",
- 'email': invoice.partner_id.email,
- 'estado_civil': invoice.partner_id.estado_civil or "",
- 'phone': invoice.partner_id.phone,
- 'mobile': invoice.partner_id.mobile,
- 'trab_empresa': invoice.partner_id.trab_empresa,
- 'trab_telefono': invoice.partner_id.trab_telefono,
- 'trab_street': invoice.partner_id.trab_street,
- 'trab_city': invoice.partner_id.trab_city,
- 'trab_cargo': invoice.partner_id.trab_cargo or "",
- 'trab_antiguedad_a': invoice.partner_id.trab_antiguedad_a or "",
- 'trab_antiguedad_m': invoice.partner_id.trab_antiguedad_m or "",
- 'casa_propia': invoice.partner_id.casa_propia or "",
- 'casa_alquiler': invoice.partner_id.casa_alquiler or "",
- 'trab_salario': invoice.partner_id.trab_salario or "",
- 'name_deudor': invoice.partner_id.name_deudor or "",
- 'cin_deudor': invoice.partner_id.cin_deudor or "",
- 'tel_deudor': invoice.partner_id.tel_deudor or "",
- 'dir_deudor': invoice.partner_id.dir_deudor or "",
- 'conyuge_id':[{
- 'cony_id': invoice.partner_id.conyuge_id.id or "",
- 'cony_name': invoice.partner_id.conyuge_id.name or "",
- 'cony_ruc': invoice.partner_id.conyuge_id.ruc or "",
- 'cony_phone': invoice.partner_id.conyuge_id.phone or "",
- 'cony_mobile': invoice.partner_id.conyuge_id.mobile or "",
- 'cony_city': invoice.partner_id.conyuge_id.city or "",
- 'cony_street': invoice.partner_id.conyuge_id.street or "",
- 'cony_trab_empresa': invoice.partner_id.conyuge_id.trab_empresa or "",
- 'cony_trab_telefono': invoice.partner_id.conyuge_id.trab_telefono or "",
- }],
- 'ref_personal_ids': [{
- 'id': refPartner.id or "",
- 'name': refPartner.name or "",
- 'phone': refPartner.phone or "",
- 'email': refPartner.email or "",
- } for refPartner in invoice.partner_id.ref_personal_ids],
- 'ref_comercial_ids': [{
- 'id': comPartner.id or "",
- 'name': comPartner.name or "",
- 'phone': comPartner.phone or "",
- } for comPartner in invoice.partner_id.ref_comercial_ids],
- }],
- # 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),('date_maturity','!=', False)],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,
- 'tot_cuota': str(x),
- })
- 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
|