diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/mail/models/ir_model_fields.py | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/mail/models/ir_model_fields.py')
| -rw-r--r-- | addons/mail/models/ir_model_fields.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/addons/mail/models/ir_model_fields.py b/addons/mail/models/ir_model_fields.py new file mode 100644 index 00000000..e2bed7af --- /dev/null +++ b/addons/mail/models/ir_model_fields.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import fields, models + + +class IrModelField(models.Model): + _inherit = 'ir.model.fields' + + tracking = fields.Integer( + string="Enable Ordered Tracking", + help="If set every modification done to this field is tracked in the chatter. Value is used to order tracking values.", + ) + + def _reflect_field_params(self, field, model_id): + """ Tracking value can be either a boolean enabling tracking mechanism + on field, either an integer giving the sequence. Default sequence is + set to 100. """ + vals = super(IrModelField, self)._reflect_field_params(field, model_id) + tracking = getattr(field, 'tracking', None) + if tracking is True: + tracking = 100 + elif tracking is False: + tracking = None + vals['tracking'] = tracking + return vals + + def _instanciate_attrs(self, field_data): + attrs = super(IrModelField, self)._instanciate_attrs(field_data) + if attrs and field_data.get('tracking'): + attrs['tracking'] = field_data['tracking'] + return attrs |
