From 32421c4daa749c48ff0f74f93f7df8fed1a08784 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Tue, 27 Mar 2018 17:14:14 +0200 Subject: [PATCH 1/9] [FIX] account: Name of an account.payment Steps to reproduce the bug: - Create a bank statement with a blank name - Reconcile any line statement with an invoice - Review the payment that was made for this statement Bug: The payment had no name. opw:182754 --- addons/account/i18n/account.pot | 6 ++++++ addons/account/models/account_bank_statement.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/account/i18n/account.pot b/addons/account/i18n/account.pot index 2cc903886d2..e899b46b5af 100644 --- a/addons/account/i18n/account.pot +++ b/addons/account/i18n/account.pot @@ -1970,6 +1970,12 @@ msgstr "" msgid "Bank Statement" msgstr "" +#. module: account +#: code:addons/account/models/account_bank_statement.py:935 +#, python-format +msgid "Bank Statement %s" +msgstr "" + #. module: account #: model:ir.model,name:account.model_account_bank_statement_line msgid "Bank Statement Line" diff --git a/addons/account/models/account_bank_statement.py b/addons/account/models/account_bank_statement.py index 43745287c33..5942dfb98f9 100644 --- a/addons/account/models/account_bank_statement.py +++ b/addons/account/models/account_bank_statement.py @@ -932,7 +932,7 @@ class AccountBankStatementLine(models.Model): 'currency_id': currency.id, 'amount': abs(total), 'communication': self._get_communication(payment_methods[0] if payment_methods else False), - 'name': self.statement_id.name, + 'name': self.statement_id.name or _("Bank Statement %s") % self.date, }) # Complete dicts to create both counterpart move lines and write-offs From 2e3b249723fb4a7bc7a31de8f7a59f69bcabab7c Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Thu, 22 Mar 2018 17:13:29 +0100 Subject: [PATCH 2/9] [FIX] stock_account: Wrong decorator The function _get_anglo_saxon_price_unit using a record set and a model. --- addons/stock_account/stock_account.py | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/stock_account/stock_account.py b/addons/stock_account/stock_account.py index 18c07c0fbed..6c7271c1a3e 100644 --- a/addons/stock_account/stock_account.py +++ b/addons/stock_account/stock_account.py @@ -82,7 +82,6 @@ class ProductProduct(models.Model): ] return [] - @api.model def _get_anglo_saxon_price_unit(self, uom=False): price = self.standard_price if not uom or self.uom_id.id == uom.id: From bed33e1ca241c9cb0ff22897dbe60af476d59590 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Tue, 27 Mar 2018 15:58:36 +0200 Subject: [PATCH 3/9] [FIX] web_editor: block only the form's buttons Commit cae188514fa8b0a7c785a630ac4aff677b2071fa was largely incomplete and inaccurate in fixing the issue at hand The aim of this commit is to deactivate the form buttons when the Html field is not completely loaded thus preventing the temporary value of the iframe to be saved OPW 1824545 closes #23905 --- addons/web_editor/static/src/js/backend.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/addons/web_editor/static/src/js/backend.js b/addons/web_editor/static/src/js/backend.js index 23505c082fa..b160e6a7e97 100644 --- a/addons/web_editor/static/src/js/backend.js +++ b/addons/web_editor/static/src/js/backend.js @@ -194,7 +194,8 @@ var FieldTextHtml = widget.extend({ }, start: function () { var self = this; - + // Do not Forward port in >= 11.0 + this.$formButtons = this.getParent().$buttons; this.callback = _.uniqueId('FieldTextHtml_'); window.odoo[this.callback+"_editor"] = function (EditorBar) { setTimeout(function () { @@ -297,7 +298,8 @@ var FieldTextHtml = widget.extend({ this.$el.closest('.modal-body').css('max-height', 'none'); this.$iframe = this.$el.find('iframe'); // deactivate any button to avoid saving a not ready iframe - $('.o_cp_buttons, .o_statusbar_buttons').find('button').addClass('o_disabled').attr('disabled', true); + // Do not Forward port in >= 11.0 + this.$formButtons.find('button').addClass('o_disabled').attr('disabled', true); this.document = null; this.$body = $(); this.$content = $(); @@ -324,7 +326,8 @@ var FieldTextHtml = widget.extend({ this._dirty_flag = false; this.render_value(); // reactivate all the buttons when the field's content (the iframe) is loaded - $('.o_cp_buttons, .o_statusbar_buttons').find('button').removeClass('o_disabled').attr('disabled', false); + // Do not Forward port in >= 11.0 + this.$formButtons.find('button').removeClass('o_disabled').attr('disabled', false); setTimeout(function () { self.add_button(); setTimeout(self.resize,0); @@ -422,6 +425,8 @@ var FieldTextHtml = widget.extend({ } }, destroy: function () { + // Do not Forward port in >= 11.0 + this.$formButtons.find('button').removeClass('o_disabled').attr('disabled', false); $(window).off('resize', this.resize); delete window.odoo[this.callback+"_editor"]; delete window.odoo[this.callback+"_content"]; From 97fc813a1a416caffdd3ca3b057dab1974a4f239 Mon Sep 17 00:00:00 2001 From: "Yenthe V.G" Date: Mon, 26 Mar 2018 14:19:46 +0200 Subject: [PATCH 4/9] [FIX] account: fix performance issue with check_lock_date --- addons/account/models/account_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index ee1aded3938..6fe81fbf202 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -1216,7 +1216,7 @@ class AccountMoveLine(models.Model): raise UserError(_('You cannot do this modification on a reconciled entry. You can just change some non legal fields or you must unreconcile first.\n%s.') % err_msg) if line.move_id.id not in move_ids: move_ids.add(line.move_id.id) - self.env['account.move'].browse(list(move_ids))._check_lock_date() + self.env['account.move'].browse(list(move_ids))._check_lock_date() return True #################################################### From a52a6b865c782a8ad23108d569e577ff54543e4f Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 29 Mar 2018 10:56:08 +0200 Subject: [PATCH 5/9] [FIX] calendar: set color on right partner When doing a sudo on top, the fields are accessed with user 1 but the set is also made with user 1. meeting.user_id.partner_id.id is correctly computed but meeting.partner_color_id is not set for the current user (return 0) All events were in the same color Introduced at b669c71aa39 opw-1829793 Closes #23923 --- addons/calendar/models/calendar.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/calendar/models/calendar.py b/addons/calendar/models/calendar.py index 7103a103b06..cf788a42432 100644 --- a/addons/calendar/models/calendar.py +++ b/addons/calendar/models/calendar.py @@ -841,8 +841,8 @@ class Meeting(models.Model): @api.multi def _compute_color_partner(self): - for meeting in self.sudo(): - meeting.color_partner_id = meeting.user_id.partner_id.id + for meeting in self: + meeting.color_partner_id = meeting.sudo().user_id.partner_id.id @api.constrains('start_datetime', 'stop_datetime', 'start_date', 'stop_date') def _check_closing_date(self): From 1dbc65567604d85ce4cd5c663e8d9cdfd71316a4 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 28 Mar 2018 12:46:30 +0200 Subject: [PATCH 6/9] [FIX] account: reverse pair Commit b6d4cd5deb319c9 introduced the auto-reconciliation when reversing an entry. However, we should make sure to only reconcile non-reconciled entries. Such an entry can be generated from an exchange rate entry. opw-1826024 --- addons/account/models/account_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index 9933a91270e..5df5f1c93c7 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -220,7 +220,7 @@ class AccountMove(models.Model): # Do not forward port in >= saas-14 def _reconcile_reversed_pair(self, move, reversed_move): - amls_to_reconcile = move.line_ids + reversed_move.line_ids + amls_to_reconcile = (move.line_ids + reversed_move.line_ids).filtered(lambda l: not l.reconciled) accounts_reconcilable = amls_to_reconcile.mapped('account_id').filtered(lambda a: a.reconcile) for account in accounts_reconcilable: amls_for_account = amls_to_reconcile.filtered(lambda l: l.account_id.id == account.id) From 8a906f80b4120ca96afcc58331e4ef8733be28c6 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Thu, 29 Mar 2018 11:50:11 +0200 Subject: [PATCH 7/9] [FIX] stock: Inventory Adjustments Deletion It's not allowed to delete inventory adjustement linked to validated moves. opw:1826300 --- addons/stock/i18n/stock.pot | 6 ++++++ addons/stock/models/stock_inventory.py | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/addons/stock/i18n/stock.pot b/addons/stock/i18n/stock.pot index 559aa1d3b85..e6f8f7478aa 100644 --- a/addons/stock/i18n/stock.pot +++ b/addons/stock/i18n/stock.pot @@ -6647,6 +6647,12 @@ msgstr "" msgid "You cannot delete a scrap which is done." msgstr "" +#. module: stock +#: code:addons/stock/models/stock_inventory.py:103 +#, python-format +msgid "You cannot delete a validated inventory adjustement." +msgstr "" + #. module: stock #: code:addons/stock/models/stock_inventory.py:374 #, python-format diff --git a/addons/stock/models/stock_inventory.py b/addons/stock/models/stock_inventory.py index 283dc12ee5f..2f1b757960a 100644 --- a/addons/stock/models/stock_inventory.py +++ b/addons/stock/models/stock_inventory.py @@ -96,6 +96,13 @@ class Inventory(models.Model): else: self.total_qty = 0 + @api.multi + def unlink(self): + for inventory in self: + if inventory.state == 'done': + raise UserError(_('You cannot delete a validated inventory adjustement.')) + return super(Inventory, self).unlink() + @api.model def _selection_filter(self): """ Get the list of filter allowed according to the options checked From 15c3cbab55fa0b842537177824908278ea1183ee Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 29 Mar 2018 14:23:56 +0200 Subject: [PATCH 8/9] [FIX] stock_landed_costs: digits precision - Set the number of digits of 'Product Unit of Measure' to 1 - Create a stockable product: UOM: Dozens Purchase UOM: Units - Buy 17 Units, validate the picking - Create a landed cost: Amount: 100 Split Method: By Quantity - Compute The Valuation Adjustment line contains contains a line with a quantity equal to 1.4, leading to a line of 98.60. It is impossible to validate the landed cost because of the inconsistency. The method `get_valuation_lines` retrieves the data from the `stock.move` and copies the following values to the `stock.valuation.adjustment.lines`: - `product_qty` > `quantity` - `weight` > `weight` - `volume` > `volume` Therefore, we must make sure that these fields are using the same digits precision. We adapt the precisions accordingly. opw-1817783 --- addons/stock_landed_costs/models/stock_landed_cost.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/addons/stock_landed_costs/models/stock_landed_cost.py b/addons/stock_landed_costs/models/stock_landed_cost.py index 43c125415cf..a1223d896c8 100644 --- a/addons/stock_landed_costs/models/stock_landed_cost.py +++ b/addons/stock_landed_costs/models/stock_landed_cost.py @@ -282,13 +282,12 @@ class AdjustmentLines(models.Model): product_id = fields.Many2one('product.product', 'Product', required=True) quantity = fields.Float( 'Quantity', default=1.0, - digits=dp.get_precision('Product Unit of Measure'), required=True) + digits=0, required=True) weight = fields.Float( 'Weight', default=1.0, - digits=dp.get_precision('Product Unit of Measure')) + digits=dp.get_precision('Stock Weight')) volume = fields.Float( - 'Volume', default=1.0, - digits=dp.get_precision('Product Unit of Measure')) + 'Volume', default=1.0) former_cost = fields.Float( 'Former Cost', digits=dp.get_precision('Product Price')) former_cost_per_unit = fields.Float( From 2b4bc45e589de7a3d8934640ecc6ad82673ae707 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Thu, 29 Mar 2018 15:05:59 +0200 Subject: [PATCH 9/9] [FIX] sale: Wrong display of taxes in PRO-FORMA Steps to reproduce the bug: -Create a tax of 21% tax included but don't select the "affect base" checkbox. -Create another tax of 5.2% (no tax include) -Create a sale order with a line that has a unit price of 121 and both taxes. Notice that the total amount is: 126.2 (100 base amount + 21 from 21% tax + 5.2 from 5.2 tax) -Click on "Print the proforma invoice" Bug: The total amount was still 126.2 and base=100, however taxes were wrong, there were 21 for the 21% tax and 6.29 instead of 5.2 for the 5.2 tax. Back-port of this commit: f50a08bc3d53a1ccb7821c9dacd89c18f1215f15 Forward up to saas-15 opw:1819882 --- addons/sale/models/sale.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/addons/sale/models/sale.py b/addons/sale/models/sale.py index ef74b8315b0..5d0dd9d83cd 100644 --- a/addons/sale/models/sale.py +++ b/addons/sale/models/sale.py @@ -502,19 +502,14 @@ class SaleOrder(models.Model): res = {} currency = self.currency_id or self.company_id.currency_id for line in self.order_line: - base_tax = 0 + price_reduce = line.price_unit * (1.0 - line.discount / 100.0) + taxes = line.tax_id.compute_all(price_reduce, quantity=line.product_uom_qty, product=line.product_id, partner=self.partner_shipping_id)['taxes'] for tax in line.tax_id: group = tax.tax_group_id res.setdefault(group, 0.0) - # FORWARD-PORT UP TO SAAS-17 - price_reduce = line.price_unit * (1.0 - line.discount / 100.0) - taxes = tax.compute_all(price_reduce + base_tax, quantity=line.product_uom_qty, - product=line.product_id, partner=self.partner_shipping_id)['taxes'] for t in taxes: - res[group] += t['amount'] - if tax.include_base_amount: - base_tax += tax.compute_all(price_reduce + base_tax, quantity=1, product=line.product_id, - partner=self.partner_shipping_id)['taxes'][0]['amount'] + if t['id'] == tax.id or t['id'] in tax.children_tax_ids.ids: + res[group] += t['amount'] res = sorted(res.items(), key=lambda l: l[0].sequence) res = map(lambda l: (l[0].name, l[1]), res) return res