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

[15.0][MIG] contract: Migration to version 15.0 #738

Merged
merged 290 commits into from
Nov 26, 2021

Conversation

jcdrubay
Copy link
Contributor

@jcdrubay jcdrubay commented Oct 28, 2021

Fixes deprecation warnings

includes migration scripts to upgrade from v14:

To test

update ir_module_module set latest_version='15.0.0' where name='contract';

Output

2021-10-29 05:53:06,279 46091 INFO v15 OpenUpgrade: contract: post-migration script called with version 15.0.0
2021-10-29 05:53:06,279 46091 INFO v15 OpenUpgrade: contract: loading migrations/15.0.1.0.0/noupdate_changes.xml
2021-10-29 05:53:06,309 46091 DEBUG v15 OpenUpgrade: 0 rows affected after 0:00:00.000359 running
            DELETE FROM ir_translation
            WHERE module = 'contract' AND name LIKE 'mail.template,%' AND res_id = 10;

2021-10-29 05:53:06,309 46091 DEBUG v15 OpenUpgrade: 0 rows affected after 0:00:00.000221 running
            DELETE FROM ir_translation
            WHERE module = 'contract' AND name LIKE 'ir.ui.view,%' AND res_id = 752;

2021-10-29 05:53:06,309 46091 DEBUG v15 OpenUpgrade: 0 rows affected after 0:00:00.000232 running
            DELETE FROM ir_translation
            WHERE module = 'contract' AND name LIKE 'mail.template,%' AND res_id = 11;

carlosdauden and others added 4 commits October 28, 2021 14:04
Bug description
---------------

`account.analytic.contract.line` inherits
`account.analytic.invoice.line`

`account.analytic.invoice.line` defines field `analytic_account_id`:
   - comodel='account.analytic.account'

`account.analytic.contract.line` redefines field `analytic_account_id`:
   - comodel='account.analytic.contract'

On attempt to extend `account.analytic.invoice.line` model adding
field that depends on `analytic_account_id.date_start`
Odoo fails to update, because it adds this field to
`account.analytic.contract.line` through inheritance,
and `account.analytic.contract` model have no this field.

What is done
------------

Change inheritance order:
- `account.analytic.invoice.line` inherits
`account.analytic.contract.line`
- no file renames at this stage (this wil be done in next commit)
@@ -1,96 +1,92 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<odoo noupdate="0">
Copy link
Member

Choose a reason for hiding this comment

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

I find this dangerous... a subsequent module upgrade will wipe manual changes to the template.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, it did this during dev to test the mail template changes more easily and forgot to put it back.

Copy link
Member

Choose a reason for hiding this comment

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

Well. This should be a migration. I'm not sure about the best way do do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you worried about the upgrade from v14 to v15? Then, indeed, it's more complex than I first thought.

Anyway, I think we should keep the noupdate=1 because that it is the expected behavior.

Then we could have a migration script to force the update, because anyway any old templates from an older major version of Odoo wouldn't work. But is such a migration script from one major version to another meant to be here, in this repo? It has been discussed few months back (without conclusion so far I think).

OCA/OpenUpgrade#2661 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for sharing the examples @pedrobaeza .

@@ -17,7 +17,7 @@ def to_date(date):
return fields.Date.to_date(date)


class TestContractBase(common.SavepointCase):
class TestContractBase(common.TransactionCase):
Copy link
Member

Choose a reason for hiding this comment

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

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SavepointCase is deprecated:
https://github.com/odoo/odoo/blob/15.0/odoo/tests/common.py#L742

"Deprecated class SavepointCase has been merged into TransactionCase",

@dreispt
Copy link
Member

dreispt commented Oct 28, 2021

Note that pre-commit is red.

@jcdrubay
Copy link
Contributor Author

Thanks @dreispt . I will submit a new version tomorrow. Hopefully this will be merged during the OCA days :)

@jcdrubay
Copy link
Contributor Author

@dreispt @pedrobaeza I finalized the changes. Hopefully, next time you only need to ask me to rebase ;)

Copy link
Member

@dreispt dreispt left a comment

Choose a reason for hiding this comment

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

LGTM, but would like confirmation from Pedro that the template migration looks good

@dreispt dreispt requested a review from pedrobaeza October 29, 2021 20:57
@pedrobaeza pedrobaeza changed the title 15.0 mig contract [15.0][MIG] contract: Migration to version 15.0 Oct 30, 2021
@pedrobaeza pedrobaeza mentioned this pull request Oct 30, 2021
18 tasks
@pedrobaeza
Copy link
Member

Thanks for the migration. Please try to put a good PR title, or on contrary, it won't be found when searching, and this may lead to duplicated migration PR and so on. I have already changed the title for this one.

Other formal aspects before starting my review:

  • Please squash administrative commits with the main one as per the migration guide, as the number of commits is very high if not. For example, you can perform this squashing:
    Selección_022
  • It seems you have several pre-commit + black commits. You should squash them with the commit that originates them.
  • I would also squash all the migration stuff, explaining in the migration commit message the actions done.

katyukha and others added 16 commits November 9, 2021 10:05
In previous commit changed inheritance order of
'account.analytic.*.line' models, thus classes and models were renamed.

This commit only renames files to temporary names.

This commit does not change file contents.

[UPD] Update contract.pot
Runbot URL in old README.rst pointed to 10.0 runbot,
fixed by upgrading template
Currently translated at 96.0% (96 of 100 strings)

Translation: contract-11.0/contract-11.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-11-0/contract-11-0-contract/nl/
Currently translated at 53.0% (53 of 100 strings)

Translation: contract-11.0/contract-11.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-11-0/contract-11-0-contract/de/
Currently translated at 75.0% (75 of 100 strings)

Translation: contract-11.0/contract-11.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-11-0/contract-11-0-contract/de/

[UPD] README.rst
Currently translated at 98.0% (98 of 100 strings)

Translation: contract-11.0/contract-11.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-11-0/contract-11-0-contract/es/
Currently translated at 10.0% (10 of 100 strings)

Translation: contract-11.0/contract-11.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-11-0/contract-11-0-contract/pt_PT/
The test as it was, leaves to the demo pricelist the control on the price of
the product, so other modules that modifies this pricelist will make the
test to fail.

This is the minimum change needed for avoiding the problem.
    - Module: contract
    - Summary: several terms where not translated to Spanish.
Currently translated at 99.0% (99 of 100 strings)

Translation: contract-12.0/contract-12.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-12-0/contract-12-0-contract/de/
Updated by Update PO files to match POT (msgmerge) hook in Weblate.
Currently translated at 100.0% (109 of 109 strings)

Translation: contract-12.0/contract-12.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-12-0/contract-12-0-contract/es/
Currently translated at 100.0% (109 of 109 strings)

Translation: contract-12.0/contract-12.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-12-0/contract-12-0-contract/gl/
victoralmau and others added 18 commits November 9, 2021 10:08
… contract modification mail.

[UPD] Update contract.pot
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: contract-14.0/contract-14.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-14-0/contract-14-0-contract/
Currently translated at 100.0% (306 of 306 strings)

Translation: contract-14.0/contract-14.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-14-0/contract-14-0-contract/es_AR/

[UPD] Update contract.pot
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: contract-14.0/contract-14.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-14-0/contract-14-0-contract/
Currently translated at 100.0% (307 of 307 strings)

Translation: contract-14.0/contract-14.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-14-0/contract-14-0-contract/es_AR/
It seems that having several fields returned by `Form` as `False` that
are related to one2many inverse field, makes Odoo ORM mad, and get to
an unbalanced move when generating the invoice.

Cleaning these values assures to work without problems.

Not able to provide a regression test, as I don't get to reproduce the
conditions to happen in test environment, but the patch is safe and
harmless anyways.

TT30842
Currently translated at 72.9% (224 of 307 strings)

Translation: contract-14.0/contract-14.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-14-0/contract-14-0-contract/tr/
In v13, the `user_id` field is a related field to `invoice_user_id`, that defaults to the environment user (`self.env.user`).
Therefore, if we try to create an invoice just by passing `user_id`, it would be overwritten by the default computation of `invoice_user_id`.
This fixes it by passing the correct field and data.

TT31715
Currently translated at 98.3% (302 of 307 strings)

Translation: contract-14.0/contract-14.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-14-0/contract-14-0-contract/ca/
Currently translated at 80.4% (247 of 307 strings)

Translation: contract-14.0/contract-14.0-contract
Translate-URL: https://translation.odoo-community.org/projects/contract-14-0/contract-14-0-contract/pt/
Most changes are related to the switch from jinja to qweb in mail templates.

Also included:
- convert deprecated onchange that returns a domain and other deprecation warnings
  (see below)
- Add migration scripts from version 14.0 (force the update of the mail templates)
- Fix warnings from pre-commit checks

Fixes depreciation warnings:

- onchange method ContractAbstractContractLine._onchange_product_id returned
  a domain, this is deprecated
- SavepointCase is deprecated:
  https://github.com/odoo/odoo/blob/15.0/odoo/tests/common.py#L742
- assertDictContainsSubset: According to:
  https://stackoverflow.com/questions/20050913/python-unittests-assertdictcontainssubset-recommended-alternative
@jcdrubay
Copy link
Contributor Author

jcdrubay commented Nov 9, 2021

@pedrobaeza If you want to review, the rebase is complete. (it's not the place to discuss this, but I find it a bit "over-demanding" to ask contributor of migration to squash historical commits from the previous versions). I am fine with it, but I guess it is something to consider to facilitate the on-boarding of new contributors.

Runbot still fails but I think it is with know issues:

  • [0mThe command '/bin/sh -c /bin/bash -c "source ${REPO_REQUIREMENTS}/virtualenv/python3.8/bin/activate && source ${REPO_REQUIREMENTS}/virtualenv/nodejs/bin/activate && source /rvm_env.sh && /install"' returned a non-zero code: 1
  • docker: Error response from daemon: pull access denied for oca-contract, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

[Not a maintainer] [Figured how to Review now :)] Tested on clean VM all seems to work only thing that flagged in my logs was:

2021-11-18 09:24:40,145 2940 INFO odoo odoo.addons.base.models.ir_module: python external dependency on 'dateutil' does not appear to be a valid PyPI package. Using a PyPI package name is recommended.
Which I believe to not be a migration issue but a dependency issue in general. Putting it on my production instance until the merge goes through. Thanks @jcdrubay

@pedrobaeza
Copy link
Member

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

On my way to merge this fine PR!
Prepared branch 15.0-ocabot-merge-pr-738-by-pedrobaeza-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 504dba3 into OCA:15.0 Nov 26, 2021
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 06e41e5. 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.