Passa al contenuto
Odoo Menu
  • Accedi
  • Provalo gratis
  • App
    Finanze
    • Contabilità
    • Fatturazione
    • Note spese
    • Fogli di calcolo (BI)
    • Documenti
    • Firma
    Vendite
    • CRM
    • Vendite
    • Punto vendita Negozio
    • Punto vendita Ristorante
    • Abbonamenti
    • Noleggi
    Siti web
    • Configuratore sito web
    • E-commerce
    • Blog
    • Forum
    • Live chat
    • E-learning
    Supply chain
    • Magazzino
    • Produzione
    • PLM
    • Acquisti
    • Manutenzione
    • Qualità
    Risorse umane
    • Dipendenti
    • Assunzioni
    • Ferie
    • Valutazioni
    • Referral dipendenti
    • Parco veicoli
    Marketing
    • Social marketing
    • E-mail marketing
    • SMS marketing
    • Eventi
    • Marketing automation
    • Sondaggi
    Servizi
    • Progetti
    • Fogli ore
    • Assistenza sul campo
    • Helpdesk
    • Pianificazione
    • Appuntamenti
    Produttività
    • Comunicazioni
    • Approvazioni
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    App di terze parti Odoo Studio Piattaforma cloud Odoo
  • Settori
    Retail
    • Libreria
    • Negozio di abbigliamento
    • Negozio di arredamento
    • Alimentari
    • Ferramenta
    • Negozio di giocattoli
    Cibo e ospitalità
    • Bar e pub
    • Ristorante
    • Fast food
    • Pensione
    • Grossista di bevande
    • Hotel
    Agenzia immobiliare
    • Agenzia immobiliare
    • Studio di architettura
    • Edilizia
    • Gestione immobiliare
    • Impresa di giardinaggio
    • Associazione di proprietari immobiliari
    Consulenza
    • Società di contabilità
    • Partner Odoo
    • Agenzia di marketing
    • Studio legale
    • Selezione del personale
    • Audit e certificazione
    Produzione
    • Tessile
    • Metallo
    • Arredamenti
    • Alimentare
    • Birrificio
    • Ditta di regalistica aziendale
    Benessere e sport
    • Club sportivo
    • Negozio di ottica
    • Centro fitness
    • Centro benessere
    • Farmacia
    • Parrucchiere
    Commercio
    • Tuttofare
    • Hardware e assistenza IT
    • Ditta di installazione di pannelli solari
    • Calzolaio
    • Servizi di pulizia
    • Servizi di climatizzazione
    Altro
    • Organizzazione non profit
    • Ente per la tutela ambientale
    • Agenzia di cartellonistica pubblicitaria
    • Studio fotografico
    • Punto noleggio di biciclette
    • Rivenditore di software
    Carica tutti i settori
  • Community
    Apprendimento
    • Tutorial
    • Documentazione
    • Certificazioni 
    • Formazione
    • Blog
    • Podcast
    Potenzia la tua formazione
    • Programma educativo
    • Scale Up! Business Game
    • Visita Odoo
    Ottieni il software
    • Scarica
    • Versioni a confronto
    • Note di versione
    Collabora
    • Github
    • Forum
    • Eventi
    • Traduzioni
    • Diventa nostro partner
    • Servizi per partner
    • Registra la tua società di contabilità
    Ottieni servizi
    • Trova un partner
    • Trova un contabile
    • Incontra un esperto
    • Servizi di implementazione
    • Testimonianze dei clienti
    • Supporto
    • Aggiornamenti
    GitHub Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Richiedi una demo
  • Prezzi
  • Aiuto

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

  • CRM
  • e-Commerce
  • Contabilità
  • Magazzino
  • PoS
  • Progetti
  • MRP
All apps
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
È necessario essere registrati per interagire con la community.
Tutti gli articoli Persone Badge
Etichette (Mostra tutto)
odoo accounting v14 pos v15
Sul forum
Assistenza

Purchase module, unit price reset on change of qty or uom. What needs to be changed in on_change function ?

Iscriviti

Ricevi una notifica quando c'è un'attività per questo post

La domanda è stata contrassegnata
purchasefunctionv8price
1 Rispondi
10593 Visualizzazioni
Avatar
Christian Parent

When creating a purchase order, if you happen to change the price first then quantity or unit of measure after, the price will reset back to what it was before you changeg it (default price or 0.0). It have something to do with the onchange_product_id function but, cannot figure out what exactly creates this.

here is the code of the function (with non relevent code removed) :

def onchange_product_id(self, cr, uid, ids, pricelist_id, product_id, qty, uom_id,
        partner_id, date_order=False, fiscal_position_id=False, date_planned=False,
        name=False, price_unit=False, context=None):

    if context is None:
        context = {}

    res = {'value': {'price_unit': price_unit or 0.0, 'name': name or '', 'product_uom' : uom_id or False}}
    if not product_id:
        return res

    product_product = self.pool.get('product.product')
    product_uom = self.pool.get('product.uom')
    product_pricelist = self.pool.get('product.pricelist')

 ....

    if pricelist_id:
        price = product_pricelist.price_get(cr, uid, [pricelist_id],
                product.id, qty or 1.0, partner_id or False, {'uom': uom_id, 'date': date_order})[pricelist_id]
    else:
        price = product.standard_price

....

    res['value'].update({'price_unit': price, 'taxes_id': taxes_ids})

    return res

product_id_change = onchange_product_id
product_uom_change = onchange_product_uom

What cause that behavior and how to modify it to keep the price entered by the user at any time ? (This has been like that since at least V.6)

0
Avatar
Abbandona
Avatar
Qutechs, Ahmed M.Elmubarak
Risposta migliore

Hello,

the price changed by this code:

# - determine price_unit and taxes_id
    if pricelist_id:
        price = product_pricelist.price_get(cr, uid, [pricelist_id],
                product.id, qty or 1.0, partner_id or False, {'uom': uom_id, 'date': date_order})[pricelist_id]
    else:
        price = product.standard_price

it'll check the price list for the product or set it to the standard one. So if you need the price entered by the user never changed you have to overwrite this function to don't use the price variable in the line "before the return res":

res['value'].update({'price_unit': price, 'taxes_id': taxes_ids})

Update

you can add

if price_unit:
         price = price_unit

after the if - else condition ...

note: this is simple solution, in case the user doesn't change the price and then he changed the uom, there will be no automatic converting to the price ! so you'll need more work here.

I hope this could helps..

Regards...

0
Avatar
Abbandona
Christian Parent
Autore

I did had tried that change, it did not worked.

It had something to do with the declaration price_unit=False in the signature. I have moved price_unit before the date_order=False, in the signature so it did not need to be initiated, did the changes in form view too. It works. Not for the the onchange_product_uom function which calls the onchange_product_id function in its return. Did the same changes in same order (in signature) but, getting a string instead of int error.... Looking at it now !

Qutechs, Ahmed M.Elmubarak

there is no something to to with price_unit=False it just a default value, you've to don't interrupt the order of the signature. I have tried my change before I post this answer and it worked! I hope if you can return the function as it is original one with that change and try it...

Christian Parent
Autore

When using:

res['value'].update({'price_unit': price_unit, 'taxes_id': taxes_ids})

If I change the quantity afterwards or the unit of measure, the price returns to 0.00$.

I have changed everything back to original, I had already tried your solution before and it was behaving that way. I will also retry the price = price_unit and see but as I remember, it was also setting it back to 0.00$

Qutechs, Ahmed M.Elmubarak

I've updated the answer, if you still get the 0.00 , please check the order of the params in the xml view you can check the price_unit value by printing it to server and then try to change the qty.

Qutechs, Ahmed M.Elmubarak

hey man, I didn't notice that you're tagging V8, this may not work with you cause I checked it with V7 I'm so sorry for that...

Christian Parent
Autore

No prob, I have a production server which runs 6.0.x, will try your solution on it. For 8, I have set everything back to normal, re-moved price_unit in the signature of only onchange_product_id fonction so it does not need to be initiated to false, and made the appropriated changes in the xml also and it works as intended for both, onchange_product_id and onchange_product_uom. Looks like the signature sets it to 0 (false) no mather what the call pass as argument.

Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!

Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!

Registrati
Post correlati Risposte Visualizzazioni Attività
Purchase module, unit price reset on change of qty or uom. What needs to be changed in on_change function ?
purchase function v8 price
Avatar
0
mar 15
4696
Purchase module, unit price reset on change of qty or uom. What needs to be changed in on_change function ?
purchase function v8 price
Avatar
0
mar 15
4706
Adding custom field in Sale order line to show values into Purchase order line
purchase sales function
Avatar
Avatar
Avatar
Avatar
3
ago 25
2460
Why does the purchase order allow products where Can be Purchased is false?
purchase v8 product
Avatar
Avatar
1
nov 24
4773
Price not updated when new value is written from purchase order
purchase price purchase_order
Avatar
Avatar
1
set 23
7284
Community
  • Tutorial
  • Documentazione
  • Forum
Open source
  • Scarica
  • Github
  • Runbot
  • Traduzioni
Servizi
  • Hosting Odoo.sh
  • Supporto
  • Aggiornamenti
  • Sviluppi personalizzati
  • Formazione
  • Trova un contabile
  • Trova un partner
  • Diventa nostro partner
Chi siamo
  • La nostra azienda
  • Branding
  • Contattaci
  • Lavora con noi
  • Eventi
  • Podcast
  • Blog
  • Clienti
  • Note legali • Privacy
  • Sicurezza
الْعَرَبيّة 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 è un gestionale di applicazioni aziendali open source pensato per coprire tutte le esigenze della tua azienda: CRM, Vendite, E-commerce, Magazzino, Produzione, Fatturazione elettronica, Project Management e molto altro.

Il punto di forza di Odoo è quello di offrire un ecosistema unico di app facili da usare, intuitive e completamente integrate tra loro.

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