Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Immobiliari
    • Agència immobiliària
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consultoria
    • Empresa comptable
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Mobles
    • Menjar
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Sistemes d'energia solar
    • Shoe Maker
    • Serveis de neteja
    • Instal·lacions HVAC
    Altres
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

Automation to Validate Delivery and Invoice Addresses

Subscriure's

Get notified when there's activity on this post

This question has been flagged
developmentaddressmultipleinvoicingshippingvalidationautomationaddresses
141 Vistes
Avatar
Jwidess

Hello all,

We are using Odoo Online v19 with Studio, and I recently needed to figure out a way to handle multiple Invoice and Delivery addresses in Odoo Sales. To do this, I first enabled Customer Addresses following the doc linked below. Then I used Studio to add the partner_shipping_id and partner_invoice_id to the Sales module Form view. I also added {'show_address': 1} to the "Context" property of the fields to show the full address in the Form view. While this setup alone works, it allows you to select any address record, which is quite error-prone. To remedy this, I tried to use the Field->Properties->Domain to only allow addresses that had a matching parent ID of the company being invoiced/quoted, but apparently, dynamic fields don't work in the Domain. 

Instead, I decided to set up a simple Automation Rule with some Python to validate these fields. Now, when an address from a different company is selected, it raises an error and prevents saving. When an address from the same company is selected, but the address type is wrong, it places a warning in the Chatter. This also takes into account a company that has no separate delivery and invoice address, as it allows the primary company record to be selected as well. I hope this helps someone out, if it does, let me know below!

To set this up, do the following:

  1. Create a new Automation Rule in the Sales Module
  2. Select "Sales Order" as the Model.
  3. Trigger: "On create and edit"
  4. Match and Apply on all records.
  5. Add an action and select "Execute Code"
  6. Paste the code from below!
# Validate Delivery Address
if record.partner_shipping_id and record.partner_id:
# Check if it belongs to the customer (blocking)
if (
record.partner_shipping_id != record.partner_id
and record.partner_shipping_id.parent_id != record.partner_id
):
raise UserError(
"❌ The Delivery Address must belong to the selected Customer. \nContact IT for help with this error."
)
# Check type (warning), only if not the base company
elif record.partner_shipping_id != record.partner_id:
if record.partner_shipping_id.type != 'delivery':
record.message_post(
body="⚠️ The selected Delivery Address is not marked as type 'Delivery'."
)

# Validate Invoice Address
if record.partner_invoice_id and record.partner_id:
# Check if it belongs to the customer (blocking)
if (
record.partner_invoice_id != record.partner_id
and record.partner_invoice_id.parent_id != record.partner_id
):
raise UserError(
"❌ The Invoice Address must belong to the selected Customer. \nContact IT for help with this error."
)
# Check type (warning), only if not the base company
elif record.partner_invoice_id != record.partner_id:
if record.partner_invoice_id.type != 'invoice':
record.message_post(
body="⚠️ The selected Invoice Address is not marked as type 'Invoice'."
)

Links:

  1. Customer Addresses: https://www.odoo.com/documentation/19.0/applications/finance/accounting/customer_invoices/customer_addresses.html

0
Avatar
Descartar
Chris TRINGHAM

Dynamic fields do work in the domain, but you can't enter them using Studio. You need to directly update the XML for the Studio view.

Cybrosys Techno Solutions Pvt.Ltd
Hi,

In Odoo Online v19 with Studio, it is possible to manage multiple invoice and delivery addresses on Sales Orders, but Studio does not support dynamic domains on fields. While adding the Invoice Address (partner_invoice_id) and Delivery Address (partner_shipping_id) fields to the Sales Order form works, it allows users to select any address record, which can easily lead to incorrect data entry.

Because dynamic domain filtering is not available in Studio, a practical workaround is to use an Automated Action on the Sales Order model. This automation runs on both creation and update and validates the selected invoice and delivery addresses using Python code. If a selected address does not belong to the customer (i.e., it is neither the main partner nor a child contact of that partner), the system raises a blocking error and prevents the record from being saved.

If the address does belong to the customer but has an incorrect address type (for example, a delivery address not marked as “Delivery”), the automation does not block the action. Instead, it posts a warning message in the chatter to alert the user. This approach also correctly handles customers that do not have separate invoice or delivery addresses by allowing the main company record to be selected.

This solution works entirely within Odoo Online and Studio, avoids custom modules, and provides a reliable way to enforce address consistency on Sales Orders while still giving users helpful feedback.

Hope it helps


Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrar-se
Related Posts Respostes Vistes Activitat
SHIPPING ADDRESS
address shipping
Avatar
Avatar
Avatar
2
de set. 24
2295
Invoice name on Stock Picking Solved
invoicing validation
Avatar
Avatar
1
d’abr. 19
3874
Automation for creating and sending invoices from CRM Solved
crm invoicing automation
Avatar
Avatar
1
de nov. 25
1157
What are the fields ending with "_signed" in the model account_move for? Solved
development invoicing odoo16features
Avatar
Avatar
1
d’abr. 24
3928
How is the default Shipping Address chosen in a Sales order? Solved
address shipping sale.order
Avatar
2
de nov. 25
7942
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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