From 2cc09e86afad709cc13e3a686afb0687b4752b3f Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Wed, 4 Mar 2015 14:00:42 +0100 Subject: [PATCH 01/11] [FIX] web: on_change event on one2many fields was not fired if an attribute is mandatory (courtesy of Christophe Matthieu) opw: 626974 --- addons/web/static/src/js/view_form.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 1eef15a051b..52065001693 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3873,8 +3873,8 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ this.records .bind('add', this.proxy("changed_records")) - .bind('edit', this.proxy("changed_records")) .bind('remove', this.proxy("changed_records")); + this.on('save:after', this, this.proxy("changed_records")); }, start: function () { var ret = this._super(); @@ -3891,7 +3891,6 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ if (!this.fields_view || !this.editable()){ return true; } - var r; if (_.isEmpty(this.records.records)){ return true; } @@ -3902,9 +3901,8 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ current_values[field.name] = field.get('value'); }); var valid = _.every(this.records.records, function(record){ - r = record; _.each(self.editor.form.fields, function(field){ - field.set_value(r.attributes[field.name]); + field.set_value(record.attributes[field.name]); }); return _.every(self.editor.form.fields, function(field){ field.process_modifiers(); @@ -5477,11 +5475,11 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({ calc_domain: function() { var d = instance.web.pyeval.eval('domain', this.build_domain()); var domain = []; //if there is no domain defined, fetch all the records - + if (d.length) { domain = ['|',['id', '=', this.get('value')]].concat(d); } - + if (! _.isEqual(domain, this.get("evaluated_selection_domain"))) { this.set("evaluated_selection_domain", domain); } From 74497a667ff5871d97ab8e281f8833a6ef17a86f Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Mon, 9 Mar 2015 20:05:22 +0100 Subject: [PATCH 02/11] [FIX] website_sale: If there is no description_sale for the product set the cart display the product name and 'False' --- addons/website_sale/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website_sale/models/sale_order.py b/addons/website_sale/models/sale_order.py index 865217cc6e4..cae38345426 100644 --- a/addons/website_sale/models/sale_order.py +++ b/addons/website_sale/models/sale_order.py @@ -59,7 +59,7 @@ class sale_order(osv.Model): values['name'] = line.name else: product = self.pool.get('product.product').browse(cr, uid, product_id, context=context) - values['name'] = "%s\n%s" % (product.display_name, product.description_sale) + values['name'] = product.description_sale and "%s\n%s" % (product.display_name, product.description_sale) or product.display_name values['product_id'] = product_id values['order_id'] = order_id From 9562bf8398d7e45835c0d2fab0b19cc91de4ab2c Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Fri, 6 Mar 2015 13:48:11 +0100 Subject: [PATCH 03/11] [FIX] account_payment: supplier invoice on more then one payment oder The field move_line_id only shows account move lines that still have an amount to pay. This was lost during 333e83fc5ba22bcd16cfd3b4f492710c2c4a8d5e. opw: 625946 --- addons/account_payment/account_move_line.py | 42 ++++++++++++++++++- .../account_payment/account_payment_view.xml | 2 +- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/addons/account_payment/account_move_line.py b/addons/account_payment/account_move_line.py index c0d670d72e9..f909ad6c0a0 100644 --- a/addons/account_payment/account_move_line.py +++ b/addons/account_payment/account_move_line.py @@ -19,12 +19,47 @@ # ############################################################################## -from openerp.osv import osv +from openerp.osv import fields, osv from openerp.tools.translate import _ +from operator import itemgetter class account_move_line(osv.osv): _inherit = "account.move.line" + def _amount_residual(self, cr, uid, ids, field_names, args, context=None): + return self._amount_residual(self, cr, uid, ids, field_names, args, context=context) + + def _to_pay_search(self, cr, uid, obj, name, args, context=None): + if not args: + return [] + line_obj = self.pool.get('account.move.line') + query = line_obj._query_get(cr, uid, context={}) + where = ' and '.join(map(lambda x: '''(SELECT + CASE WHEN l.amount_currency < 0 + THEN - l.amount_currency + ELSE l.credit + END - coalesce(sum(pl.amount_currency), 0) + FROM payment_line pl + INNER JOIN payment_order po ON (pl.order_id = po.id) + WHERE move_line_id = l.id + AND po.state != 'cancel' + ) %(operator)s %%s ''' % {'operator': x[1]}, args)) + sql_args = tuple(map(itemgetter(2), args)) + + cr.execute(('''SELECT id + FROM account_move_line l + WHERE account_id IN (select id + FROM account_account + WHERE type=%s AND active) + AND reconcile_id IS null + AND credit > 0 + AND ''' + where + ' and ' + query), ('payable',)+sql_args ) + + res = cr.fetchall() + if not res: + return [('id', '=', '0')] + return [('id', 'in', map(lambda x:x[0], res))] + def line2bank(self, cr, uid, ids, payment_type=None, context=None): """ Try to return for each Ledger Posting line a corresponding bank @@ -57,5 +92,10 @@ class account_move_line(osv.osv): raise osv.except_osv(_('Error!'), _('There is no partner defined on the entry line.')) return line2bank + _columns = { + 'amount_to_pay': fields.function(_amount_residual, + type='float', string='Amount to pay', fnct_search=_to_pay_search), + } + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_payment/account_payment_view.xml b/addons/account_payment/account_payment_view.xml index c186e58d7b2..2d2748ec17d 100644 --- a/addons/account_payment/account_payment_view.xml +++ b/addons/account_payment/account_payment_view.xml @@ -93,7 +93,7 @@ - +