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

Hello guys I am new to Odoo and I am using odoo16 version. I want to call Model Function in owl JavaScript file, but it shows 404 error and URL is made  http://localhost:8069/[object%20Object]  like this.

I am using RPC service  this.rpc = useService("rpc")

await this.rpc({ model: 'hr.kpi.emp.desig', method: 'get_desig_emp', args: [] }).then(function (data) { console.log(data); }).catch( err => console.error(err));

I am trying to call Model function into JavaScript file. I created a component in static/src/components/


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

Hi, I got it

The problem is we use the wrong service on odoo version 16. Please use the "orm" service, not "rpc"

In your case:

this.orm = useService("orm");
// call(model, method, args, kwargs)
await result = this.orm.call('hr.kpi.emp.desig', 'get_desig_emp', [], {})
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

I have same issue, did you solved?

In my case:

      this.env.services.rpc({            model:'pos.stock.quant',            method:'add_product_to_location',            args: [[]],        })            .finally(() => {                this.state.isLoading=false;            })


Ảnh đại diện
Huỷ bỏ

Hi, I got it

The problem is we use the wrong service on odoo version 16. Please use the "orm" service, not "rpc"

In your case:

this.orm = useService("orm");
// call(model, method, args, kwargs)
await result = this.orm.call('pos.stock.quant', 'add_product_to_location', [], {})

Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 12 23
6465
1
thg 6 24
3196
1
thg 6 24
2013
0
thg 1 24
1528
1
thg 4 24
2148