When I'm creating a new record the desciption changes it's ok but when I'm editing the record is adding a new description instead of change it
@api.onchange('quotation')
def _onchange_budget(self):
if self.quotation:
res = [(0, 1, {'description': self.quotation.description,
'quantity': 0,
'value': self.quotation.value
})]
self.description = res
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- ลูกค้าสัมพันธ์
- e-Commerce
- ระบบบัญชี
- สินค้าคงคลัง
- PoS
- Project
- MRP
คำถามนี้ถูกตั้งค่าสถานะ
2
ตอบกลับ
3704
มุมมอง
Hi, wildhen
It is because [(0, values)] always create a new record and seems like "description" is a many2many field here. So can follow below code in order to achieve this part.
@api.onchange('quotation')
def _onchange_budget(self):
if self.quotation:
if self.description:
data = {'description': self.quotation.description,
'quantity': 0,
'value': self.quotation.value
}
res = [(1, id, data) for id in self.description.ids]
else:
res = [(0, 1, {'description': self.quotation.description,
'quantity': 0,
'value': self.quotation.value
})]
self.description = res
Thanks,
Ashish Singh(Team Lead)
Webkul Software Private Limited
def _onchange_budget(self):
if self.quotation:
if self.description:
data = {'description': self.quotation.description,
'quantity': 0,
'value': self.quotation.value
}
res = [(1, id, data) for id in self.description.ids]
else:
res = [(0, 1, {'description': self.quotation.description,
'quantity': 0,
'value': self.quotation.value
})]
self.description = res
สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!
สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!
ลงชื่อ
Odoo Customization Tips: https://learnopenerp.tumblr.com/