diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 06e59232ac9..2bd436fdf1d 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -295,7 +295,8 @@ class account_invoice(osv.osv): }, multi='all'), 'currency_id': fields.many2one('res.currency', 'Currency', required=True, readonly=True, states={'draft':[('readonly',False)]}, track_visibility='always'), - 'journal_id': fields.many2one('account.journal', 'Journal', required=True, readonly=True, states={'draft':[('readonly',False)]}), + 'journal_id': fields.many2one('account.journal', 'Journal', required=True, readonly=True, states={'draft':[('readonly',False)]}, + domain="[('type', 'in', {'out_invoice': ['sale'], 'out_refund': ['sale_refund'], 'in_refund': ['purchase_refund'], 'in_invoice': ['purchase']}.get(type, [])), ('company_id', '=', company_id)]"), 'company_id': fields.many2one('res.company', 'Company', required=True, change_default=True, readonly=True, states={'draft':[('readonly',False)]}), 'check_total': fields.float('Verification Total', digits_compute=dp.get_precision('Account'), readonly=True, states={'draft':[('readonly',False)]}), 'reconciled': fields.function(_reconciled, string='Paid/Reconciled', type='boolean', diff --git a/addons/event/report/report_event_registration.py b/addons/event/report/report_event_registration.py index e76b5c60d1f..c4a4dfd6b2d 100644 --- a/addons/event/report/report_event_registration.py +++ b/addons/event/report/report_event_registration.py @@ -32,7 +32,7 @@ class report_event_registration(osv.osv): 'draft_state': fields.integer(' # No of Draft Registrations', size=20), 'confirm_state': fields.integer(' # No of Confirmed Registrations', size=20), 'seats_max': fields.integer('Max Seats'), - 'nbevent': fields.integer('Number Of Events'), + 'nbevent': fields.integer('Number of Registrations'), 'event_type': fields.many2one('event.type', 'Event Type'), 'registration_state': fields.selection([('draft', 'Draft'), ('confirm', 'Confirmed'), ('done', 'Attended'), ('cancel', 'Cancelled')], 'Registration State', readonly=True, required=True), 'event_state': fields.selection([('draft', 'Draft'), ('confirm', 'Confirmed'), ('done', 'Done'), ('cancel', 'Cancelled')], 'Event State', readonly=True, required=True), @@ -59,7 +59,7 @@ class report_event_registration(osv.osv): r.name AS name_registration, e.company_id AS company_id, e.date_begin AS event_date, - count(e.id) AS nbevent, + count(r.id) AS nbevent, CASE WHEN r.state IN ('draft') THEN r.nb_register ELSE 0 END AS draft_state, CASE WHEN r.state IN ('open','done') THEN r.nb_register ELSE 0 END AS confirm_state, e.type AS event_type, diff --git a/addons/hr/hr.py b/addons/hr/hr.py index a47ec9269bb..94a6be4e541 100644 --- a/addons/hr/hr.py +++ b/addons/hr/hr.py @@ -203,7 +203,7 @@ class hr_employee(osv.osv): "resized as a 128x128px image, with aspect ratio preserved. "\ "Use this field in form views or some kanban views."), 'image_small': fields.function(_get_image, fnct_inv=_set_image, - string="Smal-sized photo", type="binary", multi="_get_image", + string="Small-sized photo", type="binary", multi="_get_image", store = { 'hr.employee': (lambda self, cr, uid, ids, c={}: ids, ['image'], 10), }, diff --git a/addons/hr/hr_view.xml b/addons/hr/hr_view.xml index eea2eb2ce41..a51fafa93f8 100644 --- a/addons/hr/hr_view.xml +++ b/addons/hr/hr_view.xml @@ -39,7 +39,9 @@ - + @@ -67,7 +69,9 @@ - + diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index b6b95427db1..277b2d727e1 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -99,7 +99,7 @@ class hr_holidays_status(osv.osv): for record in self.browse(cr, uid, ids, context=context): name = record.name if not record.limit: - name = name + (' (%d/%d)' % (record.leaves_taken or 0.0, record.max_leaves or 0.0)) + name = name + (' (%g/%g)' % (record.leaves_taken or 0.0, record.max_leaves or 0.0)) res.append((record.id, name)) return res diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 4c05d7a6d1f..84f0062cf5d 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -975,9 +975,11 @@ class mail_message(osv.Model): cr, SUPERUSER_ID, [ ('res_model', '=', message.model), ('res_id', '=', message.res_id), - ('subtype_ids', 'in', message.subtype_id.id) ], context=context) - partners_to_notify |= set(fo.partner_id.id for fo in fol_obj.browse(cr, SUPERUSER_ID, fol_ids, context=context)) + partners_to_notify |= set( + fo.partner_id for fo in fol_obj.browse(cr, SUPERUSER_ID, fol_ids, context=context) + if message.subtype_id.id in [st.id for st in fo.subtype_ids] + ) # remove me from notified partners, unless the message is written on my own wall if message.subtype_id and message.author_id and message.model == "res.partner" and message.res_id == message.author_id.id: partners_to_notify |= set([message.author_id.id]) diff --git a/addons/web/static/src/js/formats.js b/addons/web/static/src/js/formats.js index 3c32dbe0426..a56ab6be380 100644 --- a/addons/web/static/src/js/formats.js +++ b/addons/web/static/src/js/formats.js @@ -233,7 +233,8 @@ instance.web.parse_value = function (value, descriptor, value_if_empty) { value = value.replace(instance.web._t.database.parameters.thousands_sep, ""); } while(tmp !== value); tmp = Number(value); - if (isNaN(tmp)) + // do not accept not numbers or float values + if (isNaN(tmp) || tmp % 1) throw new Error(_.str.sprintf(_t("'%s' is not a correct integer"), value)); return tmp; case 'float': diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js index e2c63eb191a..fb7045477b6 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -130,15 +130,7 @@ if (this.editable()) { this.$el.find('table:first').show(); this.$el.find('.oe_view_nocontent').remove(); - this.start_edition().then(function(){ - var fields = self.editor.form.fields; - self.editor.form.fields_order.some(function(field){ - if (fields[field].$el.is(':visible')){ - fields[field].$el.find("input").select(); - return true; - } - }); - }); + this.start_edition(); } else { this._super(); } @@ -243,6 +235,7 @@ return this.ensure_saved().then(function () { var $recordRow = self.groups.get_row_for(record); var cells = self.get_cells_for($recordRow); + var fields = {}; self.fields_for_resize.splice(0, self.fields_for_resize.length); return self.with_event('edit', { record: record.attributes, @@ -256,10 +249,13 @@ // FIXME: need better way to get the field back from bubbling (delegated) DOM events somehow field.$el.attr('data-fieldname', field_name); + fields[field_name] = field; self.fields_for_resize.push({field: field, cell: cell}); }, options).then(function () { $recordRow.addClass('oe_edition'); self.resize_fields(); + var focus_field = options && options.focus_field ? options.focus_field : (self.visible_columns.length ? self.visible_columns[0].name : undefined); + if (focus_field) fields[focus_field].$el.find('input').select(); return record.attributes; }); }).fail(function () { @@ -749,31 +745,6 @@ throw new Error("is_editing's state filter must be either `new` or" + " `edit` if provided"); }, - _focus_setup: function (focus_field) { - var form = this.form; - - var field; - // If a field to focus was specified - if (focus_field - // Is actually in the form - && (field = form.fields[focus_field]) - // And is visible - && field.$el.is(':visible')) { - // focus it - field.focus(); - return; - } - - _(form.fields_order).detect(function (name) { - // look for first visible field in fields_order, focus it - var field = form.fields[name]; - if (!field.$el.is(':visible')) { - return false; - } - // Stop as soon as a field got focused - return field.focus() !== false; - }); - }, edit: function (record, configureField, options) { // TODO: specify sequence of edit calls var self = this; @@ -788,7 +759,6 @@ _(form.fields).each(function (field, name) { configureField(name, field); }); - self._focus_setup(options && options.focus_field); return form; }); }, diff --git a/openerp/osv/fields.py b/openerp/osv/fields.py index 37f1b0916b1..c7a4b4cbd8b 100644 --- a/openerp/osv/fields.py +++ b/openerp/osv/fields.py @@ -537,7 +537,7 @@ class many2one(_column): # we use uid=1 because the visibility of a many2one field value (just id and name) # must be the access right of the parent form and not the linked object itself. records = dict(obj.name_get(cr, SUPERUSER_ID, - list(set([x for x in res.values() if isinstance(x, (int,long))])), + list(set([x for x in res.values() if x and isinstance(x, (int,long))])), context=context)) for id in res: if res[id] in records: diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index 5bd91704a65..b994750b6f6 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -3310,6 +3310,8 @@ class BaseModel(object): return [] if fields_to_read is None: fields_to_read = self._columns.keys() + else: + fields_to_read = list(set(fields_to_read)) # all inherited fields + all non inherited fields for which the attribute whose name is in load is True fields_pre = [f for f in fields_to_read if