123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- # -*- 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 or "",
- 'user_name': invoice.user_id.name,
- 'amount_untaxed': invoice.amount_untaxed,
- 'amount_tax': invoice.amount_untaxed,
- 'amount_total': invoice.amount_total,
- 'date_due': invoice.date_due 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,
- '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 "",
- }],
- # 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
|