diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-10-31 16:06:40 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-10-31 16:06:40 +0700 |
| commit | 414ced359c181c612b302376cb740c7f5c02075f (patch) | |
| tree | 0dec339780bc8759823fc6272168aab831618e4f | |
| parent | c6483e28695653497b9576ab01877e6d71a4103f (diff) | |
<iman> update pengajuan tempo fix suplier ids
| -rw-r--r-- | indoteknik_api/controllers/api_v1/partner.py | 7 | ||||
| -rw-r--r-- | indoteknik_custom/models/res_partner.py | 174 | ||||
| -rw-r--r-- | indoteknik_custom/models/user_pengajuan_tempo.py | 2 | ||||
| -rw-r--r-- | indoteknik_custom/models/user_pengajuan_tempo_line.py | 2 |
4 files changed, 113 insertions, 72 deletions
diff --git a/indoteknik_api/controllers/api_v1/partner.py b/indoteknik_api/controllers/api_v1/partner.py index 1d7c682d..2ddd4437 100644 --- a/indoteknik_api/controllers/api_v1/partner.py +++ b/indoteknik_api/controllers/api_v1/partner.py @@ -301,6 +301,7 @@ class Partner(controller.Controller): try: form_supplier_data = json.loads(form_supplier_data) + supplier_ids_to_add = [] for item in form_supplier_data: supplier_name = item.get("supplier") pic_name = item.get("pic") @@ -310,8 +311,6 @@ class Partner(controller.Controller): new_data = { 'name_supplier': supplier_name, - 'pengajuan_tempo_id': pengajuan_tempo.id, - 'pengajuan_tempo_partner': False, 'pic_name': pic_name, 'phone': phone, 'tempo_duration': tempo_duration, @@ -319,6 +318,10 @@ class Partner(controller.Controller): } new_supplier_data = request.env['user.pengajuan.tempo.line'].create(new_data) + supplier_ids_to_add.append(new_supplier_data.id) + + pengajuan_tempo.write({'supplier_ids': [(4, supplier_id, 0) for supplier_id in supplier_ids_to_add]}) + except json.JSONDecodeError: return http.Response(status=400, json_body={'error': 'Invalid JSON format for formSupplier'}) category_produk_ids = kw.get('categoryProduk') diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index 017c7c96..ec027ec1 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -8,74 +8,14 @@ class GroupPartner(models.Model): name = fields.Char(string='Name') - -# class NewPengajuanTempo(models.Model): -# _name = 'new.pengajuan.tempo' -# -# # Referensi -# supplier_ids = fields.One2many('pengajuan.tempo.line', 'pengajuan_tempo_id', string="Suppliers") -# -# # informasi perusahaan -# name_tempo = fields.Char(string="Nama Perusahaan") -# industry_id_tempo = fields.Many2one('res.partner.industry', 'Customer Industry', readonly=True) -# street_tempo = fields.Char(string="Alamat Perusahaan") -# state_id_tempo = fields.Many2one('res.country.state', string='State') -# city_id_tempo = fields.Many2one('vit.kota', string='City') -# zip_tempo = fields.Char(string="Zip") -# mobile_tempo = fields.Char(string="No. Telfon Perusahaan") -# bank_name_tempo = fields.Char(string="Nama Bank") -# account_name_tempo = fields.Char(string="Nama Rekening") -# account_number_tempo = fields.Char(string="Nomor Rekening Bank") -# website_tempo = fields.Char(string='Website') -# estimasi_tempo = fields.Char(string='Estimasi Pembelian Pertahun') -# tempo_duration = fields.Char(string='Durasi Tempo') -# tempo_limit = fields.Char(string='Limit Tempo') -# category_produk_ids = fields.Many2many('product.public.category', string='Kategori Produk yang Digunakan', domain=lambda self: self._get_default_category_domain()) -# -# @api.model -# def _get_default_category_domain(self): -# return [('parent_id', '=', False)] -# -# # Kontak Perusahaan -# direktur_name = fields.Char(string='Nama Lengkap Direktur') -# direktur_mobile = fields.Char(string='No. Telpon Direktur') -# direktur_email = fields.Char(string='Email Direktur') -# purchasing_name = fields.Char(string='Nama Purchasing') -# purchasing_mobile = fields.Char(string='No. Telpon Purchasing') -# purchasing_email = fields.Char(string='Email Purchasing') -# finance_name = fields.Char(string='Nama Finance') -# finance_mobile = fields.Char(string='No. Telpon Finance') -# finance_email = fields.Char(string='Email Finance') -# -# # Pengiriman -# pic_name = fields.Char(string='Nama PIC Penerimaan Barang') -# street_pengiriman = fields.Char(string="Alamat Perusahaan") -# state_id_pengiriman = fields.Many2one('res.country.state', string='State') -# city_id_pengiriman = fields.Many2one('vit.kota', string='City') -# zip_pengiriman = fields.Char(string="Zip") -# invoice_pic = fields.Char(string='Nama PIC Penerimaan Invoice') -# street_invoice = fields.Char(string="Alamat Perusahaan") -# country_id_invoice = fields.Many2one('res.country', string='Country') -# state_id_invoice = fields.Many2one('res.country.state', string='State') -# city_id_invoice = fields.Many2one('vit.kota', string='City') -# tukar_invoice = fields.Char(string='Jadwal Penukaran Invoice') -# jadwal_bayar = fields.Char(string='Jadwal Pembayaran') -# dokumen_pengiriman = fields.Char(string='Dokumen saat Pengiriman Barang') -# dokumen_invoice = fields.Char(string='Dokumen yang dilampirkan saat Pengiriman Invoice') - - - class ResPartner(models.Model): _inherit = 'res.partner' # Referensi - supplier_ids = fields.One2many('user.pengajuan.tempo.line', 'pengajuan_tempo_partner', string="Suppliers") + supplier_ids = fields.Many2many('user.pengajuan.tempo.line', string="Suppliers") # informasi perusahaan - name_tempo = fields.Many2one( - 'res.partner', string='Nama Perusahaan', - tracking=True, # Menambahkan tracking=True - ) + name_tempo = fields.Many2one('res.partner', string='Nama Perusahaan',tracking=True) industry_id_tempo = fields.Many2one('res.partner.industry', 'Customer Industry', readonly=True) street_tempo = fields.Char(string="Alamat Perusahaan") state_id_tempo = fields.Many2one('res.country.state', string='State') @@ -89,8 +29,7 @@ class ResPartner(models.Model): estimasi_tempo = fields.Char(string='Estimasi Pembelian Pertahun') tempo_duration = fields.Char(string='Durasi Tempo') tempo_limit = fields.Char(string='Limit Tempo') - category_produk_ids = fields.Many2many('product.public.category', string='Kategori Produk yang Digunakan', - domain=lambda self: self._get_default_category_domain()) + category_produk_ids = fields.Many2many('product.public.category', string='Kategori Produk yang Digunakan', domain=lambda self: self._get_default_category_domain()) @api.model def _get_default_category_domain(self): @@ -235,8 +174,63 @@ class ResPartner(models.Model): vals['sppkp'] = vals.get('sppkp', self.sppkp) vals['alamat_lengkap_text'] = vals.get('alamat_lengkap_text', self.alamat_lengkap_text) vals['industry_id'] = vals.get('industry_id', self.industry_id.id if self.industry_id else None) - vals['company_type_id'] = vals.get('company_type_id', - self.company_type_id.id if self.company_type_id else None) + vals['company_type_id'] = vals.get('company_type_id', self.company_type_id.id if self.company_type_id else None) + + # Referensi + vals['supplier_ids'] = vals.get('supplier_ids', self.supplier_ids) + + # informasi perusahaan + vals['name_tempo'] = vals.get('name_tempo', self.name_tempo) + vals['industry_id_tempo'] = vals.get('industry_id_tempo', self.industry_id_tempo) + vals['street_tempo'] = vals.get('street_tempo', self.street_tempo) + vals['state_id_tempo'] = vals.get('state_id_tempo', self.state_id_tempo) + vals['city_id_tempo'] = vals.get('city_id_tempo', self.city_id_tempo) + vals['zip_tempo'] = vals.get('zip_tempo', self.zip_tempo) + vals['bank_name_tempo'] = vals.get('bank_name_tempo', self.bank_name_tempo) + vals['account_name_tempo'] = vals.get('account_name_tempo', self.account_name_tempo) + vals['account_number_tempo'] = vals.get('account_number_tempo', self.account_number_tempo) + vals['website_tempo'] = vals.get('website_tempo', self.website_tempo) + vals['estimasi_tempo'] = vals.get('estimasi_tempo', self.estimasi_tempo) + vals['tempo_duration'] = vals.get('tempo_duration', self.tempo_duration) + vals['tempo_limit'] = vals.get('tempo_limit', self.tempo_limit) + vals['category_produk_ids'] = vals.get('category_produk_ids', self.category_produk_ids) + + # Kontak Perusahaan + vals['direktur_name'] = vals.get('direktur_name', self.direktur_name) + vals['direktur_mobile'] = vals.get('direktur_mobile', self.direktur_mobile) + vals['direktur_email'] = vals.get('direktur_email', self.direktur_email) + vals['purchasing_name'] = vals.get('purchasing_name', self.purchasing_name) + vals['purchasing_mobile'] = vals.get('purchasing_mobile', self.purchasing_mobile) + vals['purchasing_email'] = vals.get('purchasing_email', self.purchasing_email) + vals['finance_name'] = vals.get('finance_name', self.finance_name) + vals['finance_mobile'] = vals.get('finance_mobile', self.finance_mobile) + vals['finance_email'] = vals.get('finance_email', self.finance_email) + + # Pengiriman + vals['pic_name'] = vals.get('pic_name', self.pic_name) + vals['street_pengiriman'] = vals.get('street_pengiriman', self.street_pengiriman) + vals['state_id_pengiriman'] = vals.get('state_id_pengiriman', self.state_id_pengiriman) + vals['city_id_pengiriman'] = vals.get('city_id_pengiriman', self.city_id_pengiriman) + vals['zip_pengiriman'] = vals.get('zip_pengiriman', self.zip_pengiriman) + vals['invoice_pic'] = vals.get('invoice_pic', self.invoice_pic) + vals['street_invoice'] = vals.get('street_invoice', self.street_invoice) + vals['state_id_invoice'] = vals.get('state_id_invoice', self.state_id_invoice) + vals['city_id_invoice'] = vals.get('city_id_invoice', self.city_id_invoice) + vals['tukar_invoice'] = vals.get('tukar_invoice', self.tukar_invoice) + vals['jadwal_bayar'] = vals.get('jadwal_bayar', self.jadwal_bayar) + vals['dokumen_pengiriman'] = vals.get('dokumen_pengiriman', self.dokumen_pengiriman) + vals['dokumen_invoice'] = vals.get('dokumen_invoice', self.dokumen_invoice) + + # Dokumen + vals['dokumen_nib'] = vals.get('dokumen_nib', self.dokumen_nib) + vals['dokumen_npwp'] = vals.get('dokumen_npwp', self.dokumen_npwp) + vals['dokumen_sppkp'] = vals.get('dokumen_sppkp', self.dokumen_sppkp) + vals['dokumen_akta_perubahan'] = vals.get('dokumen_akta_perubahan', self.dokumen_akta_perubahan) + vals['dokumen_ktp_dirut'] = vals.get('dokumen_ktp_dirut', self.dokumen_ktp_dirut) + vals['dokumen_akta_pendirian'] = vals.get('dokumen_akta_pendirian', self.dokumen_akta_pendirian) + vals['dokumen_laporan_keuangan'] = vals.get('dokumen_laporan_keuangan', self.dokumen_laporan_keuangan) + vals['dokumen_foto_kantor'] = vals.get('dokumen_foto_kantor', self.dokumen_foto_kantor) + vals['dokumen_tempat_bekerja'] = vals.get('dokumen_tempat_bekerja', self.dokumen_tempat_bekerja) # Simpan hanya field yang perlu di-update pada child vals_for_child = { @@ -246,7 +240,53 @@ class ResPartner(models.Model): 'sppkp': vals.get('sppkp'), 'alamat_lengkap_text': vals.get('alamat_lengkap_text'), 'industry_id': vals.get('industry_id'), - 'company_type_id': vals.get('company_type_id') + 'company_type_id': vals.get('company_type_id'), + 'supplier_ids': vals.get('supplier_ids'), + 'name_tempo': vals.get('name_tempo'), + 'industry_id_tempo': vals.get('industry_id_tempo'), + 'street_tempo': vals.get('street_tempo'), + 'state_id_tempo': vals.get('state_id_tempo'), + 'city_id_tempo': vals.get('city_id_tempo'), + 'zip_tempo': vals.get('zip_tempo'), + 'bank_name_tempo': vals.get('bank_name_tempo'), + 'account_name_tempo': vals.get('account_name_tempo'), + 'account_number_tempo': vals.get('account_number_tempo'), + 'website_tempo': vals.get('website_tempo'), + 'estimasi_tempo': vals.get('estimasi_tempo'), + 'tempo_duration': vals.get('tempo_duration'), + 'tempo_limit': vals.get('tempo_limit'), + 'category_produk_ids': vals.get('category_produk_ids'), + 'direktur_name': vals.get('direktur_name'), + 'direktur_mobile': vals.get('direktur_mobile'), + 'direktur_email': vals.get('direktur_email'), + 'purchasing_name': vals.get('purchasing_name'), + 'purchasing_mobile': vals.get('purchasing_mobile'), + 'purchasing_email': vals.get('purchasing_email'), + 'finance_name': vals.get('finance_name'), + 'finance_mobile': vals.get('finance_mobile'), + 'finance_email': vals.get('finance_email'), + 'pic_name': vals.get('pic_name'), + 'street_pengiriman': vals.get('street_pengiriman'), + 'state_id_pengiriman': vals.get('state_id_pengiriman'), + 'city_id_pengiriman': vals.get('city_id_pengiriman'), + 'zip_pengiriman': vals.get('zip_pengiriman'), + 'invoice_pic': vals.get('invoice_pic'), + 'street_invoice': vals.get('street_invoice'), + 'state_id_invoice': vals.get('state_id_invoice'), + 'city_id_invoice': vals.get('city_id_invoice'), + 'tukar_invoice': vals.get('tukar_invoice'), + 'jadwal_bayar': vals.get('jadwal_bayar'), + 'dokumen_pengiriman': vals.get('dokumen_pengiriman'), + 'dokumen_invoice': vals.get('dokumen_invoice'), + 'dokumen_nib': vals.get('dokumen_nib'), + 'dokumen_npwp': vals.get('dokumen_npwp'), + 'dokumen_sppkp': vals.get('dokumen_sppkp'), + 'dokumen_akta_perubahan': vals.get('dokumen_akta_perubahan'), + 'dokumen_ktp_dirut': vals.get('dokumen_ktp_dirut'), + 'dokumen_akta_pendirian': vals.get('dokumen_akta_pendirian'), + 'dokumen_laporan_keuangan': vals.get('dokumen_laporan_keuangan'), + 'dokumen_foto_kantor': vals.get('dokumen_foto_kantor'), + 'dokumen_tempat_bekerja': vals.get('dokumen_tempat_bekerja'), } # Lakukan update pada semua child secara rekursif diff --git a/indoteknik_custom/models/user_pengajuan_tempo.py b/indoteknik_custom/models/user_pengajuan_tempo.py index 42380fe9..47e99dbf 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo.py +++ b/indoteknik_custom/models/user_pengajuan_tempo.py @@ -77,7 +77,7 @@ class UserPengajuanTempo(models.Model): dokumen_invoice = fields.Char(string='Dokumen yang dilampirkan saat Pengiriman Invoice') # Referensi - supplier_ids = fields.One2many('user.pengajuan.tempo.line', 'pengajuan_tempo_id', string="Suppliers") + supplier_ids = fields.Many2many('user.pengajuan.tempo.line', string="Suppliers") #Dokumen dokumen_nib = fields.Many2many('ir.attachment', 'pengajuan_dokumen_nib_rel', string="NIB (SIUP/TDP/SKDP)", tracking=3, track_visibility="onchange") diff --git a/indoteknik_custom/models/user_pengajuan_tempo_line.py b/indoteknik_custom/models/user_pengajuan_tempo_line.py index 7571bd41..db519ed6 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo_line.py +++ b/indoteknik_custom/models/user_pengajuan_tempo_line.py @@ -6,8 +6,6 @@ class PengajuanTempoLine(models.Model): # Fields untuk tabel supplier name_supplier = fields.Char(string="Nama Supplier") - pengajuan_tempo_id = fields.Many2one('user.pengajuan.tempo', string='Tempo Reference', required=True, ondelete='cascade') - pengajuan_tempo_partner = fields.Many2one('res.partner', string='Tempo Reference', ondelete='cascade') pic_name = fields.Char(string="PIC") phone = fields.Char(string="Telepon") tempo_duration = fields.Char(string="Durasi Tempo") |
