This question has been flagged
1 Reply
3583 Views

Good Day everyone, I have a question again, I really have some hard time in understanding some odoo features. Ahm, how can i update this field min_date from stock.picking to field strength_date. I like that is the min_date value will be updated on the force date value. Force date and min date both from another model and the min_date is readonly.

from odoo import fields, models,


class Picking (models.Model):
_inherit = 'stock.picking'

force_date = fields.Datetime ('Put Dates')
min_date = fields.Datetime ('Please Change')


@ api.multi
def write (self, vals):
record = super (Picking, self) .write (vals)
print ("Test the Edit Button")
record ['min_date'] = self.force_date
print ("hello" + record)
return record

First, I try the self.min_date = self.force_date then it has an error 

"RuntimeError: maximum recursion depth exceeded"


I just want to know the function is working and what is the value of the object so i used print.  Then this code give me the error about 

TypeError: 'bool' object does not support item assignment


then I used record [min_date] = self.force_date and I have this

 File "C: \ projects \ odoo-rmd \ stock_force_date_extend \ models \ stocks.py", line 15, in write
    record [min_date] = self.force_date
NameError: global name 'min_date' is not defined
​​

Avatar
Discard
Best Answer

Hi,

Please try this code,

@api.multi
def write(self, vals):
vals['min_date'] = self.force_date
record = super(ClassName, self).write(vals)
return record

Thanks

Avatar
Discard