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

Add boolean field to Expense line

Suscribirse

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

Se marcó esta pregunta
hrxmlviewexpense
2 Respuestas
8789 Vistas
Avatar
Paul Strinati

I'm trying to add a boolean field to the expense line in hr.expense, but am struggling to find the relevant object and view names in Developer mode. I'm doing it as a custom module, but need some help with the onetomany relationship between hr.expense.expense, and hr.expense.line (i.e. I cannot figure out the view that I need to edit for the line item).

Basically I just want to add the boolen field at the end of the line (i.e. after the total field) - any pointers greatly appreciated!

This is the XML I'm using in the custom module:


<?xml version="1.0" encoding="utf-8"?>
<openerp>
  <data>
    <record model="ir.ui.view" id="ocl_hr_expense">
      <field name="name">hr.expense.line.tree</field>
      <field name="model">hr.expense.line</field>
      <field name="inherit_id" ref="hr_expense.hr_expense_form_view" />
      <field name="arch" type="xml">
        <xpath expr="//page[@string='Description']/field[@name='line_ids']/tree[@string='Expense Lines']/field[@name='total_amount']" position="after">
          <field name="abc" />
        </xpath>
      </field>
    </record>
  </data>
</openerp>

and my boolean field is defined as follows:

from openerp.osv import fields, osv

class ocl_hr_expense(osv.osv):

    _inherit = "hr.expense.line"

    _columns = {
        'abc': fields.boolean('ABC Reportable')
    }

    _defaults ={
        'abc': 0
    }

ocl_hr_expense()

0
Avatar
Descartar
Avatar
Paul Strinati
Autor Mejor respuesta

Solution - I was using the wrong model - I should have been using hr.expense.expense instead of hr.expense.line (I assumed because I wanted to add something to the line, I should use hr.expense.line - duh!). So my XML file is now:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
  <data>
    <record model="ir.ui.view" id="ocl_hr_expense">
      <field name="name">hr.expense.line.tree</field>
      <field name="model">hr.expense.expense</field>
      <field name="inherit_id" ref="hr_expense.view_expenses_form" />
      <field name="arch" type="xml">
        <xpath expr="/form/sheet/notebook/page[@string='Description']/field[@name='line_ids']/tree[@string='Expense Lines']/field[@name='name']" position="after">
          <field name="abc" />
        </xpath>
      </field>
    </record>
  </data>
</openerp>

and it works a dream!

 

2
Avatar
Descartar
Ludo - 21South

Try adding two slashes instead of just one between all the elements in your xpath. So like: "//page[@string='Description']//field[@name='line_ids']//tree[@string='Expense Lines']//field[@name='total_amount']"

Paul Strinati
Autor

Thanks but I still get the validation error as above.

Ludo - 21South

Around the error should be the exact part the XML is failing on. For example "Field X could not be found on view for Y". Could you update your issue with said error?

Paul Strinati
Autor

I've checked the openerp-server.log file and found this: openerp.osv.orm: Can't find field 'message_follower_ids' in the following view parts composing the view of object model 'hr.expense.expense': * hr.expense.form Either you wrongly customized this view, or some modules bringing those views are not compatible with your current data model

Paul Strinati
Autor

I've re-posted my solution as I've now got it working :)

Ludo - 21South

Good! and thnx for sharing the solution.

Avatar
Anand Patel
Mejor respuesta

Hi,

you need to add boolean field in r.expense.line and then you have to inherit the hr.expense.expense form view and put that filed by xpath like example given below
<xpath expr="//page[@string='Order Lines']/field[@name='order_line']/tree[@string='Sales Order Lines']/field[@name='product_id']" position="after">

<field name="your_booleans_field" />

</xpath>

0
Avatar
Descartar
Paul Strinati
Autor

Thanks Anand - I've created the boolean field in hr.expense.line, but it's the view name and xpath I'm struggling with as I cannot seem to construct the correct string. I'm trying this: hr.expense.line.tree hr.expense.line But it doesn't seem to like the view name: ValueError: No such external ID currently defined in the system: hr_expense.hr_expense_view and I cannot seem to find the correct view name anywhere. I was trying to work off this one: https://github.com/vnc-biz/openerp-addons-bundle/blob/master-7.0/hr_expense/hr_expense_view.xml

OdooBot
Hi,

when you activate developer mode on the top of the form you will find one drop-down shown in the attached image(developer_mode.png)
from there you will find option for the "edit form view"
there you will find (external_id.png) so take that value and pass it in the xpath



On Mon, Oct 13, 2014 at 1:29 PM, Paul Strinati <paul.strinati@optimumcredit.co.uk> wrote:

Thanks Anand - I've created the boolean field in hr.expense.line, but it's the view name and xpath I'm struggling with as I cannot seem to construct the correct string. I'm trying this: hr.expense.line.tree hr.expense.line But it doesn't seem to like the view name: ValueError: No such external ID currently defined in the system: hr_expense.hr_expense_view and I cannot seem to find the correct view name anywhere. I was trying to work off this one: https://github.com/vnc-biz/openerp-addons-bundle/blob/master-7.0/hr_expense/hr_expense_view.xml

--
Paul Strinati
Sent by OpenERP S.A. using Odoo about Forum Post False



--
Thanks,

Anand Patel
+91 9601663735

Paul Strinati
Autor

Thanks Anand - I've got the correct External ID now (hr_expense.view_expenses_form), but am now getting a weird error message in the log to do with the parsing of the XML: openerp.osv.orm: Can't find field 'message_follower_ids' in the following view parts composing the view of object model 'hr.expense.expense': * hr.expense.form Some kind of inheritance issue?

OdooBot
Hi,

you need to add following code to the python file.
_inherit = ['mail.thread']

On Mon, Oct 13, 2014 at 5:13 PM, Paul Strinati <paul.strinati@optimumcredit.co.uk> wrote:

Thanks Anand - I've got the correct External ID now (hr_expense.view_expenses_form), but am now getting a weird error message in the log to do with the parsing of the XML: openerp.osv.orm: Can't find field 'message_follower_ids' in the following view parts composing the view of object model 'hr.expense.expense': * hr.expense.form Some kind of inheritance issue?

--
Paul Strinati
Sent by OpenERP S.A. using Odoo about Forum Post False



--
Thanks,

Anand Patel
+91 9601663735

¿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
How do I remove a button from the sale.order.form? Resuelto
xml view
Avatar
Avatar
Avatar
Avatar
Avatar
6
sept 17
9509
display view if user is anonymous
xml view
Avatar
Avatar
1
mar 15
5253
How do I change default text from a module view?
xml view
Avatar
Avatar
1
mar 15
7016
XML from module not loaded after changes.
xml view
Avatar
Avatar
2
mar 15
10989
view xml, attrs use variable with attribute Resuelto
attrs xml view
Avatar
Avatar
1
mar 24
11639
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