Skip to content

Conversation

@remytms
Copy link

@remytms remytms commented Sep 25, 2024

Modifying account.move when module account_journal_lock_date is installed failed due to settings in *_lock_date.

2024-09-16 13:07:41,298 1 CRITICAL coopiteasy-upgrade odoo.service.server: Failed to initialize database `coopiteasy-upgrade`. 
Traceback (most recent call last):
  File "/odoo_env/src/odoo/odoo/service/server.py", line 1260, in preload_registries
    registry = Registry.new(dbname, update_module=update_module)
  File "/odoo_env/src/odoo/odoo/modules/registry.py", line 88, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/odoo_env/src/odoo/odoo/modules/loading.py", line 470, in load_modules
    processed_modules += load_marked_modules(cr, graph,
  File "/odoo_env/src/odoo/odoo/modules/loading.py", line 363, in load_marked_modules
    loaded, processed = load_module_graph(
  File "/odoo_env/src/odoo/odoo/modules/loading.py", line 227, in load_module_graph
    migrations.migrate_module(package, 'post')
  File "/odoo_env/src/openupgrade/openupgrade_framework/odoo_patch/odoo/modules/migration.py", line 18, in migrate_module
    MigrationManager.migrate_module._original_method(self, pkg, stage)
  File "/odoo_env/src/odoo/odoo/modules/migration.py", line 186, in migrate_module
    migrate(self.cr, installed_version)
  File "/opt/venv/lib/python3.8/site-packages/openupgradelib/openupgrade.py", line 2292, in wrapped_function
    func(
  File "/odoo_env/src/openupgrade/openupgrade_scripts/scripts/hr_expense/15.0.2.0/post-migration.py", line 51, in migrate
    _fill_payment_state(env)
  File "/odoo_env/src/openupgrade/openupgrade_scripts/scripts/hr_expense/15.0.2.0/post-migration.py", line 46, in _fill_payment_state
    move.payment_state = new_pmt_state
  File "/odoo_env/src/odoo/odoo/fields.py", line 1247, in __set__
    records.write({self.name: write_value})
  File "/odoo_env/src/oca/account-financial-tools/account_journal_lock_date/models/account_move.py", line 17, in write
    self._check_fiscalyear_lock_date()
  File "/odoo_env/src/oca/account-financial-tools/account_journal_lock_date/models/account_move.py", line 52, in _check_fiscalyear_lock_date
    raise UserError(message)
odoo.exceptions.UserError: You cannot add/modify entries for the journal 'Vendor Bills' prior to and inclusive of the lock date 12/31/2023

This propose a fix to deactivate *_lock_date during migration process.

I'm not sure if this process should go in this script. Advise are welcome.

Testing in progress.

@remytms remytms force-pushed the 15.0-fix-hr_expense branch from cd68db0 to d3cefe4 Compare September 25, 2024 14:25
@legalsylvain
Copy link
Contributor

legalsylvain commented Sep 25, 2024

Sorry. I don't get it. check will be done also if the OCA module are not installed. Or did i missed something ? AFAIK, _check_lock_date is a core function.

Note: if I missed something (it's possible, I don't use this module !), maybe you can just use the context "bypass_journal_lock_date", that will disable all the checks. It will avoid all the stuff to save and restore lock dates.

@remytms remytms force-pushed the 15.0-fix-hr_expense branch from d3cefe4 to 7782295 Compare September 25, 2024 14:51
@remytms
Copy link
Author

remytms commented Sep 25, 2024

Yes, indeed, I didn't catch the bypass_journal_lock_date in the context. I will use this way.

@legalsylvain
Copy link
Contributor

lighter patch !
Could you take pre-commit ?

@pedrobaeza pedrobaeza added this to the 15.0 milestone Sep 25, 2024
@pedrobaeza
Copy link
Member

I think the module account_journal_lock_date is not correct not filtering out certain fields that shouldn't raise the error, like payment_state. The patch should be there, not here.

@remytms remytms force-pushed the 15.0-fix-hr_expense branch 7 times, most recently from 48806ac to 5fad4e7 Compare September 30, 2024 14:45
@remytms remytms force-pushed the 15.0-fix-hr_expense branch from 5fad4e7 to f155604 Compare October 1, 2024 09:24
@remytms
Copy link
Author

remytms commented Oct 8, 2024

This PR may be replaced by #4577 I will test and keep you informed.

@remytms
Copy link
Author

remytms commented Oct 9, 2024

Closed in favor of #4577

@remytms remytms closed this Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants