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

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)
}
});
})
})


アバター
破棄
最善の回答

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);
アバター
破棄
最善の回答
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.


アバター
破棄
最善の回答

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


アバター
破棄
最善の回答

Hi,


Try this code :

/** @odoo-module **/   

 import ajax from "web.ajax";



Hope it helps


アバター
破棄
著作者

Hi,

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

関連投稿 返信 ビュー 活動
2
12月 24
6560
3
4月 24
6106
1
1月 24
4084
0
4月 25
881
0
12月 24
1629