diff --git a/.travis.yml b/.travis.yml index e4f20e684c78..997f110bd34b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,6 +53,7 @@ script: - pip install -q -r requirements.txt # this crashes if there is no test data - if [ -s ../test_data90.yml ]; then ./openerp-server --database=$DB --test-file=`readlink -f ../test_data90.yml` --test-commit --stop-after-init; fi + # Line below may fail occasionaly due to Travis bug: - git reset -q --hard $TRAVIS_COMMIT # Install Python requirements of target release - pip install -q -r requirements.txt diff --git a/addons/account/__manifest__.py b/addons/account/__manifest__.py index f3699bff5858..f2651884e9bc 100644 --- a/addons/account/__manifest__.py +++ b/addons/account/__manifest__.py @@ -67,6 +67,7 @@ ], 'demo': [ 'demo/account_demo.xml', + 'demo/openupgrade_account_demo.xml', ], 'qweb': [ "static/src/xml/account_reconciliation.xml", diff --git a/addons/account/demo/account_invoice_demo.yml b/addons/account/demo/account_invoice_demo.yml index 669bb7892fc0..2aca48803584 100644 --- a/addons/account/demo/account_invoice_demo.yml +++ b/addons/account/demo/account_invoice_demo.yml @@ -12,9 +12,13 @@ - product_id: product.consu_delivery_02 price_unit: 642.0 quantity: 5 + account_id: account.openupgrade_demo_sales_account + name: 'consu_delivery_02' - product_id: product.consu_delivery_03 price_unit: 280.0 quantity: 5.0 + account_id: account.openupgrade_demo_sales_account + name: 'consu_delivery_03' - !python {model: account.invoice, id: demo_invoice_1}: self.action_invoice_open() @@ -27,9 +31,13 @@ - product_id: product.consu_delivery_03 price_unit: 50.0 quantity: 3 + account_id: account.openupgrade_demo_sales_account + name: 'consu_delivery_03' - product_id: product.consu_delivery_01 price_unit: 25 quantity: 20 + account_id: account.openupgrade_demo_sales_account + name: 'consu_delivery_01' - !python {model: account.invoice, id: demo_invoice_2}: self.action_invoice_open() @@ -42,9 +50,13 @@ - product_id: product.consu_delivery_01 price_unit: 90.0 quantity: 5 + account_id: account.openupgrade_demo_sales_account + name: 'consu_delivery_01' - product_id: product.consu_delivery_03 price_unit: 15.0 quantity: 5.0 + account_id: account.openupgrade_demo_sales_account + name: 'consu_delivery_03' - !python {model: account.invoice, id: demo_invoice_3}: self.action_invoice_open() @@ -66,10 +78,14 @@ quantity: 1.0 product_id: product.product_delivery_01 uom_id: product.product_uom_unit + account_id: account.openupgrade_demo_purchase_account + name: 'product_delivery_01' - price_unit: 4.0 quantity: 1.0 product_id: product.product_order_01 uom_id: product.product_uom_unit + account_id: account.openupgrade_demo_purchase_account + name: 'product_order_01' - !record {model: account.invoice, id: demo_invoice_january_wages}: partner_id: base.res_partner_12 diff --git a/addons/account/demo/openupgrade_account_demo.xml b/addons/account/demo/openupgrade_account_demo.xml new file mode 100644 index 000000000000..1a92958ee73d --- /dev/null +++ b/addons/account/demo/openupgrade_account_demo.xml @@ -0,0 +1,39 @@ + + + + + + + sales + Sales + other + + + + + + purchase + Purchase + other + + + + diff --git a/addons/account/migrations/10.0.1.1/openupgrade_analysis_work.txt b/addons/account/migrations/10.0.1.1/openupgrade_analysis_work.txt index 83e0e2970e5e..e7716c8ca887 100644 --- a/addons/account/migrations/10.0.1.1/openupgrade_analysis_work.txt +++ b/addons/account/migrations/10.0.1.1/openupgrade_analysis_work.txt @@ -7,14 +7,13 @@ account / account.bank.statement / website_message_ids (one2many): DEL re # NOTHING TO DO account / account.bank.statement.line / move_name (char) : NEW -# TODO: Calculate during post-migration using the move name associated to the +# DONE: Calculate during post-migration using the move name associated to the # the move lines that have that statement_id account / account.full.reconcile / exchange_move_id (many2one) : NEW relation: account.move account / account.full.reconcile / exchange_partial_rec_id (many2one): NEW relation: account.partial.reconcile -# TODO: Can we determine what were the move lines created as part of the -# reconciliation when the exchange rate was different? If we can obtain, then -# update. Otherwise leave blank. +# DONE: Moves for exchange rate differences where in field +# rate_diff_partial_rec_id of account_move. account / account.invoice / refund_invoice_id (many2one) : NEW relation: account.invoice account / account.invoice / website_message_ids (one2many): DEL relation: mail.message @@ -24,18 +23,17 @@ account / account.invoice.line / analytic_tag_ids (many2many) : NEW re # NOTHING TO DO account / account.move / rate_diff_partial_rec_id (many2one): DEL relation: account.partial.reconcile -# TODO: Perhaps it is related to account.full.reconcile -# exchange_partial_rec_id. To be analyzed. +# DONE: The data is now on account.full.reconcile, in the field exchange_partial_rec_id. account / account.move.line / analytic_tag_ids (many2many) : NEW relation: account.analytic.tag # NOTHING TO DO account / account.payment / move_name (char) : NEW -# TODO: Calculate during post-migration using the move name associated to the +# DONE: Calculate during post-migration using the move name associated to the # the move lines that have that payment. ## NEW MODEL ACCOUNT.RECONCILE.MODEL ## -# TODO: pre-migration: rename table account.operation.template to +# DONE: pre-migration: rename table account.operation.template to # account.reconcile.model account / account.reconcile.model / name (char) : NEW required: required account / account.reconcile.model / sequence (integer) : NEW required: required, req_default: function @@ -56,8 +54,8 @@ account / account.reconcile.model / second_tax_id (many2one) : NEW re account / account.reconcile.model / second_analytic_account_id (many2one): NEW relation: account.analytic.account account / account.reconcile.model / second_journal_id (many2one) : NEW relation: account.journal -## NEW MODEL ACCOUNT.RECONCILE.MODEL ## -# TODO: pre-migration: precreate records from the account.operation.template, +## NEW MODEL ACCOUNT.RECONCILE.MODEL.TEMPLATE ## +# DONE: post-migration: precreate records from the account.reconcile.model, # selecting the ones that are distinct regardless of the company account / account.reconcile.model.template / name (char) : NEW required: required account / account.reconcile.model.template / sequence (integer) : NEW required: required, req_default: function @@ -81,7 +79,7 @@ account / account.tax.template / tax_adjustment (boolean) : NEW # NOTHING TO DO account / account.tax.template / tax_group_id (many2one) : NEW relation: account.tax.group -# ??? MORE ANALYSIS REQUIRED +# NOTHING TO DO (If not set on template, default tax group will be used) account / res.company / paypal_account (char) : DEL # NOTHING TO DO diff --git a/addons/account/migrations/10.0.1.1/post-migration.py b/addons/account/migrations/10.0.1.1/post-migration.py new file mode 100644 index 000000000000..60947a4ccaaa --- /dev/null +++ b/addons/account/migrations/10.0.1.1/post-migration.py @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- +# © 2017 Therp BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from openupgradelib import openupgrade + + +@openupgrade.migrate(use_env=True) +def migrate(env, version): + cr = env.cr + # Insert appropiate enties in account_reconcile_model_template + cr.execute( + '''INSERT INTO account_reconcile_model_template + (create_uid, create_date, write_uid, write_date, + name, sequence, has_second_line, + account_id, label, tax_id, amount_type, amount, + second_account_id, second_label, second_tax_id, second_amount_type, + second_amount) + SELECT + MIN(create_uid), MIN(create_date), MAX(write_uid), MAX(write_date), + name, sequence, has_second_line, + account_id, label, tax_id, amount_type, amount, + second_account_id, second_label, second_tax_id, second_amount_type, + second_amount + FROM account_reconcile_model + GROUP BY + name, sequence, has_second_line, + account_id, label, tax_id, amount_type, amount, + second_account_id, second_label, second_tax_id, second_amount_type, + second_amount + ''') + # Update move_name in account_payment from account_move + cr.execute( + '''UPDATE account_payment + SET move_name = subquery.name + FROM (SELECT DISTINCT ON (aml.payment_id) am.name, aml.payment_id + FROM account_move am + JOIN account_move_line aml ON am.id = aml.move_id + WHERE NOT aml.payment_id IS NULL + ORDER BY aml.payment_id, am.name + ) AS subquery + WHERE account_payment.id = subquery.payment_id + ''') + # Move old rate_diff_partial_rec_id in account_move to + # exchange_partial_rec_id in account_full_reconcile: + cr.execute( + '''UPDATE account_full_reconcile + SET exchange_partial_rec_id = subquery.rate_diff_partial_rec_id + , exchange_move_id = subquery.move_id + FROM ( + SELECT + apr.full_reconcile_id, + am.rate_diff_partial_rec_id, + am.id as move_id + FROM account_partial_reconcile apr + JOIN account_move am + ON apr.id = am.rate_diff_partial_rec_id + ) AS subquery + WHERE account_full_reconcile.id = subquery.full_reconcile_id + ''') + # Update move_name on account_bank_statement_line: + cr.execute( + '''UPDATE account_bank_statement_line + SET move_name = subquery.name + FROM ( + SELECT + am.name, + am.statement_line_id + FROM account_move am + ) AS subquery + WHERE account_bank_statement_line.id = subquery.statement_line_id + ''') diff --git a/addons/account/migrations/10.0.1.1/pre-migration.py b/addons/account/migrations/10.0.1.1/pre-migration.py new file mode 100644 index 000000000000..aa53f4ac8911 --- /dev/null +++ b/addons/account/migrations/10.0.1.1/pre-migration.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# © 2017 Therp BV +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from openupgradelib import openupgrade + + +@openupgrade.migrate(use_env=True) +def migrate(env, version): + cr = env.cr + # copy columns good practice in pre-mig script format of colum_spec should + # be: { Table_name_in_db : [( old_column_name , new_column_name, type)] + # defaults of new columname are fetchable via method get_legacy_name + openupgrade.rename_tables( + cr, + [ + ('account_operation_template', 'account_reconcile_model'), + ] + )