فهرست منبع

Impresion factura legal en pos factura ferresur

Sebas 6 سال پیش
والد
کامیت
a552c25377
12فایلهای تغییر یافته به همراه200 افزوده شده و 34 حذف شده
  1. 1 1
      __init__.py
  2. BIN
      __init__.pyc
  3. 41 0
      account_invoice.py
  4. BIN
      account_invoice.pyc
  5. 10 1
      factura_pos_ferresur.py
  6. BIN
      factura_pos_ferresur.pyc
  7. 18 17
      factura_pos_ferresur.xml
  8. 88 15
      numbers_to_letters1.py
  9. BIN
      numbers_to_letters1.pyc
  10. 26 0
      res_currency.py
  11. BIN
      res_currency.pyc
  12. 16 0
      res_currency_view.xml

+ 1 - 1
__init__.py

@@ -15,4 +15,4 @@
 #                                                                               #
 #################################################################################
 
-from . import factura_pos_ferresur, numbers_to_letters1
+from . import factura_pos_ferresur, numbers_to_letters1, res_currency

BIN
__init__.pyc


+ 41 - 0
account_invoice.py

@@ -0,0 +1,41 @@
+# -*- encoding: utf-8 -*-
+#################################################################################
+#                                                                               #
+#                                                                               #
+#    This program is free software: you can redistribute it and/or modify       #
+#    it under the terms of the GNU Affero General Public License as             #
+#    published by the Free Software Foundation, either version 3 of the         #
+#    License, or (at your option) any later version.                            #
+#                                                                               #
+#    This program is distributed in the hope that it will be useful,            #
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of             #
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              #
+#    GNU Affero General Public License for more details.                        #
+#                                                                               #
+#    You should have received a copy of the GNU Affero General Public License   #
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.      #
+#                                                                               #
+#################################################################################
+
+from openerp import models, fields, api
+
+class account_invoice(models.Model):
+    _inherit = 'account.invoice'
+    _name = 'account.invoice'
+
+    contado = fields.Boolean('Contado')
+    credito = fields.Boolean('Crédito')
+
+    _defaults = {
+        'contado': True
+    }
+
+    @api.one
+    @api.onchange('credito')
+    def cambiar_estado_credito(self):
+        self.contado = not self.credito
+
+    @api.one
+    @api.onchange('contado')
+    def cambiar_estado_contado(self):
+        self.credito = not self.contado

BIN
account_invoice.pyc


+ 10 - 1
factura_pos_ferresur.py

@@ -12,7 +12,16 @@ class report_pos_ferresur(models.AbstractModel):
             'doc_ids': self._ids,
             'doc_model': report.model,
             'docs': self.env[report.model].browse(self._ids),
-            # 'convertir':self.convertir,
+            'convertir':self.convertir,
             # 'calcular_precio':self.calcular_precio,
         }
         return report_obj.render('factura_pos_ferresur.report_pos_ferresur', docargs)
+
+    def convertir(self,nro,moneda):
+        letra = num2words(nro,lang="es")
+        letra = letra.capitalize()
+        if not moneda:
+            moneda=''
+
+        letra = letra +' '+moneda    
+        return letra

BIN
factura_pos_ferresur.pyc


+ 18 - 17
factura_pos_ferresur.xml

@@ -28,12 +28,12 @@
                             padding-right: 1cm;
                         }
                         .logo{
-                            height: 2.5cm;
+                            height: 3.1cm;
                             width: 100%;
                             top: 0px;
                         }
                         .logo1{
-                            height: 4.2cm;
+                            height: 3.6cm;
                             width: 100%;
                             top: 0px;
                         }
@@ -143,16 +143,16 @@
                                         <tbody>
                                             <tr t-foreach="o.lines" t-as="l">
                                                 <!-- CODIGO DE PRODUCTO -->
-                                                <td style="font-size:9px;font-family: Arial;width:2.2cm;overflow: auto; text-align: left;">
+                                                <td style="font-size:9px;font-family: Arial;width:2.9cm;overflow: auto; text-align: left;">
                                                     <span t-field="l.product_id.ean13"/>
                                                 </td>
                                                 <!-- CANTIDAD -->
-                                                <td style="font-size:9px;font-family: Arial;width:2.7cm;overflow: auto; text-align: center;">
+                                                <td style="font-size:9px;font-family: Arial;width:2.9cm;overflow: auto; text-align: center;">
                                                     <span t-esc="'%.0f'%l.qty"/>
                                                 </td>
 
                                                 <!-- NOMBRE DEL PRODUCTO -->
-                                                <td style="font-size:9px;font-family: Arial;width:9.8cm;overflow: auto;">
+                                                <td style="font-size:9px;font-family: Arial;width:11.7cm;overflow: auto;">
                                                     <span t-field="l.product_id.name"/>
                                                 </td>
                                                 <!-- PRECIO UNITARIO -->
@@ -196,9 +196,9 @@
                                         <tbody>
 
                                             <tr>
-                                                <td style="font-size:10px;font-family: Arial;width:2.2cm;overflow: auto; text-align: center;"></td>
-                                                <td style="font-size:10px;font-family: Arial;width:2.7cm;overflow: auto; text-align: center;"></td>
-                                                <td style="font-size:10px;font-family: Arial;width:9.8cm;overflow: auto; text-align: center;"></td>
+                                                <td style="font-size:10px;font-family: Arial;width:2.9cm;overflow: auto; text-align: center;"></td>
+                                                <td style="font-size:10px;font-family: Arial;width:2.9cm;overflow: auto; text-align: center;"></td>
+                                                <td style="font-size:10px;font-family: Arial;width:11.7cm;overflow: auto; text-align: center;"></td>
                                                 <td style="font-size:10px;font-family: Arial;width:2cm;overflow: auto; text-align: center;"></td>
                                                 <td style="font-size:10px;font-family: Arial;width:2.0cm;overflow: auto; text-align: right;">
 
@@ -221,12 +221,13 @@
                                             </tr>
 
                                             <tr>
-                                                <td style="padding-top:0.4cm;font-size:10px;font-family: Arial;width:2.2cm;overflow: auto; text-align: center;"></td>
+                                                <td style="padding-top:0.4cm;font-size:10px;font-family: Arial;width:2.9cm;overflow: auto; text-align: center;"></td>
                                                 <td style="padding-top:0.4cm;font-size:10px;font-family: Arial;width:2.5cm;overflow: auto; text-align: center;"></td>
                                                 <td style="padding-top:0.4cm;font-size:10px;font-family: Arial;width:7cm;overflow: auto; text-align: left;">
                                                         <div>
                                                             <!-- <span t-esc="o.amount_to_text(o.amount_total, o.pricelist_id.currency_id)"/> -->
-                                                            <span t-esc="o.compute_text()" />
+                                                            <span t-esc="convertir(o.amount_total,'')"/>
+
                                                             <!-- <span t-esc="o.amount_total"/> -->
                                                         </div>
                                                 </td>
@@ -242,8 +243,8 @@
 
                                             <div class="divisoria1"> </div>
                                             <tr>
-                                                <td style="padding-top:0.6cm;font-size:10px;font-family: Arial;width:2.2cm;overflow: auto; text-align: center;"></td>
-                                                <td style="padding-top:0.6cm;font-size:10px;font-family: Arial;width:2.5cm;overflow: auto; text-align: center;">
+                                                <td style="padding-top:0.9cm;font-size:10px;font-family: Arial;width:2.9cm;overflow: auto; text-align: center;"></td>
+                                                <td style="padding-top:0.9cm;font-size:10px;font-family: Arial;width:2.5cm;overflow: auto; text-align: center;">
 
                                                         <div>
                                                             <t t-if="iva_5 != 0">
@@ -252,7 +253,7 @@
                                                         </div>
 
                                                 </td>
-                                                <td style="padding-top:0.6cm;font-size:10px;font-family: Arial;width:7cm;overflow: auto; text-align: left;">
+                                                <td style="padding-top:0.9cm;font-size:10px;font-family: Arial;width:7cm;overflow: auto; text-align: left;">
 
                                                         <div>
                                                             <t t-if="iva_10 != 0">
@@ -264,20 +265,20 @@
                                                         </div>
 
                                                 </td>
-                                                <td style="padding-top:0.6cm;font-size:10px;font-family: Arial;width:2cm;overflow: auto; text-align: left;">
+                                                <td style="padding-top:0.9cm;font-size:10px;font-family: Arial;width:2cm;overflow: auto; text-align: left;">
 
 
                                                         <span t-esc="'{0:,.0f}'.format(iva_5+iva_10)"/>
 
 
                                                 </td>
-                                                <td style="padding-top:0.6cm;font-size:10px;font-family: Arial;width:2.0cm;overflow: auto; text-align: right;">
+                                                <td style="padding-top:0.9cm;font-size:10px;font-family: Arial;width:2.0cm;overflow: auto; text-align: right;">
 
                                                 </td>
 
-                                                <td style="padding-top:0.6cm;font-size:10px;font-family: Arial;width:2.2cm;overflow: auto; text-align: center;">
+                                                <td style="padding-top:0.9cm;font-size:10px;font-family: Arial;width:2.2cm;overflow: auto; text-align: center;">
                                                 </td>
-                                                <td style="padding-top:0.6cm;font-size:10px;font-family: Arial;width:2.5cm;overflow: auto; text-align: right;">
+                                                <td style="padding-top:0.9cm;font-size:10px;font-family: Arial;width:2.5cm;overflow: auto; text-align: right;">
                                                 </td>
                                             </tr>
                                         </tbody>

+ 88 - 15
numbers_to_letters1.py

@@ -1,19 +1,92 @@
-# -*- encoding: utf-8 -*-
-from openerp import models, fields, api
-from openerp.tools.amount_to_text import amount_to_text
-#
-# class pos_order(models.Model):
-#     _inherit = "pos.order"
-#
-#     @api.multi
-#     def amount_to_text(self, amount):
-#         return amount_to_text(amount)
+# -*- coding: utf-8 -*-
+import unittest
 
+def numero_to_letras(numero):
+	indicador = [("",""),("MIL","MIL"),("MILLON","MILLONES"),("MIL","MIL"),("BILLON","BILLONES")]
+	entero = int(numero)
+	decimal = int(round((numero - entero)*100))
+	#print 'decimal : ',decimal
+	contador = 0
+	numero_letras = ""
+	numero_letrasd = ""
 
+	while entero >0:
+		a = entero % 1000
+		if contador == 0:
+			en_letras = convierte_cifra(a,1).strip()
+		else :
+			en_letras = convierte_cifra(a,0).strip()
+		if a==0:
+			numero_letras = en_letras+" "+numero_letras
+		elif a==1:
+			if contador in (1,3):
+				numero_letras = indicador[contador][0]+" "+numero_letras
+			else:
+				numero_letras = en_letras+" "+indicador[contador][0]+" "+numero_letras
+		else:
+			numero_letras = en_letras+" "+indicador[contador][1]+" "+numero_letras
 
-class pos_order(models.Model):
-    _inherit = 'pos.order'
+		numero_letras = numero_letras.strip()
+		contador = contador + 1
+		entero = int(entero / 1000)
 
-    @api.multi
-    def compute_text(self, amount_total):
-        return compute_text(amount_total)
+
+	contadord=0
+	while decimal >0:
+		d = decimal % 1000
+		if contadord == 0:
+			en_letrasd = convierte_cifra(d,1).strip()
+
+		numero_letrasd =" COM "+str(en_letrasd.strip())
+		contadord = contadord + 1
+		decimal = int(decimal / 1000)
+
+	numero_letras = numero_letras+ str(numero_letrasd)
+	# print 'numero: ',numero
+	# print numero_letras
+	return numero_letras
+
+
+
+def convierte_cifra(numero,sw):
+	lista_centana = ["",("CIEN","CIENTO"),"DOSCIENTOS","TRESCIENTOS","CUATROCIENTOS","QUINIENTOS","SEISCIENTOS","SETECIENTOS","OCHOCIENTOS","NOVECIENTOS"]
+	lista_decena = ["",("DIEZ","ONCE","DOCE","TRECE","CATORCE","QUINCE","DIECISEIS","DIECISIETE","DIECIOCHO","DIECINUEVE"),
+					("VEINTE","VEINTI"),("TREINTA","TREINTA Y "),("CUARENTA" , "CUARENTA Y "),
+					("CINCUENTA" , "CINCUENTA Y "),("SESENTA" , "SESENTA Y "),
+					("SETENTA" , "SETENTA Y "),("OCHENTA" , "OCHENTA Y "),
+					("NOVENTA" , "NOVENTA Y ")
+				]
+	lista_unidad = ["",("UN" , "UNO"),"DOS","TRES","CUATRO","CINCO","SEIS","SIETE","OCHO","NUEVE"]
+	centena = int (numero / 100)
+	decena = int((numero -(centena * 100))/10)
+	unidad = int(numero - (centena * 100 + decena * 10))
+	#print "centena: ",centena, "decena: ",decena,'unidad: ',unidad
+	texto_centena = ""
+	texto_decena = ""
+	texto_unidad = ""
+
+	#Validad las centenas
+	texto_centena = lista_centana[centena]
+	if centena == 1:
+		if (decena + unidad)!=0:
+			texto_centena = texto_centena[1]
+		else :
+	 		texto_centena = texto_centena[0]
+
+
+	#Valida las decenas
+	texto_decena = lista_decena[decena]
+	if decena == 1 :
+		 texto_decena = texto_decena[unidad]
+ 	elif decena > 1 :
+ 		if unidad != 0 :
+ 			texto_decena = texto_decena[1]
+ 		else:
+ 			texto_decena = texto_decena[0]
+ 	#Validar las unidades
+ 	#print "texto_unidad: ",texto_unidad
+ 	if decena != 1:
+ 		texto_unidad = lista_unidad[unidad]
+ 		if unidad == 1:
+ 			texto_unidad = texto_unidad[sw]
+ 	return "%s %s %s" %(texto_centena,texto_decena,texto_unidad)

BIN
numbers_to_letters1.pyc


+ 26 - 0
res_currency.py

@@ -0,0 +1,26 @@
+# -*- encoding: utf-8 -*-
+#################################################################################
+#                                                                               #
+#                                                                               #
+#    This program is free software: you can redistribute it and/or modify       #
+#    it under the terms of the GNU Affero General Public License as             #
+#    published by the Free Software Foundation, either version 3 of the         #
+#    License, or (at your option) any later version.                            #
+#                                                                               #
+#    This program is distributed in the hope that it will be useful,            #
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of             #
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              #
+#    GNU Affero General Public License for more details.                        #
+#                                                                               #
+#    You should have received a copy of the GNU Affero General Public License   #
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.      #
+#                                                                               #
+#################################################################################
+
+from openerp import models, fields
+
+class res_currency(models.Model):
+    _inherit = 'res.currency'
+    _name = 'res.currency'
+
+    en_letras = fields.Char('En letras')

BIN
res_currency.pyc


+ 16 - 0
res_currency_view.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<openerp>
+    <data>
+        <record id="res_currency_en_letras" model="ir.ui.view">
+            <field name="name">res.currency.en.letras</field>
+            <field name="model">res.currency</field>
+            <field name="inherit_id" ref="base.view_currency_form" />
+            <field name="arch" type="xml">
+                <field name="symbol" position="after">
+                    <field name="en_letras"/>
+                </field>
+            </field>
+        </record>
+    </data>
+</openerp>