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

Odoo 12: Show VAT in partner name for invoice, exactly as supplier bills

Subscriure's

Get notified when there's activity on this post

This question has been flagged
xmlform_viewodoo12
7 Respostes
6070 Vistes
Avatar
Paulo Matos

Dear all.

I hope everyone safe.

On Odoo, when we issue a supplier bill, we can see the VAT number right next to supplier name (suppler_name - vat_number on partner_id field), when we're choosing the supplier from the partner_id field.

I need to achieve the same effect on customer invoices.

So, when user clicks on the partner_id many2one field, I need to show "Customer Name - VAT_NUMBER".

I look into the supplier bill xml and found:

<group modifier = {}>...
<field string="Supplier" 
                name="partner_id" 
                widget="res_partner_many2one" 
                context="{'default_customer': 0, 
                        'search_default_supplier': 1, 
                        'default_supplier': 1, 
                        'default_is_company': True, 
                        'show_vat': True}" 
                domain="[('supplier', '=', True)]" 
                on_change="1" 
                can_create="true" 
                can_write="true" 
                modifiers="{'readonly':[['state','not in',['draft']]]}"/>
...
</group>


On the customer invoice I have:

<field string="Customer" 
                name="partner_id" 
                widget="res_partner_many2one" 
                context="{'search_default_customer':1, 
                        'show_address': 1, 
                        'default_is_company': True, 
                        'show_vat': True}" 
                options="{&quot;always_reload&quot;: True, 
                &quot;no_quick_create&quot;: True}" 
                domain="[('customer', '=', True)]" 
                required="1"/>
...


I cannot find any option, widget or field that allows me to achieve the same effect.

Looking for both codes, I thought the "show_vat" did the trick but it's already selected for the customer invoices and I cannot get the same effect.

Can anyone help me please?

Thank you all very much and keep safe

PM

UPDATE: I need do show the VAT number on the partner_id field itself when user is selecting the customer.


UPDATE II: Please refer to this image: https://ibb.co/567p81x

0
Avatar
Descartar
Avatar
Paresh Wagh
Best Answer

Hi Paulo:

The value is displayed provided both of the following conditions are true:

  1. show_vat = True

  2. partner.vat has a value in it

Check to make sure the VAT field for that Partner has a value in it.

EDIT:

The context definition on the Invoice form has a parameter 'show_address' in it which causes the api to return the name + address + vat.

context="{'search_default_customer':1, 'show_address': 1, 'default_is_company': True, 'show_vat': True}"

If you customize the view and remove the 'show_address' parameter like so, you get the same result as on the Vendor Bill.

<xpath expr="//field[@name='partner_id']" position="attributes">
    <attribute name="context">{'search_default_customer':1, 'default_is_company': True, 'show_vat': True}</attribute>
</xpath>

NOTE: This will cause the address to be no longer displayed on the form. Only the name + vat will be displayed.


Screenshot of Invoice form with customized context on partner_id.


1
Avatar
Descartar
Paulo Matos
Autor

Thank you Paresh,

I think you correctly understood my question. I am referring to the VAT number shown on the partner_id field when we are choosing a supplier from the list, when issuing a new supplier bill.

If supplier has a VAT number, Odoo shows on partner_id many2one selection list:"Partner Name - VAT Number".

The same does not happens to customer invoices, and I need to achieve the same result.

Customer has a VAT number associated to his account.

Regards

Paresh Wagh

I have edited and added a screenshot to my earlier post. Taking care of the 2 things mentioned above works fine with the default out of the box functionality. Check whether some customization has been done at your site.

Paulo Matos
Autor

Paresh,

Thank you once again.

My English is not very good a perhaps I did not explain myself correctly. Please refer to the following image link for you to see what I need to achieve: https://ibb.co/567p81x

Regards

Paresh Wagh

Hi Paulo: I have updated the EDIT section in my earlier response based on your clarification.

Paulo Matos
Autor

Great Paresh,

It's working as expected. Thank you very much.

Best regards

PM

Avatar
Prakash
Best Answer

Check partner python file name_get method, using this method can append two fields  and show in many2one dropdown list.

Edit,

https://github.com/odoo/odoo/blob/13.0/odoo/addons/base/models/res_partner.py

Check _get_name method line no 657

if self._context.get('show_vat') and partner.vat:
name = "%s ‒ %s" % (name, partner.vat)
return name

def name_get(self):
res = []

for partner in self:

name = partner._get_name()

res.append((partner.id, name))
return res

The above code appending customer and vat number in many2one list.

check context set and get value. You can debug the above code

to check supplier bill form the above vat if statement is executed or not.





0
Avatar
Descartar
Paulo Matos
Autor

Dear Prakash,

I am using Odoo 12 and the core code for /base/models/res_partner.py is exactly as you described on your code sample.

Anyway, the same code is shared by both customer/supplier and the approach I need is working fine for supplier on core Odoo, and not for the customer.

I think it's something else and not this specific code.

Thank you very much

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
Element cannot be located in parent view
xml odoo12
Avatar
0
de febr. 22
2573
AssertionError: Element data has extra content: record, line 3 Solved
xml odoo12
Avatar
Avatar
Avatar
6
d’ag. 19
11217
How to prevent Odoo for creating a new record whenever I click on the menu item?
xml records odoo12
Avatar
Avatar
1
de febr. 24
3704
Odoo12's Button is not showing.
xml buttons odoo12
Avatar
0
de febr. 24
2277
How to change default form view in stock.picking model
form form_view odoo12
Avatar
Avatar
Avatar
2
de set. 22
6104
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