Commit Graph

19 Commits

Author SHA1 Message Date
Andrius Laukavičius 3cc06abfb6 [FIX] server_environment: default field label
If related field is not directly set (coming from inheritance) or string
label is not specified explicitly, it might not have it in `args`,
making it generate same default field labels, causing warnings in odoo.

Before this change you could get these kind of warnings:

```
2023-09-23 13:28:39,638 1 WARNING odoodb odoo.addons.base.models.ir_model:
Two fields (field1_env_default, field2_env_default) of your.model() have
the same label:  Env Default.
```
It would generate multiple fields having same label.
2023-09-23 16:32:29 +03:00
Simone Orsi cee6ff990e server_env: fix inverse method (closes #151)
``odoo.fields.determine`` requires inverse methods to have ``__name__`` attribute.
Unfortunately with ``partialmethod`` this attribute is not propagated
even by using ``functools.update_wrapper``.
In any case, `update_wrapper` would propagate the wrapped func name
which is not the same here.

Introduced by 36544651f2
2023-04-04 14:53:05 +02:00
Ivàn Todorovich c1ddf6bca3 [IMP] server_environment: don't print stack trace when the field can't be read 2022-10-20 08:44:15 +02:00
Simone Orsi 4ca6a71777 server_environment: do not copy tech_name 2022-10-18 15:03:24 +02:00
Guewen Baconnier 9ff914d3f2 Remove required from tech_name mixin
In some cases, we want to use a tech_name, but we do not use server
environment on all the records, so tech_name should not be required.
2022-10-18 15:03:19 +02:00
Adrien Peiffer 88755516a2
server_environment: Update default fields label
this to avoid Odoo warning messages on labels check
2022-03-28 13:47:25 +02:00
jsanchez d10f987249 [FIX] Update server_env_mixin.py to avoid NoneType error 2021-10-27 14:25:57 +02:00
jsanchez dfad546839 [MIG] server_environment: migration to 15.0 2021-10-22 13:03:14 +02:00
Ivàn Todorovich 03012cfd41 [UPD] Change LICENSE to LGPL 2021-10-22 13:03:14 +02:00
Mourad f517ff7d56 [IMP] : black, isort, prettier 2021-10-22 13:03:14 +02:00
Simone Orsi 3b8900773a Add mixin for tech name 2021-10-22 13:03:14 +02:00
Denis Roussel 814170f8c3 [13.0][FIX] server_environment: Change import for Serialized field 2021-10-22 12:35:41 +02:00
Stéphane Bidoul (ACSONE) 3e14d18801 pre-commit, black, isort 2021-10-22 12:35:41 +02:00
Akim Juillerat 7a733042b3 server-environment: Run pre-commit 2021-10-22 12:35:41 +02:00
Stéphane Bidoul (ACSONE) 9cba48fbd3 pre-commit, black, isort 2021-10-22 12:35:41 +02:00
Akim Juillerat 43211b691a Rename file to attend TODO comment 2021-10-22 12:35:41 +02:00
Akim Juillerat 9947d64d1e [MIG] server_environment: Migration to 13.0 2021-10-22 12:35:41 +02:00
Stéphane Bidoul (ACSONE) 86355fa54a [MIG] server_environment from 11 to 12 2021-10-22 12:35:41 +02:00
Guewen Baconnier d16a7dd027 Add SERVER_ENV_CONFIG to configure vars from env. variable
Add SERVER_ENV_CONFIG_SECRET alongside SERVER_ENV_CONFIG

Allows to isolate the secrets in your deployment

Improve documentation regarding variables

Add a server environment mixin

To automatically convert fields into fields reading values from the
environment. Until now, every module reimplements the same computed
field.

Read default values from database when no config is provided

Automatically add <field_name>_env_default for every field transformed
to a "computed from env" field, so a default value can be set. It will
be used when the configuration is not set in a configuration file
(when the key is absent, not empty).

Allow to edit default values for env-computed fields

When they don't have any key in the environment configuration files.
In the UI, when a field is set in a configuration file, the field is
readonly, if not the field is editable. Which means you can selectively
choose which fields depend on the environment and which can use a
"default" value stored in database.

Fix a few small issues in mixin

Use a dictionary to configure the fields

Add global section

Disable prefetch on env-computed fields

As in the inverse field that write the value into the <field>_env_default
we have to browse the record, the prefetch has the effect of calling
compute on the env-computed field which resets the value to it's
previous state before we have the occasion to store it.

Use global section name as first part of the section

Allow to edit all fields on creation

Make server_environment_files optional

Allow integration with keychain

By adding options to change the compute and inverse methods for default
fields

Update documentation of server_environment, bump

Add SERVER_ENV_CONFIG_SECRET alongside SERVER_ENV_CONFIG

Allows to isolate the secrets in your deployment

Reinforce server_environment base tests

Add tests for the server env mixin

Infer configparser getter from field type

Fixes for review feedbacks

Add tests and support of _inherits

Use SavepointCase instead of TransactionCase

It means less records to create for each test

Fix iteration on records
2021-10-22 12:35:41 +02:00