From 95038f0bf3d71ce8ec7eb5a08a49988cf008229c Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Thu, 23 Feb 2017 16:16:33 +0100 Subject: [PATCH 01/13] [FIX] stock_account: product_price_update_before_done When updating several moves for the same product, each time a write was done, the move.product_id.standard_price was not updated due to "with_context(force_company=move.company_id.id)" before write. Making a with_context before write changes the environment of the write, this why the cache was not updated. opw:709329 --- addons/stock_account/models/stock.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/stock_account/models/stock.py b/addons/stock_account/models/stock.py index 4c33b0df245..fe89547e200 100644 --- a/addons/stock_account/models/stock.py +++ b/addons/stock_account/models/stock.py @@ -184,6 +184,7 @@ class StockMove(models.Model): def product_price_update_before_done(self): tmpl_dict = defaultdict(lambda: 0.0) # adapt standard price on incomming moves if the product cost_method is 'average' + std_price_update = {} for move in self.filtered(lambda move: move.location_id.usage == 'supplier' and move.product_id.cost_method == 'average'): product_tot_qty_available = move.product_id.qty_available + tmpl_dict[move.product_id.id] @@ -192,12 +193,13 @@ class StockMove(models.Model): new_std_price = move.get_price_unit() else: # Get the standard price - amount_unit = move.product_id.standard_price + amount_unit = std_price_update.get(move.product_id.id) or move.product_id.standard_price new_std_price = ((amount_unit * product_tot_qty_available) + (move.get_price_unit() * move.product_qty)) / (product_tot_qty_available + move.product_qty) tmpl_dict[move.product_id.id] += move.product_qty # Write the standard price, as SUPERUSER_ID because a warehouse manager may not have the right to write on products move.product_id.with_context(force_company=move.company_id.id).write({'standard_price': new_std_price}) + std_price_update[move.product_id.id] = new_std_price @api.multi def product_price_update_after_done(self): From 907034b1f6e3daf146d5be35b2cf1b4cc1ed7e6f Mon Sep 17 00:00:00 2001 From: Pierre Masereel Date: Thu, 23 Feb 2017 10:17:53 +0100 Subject: [PATCH 02/13] [FIX] mrp_repair: map_tax missing attributes When the function map_tax is called on the fiscal position in repair lines to compute taxes, the partner and product are not passed to the method which leads to mistakes when the module account_taxcloud tries to get back the taxes for the specific partner and tic_category of the product. To fix the issue, we pass the product and partner that we already have to the function map_tax. --- addons/mrp_repair/models/mrp_repair.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mrp_repair/models/mrp_repair.py b/addons/mrp_repair/models/mrp_repair.py index db253930864..18c3bee3463 100644 --- a/addons/mrp_repair/models/mrp_repair.py +++ b/addons/mrp_repair/models/mrp_repair.py @@ -488,7 +488,7 @@ class RepairLine(models.Model): if not self.product_id or not self.product_uom_qty: return if partner and self.product_id: - self.tax_id = partner.property_account_position_id.map_tax(self.product_id.taxes_id).ids + self.tax_id = partner.property_account_position_id.map_tax(self.product_id.taxes_id, self.product_id, partner).ids if self.product_id: self.name = self.product_id.display_name self.product_uom = self.product_id.uom_id.id @@ -550,7 +550,7 @@ class RepairFee(models.Model): pricelist = self.repair_id.pricelist_id if partner and self.product_id: - self.tax_id = partner.property_account_position_id.map_tax(self.product_id.taxes_id).ids + self.tax_id = partner.property_account_position_id.map_tax(self.product_id.taxes_id, self.product_id, partner).ids if self.product_id: self.name = self.product_id.display_name self.product_uom = self.product_id.uom_id.id From 685f146d484fdf71cb789c67e56e5db34284633a Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 24 Feb 2017 10:57:05 +0100 Subject: [PATCH 03/13] [FIX] account: correct pluralisation Do you ever think about translators? "Bankafschrift afsluitens" is not valid Dutch opw-709657 --- addons/account/i18n/account.pot | 9 ++++++++- addons/account/static/src/xml/account_reconciliation.xml | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/addons/account/i18n/account.pot b/addons/account/i18n/account.pot index 05fef8feb3e..e07135c43e6 100644 --- a/addons/account/i18n/account.pot +++ b/addons/account/i18n/account.pot @@ -2525,11 +2525,18 @@ msgstr "" #. module: account #. openerp-web -#: code:addons/account/static/src/xml/account_reconciliation.xml:227 +#: code:addons/account/static/src/xml/account_reconciliation.xml:229 #, python-format msgid "Close the statement" msgstr "" +#. module: account +#. openerp-web +#: code:addons/account/static/src/xml/account_reconciliation.xml:228 +#, python-format +msgid "Close the statements" +msgstr "" + #. module: account #: model:ir.model.fields,field_description:account.field_account_bank_statement_date_done msgid "Closed On" diff --git a/addons/account/static/src/xml/account_reconciliation.xml b/addons/account/static/src/xml/account_reconciliation.xml index 00673d149e5..f6b11825a1e 100644 --- a/addons/account/static/src/xml/account_reconciliation.xml +++ b/addons/account/static/src/xml/account_reconciliation.xml @@ -224,7 +224,10 @@ - + From 6f1c2919825c9e690ea9a69fb94e27a1e5dbd7cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul=20=28ACSONE=29?= Date: Fri, 24 Feb 2017 15:18:51 +0100 Subject: [PATCH 04/13] [FIX] auth_ldap: allow non-ascii ldap base For installations with accents in the name Closes #15597 --- addons/auth_ldap/models/res_company_ldap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/auth_ldap/models/res_company_ldap.py b/addons/auth_ldap/models/res_company_ldap.py index dfc9070a2e9..05dcb275afa 100644 --- a/addons/auth_ldap/models/res_company_ldap.py +++ b/addons/auth_ldap/models/res_company_ldap.py @@ -145,7 +145,7 @@ class CompanyLDAP(models.Model): ldap_password = conf['ldap_password'] or '' ldap_binddn = conf['ldap_binddn'] or '' conn.simple_bind_s(ldap_binddn.encode('utf-8'), ldap_password.encode('utf-8')) - results = conn.search_st(conf['ldap_base'], ldap.SCOPE_SUBTREE, filter, retrieve_attributes, timeout=60) + results = conn.search_st(conf['ldap_base'].encode('utf-8'), ldap.SCOPE_SUBTREE, filter, retrieve_attributes, timeout=60) conn.unbind() except ldap.INVALID_CREDENTIALS: _logger.error('LDAP bind failed.') From 3401887e6ef189b80e2b8d00be3e12793a3c87a1 Mon Sep 17 00:00:00 2001 From: Leandro Di Pasquale Date: Fri, 24 Feb 2017 10:20:23 -0600 Subject: [PATCH 05/13] [CLA] Update List of Contributors of bacgroup Add Osvaldo Jorge Gentile and remove Cesar Rodriguez from Bacgroup Organization Done at #15630 --- doc/cla/corporate/bacgroup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/cla/corporate/bacgroup.md b/doc/cla/corporate/bacgroup.md index 140a12e2e31..490591c233f 100644 --- a/doc/cla/corporate/bacgroup.md +++ b/doc/cla/corporate/bacgroup.md @@ -13,9 +13,9 @@ Leandro Gabriel Di Pasquale dipasquale@bacgroup.net https://github.com/leodipasq List of contributors: Allan Daniel Aguilar Archaga aguilar@bacgroup.net https://github.com/allanaguilar -Cesar Alejandro Rodriguez Castillo rodriguez@bacgroup.net https://github.com/hondurasopen Dewin Javier Garcia Armijo garcia@bacgroup.net https://github.com/dewingarcia Jose Reynaldo Cabrera Ayala cabrera@bacgroup.net https://github.com/jcabrera1990 Leandro Gabriel Di Pasquale dipasquale@bacgroup.net https://github.com/leodipasquale Edwin Omar McClellan Salinas mcclellan@bacgroup.net https://github.com/prometeomcclellan +Osvaldo Jorge Gentile ogentile@bacgroup.net https://github.com/osvaldo35 Salvatore Josue Trimarchi Pinto trimarchi@bacgroup.net https://github.com/salvatoretrimarchi From 914f509284103d78528838dd248bf90ba8b5a60a Mon Sep 17 00:00:00 2001 From: Whitley Date: Fri, 24 Feb 2017 11:23:13 -0500 Subject: [PATCH 06/13] [IMP] doc: add dependency to CentOS installation yum-config-manager is not installed by default with CentOS from some VPS companies. Closes #15631 --- doc/setup/install.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/setup/install.rst b/doc/setup/install.rst index 3a8d45afa89..389050dd4bb 100644 --- a/doc/setup/install.rst +++ b/doc/setup/install.rst @@ -228,6 +228,7 @@ Execute the following commands to install Odoo 10.0 Community on your server: $ sudo postgresql-setup initdb $ sudo systemctl enable postgresql $ sudo systemctl start postgresql + $ sudo yum install yum-utils $ sudo yum-config-manager --add-repo=https://nightly.odoo.com/10.0/nightly/rpm/odoo.repo $ sudo yum install -y odoo $ sudo systemctl enable odoo From f1a7e3142c245b9ca25fea71b877a3f7588fb1ea Mon Sep 17 00:00:00 2001 From: gilles Date: Fri, 24 Feb 2017 08:57:04 +0100 Subject: [PATCH 07/13] [CLA] signature for GillesTephaneMeyomesse Done at #15620 --- doc/cla/individual/gillestephanemeyomesse.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 doc/cla/individual/gillestephanemeyomesse.md diff --git a/doc/cla/individual/gillestephanemeyomesse.md b/doc/cla/individual/gillestephanemeyomesse.md new file mode 100644 index 00000000000..ba6521e4741 --- /dev/null +++ b/doc/cla/individual/gillestephanemeyomesse.md @@ -0,0 +1,11 @@ +Belgium, 2017-02-24 + +I hereby agree to the terms of the Odoo Individual Contributor License +Agreement v1.0. + +I declare that I am authorized and able to make this agreement and sign this +declaration. + +Signed, + +Gilles Meyomesse meyomesse.gilles@gmail.com https://github.com/GillesTephaneMeyomesse From 961b731da37a42108a083769a97dd1a1c1178bfc Mon Sep 17 00:00:00 2001 From: gilles Date: Fri, 24 Feb 2017 08:58:00 +0100 Subject: [PATCH 08/13] [IMP] hr: add name attribute on page to improve inheritance Closes #15620 --- addons/hr/views/hr_views.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/hr/views/hr_views.xml b/addons/hr/views/hr_views.xml index d48bd650436..b2b637881b8 100644 --- a/addons/hr/views/hr_views.xml +++ b/addons/hr/views/hr_views.xml @@ -74,7 +74,7 @@ - + @@ -96,7 +96,7 @@ - + From bf8b359b299ab0ed0ffd181ead397e7da35f12d7 Mon Sep 17 00:00:00 2001 From: Laurent Smet Date: Tue, 21 Feb 2017 13:45:00 +0100 Subject: [PATCH 09/13] [FIX] delivery: fix bad Exception handling When get_price() is called during tests, a ValidationError was returned but not catched correctly due to the unavailability of delivery service. Because this method is called during the creation of new sale order, it leads to some operational error (broken cursor). --- addons/delivery/models/delivery_carrier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/delivery/models/delivery_carrier.py b/addons/delivery/models/delivery_carrier.py index ee2d61753b6..f8fce9294ef 100644 --- a/addons/delivery/models/delivery_carrier.py +++ b/addons/delivery/models/delivery_carrier.py @@ -120,7 +120,7 @@ class DeliveryCarrier(models.Model): try: computed_price = self.get_shipping_price_from_so(order)[0] self.available = True - except UserError as e: + except ValidationError as e: # No suitable delivery method found, probably configuration error _logger.info("Carrier %s: %s, not found", self.name, e.name) computed_price = 0.0 From 807751aeceb45453c667d12bf7d906002b84e3e7 Mon Sep 17 00:00:00 2001 From: qdp-odoo Date: Fri, 24 Feb 2017 16:35:39 +0100 Subject: [PATCH 10/13] [FIX] base: fix mixing currency in company/pricelist A company should have at least a pricelist having the same currency, that's common sense. This was causing problems in tests on 10.0-nightly, where the main pricelist was created in EUR, then the localization module was setting the right currency on the company without any reflection on the pricelist. To avoid this problem, when we write the currency on a company, we reflect that change on the main pricelist if it's the only company in the system. Otherwise as we can't decide which pricelist modify, we just create a new one, which should be ok. --- addons/product/models/res_company.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/addons/product/models/res_company.py b/addons/product/models/res_company.py index 05e27d47e59..3cebeac4799 100644 --- a/addons/product/models/res_company.py +++ b/addons/product/models/res_company.py @@ -25,3 +25,30 @@ class ResCompany(models.Model): 'fields_id': field.id }) return new_company + + @api.multi + def write(self, values): + # When we modify the currency of the company, we reflect the change on the list0 pricelist, if + # that pricelist is not used by another company. Otherwise, we create a new pricelist for the + # given currency. + ProductPricelist = self.env['product.pricelist'] + currency_id = values.get('currency_id') + main_pricelist = self.env.ref('product.list0', False) + if currency_id and main_pricelist: + nb_companies = self.search_count([]) + for company in self: + if main_pricelist.company_id == company or (main_pricelist.company_id.id is False and nb_companies == 1): + main_pricelist.write({'currency_id': currency_id}) + else: + pricelist = ProductPricelist.create({ + 'name': company.name, + 'currency_id': currency_id, + }) + field = self.env['ir.model.fields'].search([('model', '=', 'res.partner'), ('name', '=', 'property_product_pricelist')]) + self.env['ir.property'].create({ + 'name': 'property_product_pricelist', + 'company_id': company.id, + 'value_reference': 'product.pricelist,%s' % pricelist.id, + 'fields_id': field.id + }) + return super(ResCompany, self).write(values) From 14d1f6f6c11f463375ad6066a74813535755c453 Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Wed, 1 Feb 2017 15:57:00 +0100 Subject: [PATCH 11/13] [FIX] website_event[_sale]: don't allow register when event is done Some previous links could still point to old register page and so display an error 500 if product of ticket has been already archived. --- addons/website_event/controllers/main.py | 3 +++ addons/website_event_sale/controllers/main.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/addons/website_event/controllers/main.py b/addons/website_event/controllers/main.py index 9a9ef605118..9970d7f511e 100644 --- a/addons/website_event/controllers/main.py +++ b/addons/website_event/controllers/main.py @@ -165,6 +165,9 @@ class WebsiteEventController(http.Controller): @http.route(['/event//register'], type='http', auth="public", website=True) def event_register(self, event, **post): + if event.state == 'done': + return request.redirect("/event/%s" % slug(event)) + values = { 'event': event, 'main_object': event, diff --git a/addons/website_event_sale/controllers/main.py b/addons/website_event_sale/controllers/main.py index edb473d90e0..f8727a8ac60 100644 --- a/addons/website_event_sale/controllers/main.py +++ b/addons/website_event_sale/controllers/main.py @@ -3,6 +3,7 @@ from odoo import http, _ from odoo.addons.website_event.controllers.main import WebsiteEventController +from odoo.addons.website.models.website import slug from odoo.http import request @@ -10,6 +11,9 @@ class WebsiteEventSaleController(WebsiteEventController): @http.route(['/event//register'], type='http', auth="public", website=True) def event_register(self, event, **post): + if event.state == 'done': + return request.redirect("/event/%s" % slug(event)) + event = event.with_context(pricelist=request.website.get_current_pricelist().id) values = { 'event': event, From 6969c6c5ada167a60fbb9470094b6991a0cf1a73 Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Wed, 15 Feb 2017 12:30:21 +0100 Subject: [PATCH 12/13] [FIX] website: allow to edit master if 'automatic footer' is disabled Before this commit, impossible to edit the master if no language switcher was displayed on the web page. --- .../static/src/js/website.translator.js | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/addons/website/static/src/js/website.translator.js b/addons/website/static/src/js/website.translator.js index c7cdedb3b66..e5abe467076 100644 --- a/addons/website/static/src/js/website.translator.js +++ b/addons/website/static/src/js/website.translator.js @@ -8,6 +8,7 @@ var base = require('web_editor.base'); var translate = require('web_editor.translate'); var website = require('website.website'); var local_storage = require('web.local_storage'); +var utils = require('web.utils'); var qweb = core.qweb; @@ -31,17 +32,21 @@ website.TopBar.include({ }, edit_master: function (ev) { ev.preventDefault(); - var $link = $('.js_language_selector a[data-default-lang]'); - if (!$link.length) { - // Fallback for old website - var l = false; - _.each($('.js_language_selector a'), function(a) { - if (!l || a.href.length < l.href.length) { l = a; } - }); - $link = $(l); + + var lang = '/' + utils.get_cookie('website_lang'); + + var current = document.createElement('a'); + current.href = window.location.toString(); + current.search += (current.search ? '&' : '?') + 'enable_editor=1'; + if (current.pathname.indexOf(lang) === 0) { + current.pathname = current.pathname.replace(lang, ''); } - $link[0].search += ($link[0].search ? '&' : '?') + 'enable_editor=1'; - $link.click(); + + var link = document.createElement('a'); + link.href = '/website/lang/default'; + link.search += (link.search ? '&' : '?') + 'r=' + encodeURIComponent(current.pathname + current.search + current.hash); + + window.location = link.href; }, }); From 2cffcfd860a8c035074ca123e01d8bf5f47ecc4e Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Sat, 25 Feb 2017 02:10:30 +0100 Subject: [PATCH 13/13] [FIX] website_mail: disable sha_in based message_post The _message_post_helper() method historically allowed passing a `sha_in` signature to let an unauthenticated user post a message on a record. This option is unused and an alternative is preferred: passing a `token` value that matches the value of a given field of the record. In light of the increasingly grim future of SHA-1 as a cryptographic hash function, we consider it better to entirely remove this specific option. It has been unused for a while, and a simple alternative exists. The `object_shasign` method itself will be dropped in master. --- addons/website_mail/controllers/main.py | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/addons/website_mail/controllers/main.py b/addons/website_mail/controllers/main.py index c966b2bede7..57fb68e1330 100644 --- a/addons/website_mail/controllers/main.py +++ b/addons/website_mail/controllers/main.py @@ -11,7 +11,12 @@ from odoo.http import request def object_shasign(record=False, res_model='', res_id=None, **kw): """ Generate a sha signature using the current time, database secret and the record object or the res_model and res_id parameters - Return the sha signature and the time of generation in a tuple""" + Return the sha signature and the time of generation in a tuple + + :deprecated: Support for this SHA1-based signature was discontinued + in `_message_post_helper()`, use the `token` parameter + to allow posting from public sessions instead. + """ secret = request.env['ir.config_parameter'].sudo().get_param('database.secret') shasign = False timestamp = int(time()) @@ -24,7 +29,7 @@ def object_shasign(record=False, res_model='', res_id=None, **kw): def _message_post_helper(res_model='', res_id=None, message='', token='', token_field='token', sha_in='', sha_time=None, nosubscribe=True, **kw): """ Generic chatter function, allowing to write on *any* object that inherits mail.thread. - If a token or a shasign is specified, all logged in users will be able to write a message regardless + If a token is specified, all logged in users will be able to write a message regardless of access rights; if the user is the public user, the message will be posted under the name of the partner_id of the object (or the public user if there is no partner_id on the object). @@ -36,12 +41,8 @@ def _message_post_helper(res_model='', res_id=None, message='', token='', token_ :param string token: access token if the object's model uses some kind of public access using tokens (usually a uuid4) to bypass access rules :param string token_field: name of the field that contains the token on the object (defaults to 'token') - :param string sha_in: sha1 hash of the string composed of res_model, res_id and the dabase secret in ir.config_parameter - if you wish to allow public users to write on the object with some security but you don't want - to add a token field on the object, the sha-sign prevents public users from writing to any other - object that the one specified by res_model and res_id - to generate the shasign, you can import the function object_shasign from this file in your controller - :param str sha_time: timestamp of sha signature generation (signatures are valid for 24h) + :param string sha_in: Deprecated, use `token` and `token_field` instead + :param str sha_time: Deprecated, use `token` and `token_field` instead :param bool nosubscribe: set False if you want the partner to be set as follower of the object when posting (default to True) The rest of the kwargs are passed on to message_post() @@ -55,14 +56,6 @@ def _message_post_helper(res_model='', res_id=None, message='', token='', token_ else: if not author_id: raise NotFound() - elif sha_in: - timestamp = int(sha_time) - secret_sudo = request.env['ir.config_parameter'].sudo().get_param('database.secret') - shasign = sha1('%s%s%s%s' % (res_model, res_id, secret_sudo, timestamp)) - if sha_in == shasign.hexdigest() and int(time()) < timestamp + 3600 * 24: - record = record.sudo() - else: - raise NotFound() return record.with_context(mail_create_nosubscribe=nosubscribe).message_post(body=message, message_type=kw.pop('message_type', "comment"), subtype=kw.pop('subtype', "mt_comment"),