Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
1275 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Tác giả

Please help if anyone do this

Tác giả Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 10 24
1052
2
thg 7 25
1656
1
thg 3 25
1193
1
thg 12 24
1087
1
thg 12 24
1470