Переглянути джерело

Módulo para imprimir pagaré para tropishop

SEBAS 4 місяців тому
коміт
2944e31ec7

+ 2 - 0
__init__.py

@@ -0,0 +1,2 @@
+# -*- coding: utf-8 -*-
+import models


+ 22 - 0
__openerp__.py

@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+{
+    'name' : 'Impresion de pagare Tropishop',
+    'version' : '1.0',
+    'description' : """
+Este modulo Permite realizar impresión del pagare del Tropishop
+    """,
+    'author' : 'Eiru',
+    'category' : 'Service',
+    'depends' : [
+        'account',
+        'eiru_num2word',
+        'partner_extra_data_crifin',
+    ],
+    'data' : [
+        'views/template.xml',
+        'views/account_invoice_view.xml'
+    ],
+    'qweb' : ['static/src/xml/*.xml',],
+    'installable' : True,
+    'auto_install' : False,
+}

+ 147 - 0
models.py

@@ -0,0 +1,147 @@
+# -*- 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


BIN
static/description/icon.png


+ 4 - 0
static/src/css/style.css

@@ -0,0 +1,4 @@
+.pagare_button_box {
+    width: auto;
+    float: left;
+}

Різницю між файлами не показано, бо вона завелика
+ 608 - 0
static/src/js/main (copia).js


+ 767 - 0
static/src/js/main.js

@@ -0,0 +1,767 @@
+openerp.pagare_tropishop = function (instance, local) {
+    local.widgetInstance = null;
+    local.parentInstance = null;
+
+    local.PagareTropishopWidget = instance.Widget.extend({
+        template : "pagare_tropishop.PagareTropishop",
+        jsonDoc:[],
+
+        init:function(parent){
+            this._super(parent);
+        },
+
+        updateId : function(id){
+            var self = this;
+            self.id=id;
+        },
+
+        start: function () {
+            var self = this;
+            this.$el.click(function (e) {
+                self.fecthInitial();
+            });
+        },
+
+        valorNull:function(dato){
+            var valor ="";
+            if (dato){
+                if(dato == true && typeof dato == 'boolean'){
+                    valor=" ";
+                }else{
+                    valor=dato;
+                }
+            }
+            return valor;
+        },
+
+        fecthInitial: function(){
+            var id= openerp.webclient._current_state.id;
+            var self = this;
+            self.fetchAccountInvoice(id).then(function(AccountInvoice){
+                return AccountInvoice;
+            }).then(function(AccountInvoice){
+                self.AccountInvoice = AccountInvoice;
+                return self.fetchAccountInvoiceQuota(id);
+            }).then(function(AccountInvoiceQuota){
+                self.AccountInvoiceQuota = AccountInvoiceQuota;
+                return self.fetchAccountInvoiceLine();
+            }).then(function(AccountInvoiceLine){
+                self.AccountInvoiceLine = AccountInvoiceLine;
+                return self.drawPDF();
+            });
+            return false;
+        },
+
+        fetchAccountInvoice: function(id){
+            var domain=[['id','=', id]];
+            var AccountInvoice = new instance.web.Model('account.invoice');
+            return AccountInvoice.call('getAccountInvoicePagare',[domain], {
+                context: new instance.web.CompoundContext()
+            });
+        },
+
+        fetchAccountInvoiceQuota: function(id){
+            var domain=[['id','=', id]];
+            var AccountInvoice = new instance.web.Model('account.invoice');
+            return AccountInvoice.call('getAccountInvoicePagareQuota',[domain], {
+                context: new instance.web.CompoundContext()
+            });
+        },
+
+        fetchAccountInvoiceLine: function () {
+            var self = this;
+            var invoice_ids = _.flatten(_.map(self.AccountInvoice,function(map){
+                return map.id;
+            }));
+            var domain=[['invoice_id','in',invoice_ids]];
+            var AccountInvoiceLine = new instance.web.Model('account.invoice.line');
+            return AccountInvoiceLine.call('getAccountInvoiceLinePagare',[domain], {
+                context: new instance.web.CompoundContext()
+            });
+        },
+
+        drawPDF:function(){
+            var self = this;
+            var AccountInvoice = self.AccountInvoice;
+            var CurrencyBase = self.AccountInvoice[0].currency_id[0];
+            var docItem = [];
+            var docQuotaItem = [];
+            var getColumns = [];
+            var getColumnsQuota = [];
+
+            var pdfDoc = new jsPDF("p","mm","a4");
+
+            // pdfDoc.page=1;
+
+            // pdfDoc.addImage("data:image/png;base64," + AccountInvoice[0].company_id[0].logo, 'png', 10, 10, 50, 30);
+            //
+            // _.each(self.AccountInvoiceLine, function(item){
+            //     docItem.push({
+            //         name : item.name,
+            //         quantity : item.quantity,
+            //         price_unit : accounting.formatMoney(item.price_unit,'',CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+            //         price_subtotal : accounting.formatMoney(item.price_subtotal,'',CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+            //     });
+            // });
+            // getColumns.push({
+            //     title : 'Descripción',
+            //     halign: 'center',
+            //     dataKey: 'name'
+            // });
+            // getColumns.push({
+            //     title : 'Cantidad',
+            //     halign: 'center',
+            //     dataKey: 'quantity'
+            // });
+            // getColumns.push({
+            //     title : 'P. Unitario',
+            //     halign: 'center',
+            //     dataKey: 'price_unit'
+            // });
+            // getColumns.push({
+            //     title : 'Subtotal',
+            //     halign: 'center',
+            //     dataKey: 'price_subtotal'
+            // });
+            //
+            // pdfDoc.autoTable(getColumns, docItem, {
+            //     theme: 'grid',
+            //     styles: {
+            //         overflow: 'linebreak',
+            //         columnWidth: 'auto',
+            //         fontSize: 7
+            //     },
+            //     headerStyles: {
+            //         textColor: 20,
+            //         fillColor: null,
+            //         lineWidth: 0.1,
+            //         fontSize: 9
+            //     },
+            //     columnStyles: {
+            //         name : {columnWidth: 'auto'},
+            //         quantity : {columnWidth: 25, halign:'right'},
+            //         price_unit : {columnWidth: 25, halign:'right'},
+            //         price_subtotal : {columnWidth: 25, halign:'right'},
+            //     },
+            //
+            //     margin: { top: 200, horizontal: 10},
+            //
+            //     addPageContent: function (data) {
+
+                //
+                //     pdfDoc.addImage("data:image/png;base64," + AccountInvoice[0].company_id[0].logo, 'png', 10, 10, 50, 30);
+                //
+                //     pdfDoc.setFontSize(11);
+                //     pdfDoc.setFontStyle('bold');
+                //     pdfDoc.setTextColor(20);
+                //     pdfDoc.text(80, 25,'SOLICITUD DE LINEA DE CREDITO');
+                //
+                //     pdfDoc.text(80, 30,'Empresa: El señor de los tropishop');
+                //     pdfDoc.setFontSize(10);
+                //     pdfDoc.setFontStyle('normal');
+                //     pdfDoc.setTextColor(40);
+                //     pdfDoc.rect(10, 45, 95, 7, 'S');
+                //     pdfDoc.text(12,50,'SUCURSAL: ' );
+                //     pdfDoc.rect(105, 45, 95, 7, 'S');
+                //     pdfDoc.text(110,50,'Fecha de Operación: ' + moment(AccountInvoice[0].date_invoice).format('DD/MM/YYYY'));
+                //     pdfDoc.rect(10, 55, 95, 7, 'S');
+                //     pdfDoc.setFontSize(10);
+                //     pdfDoc.setFontStyle('normal');
+                //     pdfDoc.text(12,60,'Vendedor: ' + AccountInvoice[0].user_name);
+                //     pdfDoc.setFontSize(10);
+                //     pdfDoc.setFontStyle('bold');
+                //     pdfDoc.setTextColor(40);
+                //     pdfDoc.rect(105, 55, 95, 7, 'S');
+                //     pdfDoc.setFontSize(10);
+                //     pdfDoc.setFontStyle('normal');
+                //     pdfDoc.text(110,60,'Número de Operación: ' + AccountInvoice[0].origin + ' ' +AccountInvoice[0].number);
+                //     pdfDoc.setFontSize(10);
+                //     pdfDoc.setFontStyle('bold');
+                //     pdfDoc.setTextColor(40);
+                //     pdfDoc.text(10, 70,'Datos del Cliente o Empresa');
+                //
+                //     // Cuadro principal
+                //     pdfDoc.rect(10, 76, 105 , 7, 'S');
+                //     // Cuadro fecha de emision
+                //     pdfDoc.rect(10, 76, 105, 7, 'S');
+                //     pdfDoc.setFontSize(8);
+                //     pdfDoc.setFontStyle('normal');
+                //     pdfDoc.setTextColor(20);
+                //     pdfDoc.text(12, 80,'Fecha de emisión: ');
+                //     pdfDoc.text(45, 80,  moment(AccountInvoice[0].date_invoice).format('DD/MM/YYYY'));
+                //     // RUC / Documento de identidad No.
+                //     pdfDoc.rect(115, 76, 90, 7, 'S');
+                //     pdfDoc.text(120, 80,'RUC / Doc. de Identidad No.: ' + AccountInvoice[0].partner_id[0].ruc);
+                //     // Nombre o Razon Social
+                //     pdfDoc.rect(10, 83, 105, 7, 'S');
+                //     pdfDoc.text(12, 88,'Nombre o Razón Social: ' + AccountInvoice[0].partner_id[0].name);
+                //     // Telefono
+                //     pdfDoc.rect(115, 83, 90, 7, 'S');
+                //     pdfDoc.text(120, 88,'Teléfono: ' + self.valorNull(AccountInvoice[0].partner_id[0].phone));
+                //
+                //     // Direccion
+                //     pdfDoc.rect(10, 90, 105, 7, 'S');
+                //     pdfDoc.text(12, 94,'Direccion: ' + self.valorNull(AccountInvoice[0].partner_id[0].address));
+                //
+                //     // celular
+                //     pdfDoc.rect(115, 90, 90, 7, 'S');
+                //     pdfDoc.text(120, 94,'Celular: ' + self.valorNull(AccountInvoice[0].partner_id[0].mobile));
+                //
+                //     // Direccion
+                //     pdfDoc.rect(10, 97, 105, 7, 'S');
+                //     pdfDoc.text(12, 101,'Barrio: ' + self.valorNull(AccountInvoice[0].partner_id[0].barrio));
+                //
+                //     // celular
+                //     pdfDoc.rect(115, 97, 90, 7, 'S');
+                //     pdfDoc.text(120, 101,'Ciudad: ' + self.valorNull(AccountInvoice[0].partner_id[0].city));
+                //
+                //     // Direccion
+                //     pdfDoc.rect(10, 104, 105, 7, 'S');
+                //     pdfDoc.text(12, 108,'Estado Civil: ' + self.valorNull(AccountInvoice[0].partner_id[0].estado_civil));
+                //
+                //     // celular
+                //     pdfDoc.rect(115, 104, 90, 7, 'S');
+                //     pdfDoc.text(120, 108,'Email: ' + self.valorNull(AccountInvoice[0].partner_id[0].email));
+                //
+                //     var tipo;
+                //     if(AccountInvoice[0].partner_id[0].casa_propia == true){
+                //            tipo = "Vivienda Propia";
+                //        }else{
+                //            tipo = "Vivienda Alquilada";
+                //     }
+                //     // TIPO DE VIVIENDA
+                //     pdfDoc.rect(10, 111, 105, 7, 'S');
+                //     pdfDoc.text(12, 115,'Tipo de Vivienda: ' + self.valorNull(tipo));
+                //
+                //     // celular
+                //     pdfDoc.rect(115, 111, 90, 7, 'S');
+                //     // pdfDoc.text(120, 100,'Vivienda Alquilada: ' + self.valorNull(AccountInvoice[0].partner_id[0].casa_alquiler));
+                //
+                //     // Direccion
+                //     pdfDoc.rect(10, 118, 105, 7, 'S');
+                //     pdfDoc.text(12, 122,'Empresa o Lugar de Trabajo: ' + self.valorNull(AccountInvoice[0].partner_id[0].trab_empresa));
+                //
+                //     // celular
+                //     pdfDoc.rect(115, 118, 90, 7, 'S');
+                //     pdfDoc.text(120, 122,'Teléfono: ' + self.valorNull(AccountInvoice[0].partner_id[0].trab_telefono));
+                //
+                //     // Direccion
+                //     pdfDoc.rect(10, 125, 105, 7, 'S');
+                //     pdfDoc.text(12, 129,'Dirección: ' + self.valorNull(AccountInvoice[0].partner_id[0].trab_street));
+                //
+                //     // celular
+                //     pdfDoc.rect(115, 125, 90, 7, 'S');
+                //     pdfDoc.text(120, 129,'Ciudad: ' + self.valorNull(AccountInvoice[0].partner_id[0].trab_city));
+                //
+                //     // Direccion
+                //     pdfDoc.rect(10, 132, 105, 7, 'S');
+                //     pdfDoc.text(12, 136,'Cargo: ' + self.valorNull(AccountInvoice[0].partner_id[0].trab_cargo));
+                //
+                //     // celular
+                //     pdfDoc.rect(115, 132, 90, 7, 'S');
+                //     pdfDoc.text(120, 136,'Antiguedad: ' + self.valorNull(AccountInvoice[0].partner_id[0].trab_antiguedad_a) + ',' + self.valorNull(AccountInvoice[0].partner_id[0].trab_antiguedad_m));
+                //
+                //     // salario
+                //     pdfDoc.rect(10, 139, 105, 7, 'S');
+                //     pdfDoc.text(12, 143,'Salario: ' + self.valorNull(AccountInvoice[0].partner_id[0].trab_salario));
+                //
+                //     // ref
+                //     // pdfDoc.rect(105, 133, 95, 7, 'S');
+                //     // pdfDoc.text(125, 137,'Vivienda Alquilada: ' + self.valorNull(AccountInvoice[0].partner_id[0].casa_alquiler));
+                //
+                //     pdfDoc.setFontSize(8);
+                //     pdfDoc.setFontStyle('normal');
+                //     pdfDoc.text(12,150,'Referencias Comerciales:');
+                //
+                //     i=0;
+                //     _.each(AccountInvoice[0].partner_id[0].ref_comercial_ids,function(item){
+                //         pdfDoc.setFontSize(8);
+                //         pdfDoc.setFontStyle('normal');
+                //         pdfDoc.text(12+i,155, '' + item.name);
+                //         pdfDoc.text(55+i,155, '' + item.phone);
+                //         i=95;
+                //     });
+                //
+                //     pdfDoc.setFontSize(8);
+                //     pdfDoc.setFontStyle('normal');
+                //     pdfDoc.text(12,178,'Referencias Personales:');
+                //
+                //     i=0;
+                //     _.each(AccountInvoice[0].partner_id[0].ref_personal_ids,function(item){
+                //         pdfDoc.setFontSize(8);
+                //         pdfDoc.setFontStyle('normal');
+                //         pdfDoc.text(12+i,182, '- ' + item.email);
+                //         pdfDoc.text(30+i,182, '' + item.name);
+                //         pdfDoc.text(65+i,182, '' + item.phone);
+                //         i=95;
+                //
+                //     });
+                //
+                // pdfDoc.setFontSize(10);
+                // pdfDoc.setFontStyle('bold');
+                // pdfDoc.setTextColor(40);
+                // pdfDoc.text(85,195,'ESPECIFICACIÓN DE VENTAS ');
+
+
+                // function footer(){
+                //     pdfDoc.text(150,285, 'page ' + doc.page);
+                //     pdfDoc.page ++;
+                // };
+
+            //     }
+            // });
+
+
+            // _.each(self.AccountInvoiceQuota, function(item){
+            //     docQuotaItem.push({
+            //         date : moment(item.date).format('DD/MM/YYYY'),
+            //         name : item.name,
+            //         amount : accounting.formatMoney(item.amount,'',CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+            //     });
+            // });
+           //  getColumnsQuota.push({
+           //      title : 'Fecha',
+           //      halign: 'center',
+           //      dataKey: 'date'
+           //  });
+           //  getColumnsQuota.push({
+           //      title : 'Descripción',
+           //      halign: 'center',
+           //      dataKey: 'name'
+           //  });
+           //  getColumnsQuota.push({
+           //      title : 'Valor de la Cuota',
+           //      halign: 'center',
+           //      dataKey: 'amount'
+           //  });
+           //
+           //
+           // var finalY = pdfDoc.autoTable.previous.finalY;
+           //
+           //  pdfDoc.setFontSize(10);
+           //  pdfDoc.setFontStyle('bold');
+           //  pdfDoc.setTextColor(40);
+           //  pdfDoc.text(10,finalY + 5,'Total: ' + accounting.formatMoney(AccountInvoice[0].amount_total,CurrencyBase.symbol,CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator));
+           //
+           //  pdfDoc.setFontSize(10);
+           //  pdfDoc.setFontStyle('bold');
+           //  pdfDoc.text(10,finalY + 10,'Firma del cliente: _ _ _ _ _ _ _ _ _ _       Aclaración: _ _ _ _ _ _ _ _ _ _               C.I.N°: _ _ _ _ _ _ _');
+
+
+
+            // pdfDoc.addPage();
+            var finalY2 = 12;
+
+
+
+            var total_in_letters1 = instance.web.num2word(AccountInvoice[0].amount_total);
+
+            finalY2 +=5
+            pdfDoc.setFontSize(12);
+            pdfDoc.setFontStyle('bold');
+            pdfDoc.setTextColor(20);
+            pdfDoc.text(75, finalY2,'CONTRATO PRESTAMO Y COMPRA / VENTA');
+
+            finalY2 +=9
+
+            pdfDoc.setFontSize(11);
+            pdfDoc.setFontStyle('normal');
+
+            var aux1 = "En Ciudad del Este de la República del Paraguay, en fecha ";
+            var aux2 = " entre el señor ";
+
+            pdfDoc.setFontSize(11);
+            // pdfDoc.setFontStyle('bold');
+            var aux20 = "ANIBAL ZARACHO LÓPEZ,";
+            var aux22 = "CÉDULA DE IDENTIDAD PARAGUAYA C.I.N° 1.139.280 ";
+            var aux24 = "EL SEÑOR DE LOS ANILLOS, ";
+            var aux26 = AccountInvoice[0].partner_id[0].name;
+            var aux27 = "CÉDULA DE IDENTIDAD C.I.N° ";
+            var aux28 = AccountInvoice[0].partner_id[0].ruc;
+            var aux30 = "PRESTAMO DE DINERO EN EFECTIVO PARA LA COMPRA DE JOYAS, ";
+
+            pdfDoc.setFontSize(11);
+          //  pdfDoc.setFontStyle('normal');
+            var aux21 = "de nacionalidad paraguaya, estado civil Soltero con ";
+            var aux23 = "en representación de la firma ";
+            var aux25 = "con domicilio en la Calle Arcadio Garay Vera esq. Estrella del Bº San Isidro de Ciudad del Este, por una parte y la otra parte, del señor/a ";
+            var aux3 = ", más adelante llamado COMPRADOR, con ";
+            var aux4 = ", domiciliado en  ";
+            var aux5 = ", ";
+            var aux29 = " convienen a celebrar el presente contrato privado de ";
+            var aux31 = "lo que se regirá por las siguientes claúsulas y condiciones.";
+
+          //  pdfDoc.setFontStyle('bold');
+            pdfDoc.text(aux1 + moment(AccountInvoice[0].date_invoice).format('DD/MM/YYYY') + aux2 +  aux20 + aux21 + aux22 +aux23 +aux24 +aux25 +aux26 + aux3 + aux28 + aux4 + AccountInvoice[0].partner_id[0].address + aux5 + AccountInvoice[0].partner_id[0].city  + aux29 + aux30 + aux31 ,10,finalY2,{maxWidth:188,align:'justify'});
+
+            finalY2 +=37
+            pdfDoc.setFontSize(11);
+            pdfDoc.setFontStyle('normal');
+
+            var aux7 = "PRIMERA: El señor ANIBAL ZARACHO LÓPEZ mediante este instrumento otorga un préstamo de : ";
+            var aux8 = ", ( ";
+            var aux9 = ") en efectivo al COMPRADOR, constituyéndose en deudor de la firma EL SEÑOR DE LOS ANILLOS Recibiendo por este acto la suma señalada.";
+
+            pdfDoc.text(aux7 + accounting.formatMoney(AccountInvoice[0].amount_total,CurrencyBase.symbol,CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator) + aux8 + total_in_letters1 + aux9 ,10,finalY2,{maxWidth:188,align:'justify'});
+
+
+            finalY2 +=19
+            pdfDoc.setFontSize(11);
+            pdfDoc.setFontStyle('normal');
+            pdfDoc.text('SEGUNDA: El monto  recibido por el COMPRADOR se le otorga en  calidad de  préstamo al efectivo exclusivo para la compra de las siguientes joyas citadas en el cuadro de abajo.',10,finalY2,{maxWidth:188,align:'justify'});
+
+            // finalY2 +=5
+            // pdfDoc.setFontSize(10);
+            // pdfDoc.setFontStyle('normal');
+            // pdfDoc.text(10,finalY2, 'compra de las siguientes joyas citadas en el cuadro de abajo.');
+
+
+            var docLineItem = [];
+            var getColumnsLine = [];
+
+            _.each(self.AccountInvoiceLine, function(item){
+                docLineItem.push({
+                    name : item.name,
+                    quantity : item.quantity,
+                    price_unit : accounting.formatMoney(item.price_unit,'',CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                    price_subtotal : accounting.formatMoney(item.price_unit*item.quantity,'',CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                });
+            });
+            getColumnsLine.push({
+                title : 'Descripción',
+                halign: 'center',
+                dataKey: 'name'
+            });
+            getColumnsLine.push({
+                title : 'Cantidad',
+                halign: 'center',
+                dataKey: 'quantity'
+            });
+            getColumnsLine.push({
+                title : 'P. Unitario',
+                halign: 'center',
+                dataKey: 'price_unit'
+            });
+            getColumnsLine.push({
+                title : 'Subtotal',
+                halign: 'center',
+                dataKey: 'price_subtotal'
+            });
+
+            finalY2 +=5
+
+            pdfDoc.autoTable(getColumnsLine, docLineItem, {
+                theme: 'grid',
+                startY: finalY2 + 4,
+                styles: {
+                    overflow: 'linebreak',
+                    columnWidth: 'auto',
+                    fontSize: 8,
+
+                },
+                headerStyles: {
+                    textColor: 20,
+                    fillColor: null,
+                    lineWidth: 0.1,
+                    fontSize: 9
+                },
+                columnStyles: {
+                    name : {columnWidth: 'auto'},
+                    quantity : {columnWidth: 25, halign:'right'},
+                    price_unit : {columnWidth: 25, halign:'right'},
+                    price_subtotal : {columnWidth: 25, halign:'right'},
+                },
+                margin: {horizontal: 10},
+
+                addPageContent: function (data) {
+                    // pdfDoc.setFontSize(10);
+                    // pdfDoc.setFontStyle('bold');
+                    // pdfDoc.setTextColor(40);
+                    // pdfDoc.text(85,finalY + 15,'Información de Cuotas ');
+                    //
+                    // pdfDoc.setFontSize(10);
+                    // pdfDoc.setFontStyle('bold');
+                    // pdfDoc.setTextColor(40);
+                    // pdfDoc.text(10,finalY + 5,'Total: ' + accounting.formatMoney(AccountInvoice[0].amount_total,CurrencyBase.symbol,CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator));
+                }
+            });
+
+            var finalY2 = pdfDoc.autoTable.previous.finalY;
+            finalY2 +=9
+            pdfDoc.setFontSize(12);
+            pdfDoc.setFontStyle('normal');
+            pdfDoc.text('TERCERA: El DEUDOR suscribe en este acto UN pagaré por el monto total de las cuotas otorgados según los siguientes vencimientos.',10,finalY2,{maxWidth:188,align:'justify'});
+
+
+            finalY2 +=9
+
+            pdfDoc.setFontSize(12);
+            pdfDoc.setFontStyle('bold');
+            pdfDoc.setTextColor(40);
+            pdfDoc.text(85,finalY2 ,'Información de Cuotas ');
+
+            var docQuotaItem = [];
+            var getColumnsQuota = [];
+
+             _.each(self.AccountInvoiceQuota, function(item){
+                 docQuotaItem.push({
+                     date : moment(item.date).format('DD/MM/YYYY'),
+                     name : item.name,
+                     amount : accounting.formatMoney(item.amount,'',CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator),
+                 });
+             });
+
+              getColumnsQuota.push({
+                  title : 'Fecha',
+                  halign: 'center',
+                  dataKey: 'date'
+              });
+              getColumnsQuota.push({
+                  title : 'Descripción',
+                  halign: 'center',
+                  dataKey: 'name'
+              });
+              getColumnsQuota.push({
+                  title : 'Valor de la Cuota',
+                  halign: 'center',
+                  dataKey: 'amount'
+              });
+
+
+            pdfDoc.autoTable(getColumnsQuota, docQuotaItem, {
+                theme: 'grid',
+                startY: finalY2 + 5,
+                styles: {
+                    overflow: 'linebreak',
+                    columnWidth: 'auto',
+                    fontSize: 8,
+
+                },
+                headerStyles: {
+                    textColor: 20,
+                    fillColor: null,
+                    lineWidth: 0.1,
+                    fontSize: 9
+                },
+                columnStyles: {
+                    date : {columnWidth: 'auto', halign: 'center'},
+                    name : {columnWidth: 'auto', halign: 'center'},
+                    amount : {columnWidth: 'auto', halign: 'right'}
+                },
+                margin: {horizontal: 10},
+                addPageContent: function (data) {
+                    // pdfDoc.setFontSize(10);
+                    // pdfDoc.setFontStyle('bold');
+                    // pdfDoc.setTextColor(40);
+                    // pdfDoc.text(85,finalY + 15,'Información de Cuotas ');
+                    //
+                    // pdfDoc.setFontSize(10);
+                    // pdfDoc.setFontStyle('bold');
+                    // pdfDoc.setTextColor(40);
+                    // pdfDoc.text(10,finalY + 5,'Total: ' + accounting.formatMoney(AccountInvoice[0].amount_total,CurrencyBase.symbol,CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator));
+
+                }
+
+            });
+
+            var finalY2 = pdfDoc.autoTable.previous.finalY;
+            finalY2 += 9
+            pdfDoc.setFontSize(11);
+            pdfDoc.setFontStyle('normal');
+            var paragraph= "CUARTA: El pago de las cuotas correspondientes se realizará por los siguientes medios de pagos, dentro de los 05 días de la fecha de vencimiento.";
+            pdfDoc.text(paragraph,10,finalY2,{maxWidth:188,align:'justify'});
+
+            finalY2 +=11
+            pdfDoc.setFontSize(11);
+            pdfDoc.setFontStyle('normal');
+            var paragraph= "- Giros Tigo - Número: (0982) 264 085";
+            pdfDoc.text(paragraph,10,finalY2,{maxWidth:188,align:'justify'});
+
+            finalY2 +=6
+            pdfDoc.setFontSize(11);
+            pdfDoc.setFontStyle('normal');
+            var paragraph= "- Transferencia o Depósito bancario  - Ueno Banco, caja de ahorro";
+            pdfDoc.text(paragraph,10,finalY2,{maxWidth:188,align:'justify'});
+
+
+            finalY2 +=6
+            pdfDoc.setFontSize(11);
+            pdfDoc.setFontStyle('normal');
+            var paragraph= "N° de Cuenta: 619638080    Titular: Vilma Beatriz Godoy Castro C.I.N°: 5.962.006";
+            pdfDoc.text(paragraph,10,finalY2,{maxWidth:188,align:'justify'});
+
+            finalY2 +=6
+            pdfDoc.setFontSize(11);
+            pdfDoc.setFontStyle('normal');
+            var paragraph= "Tu Financiera - N° de Cuenta: 20271630   Titular: VILMA GODOY   C.I.N°: 5.962.006";
+            pdfDoc.text(paragraph,10,finalY2,{maxWidth:188,align:'justify'});
+
+            finalY2 +=9
+            pdfDoc.setFontSize(11);
+            pdfDoc.setFontStyle('normal');
+            var paragraph= "QUINTA: La falta de pago de una de las cuotas mensuales de este pagaré en la fecha señalada precedentemente devengará un interés moratorio de 3% mensual, además de pago de 5% de interés por gastos de cobranzas, por caso de mora.";
+            pdfDoc.text(paragraph,10,finalY2,{maxWidth:188,align:'justify'});
+
+            finalY2 +=16
+            pdfDoc.setFontSize(11);
+            pdfDoc.setFontStyle('normal');
+            var paragraph= "SEXTA: El COMPRADOR recibe el producto en perfectas condiciones para su uso con los accesorios correspondientes, manifestando su entera satisfacción y conformidad.";
+            pdfDoc.text(paragraph,10,finalY2,{maxWidth:188,align:'justify'});
+
+
+
+            pdfDoc.addPage();
+
+
+            finalY2 =22
+            pdfDoc.setFontSize(11);
+            pdfDoc.setFontStyle('normal');
+            var paragraph= "SÉPTIMA: Las partes acuerdan que en caso de controversia se someten a los juzgados de Ciudad del Este. En prueba de conformidad firmar las partes y suscriben el presente contrato.";
+            pdfDoc.text(paragraph,10,finalY2,{maxWidth:188,align:'justify'});
+
+            finalY2 +=12
+            pdfDoc.setFontSize(11);
+            pdfDoc.setFontStyle('normal');
+            var paragraph= "OCTAVA: El DEUDOR autoriza también a ceder la información para uso publicitario, encuestas, trabajos de prospección de mercadeo, servicios de cobranza, courier, con disolución o sin ella. En atención a lo dispuesto en la legislación y normativa establecidas en materia de Información de Carácter Privado, por el presente instrumento el deudor autoriza en forma irrevocable e incondicional, para que en caso de mora o ejecución judicial, derivadas del incumplimiento de las obligaciones que mantenemos con dicha empresa, incluya nuestros nombres o razón social en el registro de morosos de Informconf u otras entidades similares.";
+            pdfDoc.text(paragraph,10,finalY2,{maxWidth:188,align:'justify'});
+
+            finalY2 +=35
+            pdfDoc.setFontSize(11);
+            pdfDoc.setFontStyle('bold');
+            pdfDoc.text(10,finalY2,'Firma del deudor: _ _ _ _ _ _ _ _ _ _ _ _      Firma del codeudor: _ _ _ _ _ _ _ _ _ _ _ _ ');
+
+            finalY2 +=13
+            pdfDoc.setFontSize(11);
+            pdfDoc.setFontStyle('bold');
+            pdfDoc.text(40,finalY2,'Firma del representante: _ _ _ _ _ _ _ _ _ _ _ _ _ _');
+
+            var finalY2 = pdfDoc.autoTable.previous.finalY;
+
+            //
+            // finalY2 +=5
+            // pdfDoc.setFontSize(10);
+            // pdfDoc.setFontStyle('bold');
+            // pdfDoc.setTextColor(40);
+            // pdfDoc.text(10,finalY2,'Total: ' + accounting.formatMoney(AccountInvoice[0].amount_total,CurrencyBase.symbol,CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator));
+            //
+            // finalY2 +=5
+            // pdfDoc.setFontSize(10);
+            // pdfDoc.setFontStyle('bold');
+            // pdfDoc.text(10,finalY2,'Firma del cliente: _ _ _ _ _ _ _ _ _ _       Aclaración: _ _ _ _ _ _ _ _ _ _               C.I.N°: _ _ _ _ _ _ _');
+
+
+
+            // finalY2 +=20
+            // console.log(finalY2);
+            // if (finaly2 > 220) {
+
+               // pdfDoc.setFontSize(9);
+               // pdfDoc.setFontStyle('bold');
+               // var paragraph="Declaramos que los datos consignados en esta solicitud de MyS DECORART; son fiel reflejo de nuestra situación.";
+               // pdfDoc.text(paragraph,12, 20,{maxWidth:188,align:'justify'});
+               //
+               // pdfDoc.setFontSize(9);
+               // pdfDoc.setFontStyle('normal');
+               // pdfDoc.setTextColor(40);
+               // pdfDoc.text(12, 25,'Firma del Solicitante: _ _ _ _ _ _ _ _ _ _ _ _ _');
+               //
+               // pdfDoc.setFontSize(9);
+               // pdfDoc.setFontStyle('normal');
+               // pdfDoc.setTextColor(40);
+               // pdfDoc.text(12, 30,'Aclaración de Firma y N° de C.I.N°: _ _ _ _ _ _ _ _ _ _ _ _');
+               //
+               // pdfDoc.setFontSize(9);
+               // pdfDoc.setFontStyle('normal');
+               // pdfDoc.setTextColor(40);
+               // pdfDoc.text(12, 35,'Sello de la Empresa:');
+            //
+            // }
+
+
+            pdfDoc.addPage();
+
+            pdfDoc.addImage("data:image/png;base64," + AccountInvoice[0].company_id[0].logo, 'png', 10, 10, 50, 30);
+            pdfDoc.setFontSize(16);
+            pdfDoc.setFontStyle('bold');
+            pdfDoc.setTextColor(40);
+            pdfDoc.text(80,25,'PAGARE A LA ORDEN');
+
+            pdfDoc.setFontSize(10);
+            pdfDoc.setFontStyle('normal');
+            pdfDoc.setTextColor(40);
+            pdfDoc.rect(10, 45, 95, 7, 'S');
+            pdfDoc.text(12,50,'Número de Operación: ' + AccountInvoice[0].origin);
+            pdfDoc.rect(105, 45, 95, 7, 'S');
+            pdfDoc.text(110,50,'Fecha de Operación: ' + moment(AccountInvoice[0].date_invoice).format('DD/MM/YYYY'));
+            pdfDoc.rect(10, 55, 95, 7, 'S');
+            pdfDoc.setFontSize(10);
+            pdfDoc.setFontStyle('normal');
+            pdfDoc.text(12,60,'Monto a pagar: ' + accounting.formatMoney(AccountInvoice[0].amount_total,CurrencyBase.symbol,CurrencyBase.decimal_places, CurrencyBase.thousands_separator, CurrencyBase.decimal_separator));
+            pdfDoc.rect(105, 55, 95, 7, 'S');
+            pdfDoc.setFontSize(10);
+            pdfDoc.setFontStyle('normal');
+            _.each(self.AccountInvoiceQuota, function(item){
+                varfecha=item.date;
+            });
+            pdfDoc.text(110,60,'Vencimiento: ' + moment(varfecha).format('DD/MM/YYYY'));
+            var total_in_letters = instance.web.num2word(AccountInvoice[0].amount_total);
+            pdfDoc.rect(10, 65, pdfDoc.internal.pageSize.getWidth() - 15 , 16,'S');
+            pdfDoc.setFontSize(11);
+            pdfDoc.setFontStyle('normal');
+            pdfDoc.text(12,70,'Pagaré a la orden de la empresa de Tropishop');
+            pdfDoc.setFontSize(10.5);
+            pdfDoc.setFontStyle('normal');
+            pdfDoc.text(12,75,'La suma de Guaraníes: ' );
+            pdfDoc.setFontSize(10.5);
+            pdfDoc.setFontStyle('bold');
+            pdfDoc.text(12,79, total_in_letters);
+            pdfDoc.rect(10, 81, pdfDoc.internal.pageSize.getWidth() - 15 , 60,'S');
+            pdfDoc.setFontSize(11);
+            pdfDoc.setFontStyle('normal');
+            var paragraph="Por igual valor recibido en _______________________ a mi (nuestra) entera satisfacción. Queda expresamente convenido que la falta de pago de este pagaré me (nos) constituirá en mora automáticamente, sin necesidad de interpelación judicial o extrajudicial alguna, devengando durante el tiempo de la mora un interés moratorio del 3 % mensual por el simple retardo sin que esto implique prórroga del plazo de la obligación. Asimismo me (nos) obligamos a pagar cualquier gasto en que incurra el acreedor con relación a este préstamo, en caso de que el mismo sea reclamado por la vía judicial o extrajudicial. El simple vencimiento establecerá mora, autorizando la inclusión de nombre personal o Razón Social que represento, a la base de datos de Informconf y/o Equifax Paraguay S.A., conforme a lo establecido en la Ley 1682/2001 y su modificatoria 1969/2002, como también para que se pueda proveer la información a terceros interesados. A los efectos legales y procesales nos sometemos a la jurisdicción de los Tribunales de Ciudad del Este y renunciando a cualquier otra que pudiera corresponder las partes constituyen domicilio real y especial en los lugares señalados en el presente documento.";
+            pdfDoc.text(paragraph,12,87,{maxWidth:188,align:'justify'});
+
+            pdfDoc.setFontSize(10);
+            pdfDoc.setFontStyle('bold');
+            pdfDoc.setTextColor(40);
+            pdfDoc.text(10,165,'DEUDOR');
+            pdfDoc.text(120,165,'CO-DEUDOR');
+
+            pdfDoc.setFontSize(9);
+            pdfDoc.setFontStyle('normal');
+            pdfDoc.setTextColor(40);
+            pdfDoc.text(10,175,'Nombre y Apellido: ' + AccountInvoice[0].partner_id[0].name);
+            pdfDoc.text(120,175,'Nombre y Apellido:' + AccountInvoice[0].partner_id[0].name_deudor);
+            pdfDoc.text(10,180,'RUC / DNI: ' + self.valorNull(AccountInvoice[0].partner_id[0].ruc));
+            pdfDoc.text(120,180,'RUC / DNI:' + AccountInvoice[0].partner_id[0].cin_deudor);
+            pdfDoc.text(10,185,'Domicilio: ' + self.valorNull(AccountInvoice[0].partner_id[0].address));
+            pdfDoc.text(120,185,'Domicilio:' + AccountInvoice[0].partner_id[0].dir_deudor);
+            pdfDoc.text(10,195,'Telefono: ' + self.valorNull(AccountInvoice[0].partner_id[0].phone));
+            pdfDoc.text(120,195,'Telefono:');
+            pdfDoc.text(10,200,'Celular: ' + self.valorNull(AccountInvoice[0].partner_id[0].mobile));
+            pdfDoc.text(120,200,'Celular:' + AccountInvoice[0].partner_id[0].tel_deudor);
+            pdfDoc.text(10,210,'Firma: ');
+            pdfDoc.text(120,210,'Firma:');
+            pdfDoc.text(10,220,'Aclaración: ');
+            pdfDoc.text(120,220,'Aclaración:');
+
+            pdfDoc.save('pagare.pdf');
+        },
+    });
+    if (instance.web && instance.web.FormView) {
+        instance.web.FormView.include({
+            load_form: function (record) {
+                this._super.apply(this, arguments);
+                if (this.model !== 'account.invoice') return;
+                local.parentInstance = this;
+                if (local.widgetInstance) {
+                    local.widgetInstance.updateId(record.id);
+                }
+                local.widgetInstance = new local.PagareTropishopWidget(this);
+                var elemento = this.$el.find('.oe_form').find('.pagare_button_box');
+                local.widgetInstance.appendTo(elemento);
+                local.widgetInstance.updateId(record.id);
+            }
+        });
+    }
+};

+ 8 - 0
static/src/xml/main.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<template xml:space="preserve">
+    <t t-name="pagare_anillos.PagareTropishop">
+        <button class="print_pagare_anillos oe_button oe_form_button oe_highlight">
+            <div> Imprimir Pagare</div>
+        </button>
+    </t>
+</template>

+ 18 - 0
views/account_invoice_view.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+	<data>
+        <record model="ir.ui.view" id="account_invoice_button">
+            <field name="name">account.invoice.button</field>
+            <field name="model">account.invoice</field>
+            <field name="inherit_id" ref="account.invoice_form"/>
+            <field name="arch" type="xml">
+				<xpath expr="//button[@name='invoice_print']" position="replace">
+					<div class="pagare_button_box" attrs="{'invisible': [('state','not in',['open','paid'])]}"></div>
+				</xpath>
+				<xpath expr="//button[@name='action_invoice_sent']" position="attributes">
+					<attribute name="invisible">1</attribute>
+				</xpath>
+            </field>
+        </record>
+	</data>
+</openerp>

+ 10 - 0
views/template.xml

@@ -0,0 +1,10 @@
+<openerp>
+    <data>
+        <template id="pagare_tropishop.assets_backend" name="pagare_tropishop_assets" inherit_id="eiru_assets.assets">
+            <xpath expr="." position="inside">
+                <link rel="stylesheet" href="/pagare_tropishop/static/src/css/style.css"/>
+                <script type="text/javascript" src="/pagare_tropishop/static/src/js/main.js"/>
+            </xpath>
+        </template>
+    </data>
+</openerp>

Деякі файли не було показано, через те що забагато файлів було змінено