← Back to team overview

credativ team mailing list archive

lp:~therp-nl/openupgrade-addons/6.0_add_default_company_id_account_period into lp:openupgrade-addons/6.0

 

Holger Brunn (Therp) has proposed merging lp:~therp-nl/openupgrade-addons/6.0_add_default_company_id_account_period into lp:openupgrade-addons/6.0.

Requested reviews:
  OpenUpgrade Committers (openupgrade-committers)
Related bugs:
  Bug #1030494 in OpenUpgrade Server: "raise osv.except_osv(_('Error !'), _('No period defined for this date: %s !\nPlease create a fiscal year.')%dt)"
  https://bugs.launchpad.net/openupgrade-server/+bug/1030494

For more details, see:
https://code.launchpad.net/~therp-nl/openupgrade-addons/6.0_add_default_company_id_account_period/+merge/117190

I don't like this patch, but given that in openerp's upgrade procedure the defaults for account_move are pulled before the ones for account_fiscalyear (from which in turn account_period gets its company_id), I don't see another solution.
-- 
https://code.launchpad.net/~therp-nl/openupgrade-addons/6.0_add_default_company_id_account_period/+merge/117190
Your team OpenUpgrade Committers is requested to review the proposed merge of lp:~therp-nl/openupgrade-addons/6.0_add_default_company_id_account_period into lp:openupgrade-addons/6.0.
=== modified file 'account/migrations/6.0.1.1/pre-migration.py'
--- account/migrations/6.0.1.1/pre-migration.py	2012-06-07 14:51:52 +0000
+++ account/migrations/6.0.1.1/pre-migration.py	2012-07-29 18:01:24 +0000
@@ -45,4 +45,8 @@
     # changes data type of one of the columns
     sql.drop_view_if_exists(cr, 'report_invoice_created')
     mgr_refund_journal_type(cr)
-
+    # company of account_period needs to be updated before defaults
+    # are applied
+    cr.execute('alter table account_period add column company_id integer')
+    cr.execute('update account_period set company_id=(select '+
+    'company_id from res_users where id=account_period.create_uid)')