Skip to content
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

Merged
merged 1 commit into from
Sep 30, 2020

Conversation

lmignon
Copy link
Member

@lmignon lmignon commented Oct 11, 2019

This will prevent conflicts between databases (db.uuid, db.secret ...)

Closes #25
Progresses #26

@lmignon lmignon force-pushed the master-copydb-reset-ir-config-lmi branch from 5e971db to 9c5fd5c Compare October 11, 2019 15:57
@codecov-io
Copy link

codecov-io commented Oct 11, 2019

Codecov Report

Merging #58 into master will increase coverage by 0.31%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
click_odoo_contrib/_addon_hash.py 96.87% <100.00%> (ø)
click_odoo_contrib/_dbutils.py 100.00% <100.00%> (ø)
click_odoo_contrib/copydb.py 97.43% <100.00%> (+0.06%) ⬆️
click_odoo_contrib/manifest.py 100.00% <0.00%> (+2.89%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 90b8b47...6b7cc9d. Read the comment docs.

@lmignon lmignon mentioned this pull request Oct 11, 2019
@lmignon lmignon force-pushed the master-copydb-reset-ir-config-lmi branch 4 times, most recently from 8b75423 to e24037b Compare October 12, 2019 09:58
@sbidoul sbidoul added the enhancement New feature or request label Nov 1, 2019
Copy link
Member

@rousseldenis rousseldenis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with #57

Copy link
Member

@sbidoul sbidoul left a 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.

click_odoo_contrib/_dbutils.py Show resolved Hide resolved
tests/test_copydb.py Show resolved Hide resolved
@rousseldenis
Copy link
Member

@lmignon

@lmignon lmignon force-pushed the master-copydb-reset-ir-config-lmi branch from e24037b to f9c0d74 Compare May 3, 2020 08:06
@lmignon lmignon force-pushed the master-copydb-reset-ir-config-lmi branch from fc2fd1a to ca70ea4 Compare May 3, 2020 08:57
@lmignon
Copy link
Member Author

lmignon commented May 3, 2020

@sbidoul Requested changes implemented.

Copy link
Member

@sbidoul sbidoul left a 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?


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"]
Copy link
Member

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

Copy link
Member Author

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'), []),
}

Copy link
Member Author

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,),
)
Copy link
Member

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';
Copy link
Member

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?

Copy link
Member Author

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.

@acsone-git-bot
Copy link

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@lmignon lmignon force-pushed the master-copydb-reset-ir-config-lmi branch from 20900aa to 6b7cc9d Compare May 12, 2020 14:51
…pied

This will prevent conflicts between databases (db.uuid, db.secret ...)
@sbidoul sbidoul force-pushed the master-copydb-reset-ir-config-lmi branch from 6b7cc9d to 832bc5f Compare September 30, 2020 19:51
@codecov-commenter
Copy link

codecov-commenter commented Sep 30, 2020

Codecov Report

Merging #58 into master will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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              
Impacted Files Coverage Δ
click_odoo_contrib/_dbutils.py 100.00% <100.00%> (ø)
click_odoo_contrib/copydb.py 97.43% <100.00%> (+0.06%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6b8394c...832bc5f. Read the comment docs.

@sbidoul sbidoul merged commit bb5eeaa into master Sep 30, 2020
@acsone-git-bot acsone-git-bot deleted the master-copydb-reset-ir-config-lmi branch September 30, 2020 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

copydb --reset-uuid + enterprise contract
6 participants