Skip to Content
Menu
This question has been flagged
2 Replies
1454 Views

I wanna asked why it delete all the Done(True) users in this code, it inherits the function from the parent module and override the function. I thought the function of child module will only delete the current user

====Child Module====

​# -*- coding: utf-8 -*-

from odoo import fields,models,api

class TodoTask(models.Model):
_inherit = 'todo.task'

name = fields.Char(help='What needs to be done?')
user_id = fields.Many2one('res.users','Responsible')
date_deadline = fields.Date('Deadline')

@api.multi
def do_clear_done(self):
domain = [('is_Done', '=', True),
'|', ('user_id', '=', self.env.uid),
('user_id', '=', False)]
dones = self.search(domain)
dones.write({'active': False})
return True

====Parent Module==== 

# -*- coding: utf-8 -*-
from odoo import models,fields,api

class TodoTask(models.Model):
_name = 'todo.task'
_descrption = 'To-Do Task'

name = fields.Char('Description' , required=True)
is_Done = fields.Boolean('Done?')
active = fields.Boolean('Active?',default=True)

@api.multi
def do_toggle_done(self):
for task in self:
task.is_Done = not task.is_Done
return True

@api.multi
def do_clear_done(self):
dones = self.search([('is_Done','=',True)])
dones.write({'active':False})
return True 

Thank u in advance :)

Avatar
Discard
Best Answer

Hi MaryChan,

I don't see any code deleting the users. But I see the code which is de-activating (active=False) the Done Tasks:  dones.write({'active':False}) 

Avatar
Discard
Author Best Answer

Hi sudhir, ahm when I CLicked the clear all button, the user where the done is checked was disappeared and I thought that the extended function of do_clear_done is removing only the specific user.

Avatar
Discard

No. It does not remove the users but it de-activate the task as I said.

Related Posts Replies Views Activity
1
Aug 24
421
2
Nov 24
751
3
Oct 23
13195
2
Feb 23
1229
1
Dec 22
1371