From 2efc7b4c67f724faa953843827673bf0beef1dd6 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Mon, 23 Sep 2019 08:22:02 +0000 Subject: [PATCH 01/18] [FIX] base: Wrong field on model ir.cron The field name doesn't exist on model ir.cron closes odoo/odoo#37309 X-original-commit: 730845354bb53b0f391564c2152b7b2f2019981e Signed-off-by: Denis Vermylen --- odoo/addons/base/models/ir_cron.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo/addons/base/models/ir_cron.py b/odoo/addons/base/models/ir_cron.py index ccc34bd3dd1..f2f11742e2e 100644 --- a/odoo/addons/base/models/ir_cron.py +++ b/odoo/addons/base/models/ir_cron.py @@ -228,7 +228,7 @@ class ir_cron(models.Model): try: registry = odoo.registry(db_name) registry[cls._name]._process_job(job_cr, job, lock_cr) - _logger.info('Job `%s` done.', job['name']) + _logger.info('Job `%s` done.', job['cron_name']) except Exception: _logger.exception('Unexpected exception while processing cron job %r', job) finally: From 21f5771773b1ccd0980b3d80bb6d7efac8145dfe Mon Sep 17 00:00:00 2001 From: fw-bot Date: Mon, 23 Sep 2019 13:01:03 +0000 Subject: [PATCH 02/18] [FIX] purchase_stock: RFQ automatically created with an inactive vendor Steps to reproduce the bug: - Let's consider the storable product P and the vendor V - Set V as a supplier of P - Archive V - Go to product P and click on button "Replenish" Bug: A RFQ was created with the vendor V Fine tuning of https://github.com/odoo/odoo/commit/5040c17e873b8476c754f1f3e1686c2a02b36e48 opw:2066616 closes odoo/odoo#37285 Signed-off-by: Nicolas Martinelli (nim) --- addons/product/models/product.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/product/models/product.py b/addons/product/models/product.py index 986a59f5146..af1ec35d97b 100644 --- a/addons/product/models/product.py +++ b/addons/product/models/product.py @@ -614,7 +614,7 @@ class ProductProduct(models.Model): 'target': 'new'} def _prepare_sellers(self, params): - return self.seller_ids + return self.seller_ids.filtered(lambda s: s.name.active) @api.multi def _select_seller(self, partner_id=False, quantity=0.0, date=None, uom_id=False, params=False): @@ -805,7 +805,6 @@ class SupplierInfo(models.Model): 'res.partner', 'Vendor', domain=[('supplier', '=', True)], ondelete='cascade', required=True, help="Vendor of this product") - active = fields.Boolean(related='name.active', readonly=True) product_name = fields.Char( 'Vendor Product Name', help="This vendor's product name will be used when printing a request for quotation. Keep empty to use the internal one.") From 673d3b871d99fed549345744bf22f2b9d50d0576 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 24 Sep 2019 07:52:15 +0000 Subject: [PATCH 03/18] [FIX] stock: incorrect translation causing crash opw-2075946 closes odoo/odoo#37330 Signed-off-by: Nicolas Martinelli (nim) --- addons/stock/i18n/fr.po | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/stock/i18n/fr.po b/addons/stock/i18n/fr.po index 73ae6b4b742..950113e1471 100644 --- a/addons/stock/i18n/fr.po +++ b/addons/stock/i18n/fr.po @@ -5971,7 +5971,9 @@ msgstr "" msgid "" "The backorder %s has" " been created." -msgstr "" +msgstr "" +msgstr "Le reliquat %s a été" +" créé." #. module: stock #: sql_constraint:stock.location:0 From fba64a71535ba5e2878970379b55f1ca6cc0028e Mon Sep 17 00:00:00 2001 From: "Andrea Grazioso (agr-odoo)" Date: Mon, 23 Sep 2019 10:12:54 +0000 Subject: [PATCH 04/18] [FIX] google_calendar: Slow calendar sync Create a lot of event (i.e. 300 via recursive events) with attedees. Sync. Cancel all the events. Sync again. This and all subsequent synchronization will take a lot of time to complete. The first time is normal because odoo will cross-check every deleted event for the "syncing" user with google to ensure that there is match between OE and GC. This matching will sistematically fail because the json module cannot serialize a datetime object, so it will be retriggered again and again stalling the synchronization for minutes. Formatting the datetime before calling the dump fixes. Moreover the api usage was wrong as 'originalStartTime' is not a date but a complex object holding the date. Note: this could have been avoided via logging but error detection was suppressed. opw-2052450 closes odoo/odoo#37335 X-original-commit: 951808b2434717d38ab9d562404eb74d8bd40634 Signed-off-by: agr-odoo --- .../google_calendar/models/google_calendar.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/addons/google_calendar/models/google_calendar.py b/addons/google_calendar/models/google_calendar.py index bf9010f3023..bf15b66ba10 100644 --- a/addons/google_calendar/models/google_calendar.py +++ b/addons/google_calendar/models/google_calendar.py @@ -398,7 +398,17 @@ class GoogleCalendar(models.AbstractModel): url = "/calendar/v3/calendars/%s/events/%s?access_token=%s" % ('primary', instance_id, self.get_token()) headers = {'Content-type': 'application/json'} - data.update(recurringEventId=event_ori_google_id, originalStartTime=event_new.recurrent_id_date, sequence=self.get_sequence(instance_id)) + _originalStartTime = dict() + if event_new.allday: + _originalStartTime['date'] = event_new.recurrent_id_date.strftime("%Y-%m-%d") + else: + _originalStartTime['datetime'] = event_new.recurrent_id_date.strftime("%Y-%m-%dT%H:%M:%S.%fz") + + data.update( + recurringEventId=event_ori_google_id, + originalStartTime=_originalStartTime, + sequence=self.get_sequence(instance_id) + ) data_json = json.dumps(data) return self.env['google.service']._do_request(url, data_json, headers, type='PUT') @@ -666,8 +676,9 @@ class GoogleCalendar(models.AbstractModel): else: _logger.warning("Impossible to create event %s. [%s]", att.event_id.id, status) _logger.debug("Response : %s", response) - except: - pass + except Exception as e: + _logger.warning("Exception when updating recurrent event exclusions on google: %s", e) + return new_ids def update_events(self, lastSync=False): From aade5792e1f43d9d131895c503164736b292023d Mon Sep 17 00:00:00 2001 From: Jorge Pinna Puissant Date: Mon, 23 Sep 2019 11:54:46 +0000 Subject: [PATCH 05/18] [FIX] l10n_it_edi: xml without vat or codice fiscale Since 2302386d3ea47f3160ca5857425c99e0d4bbf62a the VAT or Codice Fiscale fields could be empty for non Italians buyers. In that cases the generated XML must be sent a dummy Codice Fiscale (99999999999), to pass the extra checks, see https://www.fatturapa.gov.it/export/fatturazione/sdi/Elenco_Controlli_V1.1_EN.pdf. opw-2045244 closes odoo/odoo#37346 X-original-commit: 98ea0872efbdb60b9dd04b31dc711b937c2195ec Signed-off-by: Jorge Pinna Puissant (jpp) --- addons/l10n_it_edi/data/invoice_it_template.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/l10n_it_edi/data/invoice_it_template.xml b/addons/l10n_it_edi/data/invoice_it_template.xml index c3af915c58c..b0ca10af9f1 100644 --- a/addons/l10n_it_edi/data/invoice_it_template.xml +++ b/addons/l10n_it_edi/data/invoice_it_template.xml @@ -112,6 +112,7 @@ + From cbea2c5cdb3c5f3a0ffcd5ccf557afdba4eeda72 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 24 Sep 2019 07:05:10 +0000 Subject: [PATCH 06/18] [FIX] account: incorrect SQL operator opw-2075897 closes odoo/odoo#37348 X-original-commit: 2f22b746fdf0315cc0199c547064376eeddf02ac Signed-off-by: Nicolas Martinelli (nim) --- addons/account/models/partner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/models/partner.py b/addons/account/models/partner.py index e9ca819a224..df3a8b2bc8a 100644 --- a/addons/account/models/partner.py +++ b/addons/account/models/partner.py @@ -242,7 +242,7 @@ class ResPartner(models.Model): RIGHT JOIN account_account acc ON aml.account_id = acc.id WHERE acc.internal_type = %s AND NOT acc.deprecated AND acc.company_id = %s - AND move.state == 'posted' + AND move.state = 'posted' GROUP BY partner.id HAVING %s * COALESCE(SUM(aml.amount_residual), 0) ''' + operator + ''' %s''', (account_type, self.env.user.company_id.id, sign, operand)) res = self._cr.fetchall() From a7a60f7c61275f26521cbc4ea0da2889095a5cc5 Mon Sep 17 00:00:00 2001 From: Mathieu Duckerts-Antoine Date: Mon, 23 Sep 2019 12:24:47 +0000 Subject: [PATCH 07/18] [FIX] web: avoid multiple displays of the "same" discard warning Before this commit, editing a record e.g. in a form view and toggling the home menu would cause the discard warning to be displayed twice when going to the home menu (in enterprise) and then once again when going to an other app. This is now fixed. Task ID: 2043027 closes odoo/odoo#37301 Signed-off-by: VincentSchippefilt Co-authored-by: Mohammed Shekha Co-authored-by: aab-odoo --- .../src/js/views/basic/basic_controller.js | 5 ++- .../tests/chrome/action_manager_tests.js | 39 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/views/basic/basic_controller.js b/addons/web/static/src/js/views/basic/basic_controller.js index 9e9e7559ede..c82bf05996b 100644 --- a/addons/web/static/src/js/views/basic/basic_controller.js +++ b/addons/web/static/src/js/views/basic/basic_controller.js @@ -382,10 +382,13 @@ var BasicController = AbstractController.extend(FieldManagerMixin, { options = options || {}; return this.canBeDiscarded(recordID) .then(function (needDiscard) { - if (options.noAbandon || (options.readonlyIfRealDiscard && !needDiscard)) { + if (options.readonlyIfRealDiscard && !needDiscard) { return; } self.model.discardChanges(recordID); + if (options.noAbandon) { + return; + } if (self.model.canBeAbandoned(recordID)) { self._abandonRecord(recordID); return; diff --git a/addons/web/static/tests/chrome/action_manager_tests.js b/addons/web/static/tests/chrome/action_manager_tests.js index 4d05d723ccf..f896fc659ef 100644 --- a/addons/web/static/tests/chrome/action_manager_tests.js +++ b/addons/web/static/tests/chrome/action_manager_tests.js @@ -4033,6 +4033,45 @@ QUnit.module('ActionManager', { actionManager.destroy(); }); + + QUnit.test('Call twice clearUncommittedChanges in a row does not display twice the discard warning', async function (assert) { + assert.expect(4); + + var actionManager = await createActionManager({ + actions: this.actions, + archs: this.archs, + data: this.data, + intercepts: { + clear_uncommitted_changes: function () { + actionManager.clearUncommittedChanges(); + }, + }, + }); + + // execute an action and edit existing record + await actionManager.doAction(3); + + await testUtils.dom.click(actionManager.$('.o_list_view .o_data_row:first')); + assert.containsOnce(actionManager, '.o_form_view.o_form_readonly'); + + await testUtils.dom.click($('.o_control_panel .o_form_button_edit')); + assert.containsOnce(actionManager, '.o_form_view.o_form_editable'); + + await testUtils.fields.editInput(actionManager.$('input[name=foo]'), 'val'); + actionManager.trigger_up('clear_uncommitted_changes'); + await testUtils.nextTick(); + + assert.containsOnce($('body'), '.modal'); // confirm discard dialog + // confirm discard changes + await testUtils.dom.click($('.modal .modal-footer .btn-primary')); + + actionManager.trigger_up('clear_uncommitted_changes'); + await testUtils.nextTick(); + + assert.containsNone($('body'), '.modal'); + + actionManager.destroy(); + }); }); }); From a5835a160ea3f7aea37644ed4e1a49e2e4a6effd Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 24 Sep 2019 09:33:28 +0000 Subject: [PATCH 08/18] [FIX] stock: do not display 'Location' and 'Warehouse' in search view - Go to Inventory > Reporting > Inventory Valuation - Run the report - In the search view, filter on 'Location' or 'Warehouse' The filter doesn't work. Actually, the filter can't work. This is a hack introduced in order to add context keys. Originally, the function `search` was added to avoid the error log 'Non-stored field %s cannot be searched.'. This happens because the web client adds the field in the domain on top of adding the context key. By using `filter_domain`, no domain is added and no error is logged. opw-2075456 closes odoo/odoo#37347 Signed-off-by: Nicolas Martinelli (nim) --- addons/stock/models/product.py | 9 ++++----- addons/stock/views/product_views.xml | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py index 5e3de7f0443..01c4f989676 100644 --- a/addons/stock/models/product.py +++ b/addons/stock/models/product.py @@ -490,11 +490,10 @@ class ProductTemplate(models.Model): outgoing_qty = fields.Float( 'Outgoing', compute='_compute_quantities', search='_search_outgoing_qty', digits=dp.get_precision('Product Unit of Measure')) - # The goal of these fields is not to be able to search a location_id/warehouse_id but - # to properly make these fields "dummy": only used to put some keys in context from - # the search view in order to influence computed field - location_id = fields.Many2one('stock.location', 'Location', store=False, search=lambda operator, operand, vals: []) - warehouse_id = fields.Many2one('stock.warehouse', 'Warehouse', store=False, search=lambda operator, operand, vals: []) + # The goal of these fields is to be able to put some keys in context from search view in order + # to influence computed field. + location_id = fields.Many2one('stock.location', 'Location', store=False) + warehouse_id = fields.Many2one('stock.warehouse', 'Warehouse', store=False) route_ids = fields.Many2many( 'stock.location.route', 'stock_route_product', 'product_id', 'route_id', 'Routes', domain=[('product_selectable', '=', True)], diff --git a/addons/stock/views/product_views.xml b/addons/stock/views/product_views.xml index 64be1d7a250..17a347594cc 100644 --- a/addons/stock/views/product_views.xml +++ b/addons/stock/views/product_views.xml @@ -73,8 +73,8 @@ - - + + From af26c704697df86b98dd9d03b7edba7302342b64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Tue, 24 Sep 2019 08:21:24 +0000 Subject: [PATCH 09/18] [FIX] mail: remove "Please wait..." in Discuss when ready MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Revision on https://github.com/odoo/odoo/commit/9a66619db33fca5f0cb81d9f6bfeb0fb0290cf68 Commit above improved webclient loading by not having to wait for the RPC `/mail/init_messaging`. It introduced an issue in which Discuss app was indefinitely showing "Please wait...". This commit fixes this issue. closes odoo/odoo#37337 Signed-off-by: Alexandre Kühn (aku) --- addons/mail/static/src/js/discuss.js | 2 +- addons/mail/static/tests/discuss_tests.js | 55 ++++++++++++++++++++++- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/addons/mail/static/src/js/discuss.js b/addons/mail/static/src/js/discuss.js index 483a1e99d29..fa4eb62256d 100644 --- a/addons/mail/static/src/js/discuss.js +++ b/addons/mail/static/src/js/discuss.js @@ -506,6 +506,7 @@ var Discuss = AbstractAction.extend({ */ _initRender: function () { var self = this; + this.$('.o_mail_discuss_loading').remove(); this._basicComposer = new BasicComposer(this, { mentionPartnersRestricted: true, showTyping: true, @@ -1420,7 +1421,6 @@ var Discuss = AbstractAction.extend({ if (!this._isStarted) { return; } - this.$('.o_mail_discuss_loading').remove(); this._initRender(); }, /** diff --git a/addons/mail/static/tests/discuss_tests.js b/addons/mail/static/tests/discuss_tests.js index 54477874f44..7b18996b831 100644 --- a/addons/mail/static/tests/discuss_tests.js +++ b/addons/mail/static/tests/discuss_tests.js @@ -1,9 +1,9 @@ odoo.define('mail.discuss_test', function (require) { "use strict"; +const Discuss = require('mail.Discuss'); var mailTestUtils = require('mail.testUtils'); -var concurrency = require('web.concurrency'); var testUtils = require('web.test_utils'); var createDiscuss = mailTestUtils.createDiscuss; @@ -165,6 +165,59 @@ QUnit.test('messaging not ready', async function (assert) { discuss.destroy(); }); +QUnit.test('messaging initially ready', async function (assert) { + assert.expect(7); + + const startDiscussProm = testUtils.makeTestPromise(); + + testUtils.mock.patch(Discuss, { + /** + * @override + */ + async start() { + const _super = this._super.bind(this, ...arguments); // due to limitation of class.js + assert.step('discuss:starting'); + await startDiscussProm; + assert.step('discuss:started'); + return _super(); + }, + }); + + const discussProm = createDiscuss({ + id: 1, + context: {}, + params: {}, + data: this.data, + services: this.services, + mockRPC(route) { + if (route === '/mail/init_messaging') { + assert.step(route); + } + return this._super(...arguments); + } + }); + await testUtils.nextTick(); + assert.verifySteps([ + '/mail/init_messaging', + 'discuss:starting', + ]); + + startDiscussProm.resolve(); + await testUtils.nextTick(); + assert.verifySteps(['discuss:started']); + const discuss = await discussProm; + assert.ok( + discuss.el, + "discuss should be rendered"); + assert.containsNone( + discuss, + '.o_mail_discuss_loading', + "should not display sidebar or content is loading (messaging is ready)"); + + testUtils.mock.unpatch(Discuss); + discuss.destroy(); +}); + QUnit.test('searchview options visibility', async function (assert) { assert.expect(5); From 3c8f9a19731056e9c1a8d95a39f0b8d22e69d412 Mon Sep 17 00:00:00 2001 From: Ankita Raval Date: Wed, 4 Sep 2019 13:35:24 +0000 Subject: [PATCH 10/18] [IMP] hr_expense : fix issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In this commit, we add a currency symbol in kanban card. closes odoo/odoo#36440 Task-id: 2061910 Signed-off-by: Jérome Maes (jem) --- addons/hr_expense/views/hr_expense_views.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/hr_expense/views/hr_expense_views.xml b/addons/hr_expense/views/hr_expense_views.xml index 3fcf76099c6..99e954f882a 100644 --- a/addons/hr_expense/views/hr_expense_views.xml +++ b/addons/hr_expense/views/hr_expense_views.xml @@ -146,6 +146,7 @@ + @@ -153,7 +154,7 @@
- +
@@ -565,13 +566,14 @@ +
- +
From 33f5fc7355115260fba122c96bea0ae965b96dc6 Mon Sep 17 00:00:00 2001 From: Andrea Date: Thu, 28 Feb 2019 08:56:51 +0000 Subject: [PATCH 11/18] [FIX] l10n_ch: set field l10n_ch_currency_name to readonly l10n_ch_currency_name is a related field to currency Without this patch, when creating an invoice, the inverse of the related field was computed, trying to write the name on the currency (with the same value). If a user did not have the required access rights (e.g. a user in the group Billing can create an invoice but not write on res.currency by default), he was unable to create the invoice. Fixes odoo/odoo#31487 Closes odoo/odoo#31489 closes odoo/odoo#37381 X-original-commit: 5e49fa8002d7581bfad6dacee0f0b75de59817ec Signed-off-by: Martin Trigaux (mat) --- addons/l10n_ch/views/account_invoice_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/l10n_ch/views/account_invoice_view.xml b/addons/l10n_ch/views/account_invoice_view.xml index e550670de85..7edc239378b 100644 --- a/addons/l10n_ch/views/account_invoice_view.xml +++ b/addons/l10n_ch/views/account_invoice_view.xml @@ -12,7 +12,7 @@ - + From 14a5983dcaf5ce953ad6dbfa9662cca69813b4f9 Mon Sep 17 00:00:00 2001 From: Nans Lefebvre Date: Tue, 24 Sep 2019 13:31:02 +0000 Subject: [PATCH 12/18] [FIX] base_import: clear cache after a dry run Test import of a file with xml ids. At the first dry run, the xml id X is associated with id R for each such record. If some records refer to X via a relational field, then in SQL it reduces to a query using R as id; but R does not exist since it was a dry run. As a result, subsequent runs fail. The cache should be cleared after a dry run, since the xml ids are not reliable. opw 2068446 closes odoo/odoo#37396 X-original-commit: 1b35294d7b8d07f373eca24977e2952b9cfb2c7d Signed-off-by: Nans Lefebvre (len) --- addons/base_import/models/base_import.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/base_import/models/base_import.py b/addons/base_import/models/base_import.py index dae5b383ca7..bdfdbe41ff4 100644 --- a/addons/base_import/models/base_import.py +++ b/addons/base_import/models/base_import.py @@ -909,6 +909,7 @@ class Import(models.TransientModel): if dryrun: self._cr.execute('ROLLBACK TO SAVEPOINT import') # cancel all changes done to the registry/ormcache + self.pool.clear_caches() self.pool.reset_changes() else: self._cr.execute('RELEASE SAVEPOINT import') From 964aa3d6965bc1cc8757e64cefd9535e991aa1df Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Tue, 3 Sep 2019 13:09:12 +0000 Subject: [PATCH 13/18] [FIX] website: make website selector work with scheme and port Before this commit, if one would introduce a scheme or a port in his website domain, it would make the website selector to crash JS side. Indeed, it would replace the current url hostname by the website domain. If the website domain was introduced with `http://` it would lead to `http://http://mysite.com`. If port was introduced, `http://mysite:8069:8069`. Also, by fixing those 2, it also make `localhost` and `127.0.0.1` to work. (which would not work without `http://`. Related to #36390 --- addons/website/models/ir_ui_view.py | 4 ++-- .../static/src/js/content/website_root.js | 17 +++++------------ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/addons/website/models/ir_ui_view.py b/addons/website/models/ir_ui_view.py index 4b5b3a3fa3a..5440052ba6e 100644 --- a/addons/website/models/ir_ui_view.py +++ b/addons/website/models/ir_ui_view.py @@ -331,9 +331,9 @@ class View(models.Model): cur = Website.get_current_website() if self.env.user.has_group('website.group_website_publisher') and self.env.user.has_group('website.group_multi_website'): - qcontext['multi_website_websites_current'] = {'website_id': cur.id, 'name': cur.name, 'domain': cur.domain} + qcontext['multi_website_websites_current'] = {'website_id': cur.id, 'name': cur.name, 'domain': cur._get_http_domain()} qcontext['multi_website_websites'] = [ - {'website_id': website.id, 'name': website.name, 'domain': website.domain} + {'website_id': website.id, 'name': website.name, 'domain': website._get_http_domain()} for website in Website.search([]) if website != cur ] diff --git a/addons/website/static/src/js/content/website_root.js b/addons/website/static/src/js/content/website_root.js index dc2b2f679d7..22363f04129 100644 --- a/addons/website/static/src/js/content/website_root.js +++ b/addons/website/static/src/js/content/website_root.js @@ -182,21 +182,14 @@ var WebsiteRoot = publicRootData.PublicRoot.extend({ * @param {Event} ev */ _onWebsiteSwitch: function (ev) { - var websiteID = ev.currentTarget.getAttribute('website-id'); - - // need to force in each case, even if domain is set - // Website 1: localhost; Website 2: 0.0.0.0; website 3: - - // when you switch 3 <--> 1, you need to force the website - + var websiteId = ev.currentTarget.getAttribute('website-id'); var websiteDomain = ev.currentTarget.getAttribute('domain'); - var url = $.param.querystring(window.location.href, {fw: websiteID}); + var url = window.location.href; if (websiteDomain && window.location.hostname !== websiteDomain) { - // if domain unchanged, this line will do a nop while we need to refresh - // the page to load the new forced website. - url = new URL(url); - url.hostname = websiteDomain; + var path = window.location.pathname + window.location.search + window.location.hash; + url = websiteDomain + path; } - window.location.href = url; + window.location.href = $.param.querystring(url, {'fw': websiteId}); }, /** * @private From f8aba7b34710719b70f03d4f3b6a14a4ee0bbee6 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Tue, 24 Sep 2019 11:46:07 +0000 Subject: [PATCH 14/18] [FIX] website: make 'Go to website' redirect to correct website Before this commit, 'Go to website' in website module dashboard might not redirect to the correct website. It would just redirect to `/` (href) without forcing the website selected in the dashboard. task-2063252 Closes #36390 closes odoo/odoo#37359 Signed-off-by: Nicolas Martinelli (nim) --- addons/website/controllers/backend.py | 6 ++++-- addons/website/static/src/js/backend/dashboard.js | 12 +++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/addons/website/controllers/backend.py b/addons/website/controllers/backend.py index b558620a0f5..6a79b8d316c 100644 --- a/addons/website/controllers/backend.py +++ b/addons/website/controllers/backend.py @@ -26,8 +26,10 @@ class WebsiteBackend(http.Controller): current_website = website_id and Website.browse(website_id) or Website.get_current_website() multi_website = request.env.user.has_group('website.group_multi_website') - dashboard_data['websites'] = (multi_website and request.env['website'].search([]) or current_website).read(['id', 'name']) - for website in dashboard_data['websites']: + websites = multi_website and request.env['website'].search([]) or current_website + dashboard_data['websites'] = websites.read(['id', 'name']) + for rec, website in zip(websites, dashboard_data['websites']): + website['domain'] = rec._get_http_domain() if website['id'] == current_website.id: website['selected'] = True diff --git a/addons/website/static/src/js/backend/dashboard.js b/addons/website/static/src/js/backend/dashboard.js index dda40102904..a1f0cf9ff58 100644 --- a/addons/website/static/src/js/backend/dashboard.js +++ b/addons/website/static/src/js/backend/dashboard.js @@ -133,6 +133,12 @@ var Dashboard = AbstractAction.extend({ }).open(); }, + on_go_to_website: function (ev) { + ev.preventDefault(); + var website = _.findWhere(this.websites, {selected: true}); + window.location.href = $.param.querystring(website.domain + '/', {'fw': website.id}); + }, + on_save_ga_client_id: function(ga_client_id, ga_analytics_key) { var self = this; return this._rpc({ @@ -393,10 +399,14 @@ var Dashboard = AbstractAction.extend({ self.on_website_button($(ev.target).data('website-id')); }); } + + var $buttons = $(QWeb.render("website.GoToButtons")); + $buttons.on('click', this.on_go_to_website.bind(this)); + this.updateControlPanel({ cp_content: { $searchview: this.$searchview, - $buttons: QWeb.render("website.GoToButtons"), + $buttons: $buttons, }, }); }, From 3371bfabd520182643e9a14d4e89c7850e3617c0 Mon Sep 17 00:00:00 2001 From: Raf Ven Date: Wed, 25 Sep 2019 05:24:46 +0000 Subject: [PATCH 15/18] [FIX] purchase_requisition: filter lines Pre-filter lines based on known products. Closes #36854 opw-2074824 closes odoo/odoo#37383 X-commit: bd3997b79a075a24afce749474fc32b43ac8c03f Signed-off-by: Nicolas Martinelli (nim) --- addons/purchase_requisition/models/purchase.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/addons/purchase_requisition/models/purchase.py b/addons/purchase_requisition/models/purchase.py index 70643757781..6d6a5aebc32 100644 --- a/addons/purchase_requisition/models/purchase.py +++ b/addons/purchase_requisition/models/purchase.py @@ -117,12 +117,11 @@ class PurchaseOrderLine(models.Model): def _onchange_quantity(self): res = super(PurchaseOrderLine, self)._onchange_quantity() if self.order_id.requisition_id: - for line in self.order_id.requisition_id.line_ids: - if line.product_id == self.product_id: - if line.product_uom_id != self.product_uom: - self.price_unit = line.product_uom_id._compute_price( - line.price_unit, self.product_uom) - else: - self.price_unit = line.price_unit - break + for line in self.order_id.requisition_id.line_ids.filtered(lambda l: l.product_id == self.product_id): + if line.product_uom_id != self.product_uom: + self.price_unit = line.product_uom_id._compute_price( + line.price_unit, self.product_uom) + else: + self.price_unit = line.price_unit + break return res From dd627b9698d18fe8a0bbf56e07edcc30f8af0117 Mon Sep 17 00:00:00 2001 From: Samuel Degueldre Date: Tue, 17 Sep 2019 12:45:11 +0000 Subject: [PATCH 16/18] [FIX] account_analytic_default: fix ocr not using default analytic account PURPOSE: Default analytic account should be used wherever possible. This wasn't the case because the module didn't implement a default_get and only filled the fields on product_id change, which isn't set by the OCR task-2067097 opw-2068110 closes odoo/odoo#37389 X-original-commit: 2c450015154f8ba2384fb1f0ad1d4075785009c0 Signed-off-by: Nicolas Martinelli (nim) --- .../models/account_analytic_default.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/addons/account_analytic_default/models/account_analytic_default.py b/addons/account_analytic_default/models/account_analytic_default.py index 707e9920ac0..8f6fb108ca3 100644 --- a/addons/account_analytic_default/models/account_analytic_default.py +++ b/addons/account_analytic_default/models/account_analytic_default.py @@ -63,6 +63,28 @@ class AccountAnalyticDefault(models.Model): class AccountInvoiceLine(models.Model): _inherit = "account.invoice.line" + @api.model + def default_get(self, fields_list): + defaults = super(AccountInvoiceLine, self).default_get(fields_list) + if set(['account_analytic_id', 'analytic_tag_ids']) & set(fields_list): + rec = self.env['account.analytic.default'].account_get( + self.product_id.id, + self.invoice_id.commercial_partner_id.id, + self.invoice_id.user_id.id or self.env.uid, + fields.Date.today(), + company_id=self.company_id.id + ) + if rec: + if 'account_analytic_id' in fields_list: + defaults.update({ + 'account_analytic_id': rec.analytic_id.id, + }) + if 'analytic_tag_ids' in fields_list: + defaults.update({ + 'analytic_tag_ids': rec.analytic_tag_ids.ids, + }) + return defaults + @api.onchange('product_id') def _onchange_product_id(self): res = super(AccountInvoiceLine, self)._onchange_product_id() From 07501d3cad68591e0afb20533f1c6e1302b8a2de Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Wed, 25 Sep 2019 14:33:08 +0200 Subject: [PATCH 17/18] [FIX] account_analytic_default: adapt code to new version Oversight of previous forward-port. --- .../models/account_analytic_default.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/account_analytic_default/models/account_analytic_default.py b/addons/account_analytic_default/models/account_analytic_default.py index f5dd829caa7..862d228fcdd 100644 --- a/addons/account_analytic_default/models/account_analytic_default.py +++ b/addons/account_analytic_default/models/account_analytic_default.py @@ -73,11 +73,11 @@ class AccountMoveLine(models.Model): defaults = super().default_get(fields_list) if {'account_analytic_id', 'analytic_tag_ids'} & set(fields_list): rec = self.env['account.analytic.default'].account_get( - self.product_id.id, - self.invoice_id.commercial_partner_id.id, - self.invoice_id.user_id.id or self.env.uid, - fields.Date.today(), - company_id=self.company_id.id + product_id=self.product_id.id, + partner_id=self.move_id.commercial_partner_id.id, + user_id=self.move_id.user_id.id or self.env.uid, + date=fields.Date.today(), + company_id=self.company_id.id, ) if rec: if 'account_analytic_id' in fields_list: From bef26222b8f3e5ac349a55f2fc2c08e09eb3653b Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Wed, 25 Sep 2019 15:26:17 +0200 Subject: [PATCH 18/18] [I18N] stock: correct fr.po file --- addons/stock/i18n/fr.po | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/stock/i18n/fr.po b/addons/stock/i18n/fr.po index aec452cb978..caf04376f9c 100644 --- a/addons/stock/i18n/fr.po +++ b/addons/stock/i18n/fr.po @@ -5933,7 +5933,6 @@ msgstr "" msgid "" "The backorder %s has" " been created." -msgstr "" msgstr "Le reliquat %s a été" " créé."