Skip to content
Merged
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions addons/account/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
],
'demo': [
'demo/account_demo.xml',
'demo/openupgrade_account_demo.xml',
],
'qweb': [
"static/src/xml/account_reconciliation.xml",
Expand Down
16 changes: 16 additions & 0 deletions addons/account/demo/account_invoice_demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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
Expand Down
39 changes: 39 additions & 0 deletions addons/account/demo/openupgrade_account_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo><data>

<!-- accounts to use with demo invoices -->
<record
id="openupgrade_demo_sales_account"
model="account.account"
>
<field
name="company_id"
eval="ref('base.main_company')"
/>
<field name="code">sales</field>
<field name="name">Sales</field>
<field name="internal_type">other</field>
<field
name="user_type_id"
eval="ref('account.data_account_type_revenue')"
/>
</record>

<record
id="openupgrade_demo_purchase_account"
model="account.account"
>
<field
name="company_id"
eval="ref('base.main_company')"
/>
<field name="code">purchase</field>
<field name="name">Purchase</field>
<field name="internal_type">other</field>
<field
name="user_type_id"
eval="ref('account.data_account_type_expenses')"
/>
</record>

</data></odoo>
20 changes: 9 additions & 11 deletions addons/account/migrations/10.0.1.1/openupgrade_analysis_work.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
71 changes: 71 additions & 0 deletions addons/account/migrations/10.0.1.1/post-migration.py
Original file line number Diff line number Diff line change
@@ -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
''')
18 changes: 18 additions & 0 deletions addons/account/migrations/10.0.1.1/pre-migration.py
Original file line number Diff line number Diff line change
@@ -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'),
]
)