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

Hello, 

I am getting this error in this javascript code yet it is working well in Odoo 16.

The following modules are needed by other modules but have not been defined, they may not be present in the correct asset bundle: web.ajax

How do I go about this?
Thanks in advance.

/** @odoo-module **/

odoo.define("dynamic_access_rights.core", [], function(require) {
"use strict";

const ajax = require("web.ajax");
let dynamics = null;

function update_buttons(target_buttons){
for(let button of target_buttons){
let klas = `dynamics-${button.restriction}`
let name = button.name
let buttons1 = $(`button[name='${name}']`)
let buttons2 = $(`.${name}`)
buttons1.each(function (){
$(this).addClass(klas)
})
buttons2.each(function (){
$(this).addClass(klas)
})
}
}
function update_pages(target_pages){
for(let page of target_pages){
let klas = `dynamics-${page.restriction}`
let name = page.name
let anchors = $(`a[role='tab']`)
anchors.each(function (){
if($(this).text().toLowerCase() === name.toString().toLowerCase()){
let page_id = $(this).attr('href');
$(this).addClass(klas)
$(`${page_id}`).addClass(klas)
}
})
}
}

function refresh_rights(){
let urlString = window.location.href.split('#')[1]
const params = new URLSearchParams(urlString);
let active_model = params.get('model')
let data = dynamics[active_model]
if(data && data['buttons']){
update_buttons(data['buttons'])
}
if(data && data['pages']){
update_pages(data['pages'])
}
}

$(document).ready(function(){
ajax.jsonRpc("/fetch-dynamic-objects", "call", {},)
.then(function (data) {
console.log("data is",data)
dynamics = data;
setInterval(refresh_rights, 500)
}).catch(function (error) {
if (error) {
console.error(error)
}
});
})
})


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

I am facing same issue with Productscreen using odoo18, please help me out.


<div class="alert alert-danger o_error_detail fw-bold m-auto">The following modules are needed by other modules but have not been defined, they may not be present in the correct asset bundle:<ul><li>@custom_pos/models/order_summary</li><li>web.ajax</li></ul>The following modules could not be loaded because they have unmet dependencies, this is a secondary error which is likely caused by one of the above problems:<ul><li>@custom_pos/models/pos_order_line</li><li>@custom_pos/app/screens/product_screen/order_summary/pos_order_summary</li></ul></div>

/** @odoo-module **/

import { registry } from "@web/core/registry";
import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen";
import PosOrderSummary from "@custom_pos/app/screens/product_screen/order_summary/order_summary";

// Extend ProductScreen and register the component
export const CustomProductScreen = {
...ProductScreen,
components: {
...ProductScreen.components,
PosOrderSummary,
},
};

registry.category("pos_screens").add("product_screen", CustomProductScreen);
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất
Hello.
With the new changes, you need to write your dependencies as follows:


import { ProductScreen } from "@point_of_sale/app/screens/product_screen/product_screen";

import { RefundButton } from "@point_of_sale/app/screens/product_screen/control_buttons/refund_button/refund_button";


and just add an empty array


odoo.define('pos_customize.ProductScreen',[], function(require) {

.

.

.

}

This worked for me, I hope it helps you.


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Based on odoo 17 doc
you can list the dependencies in array like this 

** @odoo-module **/
odoo.define("dynamic_access_rights.core", ["web.ajax"], function(require) {
"use strict";
...
}
hope it helps


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,


Try this code :

/** @odoo-module **/   

 import ajax from "web.ajax";



Hope it helps


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

Hi,

It shows a blank page meaning no modules are loaded at all.

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 12 24
4811
3
thg 4 24
4452
1
thg 1 24
2788
0
thg 4 25
109
0
thg 12 24
613