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

i have module which has three field.name,firstname and lastname,when user save it firstname and lastname

concatenate in name field,here name field must be readonly mod.

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

Hello Vijay,

This will help you.

name = fields.Char(compute='_compute_name', store="True")
firstname = fields.Char()
lastname = fields.Char()

@api.depends('firstname', 'lastname')
def _compute_name(self):
    for record in self:
        record.name = record.firstname + record.lastname

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

Hello, I think you've three options.

- Overriding the create and write functions.

-Use onchange method in the firstname and lastname: but if you used onchange method to modify a readonly field this will not update the field in DB, so you need to make an invisible field, as workaround.

-Make the name field as a functional field.

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

how to make name as functional field any demo function?

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ต.ค. 24
3674
Make field readonly based on group แก้ไขแล้ว
9
ก.ค. 21
63194
8
พ.ย. 19
7891
How to concatenate fields in a view? แก้ไขแล้ว
8
เม.ย. 25
29074
3
ส.ค. 24
16043