Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Food & Hospitality
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Browse all Industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenez partenaire
    • Services for Partners
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

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

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

How to get the previous value of field in onchange odoo 8?

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
many2oneonchangelast_modifiedodooV8
6 Réponses
26590 Vues
Avatar
Rakesh Yadav

I have many2one field and I have written onchange method on it. When onchange happens i want the previous value of it. How can it possible?

Example:

1. I selected product "A1".

2.  Then, I removed "A1" I selected product "A2".  

3. I want "A1" in method  which i selected in 1st step.

1
Avatar
Ignorer
Avatar
Sunny Sheth
Meilleure réponse

Hello Rakesh,


please see this answer:

http://www.odoo.com/forum/help-1/question/how-to-get-record-s-id-on-on-change-of-wizard-s-field-126036#answer-128511 


it will help you.


Thanks

-1
Avatar
Ignorer
Avatar
Alf Olsen
Meilleure réponse

The answer you will find in that link Sunny posted is to use self._origin to get the records as it is in the database (before any changes/saves was made in the gui)

6
Avatar
Ignorer
Avatar
Ankit H Gandhi(AHG)
Meilleure réponse

Hello

You need to create 2 extra fields to achieve this things.

Hope below Example help you.

Define fields

product_id = fields.Many2one('product.product',  'Product') # This standard field.

product_id_new = fields.Many2one('product.product',  'Product New') # This custom field.

product_id_old = fields.Many2one('product.product',  'Product Old') # This custom field.

Define onchange method

@api.onchange('product_id')

def onchange_product_id(self):

    OldProduct = self.product_id_new.id
    self.product_id_new = self.product_id.id
    self.product_id_old = OldProduct

you can get old product on product_id_old fields.

 Best Thanks,
Ankit H Gandhi.

1
Avatar
Ignorer
Avatar
Nikhil Krishnan
Meilleure réponse

Hai Rakesh Yadav,

,

you can search the same record.

     obj = self.env['model.model'].search([('id', '=', self.id)])

obj.field_name give you the first value.
and self.field_name give the new value.
this is just an idea. please try this, it may help you,
thanks.

0
Avatar
Ignorer
Avatar
ayman mohammed adam
Meilleure réponse

Dear Rakesh,


1-Try to make another field by the same type just in different name.

2-when you change the value of first field get the old value from the second field and update it by the new value.

 

field1 = fields.Char()

field2 = fields.Char()
@api.onchange('field1')
def onchange_field1(self):

     old_value = self.field2 

     self.field2= self.field1

 

 hope I helped You...



-1
Avatar
Ignorer
Ankit H Gandhi(AHG)

Thank you

Your suggestion very help full me

+1 from me

Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
how i Populate Many2One field on change of another field on v8?
many2one many2many onchange odooV8
Avatar
Avatar
Avatar
2
juin 15
8941
when i select the category in the sale list the regarding product must shown in the product id in the bill list by onchange
many2one onchange
Avatar
0
déc. 18
13
Onchange many2one partner_bank_id Résolu
many2one onchange
Avatar
Avatar
1
mai 16
5033
Is it possible to save model to database in onchange function?
onchange odooV8
Avatar
0
févr. 16
6097
Update field on on_change method.
onchange odooV8
Avatar
Avatar
Avatar
2
mars 15
6044
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenez partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة 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 est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

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