Skip to content
Extraits de code Groupes Projets
Valider a1f06b1f rédigé par Benjamin - Le Filament's avatar Benjamin - Le Filament
Parcourir les fichiers

[UPD] context view for timsheet

Merge branch '14-RV-20240407' into '14.0'

Utilisation du context pour cacher les colonnes financement régional

See merge request !11
parents 331014f7 1c7a0d72
Branches
Aucune étiquette associée trouvée
1 requête de fusion!11Utilisation du context pour cacher les colonnes financement régional
...@@ -253,3 +253,23 @@ class ScopHrTimesheet(models.Model): ...@@ -253,3 +253,23 @@ class ScopHrTimesheet(models.Model):
"default_name": self[0].name if len(self) == 1 else "", "default_name": self[0].name if len(self) == 1 else "",
}, },
} }
# ------------------------------------------------------
# Modification du context pour cacher les colonnes
# ------------------------------------------------------
@api.model
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
custom_context = self.env.context.copy()
current_ur_id = self.env.context['current_ur_id']
nbfs = self.env["ur.financial.system"].search([("ur_id", "=", current_ur_id)])
if len(nbfs) == 0:
custom_context['hide_financial_system'] = True
nbrc = self.env["ur.regional.convention"].search([("ur_id", "=", current_ur_id)])
if len(nbrc) == 0:
custom_context['hide_regional_convention'] = True
res = super(ScopHrTimesheet, self.with_context(custom_context)).fields_view_get(
view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu)
return res
...@@ -272,12 +272,14 @@ ...@@ -272,12 +272,14 @@
<field <field
name="ur_financial_system_id" name="ur_financial_system_id"
options="{'no_open': True, 'no_create': True}" options="{'no_open': True, 'no_create': True}"
attrs="{'required': [('ur_financial_system_nb', '>', 0)], 'invisible': [('ur_financial_system_nb', '&lt;', 1)], 'readonly': [('state', 'in', ('submit', 'valid'))]}" invisible="context.get('hide_financial_system')"
attrs="{'required': [('ur_financial_system_nb', '>', 0)], 'readonly': [('state', 'in', ('submit', 'valid'))]}"
/> />
<field <field
name="ur_regional_convention_id" name="ur_regional_convention_id"
options="{'no_open': True, 'no_create': True}" options="{'no_open': True, 'no_create': True}"
attrs="{'required':[('ur_regional_convention_nb', '>', 0)], 'invisible':[('ur_regional_convention_nb', '&lt;', 1)], 'readonly': [('state', 'in', ('submit', 'valid'))]}" invisible="context.get('hide_regional_convention')"
attrs="{'required':[('ur_regional_convention_nb', '>', 0)], 'readonly': [('state', 'in', ('submit', 'valid'))]}"
/> />
<field <field
name="justificatifs" name="justificatifs"
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter