mirror of
https://github.com/bringout/oca-ocb-core.git
synced 2026-04-20 11:12:05 +02:00
19.0 vanilla
This commit is contained in:
parent
d1963a3c3a
commit
2d3ee4855a
7430 changed files with 2687981 additions and 2965473 deletions
|
|
@ -400,7 +400,8 @@ def _setup(model_cls: type[BaseModel], env: Environment):
|
|||
if not company_dependent:
|
||||
# validate column type again in case the column type is changed by upgrade script
|
||||
rows = env.execute_query(sql.SQL(
|
||||
'SELECT data_type FROM information_schema.columns WHERE table_name = %s AND column_name = %s',
|
||||
'SELECT data_type FROM information_schema.columns'
|
||||
' WHERE table_name = %s AND column_name = %s AND table_schema = current_schema',
|
||||
model_cls._table, name,
|
||||
))
|
||||
if rows and rows[0][0] == 'jsonb':
|
||||
|
|
@ -560,7 +561,8 @@ def _add_manual_models(env: Environment):
|
|||
""" SELECT a.attname
|
||||
FROM pg_attribute a
|
||||
JOIN pg_class t ON a.attrelid = t.oid AND t.relname = %s
|
||||
WHERE a.attnum > 0 -- skip system columns """,
|
||||
WHERE a.attnum > 0 -- skip system columns
|
||||
AND t.relnamespace = current_schema::regnamespace """,
|
||||
[table_name]
|
||||
)
|
||||
columns = {colinfo[0] for colinfo in env.cr.fetchall()}
|
||||
|
|
@ -594,7 +596,7 @@ def add_field(model_cls: type[BaseModel], name: str, field: Field):
|
|||
isinstance(getattr(model, name, None), fields.Field)
|
||||
for model in [model_cls] + [model_cls.pool[inherit] for inherit in model_cls._inherits]
|
||||
)
|
||||
if not (is_class_field or name.startswith('x_')):
|
||||
if not (is_class_field or model_cls.pool['ir.model.fields']._is_manual_name(None, name)):
|
||||
raise ValidationError( # pylint: disable=missing-gettext
|
||||
f"The field `{name}` is not defined in the `{model_cls._name}` Python class and does not start with 'x_'"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue