oca / server-env Goto Github PK
View Code? Open in Web Editor NEWTools to manage environment-dependent configuration
License: GNU Affero General Public License v3.0
Tools to manage environment-dependent configuration
License: GNU Affero General Public License v3.0
Hi there,
is there any way to fallback mail_environment
in prod env to database smpt values?
What's needed it that if [outgoing_email]
section is not found, it should use the smtp defined in database; so that setting running_env=prod
and not defining any [outgoing_email]
it will use the one set into database.
Actually it seems that it set all smtp values to False
instead of getting the one in the database.
Am i missing something? Is there anyway to do?
Thx
https://github.com/OCA/maintainer-tools/wiki/Migration-to-version-13.0
Missing module? Check https://github.com/OCA/maintainer-tools/wiki/%5BFAQ%5D-Missing-modules-in-migration-issue-list
https://github.com/OCA/maintainer-tools/wiki/Migration-to-version-14.0
Missing module? Check https://github.com/OCA/maintainer-tools/wiki/%5BFAQ%5D-Missing-modules-in-migration-issue-list
The module server_environment
is checking if it is configured correctly:
server-env/server_environment/serv_config.py
Lines 49 to 60 in 7d6ebde
Even if it is not installed.
The following PR:
It has github statuses in red because of this warning in runbot log.
IMHO the modules don't should be checked if it is correctly configured since that it is not installed.
It should be checked from a hook
directly since it is executed only if the module is installed so the warning could be valid.
A refactoring done in odoo here odoo/odoo@3654465 which breaks server_env because the partial method cannot be inspected https://github.com/OCA/server-env/blob/14.0/server_environment/models/server_env_mixin.py#L335
Error:
2023-04-04 06:33:21,973 895 CRITICAL odoo odoo.service.server: Failed to initialize database `odoo`.
Traceback (most recent call last):
File "/opt/odoo/odoo/tools/convert.py", line 677, in _tag_root
f(rec)
File "/opt/odoo/odoo/tools/convert.py", line 580, in _tag_record
record = model._load_records([data], self.mode == 'update')
File "/opt/odoo/odoo/models.py", line 4241, in _load_records
records = self._load_records_create([data['values'] for data in to_create])
File "/opt/odoo/odoo/models.py", line 4157, in _load_records_create
return self.create(values)
File "<decorator-gen-119>", line 2, in create
File "/opt/odoo/odoo/api.py", line 348, in _model_create_multi
return create(self, arg)
File "/opt/odoo-venv/lib/python3.6/site-packages/odoo/addons/component_event/models/base.py", line 102, in create
records = super(Base, self).create(vals_list)
File "<decorator-gen-64>", line 2, in create
File "/opt/odoo/odoo/api.py", line 348, in _model_create_multi
return create(self, arg)
File "/opt/odoo/odoo/addons/base/models/ir_fields.py", line 534, in create
recs = super().create(vals_list)
File "<decorator-gen-13>", line 2, in create
File "/opt/odoo/odoo/api.py", line 348, in _model_create_multi
return create(self, arg)
File "/opt/odoo/odoo/models.py", line 3919, in create
fields[0].determine_inverse(batch_recs)
File "/opt/odoo/odoo/fields.py", line 1207, in determine_inverse
determine(self.inverse, records)
File "/opt/odoo/odoo/fields.py", line 81, in determine
if needle.__name__.find('__'):
AttributeError: 'functools.partial' object has no attribute '__name__'
Issue reported odoo/odoo#117559
Tested on v12.
When install mail_environment it change de constraints on the table. For insance smtp_host is no more required.
It can lead to smtp_host value not set and if you update base module then it fails to apply a sql constraint.
Fresh install of odoo.
\d ir_mail_server
Table "public.ir_mail_server"
Column | Type | Collation | Nullable | Default
-----------------+-----------------------------+-----------+----------+--------------------------------------------
id | integer | | not null | nextval('ir_mail_server_id_seq'::regclass)
name | character varying | | not null |
smtp_host | character varying | | not null |
smtp_port | integer | | not null |
smtp_user | character varying | | |
smtp_pass | character varying | | |
smtp_encryption | character varying | | not null |
smtp_debug | boolean | | |
sequence | integer | | |
active | boolean | | |
create_uid | integer | | |
create_date | timestamp without time zone | | |
write_uid | integer | | |
write_date | timestamp without time zone | | |
Install mail_environment
\d ir_mail_server
Table "public.ir_mail_server"
Column | Type | Collation | Nullable | Default
---------------------+-----------------------------+-----------+----------+--------------------------------------------
id | integer | | not null | nextval('ir_mail_server_id_seq'::regclass)
name | character varying | | not null |
smtp_host | character varying | | |
smtp_port | integer | | |
smtp_user | character varying | | |
smtp_pass | character varying | | |
smtp_encryption | character varying | | |
smtp_debug | boolean | | |
sequence | integer | | |
active | boolean | | |
create_uid | integer | | |
create_date | timestamp without time zone | | |
write_uid | integer | | |
write_date | timestamp without time zone | | |
server_env_defaults | text | | |
[EDIT] rewrited to be more precise
If I install "Mail configuration with server_environment" this addons,
than create a new database , and install "discuss" or other about "mail" fuction addons,
will get this error.
Mail configuration with server_environment
`..............
odoo.tools.convert.ParseError: while parsing /opt/odoo16/addons/mail/views/fetchmail_views.xml:88
.........:
.. 'is_ssl' ..... 'is_ssl' ๅจ domain of ([('is_ssl', '=', True)]))
View error context:
{'file': '/opt/odoo16/addons/mail/views/fetchmail_views.xml',
'line': 8,
'name': 'fetchmail.server.search',
'view': ir.ui.view(291,),
'view.model': 'fetchmail.server',
'view.parent': ir.ui.view(),
'xmlid': 'view_email_server_search'}
The above server error caused the following client error:
RPC_ERROR: Odoo Server Error
at makeErrorFromResponse (http://192.168.99.99:8069/web/assets/196-482f5bd/web.assets_backend.min.js:985:163)
at XMLHttpRequest. (http://192.168.99.99:8069/web/assets/196-482f5bd/web.assets_backend.min.js:993:13)`
Affected versions:
Steps to reproduce the behavior:
1.install "Mail configuration with server_environment".
2.Create a new database.
3.Login in new DB and install "discuss" or other about "mail" fuction addons
Additional context
UBUNTU 22.04
ODOO 16
This PR seems to solve one issue, but there's another one in runboat
odoo.exceptions.ValidationError: No 'encryption_key_test' entry found in config file. Use a key similar to: b'lUMc38soCfqymcvsJdsXYAB_DQGZozQQYPYHOZ2PZik='
Seems related to server_environment_data_encryption
module. Do you have any idea what could be wrong?
@florian-dacosta @sebastienbeau
2022-04-27 11:56:32,531 77 INFO b7b3579b4-0fcf-4ca0-8b98-4b272b74d91e odoo.modules.loading: loading payment_transfer/data/payment_acquirer_data.xml
2022-04-27 11:56:32,541 77 WARNING b7b3579b4-0fcf-4ca0-8b98-4b272b74d91e odoo.modules.loading: Transient module states were reset
2022-04-27 11:56:32,541 77 ERROR b7b3579b4-0fcf-4ca0-8b98-4b272b74d91e odoo.modules.registry: Failed to load registry
2022-04-27 11:56:32,541 77 CRITICAL b7b3579b4-0fcf-4ca0-8b98-4b272b74d91e odoo.service.server: Failed to initialize database `b7b3579b4-0fcf-4ca0-8b98-4b272b74d91e`.
Traceback (most recent call last):
File "/opt/odoo/odoo/tools/convert.py", line 677, in _tag_root
f(rec)
File "/opt/odoo/odoo/tools/convert.py", line 580, in _tag_record
record = model._load_records([data], self.mode == 'update')
File "/opt/odoo/odoo/models.py", line 4220, in _load_records
data['record']._load_records_write(data['values'])
File "/opt/odoo/odoo/models.py", line 4149, in _load_records_write
self.write(values)
File "/opt/odoo/addons/payment_transfer/models/payment.py", line 68, in write
return super(TransferPaymentAcquirer, self).write(values)
File "/opt/odoo/addons/payment/models/payment_acquirer.py", line 335, in write
result = super(PaymentAcquirer, self).write(vals)
File "/mnt/data/odoo-addons-dir/server_environment/models/server_env_tech_name_mixin.py", line 66, in write
return super().write(vals)
File "/opt/odoo/odoo/models.py", line 3703, in write
fields[0].determine_inverse(real_recs)
File "/opt/odoo/odoo/fields.py", line 1187, in determine_inverse
getattr(records, self.inverse)()
File "/mnt/data/odoo-addons-dir/server_environment_data_encryption/models/server_env_mixin.py", line 50, in _inverse_server_env
encrypted_data_name, values, env=env
File "/mnt/data/odoo-addons-dir/data_encryption/models/encrypted_data.py", line 145, in _encrypted_store_json
return self._encrypted_store(name, json.dumps(json_data), env=env)
File "/mnt/data/odoo-addons-dir/data_encryption/models/encrypted_data.py", line 132, in _encrypted_store
encrypted_data = self._encrypt_data(data, env)
File "/mnt/data/odoo-addons-dir/data_encryption/models/encrypted_data.py", line 119, in _encrypt_data
cipher = self._get_cipher(env)
File "/mnt/data/odoo-addons-dir/data_encryption/models/encrypted_data.py", line 111, in _get_cipher
% (key_name, Fernet.generate_key())
odoo.exceptions.ValidationError: No 'encryption_key_test' entry found in config file. Use a key similar to: b'lUMc38soCfqymcvsJdsXYAB_DQGZozQQYPYHOZ2PZik='
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/odoo/odoo/service/server.py", line 1199, in preload_registries
registry = Registry.new(dbname, update_module=update_module)
File "/opt/odoo/odoo/modules/registry.py", line 89, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/opt/odoo/odoo/modules/loading.py", line 461, in load_modules
loaded_modules, update_module, models_to_check)
File "/opt/odoo/odoo/modules/loading.py", line 349, in load_marked_modules
perform_checks=perform_checks, models_to_check=models_to_check
File "/opt/odoo/odoo/modules/loading.py", line 222, in load_module_graph
load_data(cr, idref, mode, kind='data', package=package)
File "/opt/odoo/odoo/modules/loading.py", line 69, in load_data
tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind)
File "/opt/odoo/odoo/tools/convert.py", line 733, in convert_file
convert_xml_import(cr, module, fp, idref, mode, noupdate)
File "/opt/odoo/odoo/tools/convert.py", line 799, in convert_xml_import
obj.parse(doc.getroot())
File "/opt/odoo/odoo/tools/convert.py", line 719, in parse
self._tag_root(de)
File "/opt/odoo/odoo/tools/convert.py", line 677, in _tag_root
f(rec)
File "/opt/odoo/odoo/tools/convert.py", line 685, in _tag_root
)) from e
odoo.tools.convert.ParseError: while parsing /opt/odoo/addons/payment_transfer/data/payment_acquirer_data.xml:5, near
<record id="payment.payment_acquirer_transfer" model="payment.acquirer">
<field name="name">Wire Transfer</field>
<field name="image_128" type="base64" file="payment_transfer/static/src/img/transfer_icon.png"/>
<field name="provider">transfer</field>
<field name="state">enabled</field>
<field name="company_id" ref="base.main_company"/>
<field name="view_template_id" ref="transfer_form"/>
<field name="pending_msg">
<h3>Please make a payment to: </h3>
<ul>
<li>Bank:&nbsp;</li>
<li>Account Number:</li>
<li>Account Holder: </li>
</ul>
</field>
</record>
Originally posted by @ivantodorovich in #109 (comment)
TODO:
Using server_environment with stored writeable computed fields does not work as one would intuitively expect.
Consider this example:
class MyModel(models.Model):
_name = "my.model"
_inherit = "server.env.mixin"
name = fields.Char(required=True)
uppercase_name = fields.Char(compute="_compute_uppercase_name", store=True, readonly=False)
@property
def _server_env_fields(self):
return {"uppercase_name": {"compute_default": "_compute_uppercase_name"}}
@api.depends("name")
def _compute_uppercase_name(self):
for rec in self:
rec.uppercase_name = rec.name.upper()
>> rec = self.env["my.model"].create({"name": "John"})
>> rec.uppercase_name
'JOHN'
>> rec.name = "Jacob"
>> rec.uppercase_name
'JOHN'
server_environment
does its magic by transforming all _server_env_fields
into computed fields. But by doing so, it means regular computed fields can't be used like this.
One needs to be careful to avoid this, specially when adding server_environment support on core models and with the fact that stored writeable computed fields are gaining popularity as they're used as a replacement for onchanges.
https://github.com/OCA/maintainer-tools/wiki/Migration-to-version-16.0
Missing module? Check https://github.com/OCA/maintainer-tools/wiki/%5BFAQ%5D-Missing-modules-in-migration-issue-list
server-env/server_environment/serv_config.py", line 50, in <module>
"The parameter 'running_env' has not be set neither in base config "
Exception: The parameter 'running_env' has not be set neither in base config file option -c or in openerprc.
We strongly recommend against using the rc file but instead use an explicit config file with this content:
[options]
running_env = dev
I get the point that the additional configuration is very important.
But does it justify preventing the service from starting?
I think this would be a log message, rather than a error with a traceback.
Hi,
Is it possible to override parameters in default odoo.conf?
config/odoo.conf:
[options]
running_env=dev
addons_path = /mnt/extra-addons,/mnt/_lib
...
addons/server_envronment_files/dev/odoo.conf
[options]
admin_passwd = asdf
[ir.config_parameter]
ribbon.name = ASDF
docker-compose.yml using .env
version: '2'
services:
web:
restart: always
image: gymbeam/odoo13-gb
command: ${COMMAND}
depends_on:
- db
ports:
- "${HTTP_PORT}:8069"
- "${LONGPOLLING_PORT}:8072"
volumes:
- odoo-web-data:/var/lib/odoo
- ./addons:/mnt/extra-addons
- ./addons/_lib:/mnt/_lib
- ./config:/etc/odoo
- ./backups:/var/tmp
db:
restart: always
image: postgres:10
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- PGDATA=/var/lib/postgresql/data/pgdata
volumes:
- odoo-db-data:/var/lib/postgresql/data/pgdata
pgadmin:
image: dpage/pgadmin4
restart: always
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD}
PGADMIN_LISTEN_PORT: 80
ports:
- "${PGADMIN_PORT}:80"
volumes:
- pgadmin-data:/var/lib/pgadmin
links:
- "db:pgsql-server"
volumes:
odoo-web-data:
odoo-db-data:
pgadmin-data:
Setting ir.config_parameter is working fine, but basic odoo.conf parameters are not working at all.
Am I doing something wrong?
Thanks!
Hi
I try to install the modules by pip. For example, odoo14-addon-server-environment. But I always get the error.
Many modules related to odoo. I have tested odoo14-addon-server-environment, odoo11-addon-account-payment-partner, etc.
When I use the command "pips install odoo14-addon-server-environment", I get the error.
Expected behavior
In my opinion, the error is related to the version constraint for odoo. The odoo<14.1dev and >=14.0a can not be satisfied. Maybe changing the version constraint for odoo will fix the installation error.
Fetchmail for Microsoft has some additional fields that need supported in order to utilize mail_environment in conjunction with fetchmail_outlook.
https://github.com/odoo/odoo/blob/14.0/addons/fetchmail_outlook/models/fetchmail_server.py#L12
Describe the solution you'd like
Would it be possible to allow generic configuration of mail_fields so that additional new fields for what ever fetchmail provider can be supported in the future without further changes to this module.
Describe alternatives you've considered
Since additional fields are not supported the alternative appears to be to disable mail_environment
Additional context
Microsoft is deprecating basic authentication at the end of this year.
https://github.com/OCA/maintainer-tools/wiki/Migration-to-version-15.0
Missing module? Check https://github.com/OCA/maintainer-tools/wiki/%5BFAQ%5D-Missing-modules-in-migration-issue-list
Is your feature request related to a problem?
Today, when a field is made configurable via env you can still edit values manually.
These values are stored into server_env_defaults
.
If you don't have env overrides such values will be used in all envs, which means that by restoring a prod db on staging you might have a prod conf in the wrong place.
This can easily happen when you leave to customers or to consultants the possibility to create new records manually (eg: add a new webservice to call on the fly).
Example of values today:
{"destination_pwd_env_default": "xyz", "destination_url_env_default": "https://send-somewhere.com"}
Describe the solution you'd like
Values from default should be mapped by environment. This way, we can lookup values by specific env.
Example of values in the future:
{
"prod": {
"destination_pwd_env_default": "xyz", "destination_url_env_default": "https://send-somewhere.com"
}
}
Describe alternatives you've considered
Any?
@guewen @gurneyalex @sebalix your input is appreciated :)
Hello,
The module server_environment_ir_config_parameter
depends on server_environment
but does not really use its framework. (it does not use server_env_mixin
).
As a consequence, if I am not mistaken, we can't have a environment dependent value stored in database, like it is possible with server_environment
and as another consequence, the module is not compatible with server_environment_data_encryption
(which allows to have a encrypted environement dependent value stored in the database)
I would like to know if there is a good reason no to depend on server_env_mixin
?
At first sight I have the feeling it would make the module simpler and compatible with server_environment_data_encryption
, but maybe I miss an important point ?
The only thing that would be lost is the is_environment
flag. But it seems it is only usefull to warn the user that the displayed value could be different than the real one (which is in the odoo config file). And AFAIK that would not be the case if we inherit server_env_mixin
because the field become computed/not stored.
If there is no special reason, I will be happy to propose a refactore on this module to depend on server_env_mixin
, for version 16 at least.
But I am not a user of this module (yet), I don't know it much and I may be missing an important point related to the special behaviors on ir.config.parameter
.
Any idea @simahawk @sbidoul @legalsylvain ?
I only have tested with version 16 but it probably impacts all versions.
If both mail_environment
and microsoft_outlook
are installed, it is impossible to create an outgoing mail server with smtp_authentication = 'outlook'
, unless you manage the environment dependent fields in your Odoo config files. (So it does not work with default value or data_encryption_server_environment
module)
During the creation, you will have a failure due to this constraints : https://github.com/OCA/OCB/blob/16.0/addons/microsoft_outlook/models/ir_mail_server.py#L46
The reason is, Odoo will check these constraint before the default environement value is set.
Constraints are checked there https://github.com/OCA/OCB/blob/16.0/odoo/models.py#L4206 while the not stored fields with inverse method (which is the case of the environment dependent fields) are managed later on in the create
method.
During the constraint check, the value will always be False (unless defined in config file)
So, the source of the problem is the fact that server_environment
some stored fields to not stored /computed fields.
Actually, I think I already met issues with server_environment
because of this, I think required field are not anymore, fields no more searchable, stuff like that.
Anyway, I have no perfect solution about this issue. For now, I intent to fix it for microsoft_outlook with the following :
class IrMailServer(models.Model):
_inherit = "ir.mail_server"
@api.model_create_multi
def create(self, vals_list):
res = super(IrMailServer, self.with_context(delay_field_validation=True)).create(vals_list)
res.with_context(delay_field_validation=False)._validate_fields(name for vals in vals_list for name in vals)
return res
def _validate_fields(self, field_names, excluded_names=()):
if self.env.context.get("delay_field_validation"):
return
return super()._validate_fields(field_names, excluded_names=excluded_names)
It seems good enough to me and not too dangerous because specific to the constraints of ir.mail_server
I wonder if anyone would have a better idea and/or if it was good enough to go to mail_environment_office365
module.
I guess the problem from this issue is the same as spotted here : #119 (comment)
Even though I did not experience this one.
Any feedback is appreciated @JordiBForgeFlow @simahawk @lmignon @StefanRijnhart
Hello,
Since V9, the module server_environment_ir_config_parameter has not the key installable=True .
I'm just wondering if there is any reason I would not know -> https://github.com/OCA/server-env/blob/13.0/server_environment_ir_config_parameter/__manifest__.py#L12
https://github.com/OCA/maintainer-tools/wiki/Migration-to-version-17.0
Missing module? Check https://github.com/OCA/maintainer-tools/wiki/%5BFAQ%5D-Missing-modules-in-migration-issue-list
The manifest of server_environment
declares a dependency on server_environment_files
.
With tools such as module_auto_update or click-odoo-initdb, small changes to server_environment_file (such as bumping a version number in a web_environment_ribbon parameter) tend to trigger a large chain of unncessary updates for all modules that depend on server_environment
.
In practice server_environment only relies on the presence of server_environment_files to locate the directory of configuration files. It's absence would be otherwise detected by import odoo.addons.server_environment_files
failing during server startup.
Would there be any drawback to removing this dependency from the manifest?
Hi all,
cc @sbidoul @guewen @yvaucher @gurneyalex
I dived into this module
https://github.com/OCA/server-env/blob/12.0/server_environment_ir_config_parameter
I really appreciate to have a way to combine server_env module without to have an UI to build (then a UI fallback). Thanks to the authors
But I have a question about security or confidentiality of informations
A parameter can be a credential (all that we have in server_env keys), and I ask myself why values contained in server_env files
are always written in ir.config_parameter instead of only used as substitution.
IMO, i thought that UI was for demo purposes not for real production storage informations place.
These values are also in backup, and that may imply to rise questions in gdpr context I suppose.
I think we could have an optional behaviour to prevent to store data in db.
What do you think?
Maybe I missed something, so please make me take the right way.
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.