Development Book V17:Dynamic record stages

Stages define the current status of records, typically static and unmodifiable. To introduce flexibility, many2one fields are utilized, enabling the modification and creation of new states. This functionality is exemplified through practical examples, illustrating its implementation and utility.

To independently handle stages, let's establish a new model.

 class DynamicStages(models.Model):
   _name = "dynamic.stages"
   _rec_name = 'name'
   name = fields.Char(string='Name')
   sequence = fields.integer(string='Sequence')
   fold = fields.Boolean(string='Folded in Kanban')
   name = fields.Char(string='Sequence')

This model should be incorporated into the essential parent model through a many2one relationship.

 def _get_stage_id(self):
   dynamic_stages = self.env['dynamic.stages'].search([], limit=1)
stage_id = fields.Many2one('dynamic.stages', string="Dynamic State", default='_get_stage_id', readonly=True,
                          required=True, help="Employee")

Now this field can be added to the view as the following;

<header >
    <field name="stage_id" widget="statusbar" options="{'clickable': '1', 'fold_field': 'fold'}"/ >
</header >

After declaring the fields accordingly, stages can be altered and organized. This allows for the manipulation of stage definitions.



Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635



Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.



Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message