Skip to content

[15.0][OU-FIX] account: should not merge website_legal_page module - #4536

Merged
pedrobaeza merged 1 commit into
OCA:15.0from
lefilament:15.0-fix_account_website_legal_page
Aug 13, 2025
Merged

[15.0][OU-FIX] account: should not merge website_legal_page module#4536
pedrobaeza merged 1 commit into
OCA:15.0from
lefilament:15.0-fix_account_website_legal_page

Conversation

@remi-filament

Copy link
Copy Markdown

Issue raised while migrating database with both account and website_legal_page installed.

website_legal_page is merged into account model with post-migration.py script since PR #3728

The problem is that merging module in post-migration does not reload the list of modules to be updated, so when you run the command with -u all, it then tries to update website_legal_page which does not exist anymore, leading to CacheMiss exception. (example of error in the first comment on this PR to not overload the description here).

After giving it some thoughts, I do not think merging website_legal_page into account is a good solution, because in many cases legal page from that module are not the same as the one we want to link to from account move. (for instance in France, legal page is mandatory on every website with few information to identify owner, but the terms you will need on account move are related to the sale you performed).
Also, website_legal_page adds a link to legal page in website footer which is then lost with this merging (since account is not doing that).

Still it can make sense to initialize new invoice_terms_html with legal page content as long as the new mode is not forced (already fixed/reverted with PR #4110 )

Therefore, I propose here to not merge website_legal_page into account but keeping the initialization of the company invoice_terms_html field.

One would then need to uninstall website_legal_page manually if it is not needed anymore.

@remi-filament

Copy link
Copy Markdown
Author

Traceback of exception raised when running migration of a database with both account and website_legal_page installed :

2024-08-08 07:04:49,618 14580 INFO odoo14_test_OU odoo.modules.loading: Loading module website_legal_page (31/37) 
2024-08-08 07:04:49,807 14580 WARNING odoo14_test_OU odoo.modules.loading: Transient module states were reset 
2024-08-08 07:04:49,810 14580 ERROR odoo14_test_OU odoo.modules.registry: Failed to load registry 
Traceback (most recent call last):
  File "/home/user/dev/odoo15/ocb/odoo/api.py", line 909, in get
    return field_cache[record._ids[0]]
KeyError: 90

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/dev/odoo15/ocb/odoo/fields.py", line 1083, in __get__
    value = env.cache.get(record, self)
  File "/home/user/dev/odoo15/ocb/odoo/api.py", line 912, in get
    raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: 'ir.module.module(90,).description_html'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/dev/odoo15/ocb/odoo/api.py", line 909, in get
    return field_cache[record._ids[0]]
KeyError: 90

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/dev/odoo15/ocb/odoo/fields.py", line 1083, in __get__
    value = env.cache.get(record, self)
  File "/home/user/dev/odoo15/ocb/odoo/api.py", line 912, in get
    raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: 'ir.module.module(90,).name'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/dev/odoo15/ocb/odoo/fields.py", line 1132, in __get__
    self.compute_value(recs)
  File "/home/user/dev/odoo15/ocb/odoo/fields.py", line 1295, in compute_value
    records._compute_field_value(self)
  File "/home/user/dev/odoo15/ocb/odoo/models.py", line 4277, in _compute_field_value
    fields.determine(field.compute, self)
  File "/home/user/dev/odoo15/ocb/odoo/fields.py", line 88, in determine
    return needle(*args)
  File "/home/user/dev/odoo15/ocb/odoo/addons/base/models/ir_module.py", line 192, in _get_desc
    if not module.name:
  File "/home/user/dev/odoo15/ocb/odoo/fields.py", line 1113, in __get__
    raise MissingError("\n".join([
odoo.exceptions.MissingError: Record does not exist or has been deleted.
(Record: ir.module.module(90,), User: 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/dev/odoo15/ocb/odoo/api.py", line 909, in get
    return field_cache[record._ids[0]]
KeyError: 90

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/dev/odoo15/ocb/odoo/fields.py", line 1083, in __get__
    value = env.cache.get(record, self)
  File "/home/user/dev/odoo15/ocb/odoo/api.py", line 912, in get
    raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: 'ir.module.module(90,).name'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/dev/odoo15/ocb/odoo/modules/registry.py", line 87, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/home/user/dev/odoo15/ocb/odoo/modules/loading.py", line 470, in load_modules
    processed_modules += load_marked_modules(cr, graph,
  File "/home/user/dev/odoo15/ocb/odoo/modules/loading.py", line 363, in load_marked_modules
    loaded, processed = load_module_graph(
  File "/home/user/dev/odoo15/ocb/odoo/modules/loading.py", line 217, in load_module_graph
    module._check()
  File "/home/user/dev/odoo15/ocb/addons/website/models/ir_module_module.py", line 453, in _check
    super()._check()
  File "/home/user/dev/odoo15/ocb/odoo/addons/base/models/ir_module.py", line 941, in _check
    if not module.description_html:
  File "/home/user/dev/odoo15/ocb/odoo/fields.py", line 1134, in __get__
    self.compute_value(record)
  File "/home/user/dev/odoo15/ocb/odoo/fields.py", line 1295, in compute_value
    records._compute_field_value(self)
  File "/home/user/dev/odoo15/ocb/odoo/models.py", line 4277, in _compute_field_value
    fields.determine(field.compute, self)
  File "/home/user/dev/odoo15/ocb/odoo/fields.py", line 88, in determine
    return needle(*args)
  File "/home/user/dev/odoo15/ocb/odoo/addons/base/models/ir_module.py", line 192, in _get_desc
    if not module.name:
  File "/home/user/dev/odoo15/ocb/odoo/fields.py", line 1113, in __get__
    raise MissingError("\n".join([
odoo.exceptions.MissingError: Record does not exist or has been deleted.
(Record: ir.module.module(90,), User: 1)
2024-08-08 07:04:49,818 14580 CRITICAL odoo14_test_OU odoo.service.server: Failed to initialize database `odoo14_test_OU`. 
Traceback (most recent call last):
  File "/home/user/dev/odoo15/ocb/odoo/api.py", line 909, in get
    return field_cache[record._ids[0]]
KeyError: 90

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/dev/odoo15/ocb/odoo/fields.py", line 1083, in __get__
    value = env.cache.get(record, self)
  File "/home/user/dev/odoo15/ocb/odoo/api.py", line 912, in get
    raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: 'ir.module.module(90,).description_html'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/dev/odoo15/ocb/odoo/api.py", line 909, in get
    return field_cache[record._ids[0]]
KeyError: 90

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/dev/odoo15/ocb/odoo/fields.py", line 1083, in __get__
    value = env.cache.get(record, self)
  File "/home/user/dev/odoo15/ocb/odoo/api.py", line 912, in get
    raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: 'ir.module.module(90,).name'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/dev/odoo15/ocb/odoo/fields.py", line 1132, in __get__
    self.compute_value(recs)
  File "/home/user/dev/odoo15/ocb/odoo/fields.py", line 1295, in compute_value
    records._compute_field_value(self)
  File "/home/user/dev/odoo15/ocb/odoo/models.py", line 4277, in _compute_field_value
    fields.determine(field.compute, self)
  File "/home/user/dev/odoo15/ocb/odoo/fields.py", line 88, in determine
    return needle(*args)
  File "/home/user/dev/odoo15/ocb/odoo/addons/base/models/ir_module.py", line 192, in _get_desc
    if not module.name:
  File "/home/user/dev/odoo15/ocb/odoo/fields.py", line 1113, in __get__
    raise MissingError("\n".join([
odoo.exceptions.MissingError: Record does not exist or has been deleted.
(Record: ir.module.module(90,), User: 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/dev/odoo15/ocb/odoo/api.py", line 909, in get
    return field_cache[record._ids[0]]
KeyError: 90

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/dev/odoo15/ocb/odoo/fields.py", line 1083, in __get__
    value = env.cache.get(record, self)
  File "/home/user/dev/odoo15/ocb/odoo/api.py", line 912, in get
    raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: 'ir.module.module(90,).name'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/dev/odoo15/ocb/odoo/service/server.py", line 1260, in preload_registries
    registry = Registry.new(dbname, update_module=update_module)
  File "/home/user/dev/odoo15/ocb/odoo/modules/registry.py", line 87, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/home/user/dev/odoo15/ocb/odoo/modules/loading.py", line 470, in load_modules
    processed_modules += load_marked_modules(cr, graph,
  File "/home/user/dev/odoo15/ocb/odoo/modules/loading.py", line 363, in load_marked_modules
    loaded, processed = load_module_graph(
  File "/home/user/dev/odoo15/ocb/odoo/modules/loading.py", line 217, in load_module_graph
    module._check()
  File "/home/user/dev/odoo15/ocb/addons/website/models/ir_module_module.py", line 453, in _check
    super()._check()
  File "/home/user/dev/odoo15/ocb/odoo/addons/base/models/ir_module.py", line 941, in _check
    if not module.description_html:
  File "/home/user/dev/odoo15/ocb/odoo/fields.py", line 1134, in __get__
    self.compute_value(record)
  File "/home/user/dev/odoo15/ocb/odoo/fields.py", line 1295, in compute_value
    records._compute_field_value(self)
  File "/home/user/dev/odoo15/ocb/odoo/models.py", line 4277, in _compute_field_value
    fields.determine(field.compute, self)
  File "/home/user/dev/odoo15/ocb/odoo/fields.py", line 88, in determine
    return needle(*args)
  File "/home/user/dev/odoo15/ocb/odoo/addons/base/models/ir_module.py", line 192, in _get_desc
    if not module.name:
  File "/home/user/dev/odoo15/ocb/odoo/fields.py", line 1113, in __get__
    raise MissingError("\n".join([
odoo.exceptions.MissingError: Record does not exist or has been deleted.
(Record: ir.module.module(90,), User: 1)
2024-08-08 07:04:49,819 14580 INFO odoo14_test_OU odoo.service.server: Initiating shutdown 

@remi-filament

Copy link
Copy Markdown
Author

Hi @CarlosRoca13 @chienandalu
I am proposing here to revert some of the migration scripts you added into account, if you mind to have a look ?

Best Regards,

@pedrobaeza pedrobaeza added this to the 15.0 milestone Aug 8, 2024
@pedrobaeza

Copy link
Copy Markdown
Member

The merging is correct, as now Odoo includes the term page accessible in "frontend" in account (although editable only if you have website installed).

About the CacheMiss you are talking about, I think you are executing things without loading openupgrade_framework, as there are patches in the modules loading cycle, and didn't experiment the problem you are mentioning.

@remi-filament

Copy link
Copy Markdown
Author

Hi @pedrobaeza thank you for your feedback. I see that website_legal_page is still available in v15 and v16 and already gets a PR for v17, and I understand why : because from my point of view, the account terms page from v15+ does not necessarily covers the same scope as that module, and merging it during openupgrade migration to v15 causes uninstallation of that module.

Also, I am pretty sure openupgrade_framework is properly loaded since when it is not I get different kind of errors, and I just checked adding a print in openupgrade_framework init.py which is correctly displayed when starting...

@remi-filament

Copy link
Copy Markdown
Author

I also reproduced the issue this morning before raising PR with a fresh v14 install with only account and website_legal_page installed (with their dependencies).

@pedrobaeza

Copy link
Copy Markdown
Member

Yes, they continue for that extra needs, and you can just install them again, but the general behavior is to merge it. We have done this kind of merging in a lot of occasions. Try to put it on pre-migration in your test to see, but as said, we haven't experienced any problem as is.

@remi-filament

Copy link
Copy Markdown
Author

I have the same issue having the merge in pre-migration

@christian-ramos-tecnativa christian-ramos-tecnativa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hello @pedrobaeza we are having the same issue as @remi-filament and this change LGTM

@pedrobaeza

Copy link
Copy Markdown
Member

As said, you can just install it again after running the migration, or is there any other problem?

@MiquelRForgeFlow

MiquelRForgeFlow commented Aug 13, 2025

Copy link
Copy Markdown
Contributor

I think what is missing is addingenv['ir.module.module'].update_list() after the merge. Also, later, you could add the v15 website_legal_page if you want to have it, like doing:

openupgrade.logged_query(
    env.cr,
    """
    UPDATE ir_module_module
    SET state='to upgrade'
    WHERE name = 'website_legal_page' AND state='uninstalled'""",
)

@pedrobaeza pedrobaeza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See Miquel's suggestions

@edescalona edescalona left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Excellent contribution @remi-filament tested and functional. LGTM

@christian-ramos-tecnativa

Copy link
Copy Markdown
Contributor

@pedrobaeza It triggers an error that block the process (with the framework also) @MiquelRForgeFlow even assuming that env['ir.module.module'].update_list() solves the error IMO is not intuitive between versions to merge a module that can be installed again because can add extra functionalities. My 2 cents

@pedrobaeza

Copy link
Copy Markdown
Member

Which error?

@christian-ramos-tecnativa

Copy link
Copy Markdown
Contributor

This one #4536 (comment)

@pedrobaeza pedrobaeza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Well, OK, after talking with Christian by chat, and giving the fact that I don't have customers in prior versions with this module, let's not block your reasoning.

@pedrobaeza
pedrobaeza merged commit b7e5f0a into OCA:15.0 Aug 13, 2025
@MiquelRForgeFlow

Copy link
Copy Markdown
Contributor

Wait, is not better to apply my suggestion?

@pedrobaeza

Copy link
Copy Markdown
Member

Miquel, I'm not sure the dependency graph and loading mechanism is properly handle doing the update list inside a migration script, so as I'm the only one wanting to remove website_legal_page, let's go with current patch.

@MiquelRForgeFlow

Copy link
Copy Markdown
Contributor

I'm not sure the dependency graph and loading mechanism is properly handle doing the update list inside a migration script,

No issues. Done in #5306.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants