OCA / odoo-module-migrator

Python library to migrate odoo base code from a version to another
GNU Affero General Public License v3.0
123 stars 112 forks source link

[13.0] '.env.user.company_id' -> '.env.company' + Remove 'dp.get_precision' calls #53

Closed joao-p-marques closed 3 years ago

joao-p-marques commented 3 years ago
  1. Warn about change from .env.user.company_id to .env.company
  2. Remove dp.get_precision calls

Example:

  1. New warning:
    jota@jlap:~/D/T/p/d/o/c/s/product-attribute|12.0✓
    ➤ odoo-module-migrate -m $MODULE --init-version-name 12.0 --target-version-name 13.0 --no-commit
    07:28:23   INFO        [product_multi_price] Running migration from 12.0 to 13.0
    07:28:23   INFO        Removing 'migrations' folder
    07:28:23   INFO        Change file content of multi_price_views.xml
    07:28:23   WARNING     [13] If the intended use is to get 'current active company', you need to change '.env.user.company_id' to '.env.company'. File [...]
    07:28:23   INFO        Change file content of product_multi_price.py
    07:28:23   WARNING     [13] If the intended use is to get 'current active company', you need to change '.env.user.company_id' to '.env.company'. File [...]
  2. Remove call:

    diff --git a/product_multi_price/models/product_multi_price.py b/product_multi_price/models/product_multi_price.py
    index 8be0abf2..0235f92a 100644
    --- a/product_multi_price/models/product_multi_price.py
    +++ b/product_multi_price/models/product_multi_price.py
    @@ -1,7 +1,6 @@
    # Copyright 2020 Tecnativa - David Vidal
    # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
    from odoo import api, fields, models
    -from odoo.addons import decimal_precision as dp
    
    class ProductMultiPrice(models.Model):
    @@ -19,7 +18,7 @@ class ProductMultiPrice(models.Model):
         ondelete='cascade',
     )
     price = fields.Float(
    -        digits=dp.get_precision('Product Price'),
    +        digits='Product Price',
     )
     company_id = fields.Many2one(
         comodel_name='res.company',

@Tecnativa TT27865

joao-p-marques commented 3 years ago

Thanks @legalsylvain I added a simple test for that case.

legalsylvain commented 3 years ago

thanks !

joao-p-marques commented 3 years ago

@yelizariev the latest 2 commits should fix the issue and improve the rules and test as suggested.

yelizariev commented 3 years ago

Don't forget to clean commit and merge them into 2-3 commits

joao-p-marques commented 3 years ago

@yelizariev done I left the 2 changes to the setup file and to the base migration script in separate commits to make it easier to reference in the future

joao-p-marques commented 3 years ago

@yelizariev commit history fixed. Thanks!

yelizariev commented 3 years ago

Yes, clean now :+1:

@legalsylvain this PR also fixes my update #42

OCA-git-bot commented 3 years ago

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

FernandoRomera commented 3 years ago

@legalsylvain Can you merge this PR? Thanks.

FernandoRomera commented 3 years ago

@Yajo or @legalsylvain Please, can you merge this PR?

legalsylvain commented 3 years ago

/ocabot merge nobump

OCA-git-bot commented 3 years ago

This PR looks fantastic, let's merge it! Prepared branch master-ocabot-merge-pr-53-by-legalsylvain-bump-nobump, awaiting test results.

OCA-git-bot commented 3 years ago

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