コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
1260 ビュー

I need beside filter add dynamic button based on open wizard.

my js code:

/** @odoo-module **/

import { registry } from "@web/core/registry";
import { _t } from "@web/core/l10n/translation";
import { CalendarController } from "@web/views/calendar/calendar_controller";
import { EmployeeCalendarModel } from "@timesheet_calendar_view/js/timesheet_calender_model";
import { calendarView } from "@web/views/calendar/calendar_view";

class EmployeeCalendarController extends CalendarController {
setup() {
super.setup(...arguments);
this.EmployeeRecord = this.onClickAddButtonEmployee.bind(this)
}

onClickAddButtonEmployee() {
console.log("==========================")
}
}

EmployeeCalendarController.template = "timesheet_calendar_view.EmployeeCalendarController";


export const EmployeeCalendarView = {
...calendarView,
Controller: EmployeeCalendarController,
Model: EmployeeCalendarModel,
buttonTemplate: "timesheet_calendar_view.EmployeeCalendarController",
}

registry.category("views").add("timesheet_calendar_with_wizard", EmployeeCalendarView);

My xml code:

<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="timesheet_calendar_view.EmployeeCalendarController" t-inherit="web.CalendarController"
t-inherit-mode="primary">
<xpath expr="//div[hasclass('o_calendar_container')]" position="inside">
<button class="btn btn-primary me-1" t-on-click="onClickAddButtonEmployee">Employee</button>
</xpath>
</t>
</templates>

My manifest:

'assets': {
'web.assets_backend': [
'timesheet_calendar_view/static/src/js/timesheet_calendar.js',
'timesheet_calendar_view/static/src/js/timesheet_calender_model.js',
'timesheet_calendar_view/static/src/xml/employee_calander.xml'
]
},

I need employee button near calander view

アバター
破棄
著作者

Please help if anyone do this

著作者 最善の回答

Hello this issue is resolve,

/** @odoo-module **/

import { registry } from "@web/core/registry";
import { CalendarController } from '@web/views/calendar/calendar_controller';
import { calendarView } from "@web/views/calendar/calendar_view";
import { useService } from "@web/core/utils/hooks";

export class TimesheetCalendarController extends CalendarController {
    setup() {
        super.setup(...arguments);
        this.action = useService("action");
    }

    onClickAddButtonEmployee() {
        this.action.doAction('timesheet_calendar_view.emp_timesheet_details_action_id');
    }
}

export const TimesheetCalendarView = {
    ...calendarView,
    Controller: TimesheetCalendarController,
    buttonTemplate: "timesheet_calendar_view.TimesheetCalendarController",
}

registry.category("views").add("timesheet_calendar_view", TimesheetCalendarView);

its work fine.

アバター
破棄
関連投稿 返信 ビュー 活動
1
10月 24
1039
2
7月 25
1643
1
3月 25
1186
1
12月 24
1078
1
12月 24
1458