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

Hello community, I am trying to access the model record in odoo 17 Java owl framework. For that purpose i am using rpc call, but when I executed these method console show error unknown function rpc. Can someone help which import file using for rpc call in odoo17 owl framework. 

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

Var result = this. rpc(({
model: 'res. partner',
method: 'search_read',
args: [[], []],})) ;
But i find this type error Meanwhile connection is back, odoo point of sale will operate limited operations check your connection or continue with limited functionalities

This worked for me
const order = await this.orm.call("pos.order", "search", [[['pos_reference', '=', currentPosOrder?.name]]]);

Tác giả

I need just name address and mobile. How I print it give me complete promise.

Câu trả lời hay nhất

you can use any method from below to do so

1. You can add following in js file. 

​import { useService } from "@web/core/utils/hooks";


​then add following in class 
    ​setup() {

​        super.setup();

​        this.rpc = useService("rpc");

​    }​

2. Alternatively you can use call method from orm service (Check below code)

​const var1 = await this.orm.call(

​                         "model.model",

​                         "method_name",

​                         [arguments]

​                     );

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

Thanks, works like a charm

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

Hi,

For that, you need to call the rpc from use service.

example:

import { useService } from "@web/core/utils/hooks";

export class YourClass extends Component {

    setup() {

        this.rpc = useService("rpc");

       }

    your_function(){

        const value = this.rpc({

            model:'model.name',

            method:'create',

            args:[values]

        })

}


Or in odoo 17  mostly ORM method is using instead of RPC.

example:

import { useService } from "@web/core/utils/hooks";

export class YourClass extends Component {

    setup() {

        this.orm = useService("orm");

       }

    your_function(){

        const value = this.orm.call(

          'model.name',

          'your_function',

          []

        )

}



Hope it helps

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 12 24
1946
0
thg 5 24
1043
0
thg 1 24
1419
2
thg 9 23
8959
0
thg 6 25
385