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

[17.0][MIG] stock analytic: Migration to 17.0 #614

Merged
merged 50 commits into from
Aug 7, 2024

Conversation

moitabenfdz
Copy link
Contributor

No description provided.

Hanane ELKHAL and others added 30 commits December 21, 2023 13:20
… Stock analytic XML part is now migrated

Add logo for generic modules
- migration point, put all the modules to not installable
This module allows the user to generate analytic information from stock
moves.

- Fixed flake8 and pylint errors.
Remove sale and purchase dependency. Add test

Only assign analytic account if account != valuation acc

Changing field name account_analytic_id

Adjust to OCA latest guidelines. Add some usahe info on README
Remove remaining encoding hints.
Correct lint in test
Correct flake8 in test
Fix documentation and test_flake8
Currently translated at 100.0% (2 of 2 strings)

Translation: account-analytic-11.0/account-analytic-11.0-stock_analytic
Translate-URL: https://translation.odoo-community.org/projects/account-analytic-11-0/account-analytic-11-0-stock_analytic/de/
Currently translated at 100.0% (2 of 2 strings)

Translation: account-analytic-12.0/account-analytic-12.0-stock_analytic
Translate-URL: https://translation.odoo-community.org/projects/account-analytic-12-0/account-analytic-12-0-stock_analytic/pt_BR/
Currently translated at 100.0% (2 of 2 strings)

Translation: account-analytic-12.0/account-analytic-12.0-stock_analytic
Translate-URL: https://translation.odoo-community.org/projects/account-analytic-12-0/account-analytic-12-0-stock_analytic/ca/
Currently translated at 100.0% (3 of 3 strings)

Translation: account-analytic-12.0/account-analytic-12.0-stock_analytic
Translate-URL: https://translation.odoo-community.org/projects/account-analytic-12-0/account-analytic-12-0-stock_analytic/hr/
Currently translated at 100.0% (4 of 4 strings)

Translation: account-analytic-12.0/account-analytic-12.0-stock_analytic
Translate-URL: https://translation.odoo-community.org/projects/account-analytic-12-0/account-analytic-12-0-stock_analytic/de/
Currently translated at 100.0% (4 of 4 strings)

Translation: account-analytic-12.0/account-analytic-12.0-stock_analytic
Translate-URL: https://translation.odoo-community.org/projects/account-analytic-12-0/account-analytic-12-0-stock_analytic/pt/
Currently translated at 100.0% (4 of 4 strings)

Translation: account-analytic-12.0/account-analytic-12.0-stock_analytic
Translate-URL: https://translation.odoo-community.org/projects/account-analytic-12-0/account-analytic-12-0-stock_analytic/es/
(cherry picked from commit 9255622)
@aisopuro
Copy link
Contributor

I've been using this code while migrating/developing other things. The one thing I noticed was missing was that the propagation of the analytic distribution does not actually work (I'm not sure if that is a version change or something else). Regardless, I made a fix, which the author is free to cherry-pick into this PR if that makes more sense: #645

Otherwise the tests at least are passing, and I haven't found anything that is in conflict with any version changes.

@rousseldenis
Copy link
Contributor

@moitabenfdz Could you cherry-pick the fix proposed by @aisopuro in #645 ?

@AndrzejGerasimukARCHIMEDES
Copy link

AndrzejGerasimukARCHIMEDES commented Apr 28, 2024

Hi.
I have install this version to my test environment on which I have prepare upgrade from R14 to R17.
I want to report that this module needs pre-migration scripts.
Firstly there is a confilct on a view level. Before upgrade we need to do
delete from ir_ui_view where arch_fs ~ 'stock_analytic';

Second thing: when odoo goes to odoo.models:
Prepare computation of stock.move.line.analytic_distribution
I have a lot of notification such as

odoo.schema: Keep unexpected index stock_move__name_index on table stock_move 
odoo.schema: Keep unexpected index stock_move__priority_index on table stock_move 
odoo.schema: Keep unexpected index stock_move__create_date_index on table stock_move 
odoo.schema: Keep unexpected index stock_picking__priority_index on table stock_picking 
odoo.schema: Keep unexpected index stock_picking__date_index on table stock_picking 
odoo.schema: Keep unexpected index stock_rule__company_id_index on table stock_rule 
odoo.schema: Keep unexpected index stock_rule__auto_index on table stock_rule

And after that I got a warning

py.warnings: /home/odoo/src/odoo/odoo/addons/base/models/ir_module.py:178: DeprecationWarning: XML declarations in HTML module descriptions are deprecated since Odoo 17, stock_analytic can just have a UTF8 description with not need for a declaration.
  File "/home/odoo/src/odoo/odoo-bin", line 8, in <module>

And most important: Historical data was lost. There are no premigration script that will migrate data from analytic_account_id and analitytic_tag_ids to analytic_distribution.
Upgrade just add new field and delete old ones, So I have lost whole historical data from stock analytic.

@aisopuro
Copy link
Contributor

I believe the warning about the deprecated XML can be fixed by rebasing this branch on top of 17. It is apparently caused by out-of-date tool settings in the repo, that should be updated in the latest 17.

@AndrzejGerasimukARCHIMEDES
Copy link

AndrzejGerasimukARCHIMEDES commented Apr 29, 2024

@aisopuro thanks for reply. I found reason and how to resolve it

in: stock_analytic/static/description/index.html

We need to delete XML declarations

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

and add to head section
<meta charset="UTF-8">

obraz

Also
In stock_analytic/views/stock_scrap_views.xml
There is a lack of XML declarations at the begining of code
<?xml version="1.0" encoding="UTF-8" ?>

obraz

And to be honest i think that in each view the UTF-8 sentence schould by in capital letters
obraz

This is my first project on which I collaborate with OCA.
What is the etiquette of good practice? I propose changes in the comments and the authors correct them into the code, or should I commit the proposals myself?

@aisopuro
Copy link
Contributor

@AndrzejGerasimukARCHIMEDES it depends. For small additions/improvements you can do as I did earlier in this PR and make a new branch/PR and let the author know they can cherry-pick your change if they think it works.

For this XML thing, it depends on the style guide and the project readme generation configurations (OCA/odoo-pre-commit-hooks#94).

For me personally, my philosophy is "if they didn't make a lint for it, it probably isn't worth caring about, and fixing it will just add noise to the git log". So I wouldn't change the case of XML declarations unless a lint in the project said something about it.

Ultimately its up to the maintainers to weigh in on whether they think its worth it or not.

If you want to have it fixed, then I recommend my approach from earlier in this PR: make a separate branch where you include a separate commit that fixes the case. Then inform the author of this PR that they are free to cherry-pick it in here if they want to.

@AndrzejGerasimukARCHIMEDES

@aisopuro

obraz

So I can't create my own branch for cherry-picking

@moitabenfdz can You consider make small changes from #614 (comment)?

(sorry if i do anything wrong in giving a feedback - i am a newbie)

Also it would be great if You add pre-migration script in
stock_analytic/migrations/17.0.0.0.0/pre-migration-cleanup.py

import logging

_logger = logging.getLogger(__name__)


# noinspection PyUnusedLocal
def migrate(cr, installed_version):
    _logger.info(f'Start migration stock_analytic 17.0.0.0.0 from {installed_version} - pre cleanup')

    with cr.savepoint():

        cr.execute(
            """
                delete from ir_ui_view where arch_fs ~ 'stock_analytic'           
        """
        )

    _logger.info('migration stock_analytic finished')

@aisopuro
Copy link
Contributor

@AndrzejGerasimukARCHIMEDES you will need to fork the project into some organization you have write access to, either your company's or your personal one. That can then be public, and can be referenced freely.

@AndrzejGerasimukARCHIMEDES

@aisopuro Thanks for help.

@moitabenfdz i have made PR #651
Can You cherry-pick changes from it? (79b498c)

@peluko00
Copy link
Contributor

Any update @moitabenfdz ?

Copy link

@GuillemCForgeFlow GuillemCForgeFlow left a comment

Choose a reason for hiding this comment

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

code review LGTM 👍🏿

@StefanRijnhart
Copy link
Member

@AndrzejGerasimukARCHIMEDES Your migration script from #651 seems to belong primarily in the 16.0 branch, which is where the switch from analytic_account_id to analytic_distribution is made. I agree with @aisopuro that the other changes in your branch are less important and don't need to be included in here in. So I think we can proceed with merging this one first, and then go ahead with any other suggestions in new PRs.

@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
Contributor

@peluko00 peluko00 left a comment

Choose a reason for hiding this comment

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

LGTM

@peluko00
Copy link
Contributor

peluko00 commented Aug 6, 2024

It's ready @StefanRijnhart?

@StefanRijnhart
Copy link
Member

@peluko00 yes!

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 17.0-ocabot-merge-pr-614-by-StefanRijnhart-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit e930e8d into OCA:17.0 Aug 7, 2024
5 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 63dd863. Thanks a lot for contributing to OCA. ❤️

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.