diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2025-01-21 13:43:29 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2025-01-21 13:43:29 +0700 |
| commit | ff20b62d6932c6be4ffb56f63f3c05be3aa72c06 (patch) | |
| tree | b9bfad89162ade294b904275feba80d74d9a7b26 | |
| parent | c7f6d959e0e7a2e8adc45cff515f2b5666f3e732 (diff) | |
<iman> update merchant
| -rw-r--r-- | indoteknik_api/controllers/api_v1/lead.py | 50 | ||||
| -rw-r--r-- | indoteknik_api/models/res_partner.py | 17 | ||||
| -rw-r--r-- | indoteknik_custom/models/res_partner.py | 17 | ||||
| -rw-r--r-- | indoteknik_custom/models/user_form_merchant.py | 2 | ||||
| -rw-r--r-- | indoteknik_custom/models/user_merchant_request.py | 1 | ||||
| -rw-r--r-- | indoteknik_custom/views/user_form_merchant.xml | 4 |
6 files changed, 68 insertions, 23 deletions
diff --git a/indoteknik_api/controllers/api_v1/lead.py b/indoteknik_api/controllers/api_v1/lead.py index 67856dad..7ff8a8e9 100644 --- a/indoteknik_api/controllers/api_v1/lead.py +++ b/indoteknik_api/controllers/api_v1/lead.py @@ -34,7 +34,7 @@ class Lead(controller.Controller): @http.route('/api/v1/merchant/<id>', auth='public', methods=['POST', 'OPTIONS'], csrf=False) @controller.Controller.must_authorized() def create_merchant(self, **kw): - merchant_request = True if kw.get('merchantRequest') == 'true' else False + merchant_request = True if kw.get('merchant_request') == 'true' else False params = self.get_request_params(kw, { # informasi perusahaan "name_merchant": [], @@ -42,10 +42,10 @@ class Lead(controller.Controller): "pic_merchant": [], "pic_position": [], "address": [], - "state": [], - "city": [], - "district": [], - "subDistrict": [], + "state": ['number'], + "city": ['number'], + "district": ['number'], + "subDistrict": ['number'], "zip": [], "bank_name": [], "rekening_name": [], @@ -71,11 +71,10 @@ class Lead(controller.Controller): # Syarat Perdagangan "is_kembali_barang": [], - "sertifikat_produk": [], - "custom_sertifikat_produk": [], "tempo_garansi": [], "is_order_quantity": [], "explain_garansi": [], + "custom_sertifikat_produk": [], # # dokumen # @@ -102,7 +101,7 @@ class Lead(controller.Controller): if params['value']['is_kembali_barang'] == 'ya': params['value']['is_kembali_barang'] = kw.get('textReturn') else: - params['value']['is_kembali_barang'] = 'Tidak dapat return' + params['value']['is_kembali_barang'] = 'Tidak dapat direturn' if kw.get('tenggat_waktu'): if kw.get('tenggat_waktu') != 'custom': @@ -116,20 +115,37 @@ class Lead(controller.Controller): else: params['value']['is_order_quantity'] = 'Tidak ada minimum order quantity' - dokumen_kirim = [ - 'TKDN', - 'SNI', - 'Surat Terima Barang (STB)', - 'Lembar Penerimaan Barang (LPB)' - ] - - filtered_params = {key: value for key, value in params['value'].items() if value} + filtered_params = {key: value for key, value in params['value'].items() if kw.get(key) is not None} form_merchant = request.env['user.form.merchant'].search([('partner_id', '=', main_partner.id)], limit=1) + lead = [] if form_merchant: form_merchant.write(filtered_params) else: lead = request.env['user.form.merchant'].create(filtered_params) lead.partner_id = main_partner.id + + sertifikat = [ + 'TKDN', + 'SNI', + 'K3L', + ] + sertifikat_ids = kw.get('sertifikat_produk') + sertifikat_input = kw.get('custom_sertifikat_produk') + dokumen_sertifikat = [] + + if sertifikat_ids: + dokumen_kirim_ids = list(map(int, sertifikat_ids.split(','))) + dokumen_sertifikat = [sertifikat[i] for i in dokumen_kirim_ids if 0 <= i < len(sertifikat)] + if sertifikat_input != 'false' and sertifikat_input: + input_items = [item.strip() for item in sertifikat_input.split(',')] + dokumen_sertifikat.extend(item for item in input_items if item and item not in dokumen_sertifikat) + form_merchant.sertifikat_produk = sertifikat_input + else: + # Jika sertifikat_input kosong, hapus elemen custom (yang tidak ada di daftar `sertifikat`) + dokumen_sertifikat = [item for item in dokumen_sertifikat if item in sertifikat] + if dokumen_sertifikat: + form_merchant.sertifikat_produk = ', '.join(dokumen_sertifikat) + category_ids = '' category_produk_ids = kw.get('categoryProduk', False) if category_produk_ids: @@ -183,7 +199,7 @@ class Lead(controller.Controller): if merchant_request: user_merchant_request = request.env['user.merchant.request'].create({ 'user_id': partner.id, - 'merchant_id': lead.id, + 'merchant_id': form_merchant.id, 'user_company_id': main_partner.id }) diff --git a/indoteknik_api/models/res_partner.py b/indoteknik_api/models/res_partner.py index a8ba785d..c313ffee 100644 --- a/indoteknik_api/models/res_partner.py +++ b/indoteknik_api/models/res_partner.py @@ -6,6 +6,17 @@ class ResPartner(models.Model): _inherit = 'res.partner' def api_single_response(self, form_merchant, with_detail=''): + sertifikat = [ + ['TKDN', '0'], + ['SNI', '1'], + ['K3L', '2'], + ] + dokumen_sertifikat = [] + if form_merchant.sertifikat_produk: + form_merchant_dokumen_sertifikat = form_merchant.sertifikat_produk + mapping_dokumen = {item[0]: item[1] for item in sertifikat} + dokumen_pengiriman_list = [dokumen.strip() for dokumen in form_merchant_dokumen_sertifikat.split(',')] + dokumen_sertifikat = [mapping_dokumen.get(dokumen, '3') for dokumen in dokumen_pengiriman_list] data = { 'name_merchant' : form_merchant.name_merchant, 'pejabat_name' : form_merchant.pejabat_name, @@ -41,10 +52,10 @@ class ResPartner(models.Model): # syarat perdagangan - 'is_kembali_barang': 'ya' if form_merchant.is_kembali_barang else 'tidak', - 'text_return': form_merchant.is_kembali_barang, + 'is_kembali_barang': 'tidak' if form_merchant.is_kembali_barang == 'Tidak dapat direturn' else 'ya', + 'text_return': form_merchant.is_kembali_barang if form_merchant.is_kembali_barang != 'Tidak dapat direturn' else '', 'tenggat_waktu': form_merchant.tenggat_waktu, - 'sertifikat_produk': form_merchant.sertifikat_produk, + 'sertifikat_produk': ','.join(dokumen_sertifikat) if dokumen_sertifikat else '', 'custom_sertifikat_produk': '' if form_merchant.custom_sertifikat_produk == 'false' else form_merchant.custom_sertifikat_produk, 'tempo_garansi': form_merchant.tempo_garansi, 'explain_garansi': form_merchant.explain_garansi, diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index 9e53dae1..d7bd260f 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -76,8 +76,11 @@ class ResPartner(models.Model): "this feature", tracking=3) # MERCHANT + # informasi perusahaan name_merchant = fields.Char(string='Name') + pejabat_name = fields.Char(string='Pejabat Name') pic_merchant = fields.Char(string='PIC Merchant', required=True) + pic_position = fields.Char(string='Jabatan PIC') address_merchant = fields.Char(string='Alamat') state_merchant = fields.Many2one('res.country.state', string='State') city_merchant = fields.Many2one('vit.kota', string='Kota') @@ -92,6 +95,20 @@ class ResPartner(models.Model): email_finance_merchant = fields.Char(string='Email Finance') phone_merchant = fields.Char(string='No. Telepon Perusahaan') mobile_merchant = fields.Char(string='No. Handphone') + bisnis_type = fields.Selection([ + ('1', 'PT'), + ('2', 'CV'), + ('3', 'Perorangan'), + ]) + website_merchant = fields.Char(string='Website') + category_perusahaan = fields.Selection([ + ('1', 'Principal (Pemegang merk/Produsen)'), + ('2', 'Sole Distributor (Distributor Tunggal)'), + ('3', 'Authorized Distributor (Distributor Resmi)'), + ('4', 'Importer (Pengimpor Barang)'), + ('5', 'Wholesaler (Pedagang Besar)'), + ]) + harga_tayang = fields.Char(string='Harga Tayang (HET)') file_dokumenKtpDirut = fields.Binary(string="KTP Dirut/Direktur", tracking=True, track_visibility="onchange") file_kartuNama = fields.Binary(string="Kartu Nama", tracking=True, track_visibility="onchange") diff --git a/indoteknik_custom/models/user_form_merchant.py b/indoteknik_custom/models/user_form_merchant.py index dd143381..6d881621 100644 --- a/indoteknik_custom/models/user_form_merchant.py +++ b/indoteknik_custom/models/user_form_merchant.py @@ -8,7 +8,7 @@ class UserFormMerchant(models.Model): _inherit = ['mail.thread', 'mail.activity.mixin'] name = fields.Char(string='Name') - # informasi peruhaan + # informasi peruhsaan name_merchant = fields.Char(string='Name') pejabat_name = fields.Char(string='Pejabat Name') pic_merchant = fields.Char(string='PIC Merchant') diff --git a/indoteknik_custom/models/user_merchant_request.py b/indoteknik_custom/models/user_merchant_request.py index 7f6c5f3c..a373a771 100644 --- a/indoteknik_custom/models/user_merchant_request.py +++ b/indoteknik_custom/models/user_merchant_request.py @@ -70,6 +70,7 @@ class UserMerchantRequest(models.Model): def write(self, vals): is_approve = True if self.state_merchant == 'approved' or vals.get('state_merchant') == 'approved' else False if is_approve: + # Informasi Perusahaan self.user_company_id.name_merchant = self.merchant_id.name_merchant self.user_company_id.pic_merchant = self.merchant_id.pic_merchant self.user_company_id.address_merchant = self.merchant_id.address diff --git a/indoteknik_custom/views/user_form_merchant.xml b/indoteknik_custom/views/user_form_merchant.xml index cbb7c756..cd3f1de3 100644 --- a/indoteknik_custom/views/user_form_merchant.xml +++ b/indoteknik_custom/views/user_form_merchant.xml @@ -63,7 +63,7 @@ <field name="is_kembali_barang" /> <field name="tenggat_waktu" /> <field name="sertifikat_produk" /> - <field name="custom_sertifikat_produk" /> +<!-- <field name="custom_sertifikat_produk" />--> <field name="tempo_garansi" /> <field name="explain_garansi" /> <field name="is_order_quantity" /> @@ -82,7 +82,7 @@ <field name="file_pricelist" /> </group> <group> - <field name="description" /> +<!-- <field name="description" />--> </group> </group> </sheet> |
