From bb90e55fb5f8e38f3c80495a96e747306de9edd4 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 25 Nov 2015 15:50:28 +0100 Subject: [PATCH 1/5] [FIX] product_visible_discount: corrected price This applies the commits 503820a and f26b94fd (and their subsequent corrections) to the calculation of the discount. Indeed, the calculation of the discount must take into account the corrected price, otherwise the discount is wrongly computed. opw-656604 --- .../product_visible_discount.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/addons/product_visible_discount/product_visible_discount.py b/addons/product_visible_discount/product_visible_discount.py index d5f53197e0b..549be580530 100644 --- a/addons/product_visible_discount/product_visible_discount.py +++ b/addons/product_visible_discount/product_visible_discount.py @@ -20,6 +20,7 @@ # ############################################################################## +from openerp import SUPERUSER_ID from openerp.osv import fields, osv from openerp.tools.translate import _ @@ -80,6 +81,7 @@ class sale_order_line(osv.osv): result=res['value'] pricelist_obj=self.pool.get('product.pricelist') product_obj = self.pool.get('product.product') + account_tax_obj = self.pool.get('account.tax') if product and pricelist and self.pool.get('res.users').has_group(cr, uid, 'sale.group_discount_per_so_line'): if result.get('price_unit',False): price=result['price_unit'] @@ -94,6 +96,16 @@ class sale_order_line(osv.osv): so_pricelist = pricelist_obj.browse(cr, uid, pricelist, context=context) new_list_price, currency_id = get_real_price_curency(list_price, product.id, qty, uom, pricelist) + + # The superuser is used by website_sale in order to create a sale order. We need to make + # sure we only select the taxes related to the company of the partner. This should only + # apply if the partner is linked to a company. + if uid == SUPERUSER_ID and context.get('company_id'): + taxes = product.taxes_id.filtered(lambda r: r.company_id.id == context['company_id']) + else: + taxes = product.taxes_id + new_list_price = account_tax_obj._fix_tax_included_price(cr, uid, new_list_price, taxes, result.get('tax_id', [])) + if so_pricelist.visible_discount and list_price[pricelist][0] != 0 and new_list_price != 0: if product.company_id and so_pricelist.currency_id.id != product.company_id.currency_id.id: # new_list_price is in company's currency while price in pricelist currency From 5c0fd9780e1509e0c62ee33e1c305d1d01530f21 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 26 Nov 2015 09:52:29 +0100 Subject: [PATCH 2/5] [FIX] calendar: duplicated term --- addons/calendar/i18n/calendar.pot | 5 ----- 1 file changed, 5 deletions(-) diff --git a/addons/calendar/i18n/calendar.pot b/addons/calendar/i18n/calendar.pot index 28c48a2b77c..3190ec2b1d0 100644 --- a/addons/calendar/i18n/calendar.pot +++ b/addons/calendar/i18n/calendar.pot @@ -1464,11 +1464,6 @@ msgstr "" msgid "count cannot be negative or 0." msgstr "" -#. module: calendar -#: field:calendar.alarm,duration_minutes:0 -msgid "Duration in minutes" -msgstr "" - #. module: calendar #: code:addons/calendar/calendar.py:1245 #, python-format From b459c4dc0324e2a3949d02ae246f4233cd6131ea Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Thu, 26 Nov 2015 10:02:41 +0100 Subject: [PATCH 3/5] [FIX] website: possibility to set no url for the home menu Unsetting the URL of the menu `Home`, in Settings > Configuration > Website Settings > Configure Website, leaded to the unavailability of the website. opw-657572 --- addons/website/controllers/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index 7ef9dbe38b2..3862d19f0f8 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -40,9 +40,9 @@ class Website(openerp.addons.web.controllers.main.Home): else: first_menu = main_menu.child_id and main_menu.child_id[0] if first_menu: - if not (first_menu.url.startswith(('/page/', '/?', '/#')) or (first_menu.url=='/')): + if first_menu.url and (not (first_menu.url.startswith(('/page/', '/?', '/#')) or (first_menu.url == '/'))): return request.redirect(first_menu.url) - if first_menu.url.startswith('/page/'): + if first_menu.url and first_menu.url.startswith('/page/'): return request.registry['ir.http'].reroute(first_menu.url) return self.page(page) From 78ea8eb0586ff108bde4da3c144ff48b73dbedf8 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 26 Nov 2015 10:40:59 +0100 Subject: [PATCH 4/5] [FIX] core: correcly handle pidfile deletion. As atexit function are inherited by subprocess, the pidfile was always deleted when the first worker (http or cron) died. Now, only the process that created the pidfile will delete it. --- openerp/cli/server.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openerp/cli/server.py b/openerp/cli/server.py index f3932b4bf60..d532a067b5b 100644 --- a/openerp/cli/server.py +++ b/openerp/cli/server.py @@ -80,9 +80,9 @@ def report_configuration(): ('database user', config['db_user'])]: _logger.info("%s: %s", name, value) -def rm_pid_file(): +def rm_pid_file(main_pid): config = openerp.tools.config - if not openerp.evented and config['pidfile']: + if config['pidfile'] and main_pid == os.getpid(): try: os.unlink(config['pidfile']) except OSError: @@ -95,10 +95,10 @@ def setup_pid_file(): """ config = openerp.tools.config if not openerp.evented and config['pidfile']: + pid = os.getpid() with open(config['pidfile'], 'w') as fd: - pidtext = "%d" % (os.getpid()) - fd.write(pidtext) - atexit.register(rm_pid_file) + fd.write(str(pid)) + atexit.register(rm_pid_file, pid) def export_translation(): From adf6d0e557dd952c6366b9010638e4fe52563803 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Thu, 26 Nov 2015 11:06:58 +0100 Subject: [PATCH 5/5] [FIX] sale_layout: remove `categ_sequence` default value. `categ_sequence` are stored related fields, to `sale_layout_cat_id.sequence`. Setting a default value for them has as side effect to rewrite the value on the related field. To reproduce the issue: - Create a sale layout category, with 10 as sequence - Create an invoice with one line, with this sale layout category - Come back to the sale layout category, notice that the sequence has been changed to 0. Besides, as the sequence was rewritten on the sale layout category, the sequence was rewritten on all sale order lines and invoice lines having this sale layout category. If you have a bunch of them, this could take a while. The `categ_sequence` default value is supposed to come from the sale layout category. opw-651937 --- addons/sale_layout/models/sale_layout.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/addons/sale_layout/models/sale_layout.py b/addons/sale_layout/models/sale_layout.py index ed42fabb991..d2b5777c059 100644 --- a/addons/sale_layout/models/sale_layout.py +++ b/addons/sale_layout/models/sale_layout.py @@ -84,10 +84,6 @@ class AccountInvoiceLine(osv.Model): sale_layout_cat_id = openerp.fields.Many2one('sale_layout.category', string='Section') categ_sequence = openerp.fields.Integer(related='sale_layout_cat_id.sequence', string='Layout Sequence', store=True) - _defaults = { - 'categ_sequence': 0 - } - class SaleOrder(osv.Model): _inherit = 'sale.order' @@ -117,10 +113,6 @@ class SaleOrderLine(osv.Model): # Store is intentionally set in order to keep the "historic" order. } - _defaults = { - 'categ_sequence': 0 - } - _order = 'order_id, categ_sequence, sale_layout_cat_id, sequence, id' def _prepare_order_line_invoice_line(self, cr, uid, line, account_id=False, context=None):