From 61fe7a782002abb5d7cd7394d83a81f6248267e9 Mon Sep 17 00:00:00 2001 From: qdp-odoo Date: Mon, 23 Apr 2018 16:47:00 +0200 Subject: [PATCH 1/5] [FIX] account: allow switching from CoA if empty moves exists This is needed in case we open the Chart of Account step from the configuration bar, as it will silently create the opening journal entry --- addons/account/models/chart_template.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account/models/chart_template.py b/addons/account/models/chart_template.py index f2e5183eee0..8de2ea0f685 100644 --- a/addons/account/models/chart_template.py +++ b/addons/account/models/chart_template.py @@ -847,7 +847,7 @@ class WizardMultiChartsAccounts(models.TransientModel): @api.multi def existing_accounting(self, company_id): - model_to_check = ['account.move.line', 'account.invoice', 'account.move', 'account.payment', 'account.bank.statement'] + model_to_check = ['account.move.line', 'account.invoice', 'account.payment', 'account.bank.statement'] for model in model_to_check: if len(self.env[model].search([('company_id', '=', company_id.id)])) > 0: return True @@ -882,7 +882,7 @@ class WizardMultiChartsAccounts(models.TransientModel): accounting_props.unlink() # delete account, journal, tax, fiscal position and reconciliation model - models_to_delete = ['account.reconcile.model', 'account.fiscal.position', 'account.tax', 'account.journal'] + models_to_delete = ['account.reconcile.model', 'account.fiscal.position', 'account.tax', 'account.move', 'account.journal'] for model in models_to_delete: res = self.env[model].search([('company_id', '=', self.company_id.id)]) if len(res): From c1bf1c6a5460611c2c1cfdbe736d3b1741c7300b Mon Sep 17 00:00:00 2001 From: Mohammed Shekha Date: Mon, 16 Apr 2018 15:06:10 +0530 Subject: [PATCH 2/5] [FIX] web: preserve new column order after creation When a user creates a new column in a kanban view, leave the action and comes back, the order is not preserved. With this commit, we force a call to resequence to ensure that the order does not change. --- .../src/js/views/kanban/kanban_controller.js | 18 +++++++++++++++--- addons/web/static/tests/helpers/mock_server.js | 3 +++ addons/web/static/tests/views/kanban_tests.js | 12 +++++++++--- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/addons/web/static/src/js/views/kanban/kanban_controller.js b/addons/web/static/src/js/views/kanban/kanban_controller.js index 11d17a78fa9..5cc2653d6cf 100644 --- a/addons/web/static/src/js/views/kanban/kanban_controller.js +++ b/addons/web/static/src/js/views/kanban/kanban_controller.js @@ -107,6 +107,16 @@ var KanbanController = BasicController.extend({ var groupedByM2o = groupByField && (groupByField.type === 'many2one'); return groupedByM2o; }, + /** + * @param {string[]} ids + * @private + * @returns {Deferred} + */ + _resequenceColumns: function (ids) { + var state = this.model.get(this.handle, {raw: true}); + var model = state.fields[state.groupedBy[0]].relation; + return this.model.resequence(model, ids, this.handle); + }, /** * This method calls the server to ask for a resequence. Note that this * does not rerender the user interface, because in most case, the @@ -156,6 +166,10 @@ var KanbanController = BasicController.extend({ _onAddColumn: function (event) { var self = this; this.model.createGroup(event.data.value, this.handle).then(function () { + var state = self.model.get(self.handle, {raw: true}); + var ids = _.pluck(state.data, 'res_id').filter(_.isNumber); + return self._resequenceColumns(ids); + }).then(function () { return self.update({}, {reload: false}); }).then(function () { self._updateButtons(); @@ -428,9 +442,7 @@ var KanbanController = BasicController.extend({ */ _onResequenceColumn: function (event) { var self = this; - var state = this.model.get(this.handle, {raw: true}); - var model = state.fields[state.groupedBy[0]].relation; - this.model.resequence(model, event.data.ids, this.handle).then(function () { + this._resequenceColumns(event.data.ids).then(function () { self._updateEnv(); }); }, diff --git a/addons/web/static/tests/helpers/mock_server.js b/addons/web/static/tests/helpers/mock_server.js index b7addb7cb45..5955bae6af7 100644 --- a/addons/web/static/tests/helpers/mock_server.js +++ b/addons/web/static/tests/helpers/mock_server.js @@ -921,6 +921,9 @@ var MockServer = Class.extend({ case '/web/dataset/search_read': return $.when(this._mockSearchReadController(args)); + + case '/web/dataset/resequence': + return $.when(); } if (route.indexOf('/web/image') >= 0 || _.contains(['.png', '.jpg'], route.substr(route.length - 4))) { return $.when(); diff --git a/addons/web/static/tests/views/kanban_tests.js b/addons/web/static/tests/views/kanban_tests.js index 190d94a6c7f..03a6e31ad8e 100644 --- a/addons/web/static/tests/views/kanban_tests.js +++ b/addons/web/static/tests/views/kanban_tests.js @@ -1130,7 +1130,7 @@ QUnit.module('Views', { }); QUnit.test('create a column in grouped on m2o', function (assert) { - assert.expect(13); + assert.expect(14); var nbRPCs = 0; var kanban = createView({ @@ -1149,6 +1149,11 @@ QUnit.module('Views', { if (args.method === 'name_create') { assert.ok(true, "should call name_create"); } + //Create column will call resequence to set column order + if (route === '/web/dataset/resequence') { + assert.ok(true, "should call resequence"); + return $.when(true); + } return this._super(route, args); }, }); @@ -1229,7 +1234,7 @@ QUnit.module('Views', { }); QUnit.test('delete a column in grouped on m2o', function (assert) { - assert.expect(32); + assert.expect(33); testUtils.patch(KanbanRenderer, { _renderGrouped: function () { @@ -2015,7 +2020,7 @@ QUnit.module('Views', { }); QUnit.test('archive new kanban column', function (assert) { - assert.expect(15); + assert.expect(16); this.data.partner.fields.active = {string: 'Active', type: 'char', default: true}; @@ -2044,6 +2049,7 @@ QUnit.module('Views', { kanban.$('.o_column_quick_create input').val('new colum'); kanban.$('.o_column_quick_create button.o_kanban_add').click(); rpcs.push('/web/dataset/call_kw/product/name_create'); + rpcs.push('/web/dataset/resequence'); assert.verifySteps(rpcs); // add a record inside From fcc6e9e3be6c7079c93e4476d0fe340235432aca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Tue, 24 Apr 2018 10:22:24 +0200 Subject: [PATCH 3/5] [FIX] web: correct docstring (was showing incorrect type) This is my mistake, I added the docstring without properly checking the type. --- addons/web/static/src/js/views/kanban/kanban_controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web/static/src/js/views/kanban/kanban_controller.js b/addons/web/static/src/js/views/kanban/kanban_controller.js index 5cc2653d6cf..7d3da850a7e 100644 --- a/addons/web/static/src/js/views/kanban/kanban_controller.js +++ b/addons/web/static/src/js/views/kanban/kanban_controller.js @@ -108,7 +108,7 @@ var KanbanController = BasicController.extend({ return groupedByM2o; }, /** - * @param {string[]} ids + * @param {number[]} ids * @private * @returns {Deferred} */ From 0351b492d55e297699a6881e10500d007bd7e10f Mon Sep 17 00:00:00 2001 From: qdp-odoo Date: Tue, 24 Apr 2018 10:45:57 +0200 Subject: [PATCH 4/5] [FIX] account: fix unreconciliation implying several exchange rate entries Use case fixed: manual reconciliation through the account.move.line list of items with several currencies, that will create a full reconcilation with several exchange rate entries to balance the amounts in all foreign currencies. Unreconciling these lines was wrongly creating an account.move with a lot of lines with debit = credit = amount_currency = 0. --- addons/account/models/account_move.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 727bdf298ae..11f83b3fd36 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -1135,13 +1135,15 @@ class AccountMoveLine(models.Model): #create an empty move that will hold all the exchange rate adjustments exchange_move = False - if aml_to_balance_currency: + if aml_to_balance_currency and any([residual for dummy, residual in aml_to_balance_currency.values()]): exchange_move = self.env['account.move'].create( self.env['account.full.reconcile']._prepare_exchange_diff_move(move_date=maxdate, company=self[0].company_id)) for currency, values in aml_to_balance_currency.items(): aml_to_balance = values[0] total_amount_currency = values[1] + if not total_amount_currency: + continue #eventually create journal entries to book the difference due to foreign currency's exchange rate that fluctuates aml_recs, partial_recs = self.env['account.partial.reconcile'].create_exchange_rate_entry(aml_to_balance, 0.0, total_amount_currency, currency, exchange_move) From b9ce1affbf55bb81dde718af435e4763bd19c80c Mon Sep 17 00:00:00 2001 From: qdp-odoo Date: Tue, 24 Apr 2018 12:10:06 +0200 Subject: [PATCH 5/5] [REV] account: reverts commit 0351b492d55e297699a6881e10500d007bd7e10f. Unexpected runbot failure detected. Pach reverted for further investigation. Sorry for the disturbance --- addons/account/models/account_move.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 11f83b3fd36..727bdf298ae 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -1135,15 +1135,13 @@ class AccountMoveLine(models.Model): #create an empty move that will hold all the exchange rate adjustments exchange_move = False - if aml_to_balance_currency and any([residual for dummy, residual in aml_to_balance_currency.values()]): + if aml_to_balance_currency: exchange_move = self.env['account.move'].create( self.env['account.full.reconcile']._prepare_exchange_diff_move(move_date=maxdate, company=self[0].company_id)) for currency, values in aml_to_balance_currency.items(): aml_to_balance = values[0] total_amount_currency = values[1] - if not total_amount_currency: - continue #eventually create journal entries to book the difference due to foreign currency's exchange rate that fluctuates aml_recs, partial_recs = self.env['account.partial.reconcile'].create_exchange_rate_entry(aml_to_balance, 0.0, total_amount_currency, currency, exchange_move)