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 add new button in sales invoice form

Suscribirse

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

Se marcó esta pregunta
formheaderbutton
4 Respuestas
15853 Vistas
Avatar
arcull

Hi everyone.

I'm new to odoo 8 and would like to customize it to my needs. Not to spoil the original code, I've created new module with scaffold command. Now I would need to create a button in header of sales invoice form, which will run my customized invoice print. What I've done so far with my.xml looks like this, but it is not complete yet.

<openerp>

<data>

<record id="invoice.form.my" model="ir.ui.view">

<field name="name">account.invoice.form.my</field>

<field name="model">account.invoice</field>

<field name="inherit_id" ref="account.invoice_5"/>

<field name="arch" type="xml">

<!-- some xpath expression to add "Print2" -->

</field>

</record>

</data>

</openerp>

What would be the appropriate xpath to add button "Print2" to the form header? Should this xpath expression replace the current content of form header, or can it just add new button to it? Can you please post a short example of code.

Much thanks in advance for help, regards.

0
Avatar
Descartar
Avatar
Akhil P Sivan
Mejor respuesta

Try like this:

<record id="invoice_form_my" model="ir.ui.view">

<field name="name">account.invoice.form.my</field>

<field name="model">account.invoice</field>

<field name="inherit_id" ref="account.invoice_form"/>

<field name="arch" type="xml">

<button name="invoice_print" position="after">

<button name="my_button" string="Print2"/>

</button>

</field>

</record>

Another way using xpath (if you want to add your button next to "Print" button ):

<record id="invoice_form_my" model="ir.ui.view">

<field name="name">account.invoice.form.my</field>

<field name="model">account.invoice</field>

<field name="inherit_id" ref="account.invoice_form"/>

<field name="arch" type="xml">

<xpath expr="/form/header/button[2][@string='Print']" position="after">

<button name="my_button" string="Print2" class="oe_highlight"/>

</xpath>

</field>

</record>

4
Avatar
Descartar
arcull
Autor

Works just great ;) Even though position="after" doesn't move my button to the end, it appears at the beginning on the left side of form header. Anyway I'm happy with this, I have my button ;) Thanks.

Akhil P Sivan

Arcull, please try using xpath also, which is another way to extend existing views.

arcull
Autor

Akhil, your suggestion with xpath version works as well, many thanks.

Nitin Nath Giri

how can i make it runnable or how can i perform some function on click of this button

Nitin Nath Giri

how can i make it runnable or how can i perform some function on click of this button????

i have tried this :

<record id="hr_payslip_form" model="ir.ui.view">

<field name="name">hr.payslip.form</field>

<field name="model">hr.payslip</field>

<field name="type">form</field>

<field name="inherit_id" ref="hr_payroll.view_hr_payslip_form"/>

<field name="arch" type="xml">

<xpath expr="//header" position="inside">

<button name="my_button" string="Print2" class="oe_highlight"/>

</xpath>

</field>

</record>

models.py

class custom_hr_payslip(models.Model):

_name = 'custom.hr.payslip'

_inherit = 'hr.payslip'

@api.one

def my_button(self):

print("##########################################")

Avatar
Jignesh Mehta
Mejor respuesta

Hello Arcull,


Here is the xpath for add button in account.invoice


<xpath expr="/form/header/button[@name='invoice-open']" position="after">

     <!-- put your button here -->

</xpath>



Hope its works for you.

Thanks,

2
Avatar
Descartar
arcull
Autor

Thanks. But I can't make it work. I guess I don't know where to position the xpath tag. I tried: account.invoice.form.my account.invoice <xpath expr="/form/header/button[@name='invoice-open']" position="after">

Avatar
Kalpana Hemnani
Mejor respuesta

Hello Arcull,

Another way of putting button is like below:

<button name="invoice_print" position="after">

<!--Add your button-->

</button>



1
Avatar
Descartar
arcull
Autor

Thanks, I'm currently using this solution.

Avatar
arcull
Autor Mejor respuesta

Thank you guys, you are awesome ;) I was banging my head against the wall for 2 days with this, it's when you know you are very close to solution, but from another point of view, still far away...And the solution is always simple when you know it ;) Thanks again.


PS: the solution with xpath, still doesn't work, but I guess it is my fault positioning the xpath tag. I tried like this:


<openerp>

<data>

<record id="invoice_form_my" model="ir.ui.view">

<field name="name">account.invoice.form.my</field>

<field name="model">account.invoice</field>

<field name="inherit_id" ref="account.invoice_form"/>

<field name="arch" type="xml">

<xpath expr="/form/header/button[@name='invoice-open']" position="after">

<button name="my_button" string="Print3"/>

</xpath>

</field>

</record>

</data>

</openerp>

---------------------------------------------------------------------------------------------------------

I can't put second answer so I'll use this one...

Can you please suggest, how can I refernce function in my model when hitting my new print button. Then "print_invoice_my" refers to account.invoice model, while it should to "my" model in my addon. Therefore I get an error when trying to run, it says it can not find  "print_invoice_my" in account.invoice.Here is my xml:

<openerp>

<data>

<record id="invoice_form_my" model="ir.ui.view">

<field name="name">account.invoice.form.my</field>

<field name="model">account.invoice</field>

<field name="inherit_id" ref="account.invoice_form"/>

<field name="arch" type="xml">

<button name="invoice_print" position="after">

<button type="object" name="print_invoice_my" string="my Invoice"/>

</button>

</field>

</record>

</data>

</openerp>

Much thanks again, Arcull

0
Avatar
Descartar
arcull
Autor

maybe someone knows the answer, thanks

¿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
The issue with button related to method in the creation screen
form method button
Avatar
0
ago 23
2489
Add custom button to trigger JS function alongside a submit button inside a website form
form button website
Avatar
Avatar
1
dic 22
5848
[odoo10.0]how do i trigger java script from form view button?
javascript form button
Avatar
0
sept 17
3995
How to set save as default button?
form button openerp
Avatar
0
mar 15
4640
Add binary field to form header
form v7 header
Avatar
0
mar 15
4439
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.

Website made with

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