-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensures reset of ir.config_params into target database when db are co… #58
Conversation
5e971db
to
9c5fd5c
Compare
Codecov Report
@@ Coverage Diff @@
## master #58 +/- ##
==========================================
+ Coverage 93.84% 94.15% +0.31%
==========================================
Files 13 13
Lines 763 770 +7
Branches 126 127 +1
==========================================
+ Hits 716 725 +9
+ Misses 32 31 -1
+ Partials 15 14 -1
Continue to review full report at Codecov.
|
8b75423
to
e24037b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with #57
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Could you add a changelog entry, calling out the breaking change in copydb (i.e. the reset of the default parameters - uuid, etc)? I think it's good to do it by default, and later if needed we can still add an option to preserve them.
e24037b
to
f9c0d74
Compare
fc2fd1a
to
ca70ea4
Compare
@sbidoul Requested changes implemented. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Could you add a file name 25.feature
with the changelog entry?
tests/test_copydb.py
Outdated
|
||
from click_odoo_contrib._dbutils import db_exists | ||
from click_odoo_contrib.copydb import main | ||
|
||
TEST_DBNAME = "click-odoo-contrib-testcopydb" | ||
TEST_DBNAME_NEW = "click-odoo-contrib-testcopydb-new" | ||
_DEFAULT_IR_CONFIG_PARAMETERS = ["database.uuid", "database.create_date"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to handle the other database keys?
database.create_date
database.secret
database.uuid
database.enterprise_code
database.expiration_date
database.expiration_reason
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This list is not the same into all the odoo versions...
I maybe should reuse the definition provided by odoo:
https://github.com/odoo/odoo/blob/13.0/odoo/addons/base/models/ir_config_parameter.py#L18
_default_parameters = {
"database.secret": lambda: str(uuid.uuid4()),
"database.uuid": lambda: str(uuid.uuid1()),
"database.create_date": fields.Datetime.now,
"web.base.url": lambda: "http://localhost:%s" % config.get('http_port'),
"base.login_cooldown_after": lambda: 10,
"base.login_cooldown_duration": lambda: 60,
}
https://github.com/odoo/odoo/blob/12.0/odoo/addons/base/models/ir_config_parameter.py#L18
_default_parameters = {
"database.secret": lambda: pycompat.text_type(uuid.uuid4()),
"database.uuid": lambda: pycompat.text_type(uuid.uuid1()),
"database.create_date": fields.Datetime.now,
"web.base.url": lambda: "http://localhost:%s" % config.get('http_port'),
"base.login_cooldown_after": lambda: 10,
"base.login_cooldown_duration": lambda: 60,
}
https://github.com/odoo/odoo/blob/11.0/odoo/addons/base/ir/ir_config_parameter.py#L18
_default_parameters = {
"database.secret": lambda: pycompat.text_type(uuid.uuid4()),
"database.uuid": lambda: pycompat.text_type(uuid.uuid1()),
"database.create_date": fields.Datetime.now,
"web.base.url": lambda: "http://localhost:%s" % config.get('http_port'),
}
https://github.com/odoo/odoo/blob/10.0/odoo/addons/base/ir/ir_config_parameter.py#L16
_default_parameters = {
"database.secret": lambda: (str(uuid.uuid4()), ['base.group_erp_manager']),
"database.uuid": lambda: (str(uuid.uuid1()), []),
"database.create_date": lambda: (fields.Datetime.now(), ['base.group_user']),
"web.base.url": lambda: ("http://localhost:%s" % config.get('xmlrpc_port'), []),
}
https://github.com/odoo/odoo/blob/9.0/openerp/addons/base/ir/ir_config_parameter.py#L20
_default_parameters = {
"database.secret": lambda: (str(uuid.uuid4()), ['base.group_erp_manager']),
"database.uuid": lambda: (str(uuid.uuid1()), []),
"database.create_date": lambda: (datetime.datetime.now().strftime(misc.DEFAULT_SERVER_DATETIME_FORMAT), ['base.group_user']),
"web.base.url": lambda: ("http://localhost:%s" % config.get('xmlrpc_port'), []),
}
https://github.com/odoo/odoo/blob/8.0/openerp/addons/base/ir/ir_config_parameter.py#L38
_default_parameters = {
"database.uuid": lambda: (str(uuid.uuid1()), []),
"database.create_date": lambda: (datetime.datetime.now().strftime(misc.DEFAULT_SERVER_DATETIME_FORMAT), ['base.group_user']),
"web.base.url": lambda: ("http://localhost:%s" % config.get('xmlrpc_port'), []),
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bu default database.enterprise_code
, database.expiration_date
and database.expiration_reason
are never reset. We should maybe do it.
(%s, 'test value') | ||
""", | ||
(key,), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: with insert into ... on conflict (key) do update set value=%s
that can be done in one statement.
|
||
UPDATE ir_config_parameter | ||
SET value = CURRENT_DATE + INTERVAL '2 month' | ||
WHERE key = 'database.expiration_date'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any specific reason to change these keys and not delete them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really. if enterprise addons are installed I prefer to keep the related keys.
This PR has the |
20900aa
to
6b7cc9d
Compare
…pied This will prevent conflicts between databases (db.uuid, db.secret ...)
6b7cc9d
to
832bc5f
Compare
Codecov Report
@@ Coverage Diff @@
## master #58 +/- ##
==========================================
+ Coverage 94.10% 94.15% +0.05%
==========================================
Files 13 13
Lines 763 770 +7
Branches 126 127 +1
==========================================
+ Hits 718 725 +7
Misses 31 31
Partials 14 14
Continue to review full report at Codecov.
|
This will prevent conflicts between databases (db.uuid, db.secret ...)
Closes #25
Progresses #26