From 34d45085358552794ee6303b387424ef1d409106 Mon Sep 17 00:00:00 2001 From: Christophe Combelles Date: Sun, 8 Feb 2015 23:30:40 +0200 Subject: [PATCH 1/8] [FIX] hr_payroll: nicer error message for some bad rule definitions For example avoids a crash with: TypeError: can't multiply sequence by non-int of type 'float' when setting the quantity field of a salary rule to `1,0` instead of `1.0`. Fixes #5154 Closes #5155 --- addons/hr_payroll/hr_payroll.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index 90cf53775c5..52e2a6f30c8 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -868,18 +868,20 @@ result = rules.NET > categories.NET * 0.10''', rule = self.browse(cr, uid, rule_id, context=context) if rule.amount_select == 'fix': try: - return rule.amount_fix, eval(rule.quantity, localdict), 100.0 + return rule.amount_fix, float(eval(rule.quantity, localdict)), 100.0 except: raise osv.except_osv(_('Error!'), _('Wrong quantity defined for salary rule %s (%s).')% (rule.name, rule.code)) elif rule.amount_select == 'percentage': try: - return eval(rule.amount_percentage_base, localdict), eval(rule.quantity, localdict), rule.amount_percentage + return (float(eval(rule.amount_percentage_base, localdict)), + float(eval(rule.quantity, localdict)), + rule.amount_percentage) except: raise osv.except_osv(_('Error!'), _('Wrong percentage base or quantity defined for salary rule %s (%s).')% (rule.name, rule.code)) else: try: eval(rule.amount_python_compute, localdict, mode='exec', nocopy=True) - return localdict['result'], 'result_qty' in localdict and localdict['result_qty'] or 1.0, 'result_rate' in localdict and localdict['result_rate'] or 100.0 + return float(localdict['result']), 'result_qty' in localdict and localdict['result_qty'] or 1.0, 'result_rate' in localdict and localdict['result_rate'] or 100.0 except: raise osv.except_osv(_('Error!'), _('Wrong python code defined for salary rule %s (%s).')% (rule.name, rule.code)) From 4e2025719b09b147dfc4d8e71bccc449676a8ca4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Fri, 13 Feb 2015 10:01:42 +0100 Subject: [PATCH 2/8] [FIX] web: viewlist editable use correct record_id in dataset When clicking on an element in a listview editable, the record_id is not updated in the dataset, which means that when you switch to form view, the list view does not display the last selected record. Also, it should fix the issue solved by PR pull/2725 --- addons/web/static/src/js/view_list_editable.js | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js index 11a5d884f57..98585fd6757 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -223,6 +223,7 @@ openerp.web.list_editable = function (instance) { var item = false; if (record) { item = record.attributes; + this.dataset.select_id(record.get('id')); } else { record = this.make_empty_record(false); this.records.add(record, { From 3fed8ca58da5c594e411b7b09e3fd3e9d0aaeaff Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Fri, 13 Feb 2015 16:01:07 +0100 Subject: [PATCH 3/8] [FIX] base: Address must stay readonly when field use_parent_address is checked When you change the country of your company, each field of a company address keeps its attrs. This is why the company address stays on readonly when use_parent_address is checked. Closes #4808 opw: 627033 --- openerp/addons/base/res/res_partner.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openerp/addons/base/res/res_partner.py b/openerp/addons/base/res/res_partner.py index 7d357ed0c9e..4f2dcaf4b85 100644 --- a/openerp/addons/base/res/res_partner.py +++ b/openerp/addons/base/res/res_partner.py @@ -68,6 +68,10 @@ class format_address(object): doc = etree.fromstring(arch) for node in doc.xpath("//div[@class='address_format']"): tree = etree.fromstring(v) + for child in node.xpath("//field"): + if child.attrib.get('modifiers'): + for field in tree.xpath("//field[@name='%s']" % child.attrib.get('name')): + field.attrib['modifiers'] = child.attrib.get('modifiers') node.getparent().replace(node, tree) arch = etree.tostring(doc) break From 11bd7a6774a17216bbb04afcbedf3b5c9eebee89 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 16 Feb 2015 14:18:43 +0100 Subject: [PATCH 4/8] [FIX] purchase: order line description being reset on qty change The name must be changed when changing of product, but not for other changes, quantity for instance. The 'or not uom_id' is just for retro-compatibility concerns uom_id being False actually means we just changed of product, and the name must therefore be changed name as been set as False in the onchange call in the view for the product_id field, in this rev., so the name being False now means th change of product Nevertheless, existing databases for which the view is not up to date won't have this change and we therefore have to rely on something else to know when the product has been changed or not. fixes #5295 opw-628138 --- addons/purchase/purchase.py | 10 ++++++---- addons/purchase/purchase_view.xml | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index eea61a7b3c9..accce18ddbb 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -1007,10 +1007,12 @@ class purchase_order_line(osv.osv): context_partner.update( {'lang': lang, 'partner_id': partner_id} ) product = product_product.browse(cr, uid, product_id, context=context_partner) #call name_get() with partner in the context to eventually match name and description in the seller_ids field - dummy, name = product_product.name_get(cr, uid, product_id, context=context_partner)[0] - if product.description_purchase: - name += '\n' + product.description_purchase - res['value'].update({'name': name}) + if not name or not uom_id: + # The 'or not uom_id' part of the above condition can be removed in master. See commit message of the rev. introducing this line. + dummy, name = product_product.name_get(cr, uid, product_id, context=context_partner)[0] + if product.description_purchase: + name += '\n' + product.description_purchase + res['value'].update({'name': name}) # - set a domain on product_uom res['domain'] = {'product_uom': [('category_id','=',product.uom_id.category_id.id)]} diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index 3c8afceb6e7..41088f998a9 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -205,7 +205,7 @@ - + From 4606b4535a1f1900497845ff97706ce00e819205 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 16 Feb 2015 15:01:12 +0100 Subject: [PATCH 5/8] [FIX] warning: onchange_product method signature Module 'Warning' overwrites onchange_product_id method of purchase.order.line The signature in the warning module had 'notes', while there isn't any 'notes' parameter in the original method, in the purchase module. The super call was also wrong, ignoring the optional fields, which were therefore always set to the default value --- addons/warning/warning.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/warning/warning.py b/addons/warning/warning.py index b4e3c5a116d..926974dee4f 100644 --- a/addons/warning/warning.py +++ b/addons/warning/warning.py @@ -304,7 +304,7 @@ class purchase_order_line(osv.osv): _inherit = 'purchase.order.line' def onchange_product_id(self,cr, uid, ids, pricelist, product, qty, uom, partner_id, date_order=False, fiscal_position_id=False, date_planned=False, - name=False, price_unit=False, notes=False, context=None): + name=False, price_unit=False, context=None): warning = {} if not product: return {'value': {'price_unit': price_unit or 0.0, 'name': name or '', 'notes': notes or '', 'product_uom' : uom or False}, 'domain':{'product_uom':[]}} @@ -322,7 +322,7 @@ class purchase_order_line(osv.osv): return {'value': {'product_id': False}, 'warning': warning} result = super(purchase_order_line, self).onchange_product_id(cr, uid, ids, pricelist, product, qty, uom, - partner_id, date_order, fiscal_position_id) + partner_id, date_order, fiscal_position_id, date_planned, name, price_unit, context=context) if result.get('warning',False): warning['title'] = title and title +' & '+result['warning']['title'] or result['warning']['title'] From 30d3f9605f682b41dd77408200bcc3c6950d0aa0 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 16 Feb 2015 15:04:22 +0100 Subject: [PATCH 6/8] [FIX] purchase: order line description being reset on qty change Also set name as False for product_id field in the purchase order line form (popup) This rev. is related to 11bd7a6774a17216bbb04afcbedf3b5c9eebee89 --- addons/purchase/purchase_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index 41088f998a9..40f7ca11f97 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -384,7 +384,7 @@ - +