[MERGE] Forward-port of latest 7.0 bugfixes, up to rev. 9770 revid:chs@openerp.com-20140116154645-sy4zhdgqc48xaqbx

bzr revid: dle@openerp.com-20131224112612-5gjit5uu1aaaqstx
bzr revid: dle@openerp.com-20140103094532-mbczi9ssr3gc90o1
bzr revid: dle@openerp.com-20140108105833-gblxqdw3if1gt35k
bzr revid: dle@openerp.com-20140115121441-bskbyxxbc09ubavh
bzr revid: dle@openerp.com-20140115165506-yuux9km39gbv7k4n
bzr revid: dle@openerp.com-20140116161415-0y9m0kgavcytzj9z
This commit is contained in:
Denis Ledoux 2014-01-16 17:14:15 +01:00
commit 5649e0bbf2
16 changed files with 123 additions and 45 deletions

View File

@ -1273,7 +1273,12 @@ rule or repeating pattern of time to exclude from the recurring rule."),
def comparer(left, right):
for fn, mult in comparers:
result = cmp(fn(left), fn(right))
if type(fn(left)) == tuple and type(fn(right)) == tuple:
# comparing many2one values, sorting on name_get result
leftv, rightv = fn(left)[1], fn(right)[1]
else:
leftv, rightv = fn(left), fn(right)
result = cmp(leftv, rightv)
if result:
return mult * result
return 0
@ -1405,12 +1410,12 @@ rule or repeating pattern of time to exclude from the recurring rule."),
new_id = get_real_ids(arg[2])
new_arg = (arg[0], arg[1], new_id)
new_args.append(new_arg)
if context.get('virtual_id', True):
#offset, limit, order and count must be treated separately as we may need to deal with virtual ids
res = super(calendar_event, self).search(cr, uid, new_args, offset=0, limit=0, order=None, context=context, count=False)
res = self._get_recurrent_ids(cr, uid, res, args, limit, order=order, context=context)
else:
res = super(calendar_event, self).search(cr, uid, new_args, offset=offset, limit=limit, order=order, context=context, count=count)
if not context.get('virtual_id', True):
return super(calendar_event, self).search(cr, uid, new_args, offset=offset, limit=limit, order=order, context=context, count=count)
# offset, limit, order and count must be treated separately as we may need to deal with virtual ids
res = super(calendar_event, self).search(cr, uid, new_args, offset=0, limit=0, order=None, context=context, count=False)
res = self._get_recurrent_ids(cr, uid, res, args, limit, order=order, context=context)
if count:
return len(res)

View File

@ -50,9 +50,9 @@ class decimal_precision(osv.osv):
self.precision_get.clear_cache(self)
for obj in self.pool.obj_list():
for colname, col in self.pool.get(obj)._columns.items():
if isinstance(col, (fields.float, fields.function)):
if hasattr(col, 'digits_change'):
col.digits_change(cr)
RegistryManager.signal_registry_change(cr.dbname)
RegistryManager.signal_caches_change(cr.dbname)
def create(self, cr, uid, data, context=None):
res = super(decimal_precision, self).create(cr, uid, data, context=context)

View File

@ -9,12 +9,14 @@ openerp.hr_timesheet_sheet = function(instance) {
},
init: function() {
this._super.apply(this, arguments);
var self = this;
this.set({
sheets: [],
date_to: false,
date_from: false,
});
this.updating = false;
this.defs = [];
this.field_manager.on("field_changed:timesheet_ids", this, this.query_sheets);
this.field_manager.on("field_changed:date_from", this, function() {
this.set({"date_from": instance.web.str_to_date(this.field_manager.get_field_value("date_from"))});
@ -29,6 +31,14 @@ openerp.hr_timesheet_sheet = function(instance) {
this.res_o2m_drop = new instance.web.DropMisordered();
this.render_drop = new instance.web.DropMisordered();
this.description_line = _t("/");
// Original save function is overwritten in order to wait all running deferreds to be done before actually applying the save.
this.view.original_save = _.bind(this.view.save, this.view);
this.view.save = function(prepend_on_create){
self.prepend_on_create = prepend_on_create;
return $.when.apply($, self.defs).then(function(){
return self.view.original_save(self.prepend_on_create);
});
};
},
go_to: function(event) {
var id = JSON.parse($(event.target).data("id"));
@ -192,11 +202,11 @@ openerp.hr_timesheet_sheet = function(instance) {
account.days[day_count].lines[0].unit_amount += num - self.sum_box(account, day_count);
var product = (account.days[day_count].lines[0].product_id instanceof Array) ? account.days[day_count].lines[0].product_id[0] : account.days[day_count].lines[0].product_id
var journal = (account.days[day_count].lines[0].journal_id instanceof Array) ? account.days[day_count].lines[0].journal_id[0] : account.days[day_count].lines[0].journal_id
new instance.web.Model("hr.analytic.timesheet").call("on_change_unit_amount", [[], product, account.days[day_count].lines[0].unit_amount, false, false, journal]).then(function(res) {
self.defs.push(new instance.web.Model("hr.analytic.timesheet").call("on_change_unit_amount", [[], product, account.days[day_count].lines[0].unit_amount, false, false, journal]).then(function(res) {
account.days[day_count].lines[0]['amount'] = res.value.amount || 0;
self.display_totals();
self.sync();
});
}));
if(!isNaN($(this).val())){
$(this).val(self.sum_box(account, day_count, true));
}

View File

@ -23,7 +23,7 @@ import logging
from openerp.osv import fields, osv
from openerp.tools.translate import _
from openerp.tools import email_re
from openerp.tools import email_split
from openerp import SUPERUSER_ID
_logger = logging.getLogger(__name__)
@ -53,8 +53,8 @@ http://www.openerp.com
def extract_email(email):
""" extract the email address from a user-friendly email address """
m = email_re.search(email or "")
return m and m.group(0) or ""
addresses = email_split(email)
return addresses[0] if addresses else ''

View File

@ -245,7 +245,7 @@ class purchase_order(osv.osv):
_name = "purchase.order"
_inherit = ['mail.thread', 'ir.needaction_mixin']
_description = "Purchase Order"
_order = "name desc"
_order = 'date_order desc, id desc'
def create(self, cr, uid, vals, context=None):
if vals.get('name','/')=='/':

View File

@ -238,7 +238,7 @@ class sale_order(osv.osv):
_sql_constraints = [
('name_uniq', 'unique(name, company_id)', 'Order Reference must be unique per Company!'),
]
_order = 'name desc'
_order = 'date_order desc, id desc'
# Form filling
def unlink(self, cr, uid, ids, context=None):

View File

@ -91,13 +91,11 @@ db_list = http.db_list
db_monodb = http.db_monodb
def redirect_with_hash(url, code=303):
if request.httprequest.user_agent.browser in ('msie', 'safari'):
# Most IE and Safari versions decided not to preserve location.hash upon
# redirect. And even if IE10 pretends to support it, it still fails
# inexplicably in case of multiple redirects (and we do have some).
# See extensive test page at http://greenbytes.de/tech/tc/httpredirects/
return "<html><head><script>window.location = '%s' + location.hash;</script></head></html>" % url
return werkzeug.utils.redirect(url, code)
# Most IE and Safari versions decided not to preserve location.hash upon
# redirect. And even if IE10 pretends to support it, it still fails
# inexplicably in case of multiple redirects (and we do have some).
# See extensive test page at http://greenbytes.de/tech/tc/httpredirects/
return "<html><head><script>window.location = '%s' + location.hash;</script></head></html>" % url
def module_topological_sort(modules):
""" Return a list of module names sorted so that their dependencies of the

View File

@ -646,6 +646,10 @@
display: block;
color: gray;
}
.openerp .ui-tabs .oe_notebook.ui-tabs-nav li.ui-tabs-active {
border-bottom: none;
padding-bottom: 1px;
}
.openerp .oe_notebook > li.ui-tabs-active > a {
color: #4c4c4c;
}
@ -2904,6 +2908,9 @@
.openerp .oe_list.oe_list_editable.oe_editing .oe_form_field.oe_form_field_datetime input.oe_datepicker_master, .openerp .oe_list.oe_list_editable.oe_editing .oe_form_field.oe_form_field_date input.oe_datepicker_master {
width: 100% !important;
}
.openerp .oe_list.oe_list_editable.oe_editing .oe_form_field.oe_form_field_reference {
display: table;
}
.openerp .oe_list_group_name {
white-space: nowrap;
}

View File

@ -582,6 +582,9 @@ $sheet-padding: 16px
text-decoration: none
background-color: #eee
border-color: #eee #eee #ddd
.ui-tabs .oe_notebook.ui-tabs-nav li.ui-tabs-active
border-bottom: none
padding-bottom: 1px
.oe_notebook > li.ui-state-active > a, .oe_notebook > li.ui-state-active > a:hover
background-color: #ffffff
border: 1px solid #ddd
@ -2290,6 +2293,8 @@ $sheet-padding: 16px
&.oe_form_field_datetime,&.oe_form_field_date
input.oe_datepicker_master
width: 100% !important
&.oe_form_field_reference
display: table
.oe_list_group_name
white-space: nowrap
// }}}

View File

@ -868,7 +868,7 @@ instance.web.client_actions.add("history_back", "instance.web.HistoryBack");
*/
instance.web.Home = function(parent, action) {
var url = '/' + (window.location.search || '');
instance.web.redirect(url, action.params && action.params.wait);
instance.web.redirect(url, action && action.params && action.params.wait);
};
instance.web.client_actions.add("home", "instance.web.Home");

View File

@ -939,6 +939,15 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({
* @param {Object} id record to remove from the BDS's cache
*/
evict_record: function (id) {
// Don't evict records which haven't yet been saved: there is no more
// recent data on the server (and there potentially isn't any data),
// and this breaks the assumptions of other methods (that the data
// for new and altered records is both in the cache and in the to_write
// or to_create collection)
if (_(this.to_create.concat(this.to_write)).find(function (record) {
return record.id === id; })) {
return;
}
for(var i=0, len=this.cache.length; i<len; ++i) {
var record = this.cache[i];
// if record we call the button upon is in the cache

View File

@ -147,6 +147,7 @@ instance.web.format_value = function (value, descriptor, value_if_empty) {
console.warn('Field', descriptor, 'had an empty string as value, treating as false...');
return value_if_empty === undefined ? '' : value_if_empty;
case false:
case undefined:
case Infinity:
case -Infinity:
return value_if_empty === undefined ? '' : value_if_empty;

View File

@ -1848,9 +1848,14 @@ instance.web.search.Advanced = instance.web.search.Input.extend({
new instance.web.Model(this.view.model).call('fields_get', {
context: this.view.dataset.context
}).done(function(data) {
self.fields = _.extend({
self.fields = {
id: { string: 'ID', type: 'id' }
}, data);
};
_.each(data, function(field_def, field_name) {
if (field_def.selectable !== false && field_name != 'id') {
self.fields[field_name] = field_def;
}
});
})).done(function () {
self.append_proposition();
});

View File

@ -2615,6 +2615,11 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we
e.stopPropagation();
}
},
'keypress': function (e) {
if (e.which === $.ui.keyCode.ENTER) {
e.stopPropagation();
}
},
'change textarea': 'store_dom_value',
},
initialize_content: function() {
@ -3411,6 +3416,10 @@ instance.web.form.FieldMany2One = instance.web.form.AbstractField.extend(instanc
if (! no_recurse) {
var dataset = new instance.web.DataSetStatic(this, this.field.relation, self.build_context());
this.alive(dataset.name_get([self.get("value")])).done(function(data) {
if (!data[0]) {
self.do_warn(_t("Render"), _t("No value found for the field "+self.field.string+" for value "+self.get("value")));
return;
}
self.display_value["" + self.get("value")] = data[0][1];
self.render_value(true);
}).fail( function (data, event) {
@ -3945,7 +3954,6 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
GroupsType: instance.web.form.One2ManyGroups,
ListType: instance.web.form.One2ManyList
}));
this.on('edit:before', this, this.proxy('_before_edit'));
this.on('edit:after', this, this.proxy('_after_edit'));
this.on('save:before cancel:before', this, this.proxy('_before_unedit'));
@ -3958,7 +3966,7 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
var ret = this._super();
this.$el
.off('mousedown.handleButtons')
.on('mousedown.handleButtons', 'table button', this.proxy('_button_down'));
.on('mousedown.handleButtons', 'table button, div a.oe_m2o_cm_button', this.proxy('_button_down'));
return ret;
},
changed_records: function () {
@ -4066,11 +4074,10 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
});
},
_before_edit: function () {
_after_edit: function () {
this.__ignore_blur = false;
this.editor.form.on('blurred', this, this._on_form_blur);
},
_after_edit: function () {
// The form's blur thing may be jiggered during the edition setup,
// potentially leading to the o2m instasaving the row. Cancel any
// blurring triggered the edition startup here
@ -4103,7 +4110,7 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
}
this.cancel_edition();
},
keyup_ENTER: function () {
keypress_ENTER: function () {
// blurring caused by hitting the [Return] key, should skip the
// autosave-on-blur and let the handler for [Return] do its thing (save
// the current row *anyway*, then create a new one/edit the next one)
@ -4118,6 +4125,12 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({
} finally {
window.confirm = confirm;
}
},
reload_record: function (record) {
// Evict record.id from cache to ensure it will be reloaded correctly
this.dataset.evict_record(record.get('id'));
return this._super(record);
}
});
instance.web.form.One2ManyGroups = instance.web.ListView.Groups.extend({

View File

@ -1056,7 +1056,7 @@ instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web.
id = parseInt(ref_match[2], 10);
new instance.web.DataSet(this.view, model).name_get([id]).done(function(names) {
if (!names.length) { return; }
record.set(column.id, names[0][1]);
record.set(column.id + '__display', names[0][1]);
});
}
} else if (column.type === 'many2one') {
@ -1318,7 +1318,8 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we
}
},
close: function () {
this.$row.children().last().empty();
this.$row.children().last().find('button').remove();
this.$row.children().last().find('span').remove();
this.records.reset();
},
/**
@ -1489,7 +1490,8 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we
} else {
if (dataset.size() == records.length) {
// only one page
self.$row.find('td.oe_list_group_pagination').empty();
self.$row.find('td.oe_list_group_pagination').find('button').remove();
self.$row.find('td.oe_list_group_pagination').find('span').remove();
} else {
var pages = Math.ceil(dataset.size() / limit);
self.$row
@ -2131,6 +2133,7 @@ instance.web.list.columns = new instance.web.Registry({
'field.handle': 'instance.web.list.Handle',
'button': 'instance.web.list.Button',
'field.many2onebutton': 'instance.web.list.Many2OneButton',
'field.reference': 'instance.web.list.Reference',
'field.many2many': 'instance.web.list.Many2Many'
});
instance.web.list.columns.for_ = function (id, field, node) {
@ -2357,5 +2360,18 @@ instance.web.list.Many2Many = instance.web.list.Column.extend({
return this._super(row_data, options);
}
});
instance.web.list.Reference = instance.web.list.Column.extend({
_format: function (row_data, options) {
if (!_.isEmpty(row_data[this.id].value)) {
// If value, use __display version for printing
if (!!row_data[this.id + '__display']) {
row_data[this.id] = row_data[this.id + '__display'];
} else {
row_data[this.id] = {'value': ''};
}
}
return this._super(row_data, options);
}
});
})();
// vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax:

View File

@ -53,8 +53,10 @@
});
this.on('edit:after', this, function () {
self.$el.add(self.$buttons).addClass('oe_editing');
self.$('.ui-sortable').sortable('disable');
});
this.on('save:after cancel:after', this, function () {
self.$('.ui-sortable').sortable('enable');
self.$el.add(self.$buttons).removeClass('oe_editing');
});
},
@ -275,7 +277,7 @@
if (!this.editor.is_editing()) { return; }
for(var i=0, len=this.fields_for_resize.length; i<len; ++i) {
var item = this.fields_for_resize[i];
if (!item.field.get('invisible')) {
if (!item.field.get('effective_invisible')) {
this.resize_field(item.field, item.cell);
}
}
@ -441,20 +443,26 @@
setup_events: function () {
var self = this;
_.each(this.editor.form.fields, function(field, field_name) {
var setting = false;
var set_invisible = function() {
if (!setting && field.get("effective_readonly")) {
setting = true;
field.set({invisible: true});
setting = false;
}
field.set({'force_invisible': field.get('effective_readonly')});
};
field.on("change:effective_readonly", self, set_invisible);
field.on("change:invisible", self, set_invisible);
set_invisible();
field.on('change:effective_invisible', self, function () {
if (field.get('effective_invisible')) { return; }
var item = _(self.fields_for_resize).find(function (item) {
return item.field === field;
});
if (item) {
setTimeout(function() {
self.resize_field(item.field, item.cell);
}, 0);
}
});
});
this.editor.$el.on('keyup keydown', function (e) {
this.editor.$el.on('keyup keypress keydown', function (e) {
if (!self.editor.is_editing()) { return true; }
var key = _($.ui.keyCode).chain()
.map(function (v, k) { return {name: k, code: v}; })
@ -480,6 +488,7 @@
next_record = next_record || 'succ';
var self = this;
return this.save_edition().then(function (saveInfo) {
if (!saveInfo) { return null; }
if (saveInfo.created) {
return self.start_edition();
}
@ -488,7 +497,7 @@
return self.start_edition(record, options);
});
},
keyup_ENTER: function () {
keypress_ENTER: function () {
return this._next();
},
keydown_ESCAPE: function (e) {