| 1 |
import { registry } from "@web/core/registry"; |
| 2 |
import { computeM2OProps, Many2One } from "@web/views/fields/many2one/many2one"; |
| 3 |
import { buildM2OFieldDescription, Many2OneField } from "@web/views/fields/many2one/many2one_field"; |
| 4 |
import { Component, onWillStart } from "@odoo/owl"; |
| 5 |
|
| 6 |
export class TaskWithHours extends Component { |
| 7 |
static template = "hr_timesheet.TaskWithHours"; |
| 8 |
static components = { Many2One }; |
| 9 |
static props = { ...Many2OneField.props }; |
| 10 |
|
| 11 |
setup() { |
| 12 |
super.setup(); |
| 13 |
onWillStart(this.onWillStart); |
| 14 |
} |
| 15 |
|
| 16 |
async onWillStart() { } |
| 17 |
|
| 18 |
canCreate() { |
| 19 |
return Boolean(this.props.context.default_project_id); |
| 20 |
} |
| 21 |
|
| 22 |
get m2oProps() { |
| 23 |
const props = computeM2OProps(this.props); |
| 24 |
return { |
| 25 |
...props, |
| 26 |
canCreate: props.canCreate && this.canCreate(), |
| 27 |
canCreateEdit: props.canCreateEdit && this.canCreate(), |
| 28 |
canQuickCreate: props.canQuickCreate && this.canCreate(), |
| 29 |
context: { ...props.context, hr_timesheet_display_remaining_hours: true }, |
| 30 |
value: props.value && { |
| 31 |
...props.value, |
| 32 |
display_name: props.value.display_name?.split("\u00A0")[0], |
| 33 |
}, |
| 34 |
}; |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
registry.category("fields").add("task_with_hours", { |
| 39 |
...buildM2OFieldDescription(TaskWithHours), |
| 40 |
}); |