Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita una demostración
  • Precios
  • Ayuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyectos
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

How to return a popup when click in validate of account.invoice?

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
wizardviewpopupreturn
2 Respuestas
10634 Vistas
Avatar
Anabela Damas

Hi,

In order to have a popup when click in Validate button of account.invoice I have made some changes:

In addons/mymodule/account_invoice.py:

class account_invoice(osv.osv):
    _inherit = "account.invoice"
    def verify_vat(self, cr, uid, ids, context=None):
        """ Verify if the client has nif"""

        invoice_obj = self.pool.get('account.invoice')
        this = self.browse(cr, uid, ids)[0]
        for invoice_vi in invoice_obj.browse(cr,uid,ids):

            if invoice_vi.partner_id:
                if not invoice_vi.partner_id.vat:
                    form_res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'vi_saft_pt', 'warning_vat_form')
                    form_id = form_res and form_res[1] or False
                    #import pdb
                    #pdb.set_trace()
                    print "VERIFY_VAT"
                    return {
                        'name': _('Warning Vat'),
                        'view_type': 'form',
                        'view_mode': 'form',
                        'res_model': 'warning.vat',
                        'view_id':[form_res and form_res[1] or False],
                        'target': 'new',
                        'domain': [],
                        'type': 'ir.actions.act_window',
                        'context': context,
                    }
            else:
                print "VERIFY_VAT 2return"
                return True 
account_invoice()

In addons/mymodule/warning_vat_view.xml:

<record id="warning_vat_form" model="ir.ui.view">
        <field name="name">warning.vat.form</field>
        <field name="model">warning.vat</field>
        <field name="arch" type="xml">
            <form string="Warning Vat" version="7.0">
                <separator string="The following client has no associated nif."/>
                <field name="vat"/>
                <field name="partner_id"/>
                <footer>
                    <button string="Cancel" class="oe_link" special="cancel" />
                </footer>
            </form>
        </field>
    </record>

<record id="action_warning_vat_form" model="ir.actions.act_window">
    <field name="name">Warning Vat</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">warning.vat</field>
    <field name="view_type">form</field>
    <field name="view_mode">form</field>
    <field name="target">new</field>
</record>

<record model="ir.actions.act_window.view" id="action_warning_vat_form_view">
    <field name="name">Warning Vat</field>
    <field name="view_mode">form</field>
    <field name="view_id" ref="warning_vat_form"/>
</record>

In addons/mymodule/account_invoice_workflow.xml :

    <record id="account.act_open" model="workflow.activity">
        <field name="wkf_id" ref="account.wkf"/>
        <field name="name">open</field>
        <field name="action">action_date_assign()

action_move_create() action_number() invoice_validate() verify_vat()</field> <field name="kind">function</field> </record>

This code gives me the following error:

Uncaught TypeError: Cannot read property 'view_type' of undefined
http://localhost:8069/web/webclient/js?db=..

If I change the order in addons/mymodule/account_invoice_workflow.xml like this :

    <record id="account.act_open" model="workflow.activity">
        <field name="wkf_id" ref="account.wkf"/>
        <field name="name">open</field>
        <field name="action">verify_vat()
action_date_assign()
action_move_create()
action_number()
invoice_validate()
</field>
            <field name="kind">function</field>
        </record>

It prints the "VERIFY_VAT" but nothing appears and the invoice is validated.

I had change the code in the return of verify_vat but nothing appears...

Thanks

0
Avatar
Descartar
Avatar
Anabela Damas
Autor Mejor respuesta

If I change the code of verify_vat to :

def verify_vat(self, cr, uid, ids, context=None):
    """ Verify if the client has nif"""

    invoice_obj = self.pool.get('account.invoice')
    this = self.browse(cr, uid, ids)[0]
    for invoice_vi in invoice_obj.browse(cr,uid,ids):

        if invoice_vi.partner_id:
            if not invoice_vi.partner_id.vat:
                form_res = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'vi_saft_pt', 'warning_vat_form')
                form_id = form_res and form_res[1] or False
                wizard_id = self.pool.get("warning.vat").create(cr, uid, {}, context)
                print "VERIFY_VAT"
                return {
                    'type': 'ir.actions.act_window',
                    'name': _('Warning Vat'),
                    'view_type': 'form',
                    'view_mode': 'form',
                    'res_model': 'warning.vat',
                    'view_id': False,
                    'target': 'new',
                    'nodestroy': True, 
                    'domain': [],
                    'views': [(form_id, 'form')],
                    'res_id': wizard_id,
                    'context': context,
                }

And in addons/mymodule/account_invoice_workflow.xml :

   <record id="account.act_open" model="workflow.activity">
        <field name="wkf_id" ref="account.wkf"/>
        <field name="name">open</field>
        <field name="action">action_date_assign()
action_move_create()
action_number()
invoice_validate()
verify_vat()
</field>
            <field name="kind">function</field>
        </record>

It works.

Thanks.

3
Avatar
Descartar
Avatar
fussions
Mejor respuesta

Hello Anabela, I need to run a wizard on creation of Invoice, when it is in draft. I've tried your code, adding the function to act_draft activity. The function is executed but wizard doesn't show. When I add it to the act_open activiti it works well. Do you have any idea why its not working in a draft on creation of Invoice?

I've even tried to start a subflow and execute the function there, but still no results.

Anyways thanks for your post it is really helpful. Cheers!

0
Avatar
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
Before view form show an wizard related!!!
wizard view
Avatar
Avatar
Avatar
2
mar 15
4464
Is it possible to redirect user an external url & open view at the same function ?
views view return
Avatar
0
abr 20
4858
Open a View in Pop Up in a one to many relationship
view popup custom_module
Avatar
Avatar
1
mar 15
7737
Return tree view from wizard
wizard view v6.0
Avatar
0
mar 15
8314
How to disable wizard call in specific views ?
action wizard view
Avatar
0
mar 15
4788
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidad
  • Seguridad
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

Sitio web hecho con

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now