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

How to disable auto-fill shipping address on sales order

Subscribe

Get notified when there's activity on this post

This question has been flagged
2 Replies
7334 Views
Avatar
kaynis

Hi all, Using V6 on Windows Can anyone help please me with this, I am trying to stop auto fill function onchange of partner id in sales order. We have lots of customers with many shipping addresses and the users of OpenERP always seem to put the wrong addresses in the shipping address location because the system fills it with a default one. I want the shipping address to be blank so that a user will have to select the correct shipping address everytime

    class sale_order(osv.osv):
        _inherit = "sale.order"
        def onchange_partner_id(self, cr, uid, ids, part, context=None):
            if not part:
                return {'value': { 'payment_term': False, 'fiscal_position': False, 'partner_invoice_id': False, 'partner_order_id': False,}} #'partner_shipping_id': False, 

    part = self.pool.get('res.partner').browse(cr, uid, part, context=context)
    addr = self.pool.get('res.partner').address_get(cr, uid, [part.id], ['invoice', 'contact'])
    pricelist = part.property_product_pricelist and part.property_product_pricelist.id or False
    payment_term = part.property_payment_term and part.property_payment_term.id or False
    fiscal_position = part.property_account_position and part.property_account_position.id or False
    dedicated_salesman = part.user_id and part.user_id.id or uid
    val = {
        'partner_invoice_id': addr['invoice'],
        'partner_order_id': addr['contact'],
    #            'partner_shipping_id': addr['delivery'],
        'payment_term': payment_term,
        'fiscal_position': fiscal_position,
        'user_id': dedicated_salesman,
    }
    if pricelist:
        val['pricelist_id'] = pricelist
    return {'value': val}

sale_order()

0
Avatar
Discard
Xsias

Does it work ?

Avatar
Xsias
Best Answer

(On the V7)

For a complete no-filling information, in XML : You can inherit the base view on a custom module and delete the onchange like that :

<record id="view_order_form_inherit" model="ir.ui.view">
    <field name="name">sale.order.form.inherit</field>
    <field name="model">sale.order</field>
    <field name="inherit_id" ref="sale.view_order_form"/>
    <field name="arch" type="xml">
        <xpath expr="//field[@name='partner_id']" position="replace">
            <field name="partner_id" domain="[('customer','=',True)]" context="{'search_default_customer':1, 'show_address': 1}" options='{"always_reload": True}'/>
        </xpath>
    </field>
</record>

For a targeted edit in Python (V7):

class sale_order(osv.osv):
    _inherit = "sale.order"
    def onchange_partner_id(self, cr, uid, ids, part, context=None):
        if not part:
            return {'value': { 'payment_term': False, 'fiscal_position': False}} #'partner_invoice_id': False, 'partner_shipping_id': False, 

        part = self.pool.get('res.partner').browse(cr, uid, part, context=context)
#        addr = self.pool.get('res.partner').address_get(cr, uid, [part.id], ['delivery', 'invoice', 'contact'])
        pricelist = part.property_product_pricelist and part.property_product_pricelist.id or False
        payment_term = part.property_payment_term and part.property_payment_term.id or False
        fiscal_position = part.property_account_position and part.property_account_position.id or False
        dedicated_salesman = part.user_id and part.user_id.id or uid
        val = {
#            'partner_invoice_id': addr['invoice'],
#            'partner_shipping_id': addr['delivery'],
            'payment_term': payment_term,
            'fiscal_position': fiscal_position,
            'user_id': dedicated_salesman,
        }
        if pricelist:
            val['pricelist_id'] = pricelist
        return {'value': val}
sale_order()

I've put unwanted code preceded by #

I don't know if it's working under V6, sorry.

1
Avatar
Discard
kaynis
Author

Really appreciate the quick response. Thanks a lot but is it possible to disable the shipping address alone?

Xsias

I've just notice that you are on v6. My answer was about V7, but i thnk it's wok on v6 too.

If you just want to avoid the filling of shipping address you can try an inherit in python. You can edit the onchange_partner_id. I edit my answer with a solution.

Xsias

It's ok ? (I've disabled shipping and invoice addresses)

kaynis
Author

Thank you so much mate will get back to you soon

kaynis
Author

I realized that assumed that was on purpose to illustrate the effects of the commented codes. Thanks

Xsias

If my answer is good, don't hesitate to mark her as correct and vote for her.

kaynis
Author

Hi I have tried your solution but i keep getting an error when I try to add a new sales order AttributeError: 'int' object has no attribute 'property_product_pricelist'

Xsias

My bad, i've commented a wrong line : part = self.pool.get('res.partner').browse(cr, uid, part, context=context) should not be commented. I've edited my answer.

Avatar
kaynis
Author Best Answer

I get this error when i select a partner on new sales order Client Traceback (most recent call last): File "C:\Program Files (x86)\OpenERP 6.1-1\server\openerp\addons\web\common\http.py", line 180, in dispatch File "C:\Program Files (x86)\OpenERP 6.1-1\server\openerp\addons\web\controllers\main.py", line 1032, in onchange File "C:\Program Files (x86)\OpenERP 6.1-1\server\openerp\addons\web\controllers\main.py", line 996, in call_common File "C:\Program Files (x86)\OpenERP 6.1-1\server\openerp\addons\web\controllers\main.py", line 1010, in _call_kw File "C:\Program Files (x86)\OpenERP 6.1-1\server\openerp\addons\web\common\openerplib\main.py", line 250, in proxy File "C:\Program Files (x86)\OpenERP 6.1-1\server\openerp\addons\web\common\openerplib\main.py", line 117, in proxy File "C:\Program Files (x86)\OpenERP 6.1-1\server\openerp\addons\web\common\http.py", line 608, in send

Server Traceback (most recent call last): File "C:\Program Files (x86)\OpenERP 6.1-1\server\openerp\addons\web\common\http.py", line 593, in send File "C:\Program Files (x86)\OpenERP 6.1-1\server.\openerp\netsvc.py", line 360, in dispatch_rpc File "C:\Program Files (x86)\OpenERP 6.1-1\server.\openerp\service\web_services.py", line 572, in dispatch File "C:\Program Files (x86)\OpenERP 6.1-1\server.\openerp\osv\osv.py", line 167, in execute_kw File "C:\Program Files (x86)\OpenERP 6.1-1\server.\openerp\osv\osv.py", line 121, in wrapper File "C:\Program Files (x86)\OpenERP 6.1-1\server.\openerp\osv\osv.py", line 176, in execute File "C:\Program Files (x86)\OpenERP 6.1-1\server.\openerp\osv\osv.py", line 164, in execute_cr File "C:\Program Files (x86)\OpenERP 6.1-1\server\openerp\addons\sale_journal\sale_journal.py", line 76, in onchange_partner_id File "C:\Program Files (x86)\OpenERP 6.1-1\server\openerp\addons\delivery\sale.py", line 33, in onchange_partner_id File "C:\Program Files (x86)\OpenERP 6.1-1\server\openerp\addons\sales_extended\sales_extended.py", line 19, in onchange_partner_id AttributeError: 'int' object has no attribute 'property_product_pricelist'

0
Avatar
Discard
Xsias

Have you tried my correction ? (Uncomment the line : part = self.pool.get('res.partner').browse(cr, uid, part, context=context) )

kaynis
Author

Yes i did. I literally copied and pasted your comment

Xsias

Can you find your def onchange_partner_id() (in your installation) and past it here ? I need to see your original code.

kaynis
Author

worked when i uncoment the "part" and "addr" but I now have a new problem. When I select a partner, the invoice address is inserted into the shipping address, which is ok but when i change the partner assuming a wrong partner was selected, the shipping address stays as the address first selected. ie assume select partner A, invoice address A in shipping address, change to partner B but shipping address still stays as invoice address A. By the way, Thanks a lot you have been very helpful.

Xsias

Can you post the actual code you use ? I'm a little bit confused.

kaynis
Author

Please see code above in my initial question.

Xsias

It's a silly question but, do you test with a partner B who have an invoice address ?

kaynis
Author

Yes I did. Sorry it seem our server has been down for a while I tested with few partners

Xsias

When you put some print variableIWantToPrint and look at the log, what do you see ? Test some importants variables like part or val.

kaynis
Author

Good morning. Solved when i upgraded/updated base module. Thanks

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