Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
4202 มุมมอง

Hi Everyone,

I need a created record ID from Python to JS.

I'm opening a form view from Js using do_action method

this.do_action({
        views: [[false, 'form']],
        view_type: 'form',
        view_mode: 'form',
        res_model: 'expense.mode',
        type: 'ir.actions.act_window',
        target: 'new',
}, {
    on_close: function (record_id) {
         // Here i need created record ID
    }
});


In form View, i added a footer to send created record ID

<footer invisible="context.get('hide_footer')">
        <button name="action_save" type="object" string="Save" class="oe_highlight"/>
        <button special="cancel" string="Cancel"/>
</footer>


In Python

@api.multi
def action_save(self):
    return self.id


But i'm getting undefined, How can i get a record ID?

Thanks in Advance.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

you can simply send context with action. also can set field value using default_FIELDNAME in context.


this.do_action({
        views: [[false, 'form']],
        view_type: 'form',
        view_mode: 'form',
        res_model: 'expense.mode',
        type: 'ir.actions.act_window',
        target: 'new',

        context: {'key': value}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      

}

อวตาร
ละทิ้ง
ผู้เขียน

Hi Haresh,

I need a record ID, not need to set default value while opening form.

Thanks.

Related Posts ตอบกลับ มุมมอง กิจกรรม
Hide fields in Filters And Group By แก้ไขแล้ว
3
มิ.ย. 23
16136
3
ก.ย. 22
7381
1
ส.ค. 22
4957
3
มี.ค. 21
2194
5
ก.พ. 20
12287