Skip to content

Commit

Permalink
# This is a combination of 13 commits.
Browse files Browse the repository at this point in the history
parent c973596
author 张飞虎 <feihu.zhang@yumtown.com.cn> 1711431231 +0000
committer 张飞虎 <feihu.zhang@yumtown.com.cn> 1717058855 +0000

# This is a combination of 2 commits.
# This is the 1st commit message:

parent c973596
author 张飞虎 <feihu.zhang@yumtown.com.cn> 1711431231 +0000
committer 张飞虎 <feihu.zhang@yumtown.com.cn> 1717058818 +0000

添加openupgrade_framework代码OCA#4327

增加upgrade_anaylysis_work.txt

init base migration script

初步完成base模块的升级脚本

初步添加account模块升级脚本

修复文件名错误

BUG Fix

增加mail模块升级脚本

完成mail升级脚本

初步添加hr升级脚本

完成hr模块升级脚本

# This is the commit message OCA#2:

完成account模块升级脚本

# This is the commit message OCA#3:

更新模块清单

# This is the commit message OCA#4:

添加sale_management升级脚本

# This is the commit message OCA#5:

修复升级问题

# This is the commit message OCA#6:

完善project模块升级脚本

# This is the commit message OCA#7:

增加一堆模块no_update的处理

# This is the commit message OCA#8:

BUG Fix

# This is the commit message OCA#9:

暂时移除delivery升级脚本

# This is the commit message OCA#10:

改进项目升级脚本

# This is the commit message OCA#11:

添加针对hr_responsible_id字段的处理

# This is the commit message OCA#12:

增加auth_signup升级脚本

# This is the commit message OCA#13:

修复mail_alias上的mail_channel数据
  • Loading branch information
xtanuiha committed May 30, 2024
1 parent c973596 commit 87bdc24
Show file tree
Hide file tree
Showing 32 changed files with 1,988 additions and 60 deletions.
211 changes: 211 additions & 0 deletions openupgrade_framework/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,217 @@
Openupgrade Framework
=====================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:06d77ecf97625ec075fa31dde7f8f41bcf849fa13af0598f8c1de397348f2dfd
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fopenupgrade-lightgray.png?logo=github
:target: https://github.com/OCA/openupgrade/tree/17.0/openupgrade_framework
:alt: OCA/openupgrade
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/openupgrade-17-0/openupgrade-17-0-openupgrade_framework
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/openupgrade&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module is a technical module that contains a number of
monkeypatches to improve the behaviour of Odoo when migrating your
database using the OpenUpgrade migration scripts:

- Prevent dropping columns or tables in the database when fields or
models are obsoleted in the Odoo data model of the target release.
After the migration, you can review and delete unused database tables
and columns using database_cleanup. See
https://odoo-community.org/shop/product/database-cleanup-918
- When data records are deleted during the migration (such as views or
other system records), this is done in a secure mode. If the deletion
fails because of some unforeseen dependency, the deletion will be
cancelled and a message is logged, after which the migration
continues.
- Prevent a number of log messages that do not apply when using
OpenUpgrade.
- Suppress log messages about failed view validation, which are to be
expected during a migration.
- Run migration scripts for modules that are installed as new
dependencies of upgraded modules (when there are such scripts for
those particular modules)
- Production databases generated with demo data, will be transformed to
non-demo ones. If you want to avoid that, you have to pass through
the environment variable OPENUPGRADE_USE_DEMO, the value "yes".

For detailed documentation see:

- https://github.com/OCA/OpenUpgrade/
- https://oca.github.io/OpenUpgrade

**Table of contents**

.. contents::
:local:

Installation
============

This module does not need to be installed on a database. It simply needs
to be available via your ``addons-path``.

Configuration
=============

- call your odoo instance with the option
``--load=base,web,openupgrade_framework``

or

- add the key to your configuration file:

.. code:: shell
[options]
server_wide_modules = web,openupgrade_framework
When you load the module in either way of these ways, and you have the
openupgrade_scripts module in your addons path available, the
--upgrade-path option of Odoo will be set automatically to the location
of the OpenUpgrade migration scripts.

Development
===========

The odoo_patch folder contains python files in a tree that mimicks the
folder tree of the Odoo project. It contains a number of monkey patches
to improve the migration of an Odoo database between two major versions.

So far, we are able to make everything work without overwriting large
blocks of code, but if larger patches need to be added, please use the
method described below:

To see the patches added, you can use ``meld`` tools:

``meld PATH_TO_ODOO_FOLDER/odoo/ PATH_TO_OPENUPGRADE_FRAMEWORK_MODULE/odoo_patch``

To make more easy the diff analysis :

- Make sure the python files has the same path as the original one.
- Keep the same indentation as the original file. (using ``if True:``
if required)
- Add the following two lines at the beginning of your file, to avoid
flake8 / pylint errors

.. code:: python
# flake8: noqa
# pylint: skip-file
- When you want to change the code. add the following tags:

For an addition:

.. code:: python
# <OpenUpgrade:ADD>
some code...
# </OpenUpgrade>
For a change:

.. code:: python
# <OpenUpgrade:CHANGE>
some code...
# </OpenUpgrade>
For a removal:

.. code:: python
# <OpenUpgrade:REMOVE>
# Comment the code, instead of removing it.
# </OpenUpgrade>
Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/openupgrade/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/openupgrade/issues/new?body=module:%20openupgrade_framework%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Therp BV
* Opener B.V.
* GRAP
* Hunki Enterprises BV

Contributors
------------

- Stefan Rijnhart <stefan@opener.amsterdam>
- Sylvain LE GAL <https://twitter.com/legalsylvain>

Other credits
-------------

Many developers have contributed to the OpenUpgrade framework in its
previous incarnation. Their original contributions may no longer needed,
or they are no longer recognizable in their current form but OpenUpgrade
would not have existed at this point without them.

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-legalsylvain| image:: https://github.com/legalsylvain.png?size=40px
:target: https://github.com/legalsylvain
:alt: legalsylvain
.. |maintainer-StefanRijnhart| image:: https://github.com/StefanRijnhart.png?size=40px
:target: https://github.com/StefanRijnhart
:alt: StefanRijnhart
.. |maintainer-hbrunn| image:: https://github.com/hbrunn.png?size=40px
:target: https://github.com/hbrunn
:alt: hbrunn

Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-legalsylvain| |maintainer-StefanRijnhart| |maintainer-hbrunn|

This module is part of the `OCA/openupgrade <https://github.com/OCA/openupgrade/tree/17.0/openupgrade_framework>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

=====================
Openupgrade Framework
=====================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
Expand Down
16 changes: 16 additions & 0 deletions openupgrade_scripts/scripts/account/17.0.1.2/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2023 Odoo Community Association (OCA)
# Copyright 2023 Shanghai Yumtown <info@yumtown.com.cn>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from openupgradelib import openupgrade

def update_company(env):
openupgrade.logged_query(
env.cr,
"UPDATE res_company SET invoice_is_download = invoice_is_print;"
)

@openupgrade.migrate()
def migrate(env, version):
openupgrade.load_data(env, "account", "17.0.1.2/noupdate_changes.xml")
update_company(env)
19 changes: 19 additions & 0 deletions openupgrade_scripts/scripts/account/17.0.1.2/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2023 Odoo Community Association (OCA)
# Copyright 2023 Shanghai Yumtown <info@yumtown.com.cn>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from openupgradelib import openupgrade

def update_account_report(env):
openupgrade.logged_query(
env.cr,
"""
ALTER TABLE account_report
ALTER COLUMN filter_account_type TYPE varchar
USING CASE WHEN filter_account_type THEN 'both' ELSE 'disabled' END;
"""
)

@openupgrade.migrate()
def migrate(env, version):
update_account_report(env)
Loading

0 comments on commit 87bdc24

Please sign in to comment.