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

inject fields in ubl_bis3.xml files in Odoo 17

Suscribirse

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

Se marcó esta pregunta
3 Respuestas
1508 Vistas
Avatar
Georges Moes

We want to inject the following 3 fields in the generated ..ubl_bis3.xml files in Odoo 17 Community edition.


<cbc:ID> (bt13 = identifier of a referenced purchase order, issued by the Buyer)

<cbc:AccountingCost> (bt19 = A textual value that specifies where to book the relevant data into the Buyer's financial accounts.)

<cbc:Note> (bt22 = textual note that gives unstructured information that is relevant to the Invoice as a whole.)


The data of the 3 xml-nodes is present in the database model account_move as the fields

<cbc:ID> =  buyer_reference
<cbc:AccountingCost> = accounting_cost
<cbc:Note> = invoice_note


How can we inject these 3 xml-nodes in the generated ..ubl_bis3.xml, that is send via PEPPOL? We would like to write code in a custom module to archieve this. 



--- Update



Thx Christoph for pointing me in the right direction.

In my module I added to the class


class AccountMove(models.Model):

    _inherit = 'account.move'

    def _export_invoice_vals(self, invoice):

        vals = super()._export_invoice_vals(invoice)

        vals['vals'].update({

            'accounting_cost': invoice.accounting_cost,

            'invoice_note': invoice.invoice_note,

            'contract_document_reference_vals': [{

                'id': invoice.buyers_reference if invoice.buyers_reference else 'N/A',

            ​ ​# 'issue_date': invoice.contract_id.date_start if invoice.contract_id else None,

            }],

        })

        return vals



In the in ubl_20_template.xml

I added two lines in the section


<template id="ubl_20_CommonType">
(...)
         <cbc:AccountingCost t-out="vals.get('accounting_cost')" />
         <cbc:Note t-out="vals.get('invoice_note')"/>


But stil I don't get the desired result?

0
Avatar
Descartar
Georges Moes
Autor

I've followed your instructions, but without getting the desired result. We are using the Community edition, and it seems as if the creation of the ubl_bis3.xml slightly different.
In the whole files in the /addons directory in odoo I cannot locate the method '_export_as_ubl_invoice' that You mention. Therefore the proposed code does not give the desired result. 

Christoph Farnleitner

This is, because it's just AI generated without any proof-reading whatsoever...

Christoph Farnleitner

_export_invoice_vals() is nowhere defined in account.move but, for example, account.edi.xml.ubl_20, your inherit needs to reflect that. Also, I don't know what you template modification looks with just that snippet.

Raymond Sterling

Hi there,


Did you manage to sort this out? I have been facing the exact same issue and still cannot get the fields inserted in the final xml 

I am probably using the wrong hook in the template.xml, or odoo redoes the xml always, not sure


Cheers


Any help will be greatly appreciated

Avatar
Christoph Farnleitner
Mejor respuesta

You're interested in investigating the module account_edi_ubl_cii from core: https://github.com/odoo/odoo/tree/17.0/addons/account_edi_ubl_cii

More so, probably in the function _export_invoice_vals() of account.edi.xml.ubl_20 at https://github.com/odoo/odoo/blob/17.0/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_20.py#L521

In here, further down the line a dictionary is defined that holds the data that then is used in the actual template: https://github.com/odoo/odoo/blob/17.0/addons/account_edi_ubl_cii/data/ubl_20_templates.xml


1
Avatar
Descartar
Avatar
Raymond Sterling
Mejor respuesta

Life saver!!!

Thanks a trillion!

0
Avatar
Descartar
Avatar
Georges Moes
Autor Mejor respuesta

Hi,

after a lot of try and error and the help of AI we got it to work.

our account_edi_xml_ubl_bis3_extension.py

from odoo import models


class AccountEdiXmlUBLBIS3Extension(models.AbstractModel):

    _inherit = "account.edi.xml.ubl_bis3"


    def _export_invoice_vals(self, invoice):

        vals = super()._export_invoice_vals(invoice)


        # Inject custom fields into the nested 'vals' dictionary

        vals['vals']['accounting_cost'] = invoice.l10n_lu_mddi_engagement_ref

        vals['vals']['note_vals'] = [{'note': invoice.l10n_lu_mddi_general_info}]

        vals['vals']['order_reference'] = invoice.l10n_lu_mddi_order_ref or '-'

        vals['vals']['buyer_reference'] = invoice.l10n_lu_mddi_order_ref or '-'


        return vals



the views/account_edi_templates.xml

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>
        <template id="ubl_21_invoice_type_inherit_l10n_lu_mddi" inherit_id="account_edi_ubl_cii.ubl_21_InvoiceType">
            <xpath expr="//*[local-name()='BuyerReference']" position="before">
                <t xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">
                    <cbc:AccountingCost t-if="vals.get('accounting_cost')">
                        <t t-esc="vals.get('accounting_cost')"/>
                    </cbc:AccountingCost>
                </t>
            </xpath>
        </template>
    </data>
</odoo>

the views/account_move_view.xml

<?xml version='1.0' encoding='utf-8'?>
<odoo>
    <data>
        <record id="view_move_form_l10n_lu_mddi" model="ir.ui.view">
            <field name="name">account.move.form.l10n_lu_mddi</field>
            <field name="model">account.move</field>
            <field name="inherit_id" ref="account.view_move_form"/>
            <field name="arch" type="xml">
                <xpath expr="//notebook" position="inside">
                    <page string="MDDI" name="mddi">
                        <group>
                            <field name="l10n_lu_mddi_engagement_ref"/>
                            <field name="l10n_lu_mddi_general_info"/>
                            <field name="l10n_lu_mddi_order_ref"/>
                        </group>
                    </page>
                </xpath>
            </field>
        </record>
    </data>
</odoo>


You need to adapt the script to Your needs. 
I had to give the field 'l10n_lu_mddi_order_ref' from the relation account_move a default value '_'. Otherwise Odoo complains that this field cannot be empty.
Good luck 

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
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