prev_stage_name = fields.Char(string='stage previuos', store=True, default=False, compute='_compute_prev_stage_id')
@api.depends('stage_id')
def _compute_prev_stage_id(self):
for record in self:
record.prev_stage_name = record._origin.stage_id.name if record._origin else False
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
1
Reply
825
Views
Hi,
For this you can inherit the write method of the corresponding model and from it, you can update the value of prev_stage_name field whenever a new value is updated to the stage_id field.
Sample code:
def write(self, vals):
if 'stage_id' in vals:
vals['prev_stage_name'] = self.stage_id.name
return super(CRMLead, self).write(vals)
Thanks