credativ team mailing list archive
-
credativ team
-
Mailing list archive
-
Message #05348
[Merge] lp:~therp-nl/openupgrade-server/7.0-sync_commercial_fields into lp:openupgrade-server
Stefan Rijnhart (Therp) has proposed merging lp:~therp-nl/openupgrade-server/7.0-sync_commercial_fields into lp:openupgrade-server.
Requested reviews:
OpenUpgrade Committers (openupgrade-committers)
For more details, see:
https://code.launchpad.net/~therp-nl/openupgrade-server/7.0-sync_commercial_fields/+merge/176473
--
https://code.launchpad.net/~therp-nl/openupgrade-server/7.0-sync_commercial_fields/+merge/176473
Your team OpenUpgrade Committers is requested to review the proposed merge of lp:~therp-nl/openupgrade-server/7.0-sync_commercial_fields into lp:openupgrade-server.
=== modified file 'openerp/modules/loading.py'
--- openerp/modules/loading.py 2013-05-07 07:08:52 +0000
+++ openerp/modules/loading.py 2013-07-23 20:02:25 +0000
@@ -444,6 +444,10 @@
else:
_logger.info('removed %d unused menus', cr.rowcount)
+ # STEP 5 1/2 (OpenUpgrade): deferred call to sync commercial partner fields
+ if update_module:
+ openupgrade_loading.sync_commercial_fields(cr, pool)
+
# STEP 6: Uninstall modules to remove
if update_module:
# Remove records referenced from ir_model_data for modules to be
=== modified file 'openerp/openupgrade/openupgrade_loading.py'
--- openerp/openupgrade/openupgrade_loading.py 2012-11-24 22:38:22 +0000
+++ openerp/openupgrade/openupgrade_loading.py 2013-07-23 20:02:25 +0000
@@ -19,7 +19,9 @@
#
##############################################################################
+import logging
import types
+from openerp import SUPERUSER_ID
from openerp.osv.orm import TransientModel
from openerp.osv import fields
from openerp.openupgrade.openupgrade import table_exists
@@ -27,6 +29,8 @@
# A collection of functions used in
# openerp/modules/loading.py
+logger = logging.getLogger("OpenUpgrade")
+
def add_module_dependencies(cr, module_list):
"""
Select (new) dependencies from the modules in the list
@@ -158,3 +162,25 @@
(key, value, record_id)
)
old_field[key] = value
+
+def sync_commercial_fields(cr, pool):
+ """
+ Take care of propagating the commercial fields
+ in the new partner model. To be called after the
+ upgrade process has finished.
+ """
+ partner_obj = pool.get('res.partner')
+ fields = partner_obj._commercial_fields(
+ cr, SUPERUSER_ID)
+ partner_ids = partner_obj.search(
+ cr, SUPERUSER_ID,
+ [], False, False, {'active_test': False})
+ logger.info("Syncing commercial fields between %s partners",
+ len(partner_ids))
+ for partner_id in partner_ids:
+ vals = partner_obj.read(
+ cr, SUPERUSER_ID, partner_id, fields, load='_classic_write')
+ partner_obj._fields_sync(
+ cr, SUPERUSER_ID,
+ partner_obj.browse(cr, SUPERUSER_ID, partner_id),
+ vals)
Follow ups