hello all,
Please help overcome this issue I can not get context value
@api.model
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
# Call the super method to get the base view structure
res = super(HrEmployeePrivate, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar,
submenu=submenu)
if view_type == 'form':
# Ensure the branch category is correctly set in the context
rec = self.env['flex.branch'].search([('id', 'in', self.branch_name_id.ids)]).ids
branch_cate = self.branch_name_id.branch_cate if self.branch_name_id else "tttttt"
# Add branch category to the context
print('the value is :', rec)
self = self.sudo().with_context(bra_class=branch_cate)
# Retrieve the value from the context
bra_class_value = self._context.get('bra_class', 'لايوجد') # Default to 'لايوجد' if not found
print("Context Value for 'bra_class':", bra_class_value)
# Iterate through fields in the view
for field_name, field_data in res.get('fields', {}).items():
if field_name == 'job_ids':
# Dynamically set the domain for the field
field_data['domain'] = [
'|',
('company_id', '=', False),
('company_id', '=', self.env.user.company_id.id),
('bra_class', '=', bra_class_value) # Use the context value dynamically
]
return res