[ADD] web_widget_pattern

This commit is contained in:
Holger Brunn
2024-04-23 17:17:04 +02:00
parent 5f6aa6c566
commit 7a59f5ef4d
33 changed files with 1373 additions and 0 deletions

View File

@@ -0,0 +1 @@
from . import base

View File

@@ -0,0 +1,28 @@
# Copyright 2024 Hunki Enterprises BV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)
from odoo import api, fields, models
class Base(models.AbstractModel):
_inherit = "base"
def _valid_field_parameter(self, field, name):
return super()._valid_field_parameter(field, name) or (
name == "pattern" and isinstance(field, fields.Char)
)
@api.model
def _get_view_field_attributes(self):
return super()._get_view_field_attributes() + ["pattern"]
@api.model
def fields_get(self, allfields=None, attributes=None):
result = super().fields_get(allfields=allfields, attributes=attributes)
if attributes is None or "pattern" in attributes:
for field_name, description in result.items():
field = self._fields.get(field_name)
pattern = getattr(field, "pattern", None)
if pattern is not None:
description["pattern"] = pattern
return result