Search code examples
pythonodooodoo-11

After inherit abstract model 'mail.activity.mixin' parent model 'crm.lead' cannot save data


I have created a new class to inherit abstract model 'mail.activity.mixin' but after using the parent class crm.lead cannot store data. I couldn't do it. Can anyone please tell me how can I do it. Here is my code

class forcaMailMixin(models.AbstractModel):
    _inherit = 'mail.activity.mixin'

    @api.multi
    def write(self, vals):
        check_undone = self.env['mail.activity'].sudo().search(
                        [('res_model', '=', self._name), ('res_id', 'in', self.ids), ('status', '!=', 1)] ,order = 'create_date desc', limit=1)
        if check_undone :
            value = {
                'activity_date_deadline' : check_undone.date_deadline,
                'activity_summary' : check_undone.summary
            }
        else :
             value = {
                'activity_date_deadline' : "",
                'activity_summary' : ""
            }
        return super(forcaMailMixin, self).write(value)

Solution

  • You've overridden the write values. So the original values never get into the super calls, where the magic is happening (the write to db).

    So you should update the original values right before the super call at the end:

    vals.update(value)
    return super(forcaMailMixin, self).write(vals)