mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[14.0][ADD] New module web_custom_modifier
[14.0][ADD] New module web_custom_modifier
This commit is contained in:
committed by
Abdellatif Benzbiria
parent
fc63411fa1
commit
3917886453
26
web_custom_modifier/models/common.py
Normal file
26
web_custom_modifier/models/common.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# © 2023 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
|
||||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
|
||||
|
||||
from typing import List, Mapping
|
||||
|
||||
|
||||
def set_custom_modifiers_on_fields(modifiers: List[dict], fields: Mapping[str, dict]):
|
||||
_hide_selection_items(modifiers, fields)
|
||||
|
||||
|
||||
def _hide_selection_items(modifiers, fields):
|
||||
hidden_items = (
|
||||
m
|
||||
for m in modifiers
|
||||
if m["type_"] == "field" and m["modifier"] == "selection_hide"
|
||||
)
|
||||
for item in hidden_items:
|
||||
_hide_single_selection_item(item, fields)
|
||||
|
||||
|
||||
def _hide_single_selection_item(modifier, fields):
|
||||
field = fields.get(modifier["reference"])
|
||||
if field and "selection" in field:
|
||||
field["selection"] = [
|
||||
(k, v) for k, v in field["selection"] if k != modifier["key"]
|
||||
]
|
||||
Reference in New Issue
Block a user