Odoo Help

0

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

By
Rakesh Yadav
on 1/20/18, 12:15 AM 1,334 views

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.

0
Alf Olsen
On 10/22/18, 3:18 AM

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)

0
Sunny Dev
On 2/10/18, 3:55 AM

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

0
ayman mohammed adam
On 1/21/18, 9:43 AM

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



0

NIKHIL KRISHNAN

--NIKHIL KRISHNAN--
--NIKHIL KRISHNAN--

-- Nikhilkrishnan --

Exploring new ways in odoo..!
And want to become a key to the new odoo trends.

-> Odoo Consultancy,
-> Functional and Technical Consultant,
-> Requirement Collection and Analysis,
-> Module Customization,
-> Odoo ERP Community Contributor,
-> Handling ERP/Odoo projects,
-> ERP Workshop Facilitator.
Feel happy working with best and good supporting team.

#PITS Family

Nikhil Krishnan

nikhilkrishnan0101@gmail.com

NIKHIL KRISHNAN
On 1/20/18, 6:54 AM

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.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 1/20/18, 12:15 AM
Seen: 1334 times
Last updated: 10/22/18, 3:18 AM