Hello everyone,
Another newbie question related to Odoo v12.
I need to get the current fields values while creating a new record (create method).
Since I am having some problems doing it and could not find any solution, I am trying to use a global variable for this. The global variable (var_field_value) is set on the top of the module.py outside all classes.
I have tried to use "self.field_name" on create method and it is not working. For instance:
var_field_value = 0
class test (models.Model):
field_name = fields.Integer('Field Value')
On the form view for the class, I enter any integer value to the field_name field.
If I print the field value on the on_change method, I can see the value is there and I can set this value to my global variable:
@api.onchange('field_name')
def onchange_field_name(self):
print(self.field_name)
var_field_value = self.field_name
print(var_field_value)
Until this point, everything runs fine.
Now, on Create method, if I print both "self.field_name" and "var_field_value", the values are 0 for both.
@api.model
def create(self, vals):
print(var_field_value)
print(self.field_name)
...
So, I can see the variable and field values on on_change event, but I cannot see them on create method.
How can I get the current field values on create method?
Thank you in advance
Odoo Methods (Create, Write, Unlink): http://learnopenerp.blogspot.com/2017/11/how-to-override-odoo-functions.html