[FIX] hr_timesheet_sheet: accept custom fields in timesheets
When creating hr.analytic.timesheet do not filter the list of fields to accept but set the list of fields to remove.
This commit is contained in:
parent
22e99755bb
commit
9404ab4cfb
|
@ -7,6 +7,9 @@ openerp.hr_timesheet_sheet = function(instance) {
|
||||||
events: {
|
events: {
|
||||||
"click .oe_timesheet_weekly_account a": "go_to",
|
"click .oe_timesheet_weekly_account a": "go_to",
|
||||||
},
|
},
|
||||||
|
ignore_fields: function() {
|
||||||
|
return ['line_id'];
|
||||||
|
},
|
||||||
init: function() {
|
init: function() {
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -323,11 +326,8 @@ openerp.hr_timesheet_sheet = function(instance) {
|
||||||
generate_o2m_value: function() {
|
generate_o2m_value: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
var ops = [];
|
var ops = [];
|
||||||
|
var ignored_fields = self.ignore_fields();
|
||||||
_.each(self.accounts, function(account) {
|
_.each(self.accounts, function(account) {
|
||||||
var auth_keys = _.extend(_.clone(account.account_defaults), {
|
|
||||||
name: true, amount:true, unit_amount: true, date: true, account_id:true,
|
|
||||||
});
|
|
||||||
_.each(account.days, function(day) {
|
_.each(account.days, function(day) {
|
||||||
_.each(day.lines, function(line) {
|
_.each(day.lines, function(line) {
|
||||||
if (line.unit_amount !== 0) {
|
if (line.unit_amount !== 0) {
|
||||||
|
@ -338,12 +338,8 @@ openerp.hr_timesheet_sheet = function(instance) {
|
||||||
tmp[k] = v[0];
|
tmp[k] = v[0];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// we have to remove some keys, because analytic lines are shitty
|
// we remove line_id as the reference to the _inherits field will no longer exists
|
||||||
_.each(_.keys(tmp), function(key) {
|
tmp = _.omit(tmp, ignored_fields);
|
||||||
if (auth_keys[key] === undefined) {
|
|
||||||
tmp[key] = undefined;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
ops.push(tmp);
|
ops.push(tmp);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue