From 694fe1fb3ff87a5f811c6aa0f388cfa4946b113d Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Wed, 18 Mar 2015 12:16:24 +0100 Subject: [PATCH 1/8] [FIX] web: remove deprecated hack for future_display_name This temporary patch was used to simulate the presence of a `display_name` field in all models. It is not needed anymore as of version 8.0, which comes with the actual magic to make `display_name` work everywhere. --- addons/web/controllers/main.py | 14 -------------- addons/web/static/src/js/view_form.js | 2 +- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index c652e678a34..9819e5b895b 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -921,20 +921,6 @@ class DataSet(http.Controller): return self._call_kw(model, method, args, {}) def _call_kw(self, model, method, args, kwargs): - # Temporary implements future display_name special field for model#read() - if method in ('read', 'search_read') and kwargs.get('context', {}).get('future_display_name'): - if 'display_name' in args[1]: - if method == 'read': - names = dict(request.session.model(model).name_get(args[0], **kwargs)) - else: - names = dict(request.session.model(model).name_search('', args[0], **kwargs)) - args[1].remove('display_name') - records = getattr(request.session.model(model), method)(*args, **kwargs) - for record in records: - record['display_name'] = \ - names.get(record['id']) or "{0}#{1}".format(model, (record['id'])) - return records - if method.startswith('_'): raise Exception("Access Denied: Underscore prefixed methods cannot be remotely called") diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 06462a9077d..df86223c57c 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -292,7 +292,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM var fields = _.keys(self.fields_view.fields); fields.push('display_name'); return self.dataset.read_index(fields, { - context: { 'bin_size': true, 'future_display_name' : true } + context: { 'bin_size': true } }).then(function(r) { self.trigger('load_record', r); }); From d8c4e4fa76c2eb6e70b6f2711de2e580af81740c Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Wed, 18 Mar 2015 12:35:00 +0100 Subject: [PATCH 2/8] [FIX] product: unused import as of 489a96c2572bbe2cc04c0658ed2b862aca31fc0f --- addons/product/product.py | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/product/product.py b/addons/product/product.py index 0a765623cb8..5a637f457d8 100644 --- a/addons/product/product.py +++ b/addons/product/product.py @@ -22,7 +22,6 @@ import math import re import time -from collections import OrderedDict from _common import ceiling From d93148240b9149fd222eed30e04a0e151a1697c4 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Wed, 18 Mar 2015 12:44:44 +0100 Subject: [PATCH 3/8] [FIX] ir.model.data: update_dummy should mark `inherits` parents too When a `noupdate` record is processed during an update, the update_dummy method marks the record as "seen" so it won't be deleted at the garbage collection step, and seen as an obsolete external ID. This needs to be done also for the parent records via _inherits, because they have also received an implicit external ID at creation, and must not be garbage collected, even if their `noupdate` flag (db side) is not set because the flag was added later. This rare problem could be reproduced by creating a product in a module, then referencing it in e.g. a sales order, then updating the module after changing the product record to be in a `noupdate` block. At the end of the update the implicit product.template record would be garbage collected, and trigger a cascade deletion of its children - blocked by the SO reference to the product. --- openerp/addons/base/ir/ir_model.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openerp/addons/base/ir/ir_model.py b/openerp/addons/base/ir/ir_model.py index 282d76d7ef0..e488515b09a 100644 --- a/openerp/addons/base/ir/ir_model.py +++ b/openerp/addons/base/ir/ir_model.py @@ -992,6 +992,10 @@ class ir_model_data(osv.osv): if record: id = record.id self.loads[(module,xml_id)] = (model,id) + for table, inherit_field in self.pool[model]._inherits.iteritems(): + parent_id = record[inherit_field].id + parent_xid = '%s_%s' % (xml_id, table.replace('.', '_')) + self.loads[(module, parent_xid)] = (table, parent_id) except Exception: pass return id From 01f2c5c9d262a3c7a7584badc4f71d5b244ef928 Mon Sep 17 00:00:00 2001 From: Dharmraj Jhala Date: Mon, 9 Mar 2015 10:48:20 +0530 Subject: [PATCH 4/8] [IMP] Allow custom ordering of files contained in zip dumps This will allow to speed up our migration platform: as funzip can pipe the output of the first file of the archive, even if the file is not fully unzipped yet. This is useful to plays with dump.sql without waiting for the full archive decompression. --- openerp/service/db.py | 4 ++-- openerp/tools/osutil.py | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/openerp/service/db.py b/openerp/service/db.py index 0dbc50e2747..485a35c4abd 100644 --- a/openerp/service/db.py +++ b/openerp/service/db.py @@ -195,10 +195,10 @@ def dump_db(db_name, stream, backup_format='zip'): cmd.insert(-1, '--file=' + os.path.join(dump_dir, 'dump.sql')) openerp.tools.exec_pg_command(*cmd) if stream: - openerp.tools.osutil.zip_dir(dump_dir, stream, include_dir=False) + openerp.tools.osutil.zip_dir(dump_dir, stream, include_dir=False, fnct_sort=lambda file_name: file_name != 'dump.sql') else: t=tempfile.TemporaryFile() - openerp.tools.osutil.zip_dir(dump_dir, t, include_dir=False) + openerp.tools.osutil.zip_dir(dump_dir, t, include_dir=False, fnct_sort=lambda file_name: file_name != 'dump.sql') t.seek(0) return t else: diff --git a/openerp/tools/osutil.py b/openerp/tools/osutil.py index afe3fc459f3..a71b6ccbd54 100644 --- a/openerp/tools/osutil.py +++ b/openerp/tools/osutil.py @@ -73,7 +73,12 @@ def tempdir(): finally: shutil.rmtree(tmpdir) -def zip_dir(path, stream, include_dir=True): # TODO add ignore list +def zip_dir(path, stream, include_dir=True, fnct_sort=None): # TODO add ignore list + """ + : param fnct_sort : Function to be passed to "key" parameter of built-in + python sorted() to provide flexibility of sorting files + inside ZIP archive according to specific requirements. + """ path = os.path.normpath(path) len_prefix = len(os.path.dirname(path)) if include_dir else len(path) if len_prefix: @@ -81,6 +86,7 @@ def zip_dir(path, stream, include_dir=True): # TODO add ignore list with zipfile.ZipFile(stream, 'w', compression=zipfile.ZIP_DEFLATED, allowZip64=True) as zipf: for dirpath, dirnames, filenames in os.walk(path): + filenames = sorted(filenames, key=fnct_sort) for fname in filenames: bname, ext = os.path.splitext(fname) ext = ext or bname From 05908a0fac100b1f1083eeb708a6b2b2a76958f1 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 18 Mar 2015 11:29:56 +0100 Subject: [PATCH 5/8] [FIX] account_payment: supplier invoice on more then one payment oder The field move_line_id in payment.order.form only shows account move lines that still have an amount to pay. This was lost during 333e83f. --- addons/account_payment/account_move_line.py | 11 +++++++---- addons/account_payment/test/payment_order_process.yml | 4 ++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/addons/account_payment/account_move_line.py b/addons/account_payment/account_move_line.py index d0ef119640c..9b1a88ad40b 100644 --- a/addons/account_payment/account_move_line.py +++ b/addons/account_payment/account_move_line.py @@ -27,9 +27,12 @@ class account_move_line(osv.osv): _inherit = "account.move.line" # delegate to parent, used for local fields.function redefinition - def _amount_residual(self, cr, uid, ids, field_names, args, context=None): - return super(account_move_line, self)._amount_residual( - cr, uid, ids, field_names, args, context=context) + def _amount_to_pay(self, cr, uid, ids, field_names, args, context=None): + return { + id: value['amount_residual'] + for id, value in self._amount_residual(cr, uid, ids, field_names, args, + context=context).items() + } def _to_pay_search(self, cr, uid, obj, name, args, context=None): if not args: @@ -95,7 +98,7 @@ class account_move_line(osv.osv): return line2bank _columns = { - 'amount_to_pay': fields.function(_amount_residual, + 'amount_to_pay': fields.function(_amount_to_pay, type='float', string='Amount to pay', fnct_search=_to_pay_search), } diff --git a/addons/account_payment/test/payment_order_process.yml b/addons/account_payment/test/payment_order_process.yml index 5aaf97b9e71..7c93c312c15 100644 --- a/addons/account_payment/test/payment_order_process.yml +++ b/addons/account_payment/test/payment_order_process.yml @@ -60,6 +60,10 @@ assert invoice.partner_id == payment_line.partner_id, "Partner is not correct." assert invoice.date_due == payment_line.ml_maturity_date, "Due date is not correct." assert invoice.amount_total == payment_line.amount, "Payment amount is not correct." + assert payment_line.move_line_id.amount_to_pay > 0, "Move line paid" + assert len(self.pool("account.move.line").search(cr, uid, + [('amount_to_pay', '>', 0), ('id', '=', payment_line.move_line_id.id)])) == 0, \ + "No payment order found for this move line" - After making all payments, I finish the payment order. - From 3da6c1a610af30a0c55a674cdcd4eaa9d8b98ee8 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 12 Mar 2015 15:51:30 +0100 Subject: [PATCH 6/8] [FIX] web_calendar: reactivate the possibility to remove a calendar from side list It is now possible again to remove a calendar from the side list thanks to the 'X' opw: 629511 --- addons/calendar/static/src/xml/base_calendar.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/calendar/static/src/xml/base_calendar.xml b/addons/calendar/static/src/xml/base_calendar.xml index 31721b238ae..c3e6613a86e 100644 --- a/addons/calendar/static/src/xml/base_calendar.xml +++ b/addons/calendar/static/src/xml/base_calendar.xml @@ -75,7 +75,7 @@ - + From ac67ce4ecc7e04467f3f4e0bdbdb32eef151ab31 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Thu, 19 Mar 2015 11:10:51 +0100 Subject: [PATCH 7/8] [FIX] stock: quants not being reserved correctly `product_qty` field is not recomputed at record creation. Force field recomputation at any change Removing the trigger on `product.product` should not be a problem as product uom can't be changed once there are move lines. opw:629650 --- addons/stock/stock.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 6b4a5b39442..61391bb2315 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -1720,10 +1720,7 @@ class stock_move(osv.osv): 'date': fields.datetime('Date', required=True, select=True, help="Move date: scheduled date until move is done, then date of actual move processing", states={'done': [('readonly', True)]}), 'date_expected': fields.datetime('Expected Date', states={'done': [('readonly', True)]}, required=True, select=True, help="Scheduled date for the processing of this move"), 'product_id': fields.many2one('product.product', 'Product', required=True, select=True, domain=[('type', '<>', 'service')], states={'done': [('readonly', True)]}), - 'product_qty': fields.function(_quantity_normalize, fnct_inv=_set_product_qty, type='float', digits=0, store={ - 'stock.move': (lambda self, cr, uid, ids, ctx: ids, ['product_id', 'product_uom_qty', 'product_uom'], 20), - 'product.product': (_get_moves_from_prod, ['uom_id'], 20), - }, string='Quantity', + 'product_qty': fields.function(_quantity_normalize, fnct_inv=_set_product_qty, type='float', digits=0, store=True, string='Quantity', help='Quantity in the default UoM of the product'), 'product_uom_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product Unit of Measure'), required=True, states={'done': [('readonly', True)]}, From 7780004f95203fb9f86273eea9ea81a261277a52 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 19 Mar 2015 18:41:45 +0100 Subject: [PATCH 8/8] [FIX] web: correct many2one dropdown visibility. The dropdown should only be append to visible elements. --- addons/web/static/src/js/view_form.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index df86223c57c..a1241288450 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3740,9 +3740,9 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc minLength: 0, delay: 200, }); - var appendTo = this.$el.parents('.oe_view_manager_body, .modal-dialog').last(); + var appendTo = this.$el.parents('.oe_view_manager_body:visible, .modal-dialog:visible').last(); if (appendTo.length === 0){ - appendTo = '.oe_application > *'; + appendTo = '.oe_application > *:visible:last'; } this.$input.autocomplete({ appendTo: appendTo