From 8052869b19aaf2105713e0a8ba0555ca25dc26ef Mon Sep 17 00:00:00 2001 From: nafex Date: Tue, 6 Jun 2017 15:25:42 +0200 Subject: [PATCH 1/3] [FIX] delivery: create_price_rules won't create unnecessary rules anymore When updating a carrier that is not "fixed" or "base_on_rule", this method was creating unnecessary delivery.price.rule at each write. This patch fixes this issue. Closes PR #17443 --- addons/delivery/models/delivery_carrier.py | 40 +++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/addons/delivery/models/delivery_carrier.py b/addons/delivery/models/delivery_carrier.py index dad4e8a315f..fa46ef9b5f3 100644 --- a/addons/delivery/models/delivery_carrier.py +++ b/addons/delivery/models/delivery_carrier.py @@ -201,26 +201,26 @@ class DeliveryCarrier(models.Model): if record.delivery_type == 'fixed': PriceRule.search([('carrier_id', '=', record.id)]).unlink() - line_data = { - 'carrier_id': record.id, - 'variable': 'price', - 'operator': '>=', - } - # Create the delivery price rules - if record.free_if_more_than: - line_data.update({ - 'max_value': record.amount, - 'standard_price': 0.0, - 'list_base_price': 0.0, - }) - PriceRule.create(line_data) - if record.fixed_price is not False: - line_data.update({ - 'max_value': 0.0, - 'standard_price': record.fixed_price, - 'list_base_price': record.fixed_price, - }) - PriceRule.create(line_data) + line_data = { + 'carrier_id': record.id, + 'variable': 'price', + 'operator': '>=', + } + # Create the delivery price rules + if record.free_if_more_than: + line_data.update({ + 'max_value': record.amount, + 'standard_price': 0.0, + 'list_base_price': 0.0, + }) + PriceRule.create(line_data) + if record.fixed_price is not False: + line_data.update({ + 'max_value': 0.0, + 'standard_price': record.fixed_price, + 'list_base_price': record.fixed_price, + }) + PriceRule.create(line_data) return True @api.model From c4c9347b9986f60f1b8a534b805e248b25e3eef8 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Thu, 8 Jun 2017 13:53:49 +0200 Subject: [PATCH 2/3] [IMP] web: Expose char_domain dialog widget This simple return allows submodules to be able to know when a dialog is shown and modify something in it. Note from GED: I am aware that this is a IMP in a stable version, and I really don't like that... But it looks like it really helps many people, as shown by the PR, and the risk induced by this commit is definitely extremely low, so I will make an exception. (PR: #15579) --- addons/web/static/src/js/views/form_widgets.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/web/static/src/js/views/form_widgets.js b/addons/web/static/src/js/views/form_widgets.js index 450025ee06b..70a11214901 100644 --- a/addons/web/static/src/js/views/form_widgets.js +++ b/addons/web/static/src/js/views/form_widgets.js @@ -501,6 +501,8 @@ var FieldCharDomain = common.AbstractField.extend(common.ReinitializeFieldMixin, } } }).open(); + this.trigger("dialog_opened", dialog); + return dialog; }, }); From 77be3d8b396f31adfa11d2cd10a22ee3a7f27883 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 7 Jun 2017 15:49:32 +0200 Subject: [PATCH 3/3] [FIX] account: avoid duplicated move name Commits 9365482df05 and 8fc81b871debc2 attempted to prevent the creation of two moves with the same name during reconciliation. It works in most cases, but it is still possible to reconcile the same statement line with more than one line. We add an extra check to make sure duplicate never happen. opw-742018 --- addons/account/models/account_bank_statement.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py index c9634d5f270..e49546e31e7 100644 --- a/addons/account/models/account_bank_statement.py +++ b/addons/account/models/account_bank_statement.py @@ -891,6 +891,10 @@ class AccountBankStatementLine(models.Model): # Create the move self.sequence = self.statement_id.line_ids.ids.index(self.id) + 1 move_name = (self.statement_id.name or self.name) + "/" + str(self.sequence) + # Ensure no duplicate is created + if self.env['account.move'].search([('name', '=', move_name)]): + count = self.env['account.move'].search_count([('name', '=like', move_name + '/%')]) + move_name = u'{}/{}'.format(move_name, count + 1) move_vals = self._prepare_reconciliation_move(move_name) move = self.env['account.move'].create(move_vals) counterpart_moves = (counterpart_moves | move)