diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2025-02-10 14:05:12 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2025-02-10 14:05:12 +0700 |
| commit | 3d5e57a2d892551965bcf079f7c728d00989af8e (patch) | |
| tree | c8ba18622d0aa1efbad1fd92b5a8dfddb21037ad | |
| parent | e960a38aa69fbd7a75b6f06a3b30967d8b20ddd5 (diff) | |
<iman> update make contak from tempo
| -rw-r--r-- | indoteknik_custom/models/user_pengajuan_tempo_request.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/indoteknik_custom/models/user_pengajuan_tempo_request.py b/indoteknik_custom/models/user_pengajuan_tempo_request.py index b6103bbb..81509df4 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo_request.py +++ b/indoteknik_custom/models/user_pengajuan_tempo_request.py @@ -507,10 +507,20 @@ class UserPengajuanTempoRequest(models.Model): # Buat kontak baru untuk company_id for contact_data in contacts_data: - self.env['res.partner'].create({ - "parent_id": self.user_company_id.id, # Hubungkan ke perusahaan - **contact_data, # Tambahkan data kontak - }) + existing_contact = self.env['res.partner'].search([ + ('parent_id', '=', self.user_company_id.id), + ('name', '=', contact_data['name']) + ], limit=1) + + if existing_contact: + # Perbarui data yang ada + existing_contact.write(contact_data) + else: + # Buat kontak baru jika belum ada + self.env['res.partner'].create({ + "parent_id": self.user_company_id.id, # Hubungkan ke perusahaan + **contact_data, # Tambahkan data kontak + }) # Pengiriman self.user_company_id.pic_name = self.pengajuan_tempo_id.pic_name |
