Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

inject fields in ubl_bis3.xml files in Odoo 17

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
3 Risposte
1545 Visualizzazioni
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
Abbandona
Georges Moes
Autore

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

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
Abbandona
Avatar
Raymond Sterling
Risposta migliore

Life saver!!!

Thanks a trillion!

0
Avatar
Abbandona
Avatar
Georges Moes
Autore Risposta migliore

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
Abbandona
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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