@@ -28,19 +28,19 @@ def check_substate_id_value(self):
2828 }
2929 )
3030
31- def _track_template (self , changes ):
32- res = super ()._track_template (changes )
33- track = self [0 ]
34- if "substate_id" in changes and track .substate_id .mail_template_id :
31+ def _track_template (self , tracking ):
32+ res = super ()._track_template (tracking )
33+ first_rec = self [0 ]
34+ changes , tracking_value_ids = tracking [first_rec .id ]
35+ if "substate_id" in changes and first_rec .substate_id .mail_template_id :
3536 res ["substate_id" ] = (
36- track .substate_id .mail_template_id ,
37+ first_rec .substate_id .mail_template_id ,
3738 {
38- "composition_mode" : "comment" ,
39- "auto_delete" : True ,
40- "subtype_id" : self .env ["ir.model.data" ]._xmlid_to_res_id (
39+ "auto_delete_message" : True ,
40+ "subtype_id" : self .env ["ir.model.data" ].xmlid_to_res_id (
4141 "mail.mt_note"
4242 ),
43- "email_layout_xmlid " : "mail.mail_notification_light" ,
43+ "notif_layout " : "mail.mail_notification_light" ,
4444 },
4545 )
4646 return res
@@ -72,17 +72,13 @@ def _get_default_substate_domain(self, state_val=False):
7272 ]
7373 return domain
7474
75- def _get_default_state_value (
76- self ,
77- ):
75+ def _get_default_state_value (self ):
7876 """Override this method
7977 to change state_value
8078 """
8179 return "draft"
8280
83- def _get_substate_type (
84- self ,
85- ):
81+ def _get_substate_type (self ):
8682 """Override this method
8783 to change substate_type (get by xml id for example)
8884 """
@@ -95,18 +91,18 @@ def _get_substate_type(
9591 string = "Sub State" ,
9692 ondelete = "restrict" ,
9793 default = lambda self : self ._get_default_substate_id (),
98- tracking = 5 ,
9994 index = True ,
10095 domain = lambda self : [("model" , "=" , self ._name )],
10196 copy = False ,
97+ tracking = True , # Add tracking parameter here
10298 )
10399
104100 @api .constrains ("substate_id" )
105101 def check_substate_id_consistency (self ):
106102 for mixin_obj in self :
107103 if mixin_obj .substate_id and mixin_obj .substate_id .model != self ._name :
108104 raise ValidationError (
109- _ ("This substate is not define for this object but for %s" )
105+ _ ("This substate is not defined for this object but for %s" )
110106 % mixin_obj .substate_id .model
111107 )
112108
@@ -129,3 +125,9 @@ def create(self, vals_list):
129125 vals = self ._update_before_write_create (vals )
130126 res = super ().create (vals_list )
131127 return res
128+
129+ @classmethod
130+ def _valid_field_parameter (cls , field , name ):
131+ if name == "tracking" :
132+ return True
133+ return super ()._valid_field_parameter (field , name )
0 commit comments