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

How to disable auto-fill shipping address on sales order

Subscriure's

Get notified when there's activity on this post

This question has been flagged
2 Respostes
7357 Vistes
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
Descartar
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
Descartar
kaynis
Autor

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
Autor

Thank you so much mate will get back to you soon

kaynis
Autor

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
Autor

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
Autor 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
Descartar
Xsias

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

kaynis
Autor

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
Autor

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
Autor

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
Autor

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
Autor

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!

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