Ver Fonte

Habilitar Credito en la Factura

Adrielso há 8 anos atrás
commit
8243e27665

+ 3 - 0
__init__.py

@@ -0,0 +1,3 @@
+# -*- coding : utf-8 -*-
+
+from . import models

BIN
__init__.pyc


+ 12 - 0
__openerp__.py

@@ -0,0 +1,12 @@
+# -*- coding: utf-8 -*-
+
+{
+    'name': 'Restrict Invoice Credits',
+    'version': '8.0.0.1',
+    'category': 'Invoice',
+    'author': 'Adrielso Kunert',
+    'data': ['views/account_invoice_view.xml'],
+    'depends': ['base','account'],
+    'installable':True,
+    'auto_install':False
+}

+ 2 - 0
models/__init__.py

@@ -0,0 +1,2 @@
+# -*- coding : utf-8 -*-
+from . import account_invoice

BIN
models/__init__.pyc


+ 34 - 0
models/account_invoice.py

@@ -0,0 +1,34 @@
+# -*- encoding: utf-8 -*-
+from openerp import models, fields, api
+
+class account_invoice(models.Model):
+    _inherit = 'account.invoice'
+    _name = 'account.invoice'
+
+    enable_credit = fields.Boolean('Habilitar Credito')
+
+    _defaults = {
+        'enable_credit': False,
+    }
+
+    @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):
+        if self.enable_credit == False:
+            self.contado =True
+        else:
+            self.credito = not self.contado
+
+    @api.one
+    def habilitar_check(self):
+        invoice = self.env['account.invoice'].search([('id', '=', self.id)])
+        if invoice:
+            if invoice.enable_credit == False:
+                invoice.write({'enable_credit' : True})
+            else:
+                invoice.write({'enable_credit' : False, 'credito' : False, 'contado' : True })

BIN
models/account_invoice.pyc


BIN
static/description/icon.png


+ 32 - 0
views/account_invoice_view.xml

@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        <record id="account_invoice_cred_check" model="ir.ui.view">
+            <field name="name">account.invoice.cred.check</field>
+            <field name="model">account.invoice</field>
+            <field name="inherit_id" ref="account.invoice_form" />
+            <field name="arch" type="xml">
+                 <field name="fiscal_position" position="after">
+                       <button name="habilitar_check"  states="draft" string="Habilitar Credito"  class="oe_button oe_form_button oe_highlight"
+                            type="object" help="Habilitar Credito" groups="account.group_account_user"/>
+                       <field name="enable_credit" string='Habilitar Crédito' groups="account.group_account_user" readonly="1"  nolabel='1' states="draft"/>
+                </field>
+            </field>
+        </record>
+
+        <record id="account_invoice_cred_enable" model="ir.ui.view">
+            <field name="name">account.invoice.cred.enable</field>
+            <field name="model">account.invoice</field>
+            <field name="inherit_id" ref="factura_venta_golden.account_invoice_cred_cont" />
+            <field name="arch" type="xml">
+                <field name="contado" position="replace">
+                    <field name="contado" attrs="{'readonly': [('state','!=','draft')]}"/>
+                </field>
+                <field name="credito"  position="replace" >
+                    <field name="credito" attrs="{'readonly' : ['|',('state','!=','draft'), ('enable_credit', '=', False )]}"/>
+                </field>
+            </field>
+        </record>
+
+    </data>
+</openerp>