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

[16.0] [MIG] account_fiscal_year_closing #248

Open
wants to merge 27 commits into
base: 16.0
Choose a base branch
from

Conversation

Borruso
Copy link

@Borruso Borruso commented Jun 14, 2023

Migration account_fiscal_year_closing from 14.0 to 16.0

--
Confermo di aver firmato il CLA https://odoo-community.org/page/cla e di aver letto le linee guida su https://odoo-community.org/page/contributing

@Borruso Borruso mentioned this pull request Jun 14, 2023
7 tasks
@miguel-binaural
Copy link

miguel-binaural commented Jun 27, 2023

Will this be merged?

@Borruso Borruso force-pushed the 16.0-mig-account_fiscal_year_closing branch from b05e291 to 4917d69 Compare July 21, 2023 12:42
Copy link

@SirAionTech SirAionTech left a comment

Choose a reason for hiding this comment

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

account_type_id = fields.Many2one(
comodel_name="account.account.type",
string="Account type",
account_type = fields.Selection(

Choose a reason for hiding this comment

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

This change requires a migration, otherwise when a database is migrated the existing records will have an empty account_type instead of having the value corresponding to their old account_type_id.
You can have a look at https://oca.github.io/OpenUpgrade for better understanding what a migration is.

Since the migration is usually not trivial and it does not really affect the module's behavior, sometimes this can be done later; this will be probably decided by whoever wants to merge this module.

If this is the case, please at least write a note in the roadmap of the module.

Copy link
Author

@Borruso Borruso Oct 6, 2023

Choose a reason for hiding this comment

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

create migration
await you feedback

Choose a reason for hiding this comment

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

👍

not in [
"asset_receivable", # Receivable
"asset_current", # Current Assets
"income", # Current Assets

Choose a reason for hiding this comment

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

Suggested change
"income", # Current Assets
"income", # Income

Copy link
Author

@Borruso Borruso Oct 6, 2023

Choose a reason for hiding this comment

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

done

Choose a reason for hiding this comment

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

👍

@Borruso Borruso force-pushed the 16.0-mig-account_fiscal_year_closing branch from 4917d69 to a36c164 Compare October 6, 2023 10:35
@Borruso Borruso force-pushed the 16.0-mig-account_fiscal_year_closing branch 3 times, most recently from 8a0946f to 92f8abb Compare October 6, 2023 11:07
Copy link

@SirAionTech SirAionTech left a comment

Choose a reason for hiding this comment

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

Commit 21851e9 is missing from history

account_type_id = fields.Many2one(
comodel_name="account.account.type",
string="Account type",
account_type = fields.Selection(

Choose a reason for hiding this comment

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

👍

not in [
"asset_receivable", # Receivable
"asset_current", # Current Assets
"income", # Current Assets

Choose a reason for hiding this comment

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

👍

@Borruso Borruso force-pushed the 16.0-mig-account_fiscal_year_closing branch from 92f8abb to 18480fd Compare October 6, 2023 11:15
@Borruso
Copy link
Author

Borruso commented Oct 6, 2023

Commit 21851e9 is missing from history

done

@gjlong68
Copy link

V16
image

@Borruso Borruso force-pushed the 16.0-mig-account_fiscal_year_closing branch 2 times, most recently from 596da34 to 3142b69 Compare October 19, 2023 14:00
@Borruso
Copy link
Author

Borruso commented Oct 20, 2023

V16 image

@gjlong68, can you check again, please?

@Borruso Borruso force-pushed the 16.0-mig-account_fiscal_year_closing branch from 3142b69 to 6d874db Compare October 20, 2023 08:33
Copy link
Contributor

@GSLabIt GSLabIt left a comment

Choose a reason for hiding this comment

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

multi company fix

<field name="global" eval="True" />
<field
name="domain_force"
>['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
>['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field>
>['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]</field>

<field name="global" eval="True" />
<field
name="domain_force"
>['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
>['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field>
>['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]</field>

@Borruso Borruso force-pushed the 16.0-mig-account_fiscal_year_closing branch from 6d874db to 646f046 Compare October 26, 2023 08:04
@Borruso
Copy link
Author

Borruso commented Oct 26, 2023

multi company fix

@GSLabIt thanks for suggest
added migration

@gjlong68
Copy link

Borruso:OK

@Borruso Borruso force-pushed the 16.0-mig-account_fiscal_year_closing branch from 646f046 to 92367bb Compare November 13, 2023 08:19
@mde-scopea
Copy link

Hi guys, thanks for your job.

Has anyone tested the migration script?

On my side, it's KO (I'm on Odoo.sh), the pre-mig script doesn't work.
IDs, use with env.ref("account.data_account_type*), don't exist on the migrated system (when the pre script runs)

@SirAionTech
Copy link

Has anyone tested the migration script?

I didn't

On my side, it's KO (I'm on Odoo.sh), the pre-mig script doesn't work.
IDs, use with env.ref("account.data_account_type*), don't exist on the migrated system (when the pre script runs)

Then please add that as a review to the PR, have a look at https://odoo-community.org/resources/review if you don't know how.

@pedrobaeza
Copy link
Member

Please include 55998e8 in this PR.

@pedrobaeza
Copy link
Member

/ocabot migration account_fiscal_year_closing

@lk-eska
Copy link

lk-eska commented May 10, 2024

These 2 PR's are will be necessary as well:

#288
#294

francesco-ooops and others added 10 commits July 26, 2024 11:33
Currently translated at 92.1% (105 of 114 strings)

Translation: account-closing-14.0/account-closing-14.0-account_fiscal_year_closing
Translate-URL: https://translation.odoo-community.org/projects/account-closing-14-0/account-closing-14-0-account_fiscal_year_closing/it/
Currently translated at 92.1% (105 of 114 strings)

Translation: account-closing-14.0/account-closing-14.0-account_fiscal_year_closing
Translate-URL: https://translation.odoo-community.org/projects/account-closing-14-0/account-closing-14-0-account_fiscal_year_closing/it/
Currently translated at 92.9% (106 of 114 strings)

Translation: account-closing-14.0/account-closing-14.0-account_fiscal_year_closing
Translate-URL: https://translation.odoo-community.org/projects/account-closing-14-0/account-closing-14-0-account_fiscal_year_closing/it/
Currently translated at 100.0% (114 of 114 strings)

Translation: account-closing-14.0/account-closing-14.0-account_fiscal_year_closing
Translate-URL: https://translation.odoo-community.org/projects/account-closing-14-0/account-closing-14-0-account_fiscal_year_closing/it/
Currently translated at 100.0% (114 of 114 strings)

Translation: account-closing-14.0/account-closing-14.0-account_fiscal_year_closing
Translate-URL: https://translation.odoo-community.org/projects/account-closing-14-0/account-closing-14-0-account_fiscal_year_closing/it/
Currently translated at 100.0% (114 of 114 strings)

Translation: account-closing-14.0/account-closing-14.0-account_fiscal_year_closing
Translate-URL: https://translation.odoo-community.org/projects/account-closing-14-0/account-closing-14-0-account_fiscal_year_closing/it/
Currently translated at 95.6% (109 of 114 strings)

Translation: account-closing-14.0/account-closing-14.0-account_fiscal_year_closing
Translate-URL: https://translation.odoo-community.org/projects/account-closing-14-0/account-closing-14-0-account_fiscal_year_closing/pt_BR/
Currently translated at 100.0% (114 of 114 strings)

Translation: account-closing-14.0/account-closing-14.0-account_fiscal_year_closing
Translate-URL: https://translation.odoo-community.org/projects/account-closing-14-0/account-closing-14-0-account_fiscal_year_closing/it/
@Borruso Borruso force-pushed the 16.0-mig-account_fiscal_year_closing branch from b6e7c5c to 4c886b7 Compare July 26, 2024 09:33
def migrate(env, version):

all_account_type = [
("asset_receivable", env.ref("account.data_account_type_receivable").id),
Copy link

Choose a reason for hiding this comment

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

When migrating from v15 to v16 using OpenUpgrade, the following error occurs:

2024-07-30 09:16:17,113 2133688 INFO cbx_2024-07-30_v16 odoo.modules.loading: Loading module account_fiscal_year_closing (102/170)
2024-07-30 09:16:17,430 2133688 INFO cbx_2024-07-30_v16 odoo.modules.migration: module account_fiscal_year_closing: Running migration [>16.0.1.0.0] pre-migration
2024-07-30 09:16:17,444 2133688 INFO cbx_2024-07-30_v16 OpenUpgrade: account_fiscal_year_closing: pre-migration script called with version 15.0.1.0.0
2024-07-30 09:16:17,444 2133688 ERROR cbx_2024-07-30_v16 OpenUpgrade: account_fiscal_year_closing: error in migration script /opt/odoo/local/addons-oca-community/addons/account_fiscal_year_closing/migrations/16.0.1.0.0/pre-migration.py: 'account.account.type'
2024-07-30 09:16:17,444 2133688 ERROR cbx_2024-07-30_v16 OpenUpgrade: 'account.account.type'
Traceback (most recent call last):
  File "/srv/odoo/venv/lib/python3.10/site-packages/openupgradelib/openupgrade.py", line 2292, in wrapped_function
    func(
  File "/opt/odoo/local/addons-oca-community/addons/account_fiscal_year_closing/migrations/16.0.1.0.0/pre-migration.py", line 31, in migrate
    ("asset_receivable", env.ref("account.data_account_type_receivable").id),
  File "/opt/odoo/src/odoo/odoo/api.py", line 600, in ref
    record = self[res_model].browse(res_id)
  File "/opt/odoo/local/OpenUpgrade/openupgrade_framework/odoo_patch/odoo/api.py", line 39, in __getitem__
    return Environment.__getitem__._original_method(self, model_name)
  File "/opt/odoo/src/odoo/odoo/api.py", line 550, in __getitem__
    return self.registry[model_name](self, (), ())
  File "/opt/odoo/src/odoo/odoo/modules/registry.py", line 190, in __getitem__
    return self.models[model_name]
KeyError: 'account.account.type'
2024-07-30 09:16:17,500 2133688 WARNING cbx_2024-07-30_v16 odoo.modules.loading: Transient module states were reset
2024-07-30 09:16:17,501 2133688 ERROR cbx_2024-07-30_v16 odoo.modules.registry: Failed to load registry
Traceback (most recent call last):
  File "/opt/odoo/src/odoo/odoo/modules/registry.py", line 90, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/opt/odoo/src/odoo/odoo/modules/loading.py", line 484, in load_modules
    processed_modules += load_marked_modules(cr, graph,
  File "/opt/odoo/src/odoo/odoo/modules/loading.py", line 372, in load_marked_modules
    loaded, processed = load_module_graph(
  File "/opt/odoo/src/odoo/odoo/modules/loading.py", line 183, in load_module_graph
    migrations.migrate_module(package, 'pre')
  File "/opt/odoo/local/OpenUpgrade/openupgrade_framework/odoo_patch/odoo/modules/migration.py", line 18, in migrate_module
    MigrationManager.migrate_module._original_method(self, pkg, stage)
  File "/opt/odoo/src/odoo/odoo/modules/migration.py", line 189, in migrate_module
    migrate(self.cr, installed_version)
  File "/srv/odoo/venv/lib/python3.10/site-packages/openupgradelib/openupgrade.py", line 2292, in wrapped_function
    func(
  File "/opt/odoo/local/addons-oca-community/addons/account_fiscal_year_closing/migrations/16.0.1.0.0/pre-migration.py", line 31, in migrate
    ("asset_receivable", env.ref("account.data_account_type_receivable").id),
  File "/opt/odoo/src/odoo/odoo/api.py", line 600, in ref
    record = self[res_model].browse(res_id)
  File "/opt/odoo/local/OpenUpgrade/openupgrade_framework/odoo_patch/odoo/api.py", line 39, in __getitem__
    return Environment.__getitem__._original_method(self, model_name)
  File "/opt/odoo/src/odoo/odoo/api.py", line 550, in __getitem__
    return self.registry[model_name](self, (), ())
  File "/opt/odoo/src/odoo/odoo/modules/registry.py", line 190, in __getitem__
    return self.models[model_name]
KeyError: 'account.account.type'
2024-07-30 09:16:17,501 2133688 CRITICAL cbx_2024-07-30_v16 odoo.service.server: Failed to initialize database `cbx_2024-07-30_v16`.
Traceback (most recent call last):
  File "/opt/odoo/src/odoo/odoo/service/server.py", line 1310, in preload_registries
    registry = Registry.new(dbname, update_module=update_module)
  File "<decorator-gen-16>", line 2, in new
  File "/opt/odoo/src/odoo/odoo/tools/func.py", line 87, in locked
    return func(inst, *args, **kwargs)
  File "/opt/odoo/src/odoo/odoo/modules/registry.py", line 90, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/opt/odoo/src/odoo/odoo/modules/loading.py", line 484, in load_modules
    processed_modules += load_marked_modules(cr, graph,
  File "/opt/odoo/src/odoo/odoo/modules/loading.py", line 372, in load_marked_modules
    loaded, processed = load_module_graph(
  File "/opt/odoo/src/odoo/odoo/modules/loading.py", line 183, in load_module_graph
    migrations.migrate_module(package, 'pre')
  File "/opt/odoo/local/OpenUpgrade/openupgrade_framework/odoo_patch/odoo/modules/migration.py", line 18, in migrate_module
    MigrationManager.migrate_module._original_method(self, pkg, stage)
  File "/opt/odoo/src/odoo/odoo/modules/migration.py", line 189, in migrate_module
    migrate(self.cr, installed_version)
  File "/srv/odoo/venv/lib/python3.10/site-packages/openupgradelib/openupgrade.py", line 2292, in wrapped_function
    func(
  File "/opt/odoo/local/addons-oca-community/addons/account_fiscal_year_closing/migrations/16.0.1.0.0/pre-migration.py", line 31, in migrate
    ("asset_receivable", env.ref("account.data_account_type_receivable").id),
  File "/opt/odoo/src/odoo/odoo/api.py", line 600, in ref
    record = self[res_model].browse(res_id)
  File "/opt/odoo/local/OpenUpgrade/openupgrade_framework/odoo_patch/odoo/api.py", line 39, in __getitem__
    return Environment.__getitem__._original_method(self, model_name)
  File "/opt/odoo/src/odoo/odoo/api.py", line 550, in __getitem__
    return self.registry[model_name](self, (), ())
  File "/opt/odoo/src/odoo/odoo/modules/registry.py", line 190, in __getitem__
    return self.models[model_name]
KeyError: 'account.account.type'

We believe that there is a timing issue with this pre-migration script, because at this stage, those records are already deleted and therefore the keyerror occurs

Copy link
Author

@Borruso Borruso Aug 1, 2024

Choose a reason for hiding this comment

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

update pre-migration
can you check again?

@Borruso Borruso force-pushed the 16.0-mig-account_fiscal_year_closing branch from 4c886b7 to b54b04a Compare August 1, 2024 10:16
When creating from scratch, Mapping is used as an Array instead of simple id (due to many in another many).
When coming from a template, id is used
To take into account this particularity, check the type before taking the id of the array.
@Borruso Borruso force-pushed the 16.0-mig-account_fiscal_year_closing branch from b54b04a to 0e5cd59 Compare August 1, 2024 10:19
UPDATE {table} aa
SET account_type = atm.account_type
FROM account_type_map atm
WHERE atm.user_type_id = aa.user_type_id
Copy link

Choose a reason for hiding this comment

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

ERROR: column aa.user_type_id does not exist
LINE 35:             WHERE atm.user_type_id = aa.user_type_id
                                              ^
HINT:  Perhaps you meant to reference the column "atm.user_type_id".

user_type_id does not exist in any of the two tables? (account_fiscalyear_closing_type_template, account_fiscalyear_closing_type)

Copy link
Author

Choose a reason for hiding this comment

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

yes field user_type_id become account_type

odoo/odoo@26b2472 user_type_id -> account_type account.account.type

Copy link

@SirAionTech SirAionTech left a comment

Choose a reason for hiding this comment

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

I proposed Borruso#1 to support the flow where accounting data is created without loading a template chart of accounts

@peterromao
Copy link

Hello guys,

Where can I translate this module for version 16? It's not on Weblate. Also as I see it it is not yet merged into the 16.0 branch either right?

@andreampiovesana
Copy link

andreampiovesana commented Nov 7, 2024

can you enable runboat?
is good for functional review and/or merge?

@Borruso Borruso force-pushed the 16.0-mig-account_fiscal_year_closing branch from a3c19a5 to cc851f5 Compare November 8, 2024 09:59
Although we originally developped the module, we figured out soon
that this approach is not correct, so we prefer to not appearing
in the credits.
@Borruso Borruso force-pushed the 16.0-mig-account_fiscal_year_closing branch from cc851f5 to ff71bb5 Compare November 8, 2024 10:00
@Borruso
Copy link
Author

Borruso commented Nov 8, 2024

Please include 55998e8 in this PR.

commit included

Copy link

@MaurizioPellegrinet MaurizioPellegrinet left a comment

Choose a reason for hiding this comment

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

Functional test: OK

@OCA-git-bot
Copy link
Contributor

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). 🤖

Copy link

@AinohaBH AinohaBH left a comment

Choose a reason for hiding this comment

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

Functional: LGTM

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.