Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

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

Subscribe

Get notified when there's activity on this post

This question has been flagged
xmlform_viewodoo12
7 Replies
6062 Views
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
Discard
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
Discard
Paulo Matos
Author

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
Author

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
Author

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
Discard
Paulo Matos
Author

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!

Sign up
Related Posts Replies Views Activity
Element cannot be located in parent view
xml odoo12
Avatar
0
Feb 22
2571
AssertionError: Element data has extra content: record, line 3 Solved
xml odoo12
Avatar
Avatar
Avatar
6
Aug 19
11209
How to prevent Odoo for creating a new record whenever I click on the menu item?
xml records odoo12
Avatar
Avatar
1
Feb 24
3703
Odoo12's Button is not showing.
xml buttons odoo12
Avatar
0
Feb 24
2274
How to change default form view in stock.picking model
form form_view odoo12
Avatar
Avatar
Avatar
2
Sep 22
6100
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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