Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to use XML and Javascript to drag and drop in calender view in odoo9.0?

By
savita
on 6/17/16, 8:07 AM 211 views

Hi all,

I want to drag image from calender side bar to calendar view but its getting error as

Odoo Client Error

ReferenceError: drag is not defined
http://localhost:8069/web?debug=#view_type=calendar&model=vehicle.time.card.table&menu_id=232&action=316:1
Traceback:
ondragstart@http://localhost:8069/web?debug=#view_type=calendar&model=vehicle.time.card.table&menu_id=232&a

I wrote the following  code in web_fullcalendar.xml to drag the image.

<t t-name="CalendarView.sidebar.responsible">

<div t-foreach="filters" class="o_calendar_responsible" >

<t t-if="filters_value.value"><!-- don't display if no value given (or undefined) -->

<div class="o_checkbox">

<input type="checkbox" name="selection" t-att-value="filters_value.value" checked="checked" /><span/>

</div>

<t t-if="filters_value.value == -1">

<span><i class="fa fa-users fa-fw o_cal_avatar"></i></span>

</t>

<t t-if="(filters_value.value != -1) &amp;&amp; filters_value.avatar_model ">

<img t-attf-src="/web/image/#{filters_value.avatar_model}/#{filters_value.value}/image_small" class="o_cal_avatar"/>

</t>

<span t-attf-class="color_filter o_underline_color_#{filters_value.color}" ><t t-esc="filters_value.label" /></span>

<div id="div1" ondrop="drop(event)" ondragover="allowDrop(event)"></div>

<img t-if="layout == current_layout"

src="/web/static/src/img/back-enable.jpg" ondragstart="drag(event)" width="50" height="50" class="oe_dashboard_selected_layout"/>

</t>

</div>

</t>


and i called ondrop="drop(event)" ondragover="allowDrop(event) and ondragstart="drag(event)" in javascript.

fullcalendar.js

function allowDrop(ev) {

ev.preventDefault();

}

function drag(ev) {

ev.dataTransfer.setData("text", ev.target.id);

}

function drop(ev) {

ev.preventDefault();

var data = ev.dataTransfer.getData("text");

ev.target.appendChild(document.getElementById(data));

}

So how to call drag and drop in javascript? Can some one correct me in writing javascipt for drag and drop?



Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 6/17/16, 8:07 AM
Seen: 211 times
Last updated: 6/17/16, 11:13 AM