diff options
| author | trisusilo48 <tri.susilo@altama.co.id> | 2025-01-14 09:31:44 +0700 |
|---|---|---|
| committer | trisusilo48 <tri.susilo@altama.co.id> | 2025-01-14 09:31:44 +0700 |
| commit | 183cd9e68ea05e31c63000aeb992eb618edb02b5 (patch) | |
| tree | 45d710db372c2a0eba437a0137cbb74d9935a7f2 /indoteknik_api/models | |
| parent | 63878bd84a6eb9094e702963d7c78fcd8dfa1808 (diff) | |
| parent | 6dda865a1b3262ce78ed2db024fd03efb091d6a6 (diff) | |
Merge branch 'odoo-production' into feature/integrasi_biteship
# Conflicts:
# indoteknik_custom/__manifest__.py
# indoteknik_custom/models/__init__.py
# indoteknik_custom/security/ir.model.access.csv
Diffstat (limited to 'indoteknik_api/models')
| -rw-r--r-- | indoteknik_api/models/__init__.py | 1 | ||||
| -rw-r--r-- | indoteknik_api/models/account_move.py | 5 | ||||
| -rw-r--r-- | indoteknik_api/models/product_product.py | 12 | ||||
| -rw-r--r-- | indoteknik_api/models/res_partner.py | 170 | ||||
| -rw-r--r-- | indoteknik_api/models/res_users.py | 13 |
5 files changed, 191 insertions, 10 deletions
diff --git a/indoteknik_api/models/__init__.py b/indoteknik_api/models/__init__.py index 892d2657..8c85938c 100644 --- a/indoteknik_api/models/__init__.py +++ b/indoteknik_api/models/__init__.py @@ -9,3 +9,4 @@ from . import sale_order from . import x_manufactures from . import website_content from . import coupon_program +from . import res_partner diff --git a/indoteknik_api/models/account_move.py b/indoteknik_api/models/account_move.py index 23a7076c..645c157a 100644 --- a/indoteknik_api/models/account_move.py +++ b/indoteknik_api/models/account_move.py @@ -7,6 +7,7 @@ class AccountMove(models.Model): def api_v1_single_response(self, account_move, context=False): sale_order = self.env['sale.order'].search([('name', '=', account_move.invoice_origin), ('state', '=', 'done')], limit=1) + sale_order_v2 = self.env['sale.order'].search([('name', '=', account_move.invoice_origin)],limit=1) amount_residual = account_move.amount_residual if sale_order.payment_status == 'settlement' or sale_order.payment_status == 'capture': amount_residual = 0 @@ -21,6 +22,9 @@ class AccountMove(models.Model): 'amount_residual': amount_residual, 'invoice_date': account_move.invoice_date.strftime('%d/%m/%Y') or '', 'efaktur': True if account_move.efaktur_document else False, + 'invoice_date_due': account_move.invoice_date_due.strftime('%d/%m/%Y') or '-', + 'sales_order': account_move.invoice_origin, + 'sales_order_id': sale_order_v2.id, } if isinstance(object, datetime.date): data['invoice_date'] = account_move.invoice_date.strftime('%d/%m/%Y') @@ -35,7 +39,6 @@ class AccountMove(models.Model): 'sales': account_move.invoice_user_id.name, 'amount_total': account_move.amount_total, 'amount_residual': amount_residual, - 'invoice_date_due': account_move.invoice_date_due.strftime('%d/%m/%Y') or '', 'customer': res_users.api_address_response(account_move.partner_id), 'products': [], } diff --git a/indoteknik_api/models/product_product.py b/indoteknik_api/models/product_product.py index f8869c7d..10922186 100644 --- a/indoteknik_api/models/product_product.py +++ b/indoteknik_api/models/product_product.py @@ -139,39 +139,39 @@ class ProductProduct(models.Model): return retValue def _get_website_price_exclude_tax(self): - default_divide_tax = float(1.11) + default_divide_tax = float(1.12) price_incl = self._get_website_price_include_tax() res = price_incl / default_divide_tax return math.floor(res) def _v2_get_website_price_exclude_tax(self): - default_divide_tax = float(1.11) + default_divide_tax = float(1.12) price_incl = self._v2_get_website_price_include_tax() res = price_incl / default_divide_tax return math.floor(res) def _get_website_price_after_disc_and_tax(self): - default_divide_tax = float(1.11) + default_divide_tax = float(1.12) price_after_disc = self._get_website_price_after_disc() res = price_after_disc / default_divide_tax res = math.ceil(res) return res def _v2_get_website_price_after_disc_and_tax(self): - default_divide_tax = float(1.11) + default_divide_tax = float(1.12) price_after_disc = self._v2_get_website_price_after_disc() res = price_after_disc / default_divide_tax res = math.ceil(res) return res def _get_website_tax(self): - default_percent_tax = float(11) + default_percent_tax = float(12) price_after_disc = self._get_website_price_after_disc_and_tax() res = price_after_disc * default_percent_tax / 100 return math.floor(res) def _v2_get_website_tax(self): - default_percent_tax = float(11) + default_percent_tax = float(12) price_after_disc = self._v2_get_website_price_after_disc_and_tax() res = price_after_disc * default_percent_tax / 100 return math.floor(res) diff --git a/indoteknik_api/models/res_partner.py b/indoteknik_api/models/res_partner.py new file mode 100644 index 00000000..0e09fbc6 --- /dev/null +++ b/indoteknik_api/models/res_partner.py @@ -0,0 +1,170 @@ +from odoo import models +import json +import base64 + +class ResPartner(models.Model): + _inherit = 'res.partner' + + def api_single_response(self, pengajuan_tempo, with_detail=''): + config = self.env['ir.config_parameter'] + + partner = pengajuan_tempo.partner_id + + dokumen_kirim = [ + ['Surat Tanda Terima Barang (STTB)', '0'], + ['Good Receipt (GR)', '1'], + ['Surat Terima Barang (STB)', '2'], + ['Lembar Penerimaan Barang (LPB)', '3'] + ] + dokumen_pengiriman = [] + if pengajuan_tempo.dokumen_pengiriman : + pengajuan_tempo_dokumen_pengiriman = pengajuan_tempo.dokumen_pengiriman + mapping_dokumen = {item[0]: item[1] for item in dokumen_kirim} + dokumen_pengiriman_list = [dokumen.strip() for dokumen in pengajuan_tempo_dokumen_pengiriman.split(',')] + dokumen_pengiriman = [mapping_dokumen.get(dokumen, '4') for dokumen in dokumen_pengiriman_list] + data = { + 'name' : pengajuan_tempo.name_tempo.name, + 'industry_id' : pengajuan_tempo.industry_id_tempo.id, + 'street' : pengajuan_tempo.street_tempo, + 'state' : pengajuan_tempo.state_id_tempo.id, + 'city' : pengajuan_tempo.city_id_tempo.id, + 'district' : pengajuan_tempo.district_id_tempo.id, + 'subDistrict' : pengajuan_tempo.subDistrict_id_tempo.id, + 'zip' : pengajuan_tempo.zip_tempo, + 'mobile' : pengajuan_tempo.mobile_tempo, + 'bank_name' : pengajuan_tempo.bank_name_tempo, + 'account_name' : pengajuan_tempo.account_name_tempo, + 'account_number' : pengajuan_tempo.account_number_tempo, + 'website' : pengajuan_tempo.website_tempo if pengajuan_tempo.website_tempo else '', + 'estimasi' : pengajuan_tempo.estimasi_tempo, + 'bersedia' : pengajuan_tempo.bersedia, + 'portal' : 'ada' if pengajuan_tempo.portal else 'tidak', + 'tempo_duration' : pengajuan_tempo.tempo_duration.id, + 'tempo_limit' : pengajuan_tempo.tempo_limit, + 'category_produk': ','.join([str(cat.id) for cat in pengajuan_tempo.category_produk_ids]) if pengajuan_tempo.category_produk_ids else '', + + # Kontak Perusahaan + 'direktur_tittle': pengajuan_tempo.direktur_tittle if pengajuan_tempo.direktur_tittle else '', + 'direktur_name' : pengajuan_tempo.direktur_name if pengajuan_tempo.direktur_name else '', + 'direktur_mobile' : pengajuan_tempo.direktur_mobile if pengajuan_tempo.direktur_mobile else '', + 'direktur_email' : pengajuan_tempo.direktur_email if pengajuan_tempo.direktur_email else '', + 'purchasing_tittle': pengajuan_tempo.purchasing_tittle if pengajuan_tempo.purchasing_tittle else '', + 'purchasing_name' : pengajuan_tempo.purchasing_name if pengajuan_tempo.purchasing_name else '', + 'purchasing_mobile' : pengajuan_tempo.purchasing_mobile if pengajuan_tempo.purchasing_mobile else '', + 'purchasing_email' : pengajuan_tempo.purchasing_email if pengajuan_tempo.purchasing_email else '', + 'finance_tittle': pengajuan_tempo.finance_tittle if pengajuan_tempo.finance_tittle else '', + 'finance_name' : pengajuan_tempo.finance_name if pengajuan_tempo.finance_name else '', + 'finance_mobile' : pengajuan_tempo.finance_mobile if pengajuan_tempo.finance_mobile else '', + 'finance_email' : pengajuan_tempo.finance_email if pengajuan_tempo.finance_email else '', + + # Pengiriman + 'PIC_tittle' : pengajuan_tempo.pic_tittle if pengajuan_tempo.pic_tittle else '', + 'PIC_name' : pengajuan_tempo.pic_name if pengajuan_tempo.pic_name else '', + 'street_pengiriman' : pengajuan_tempo.street_pengiriman if pengajuan_tempo.street_pengiriman else '', + 'state_pengiriman' : pengajuan_tempo.state_id_pengiriman.id if pengajuan_tempo.state_id_pengiriman else '', + 'city_pengiriman' : pengajuan_tempo.city_id_pengiriman.id if pengajuan_tempo.city_id_pengiriman else '', + 'district_pengiriman': pengajuan_tempo.district_id_pengiriman.id if pengajuan_tempo.district_id_pengiriman else '', + 'subDistrict_pengiriman': pengajuan_tempo.subDistrict_id_pengiriman.id if pengajuan_tempo.subDistrict_id_pengiriman else '', + 'zip_pengiriman' : pengajuan_tempo.zip_pengiriman if pengajuan_tempo.zip_pengiriman else '', + 'invoice_pic_tittle' : pengajuan_tempo.invoice_pic_tittle if pengajuan_tempo.invoice_pic_tittle else '', + 'invoice_pic' : pengajuan_tempo.invoice_pic if pengajuan_tempo.invoice_pic else '', + 'street_invoice' : pengajuan_tempo.street_invoice if pengajuan_tempo.street_invoice else '', + 'state_invoice' : pengajuan_tempo.state_id_invoice.id if pengajuan_tempo.state_id_invoice else '', + 'city_invoice' : pengajuan_tempo.city_id_invoice.id if pengajuan_tempo.city_id_invoice else '', + 'district_invoice': pengajuan_tempo.district_id_invoice.id if pengajuan_tempo.district_id_invoice else '', + 'subDistrict_invoice': pengajuan_tempo.subDistrict_id_invoice.id if pengajuan_tempo.subDistrict_id_invoice else '', + 'zip_invoice': pengajuan_tempo.zip_invoice if pengajuan_tempo.zip_invoice else '', + 'tukar_invoice_input' : pengajuan_tempo.tukar_invoice if pengajuan_tempo.tukar_invoice else '', + 'tukar_invoice_input_pembayaran' : pengajuan_tempo.jadwal_bayar if pengajuan_tempo.jadwal_bayar else '', + 'dokumen_pengiriman' : ','.join(dokumen_pengiriman) if dokumen_pengiriman else '', + 'dokumen_pengiriman_input' : pengajuan_tempo.dokumen_pengiriman_input if pengajuan_tempo.dokumen_pengiriman_input else '', + 'dokumen_kirim_input' : pengajuan_tempo.dokumen_kirim_input if pengajuan_tempo.dokumen_kirim_input else '', + 'dokumen_pengiriman_invoice' : pengajuan_tempo.dokumen_invoice if pengajuan_tempo.dokumen_invoice else '', + 'is_same_addrees': pengajuan_tempo.is_same_address if pengajuan_tempo.is_same_address else False, + 'is_same_addrees_street': pengajuan_tempo.is_same_address_street if pengajuan_tempo.is_same_address_street else False, + 'supplier_ids': [ + { + 'id': supplier.id, + 'supplier': supplier.name_supplier, + 'telepon': supplier.phone, + 'pic': supplier.pic_name, + 'credit_limit': supplier.credit_limit, + 'durasi_tempo': supplier.tempo_duration + } + for supplier in pengajuan_tempo.supplier_ids + ] if pengajuan_tempo.supplier_ids else '', + # Dokumen + 'dokumen_npwp': + { + 'name': pengajuan_tempo.dokumen_npwp.name, + 'base64': pengajuan_tempo.dokumen_npwp.datas.decode('utf-8'), + 'format': pengajuan_tempo.dokumen_npwp.mimetype, + } if pengajuan_tempo.dokumen_npwp else '', + 'dokumen_sppkp': { + 'name': pengajuan_tempo.dokumen_sppkp.name, + 'base64': pengajuan_tempo.dokumen_sppkp.datas.decode('utf-8'), + 'format': pengajuan_tempo.dokumen_sppkp.mimetype, + } if pengajuan_tempo.dokumen_sppkp else '', + 'dokumen_nib': + { + 'name': pengajuan_tempo.dokumen_nib.name, + 'base64': pengajuan_tempo.dokumen_nib.datas.decode('utf-8'), + 'format': pengajuan_tempo.dokumen_nib.mimetype, + }if pengajuan_tempo.dokumen_nib else '', + 'dokumen_siup': + { + 'name': pengajuan_tempo.dokumen_siup.name, + 'base64': pengajuan_tempo.dokumen_siup.datas.decode('utf-8'), + 'format': pengajuan_tempo.dokumen_siup.mimetype, + }if pengajuan_tempo.dokumen_siup else '', + 'dokumen_tdp': + { + 'name': pengajuan_tempo.dokumen_tdp.name, + 'base64': pengajuan_tempo.dokumen_tdp.datas.decode('utf-8'), + 'format': pengajuan_tempo.dokumen_tdp.mimetype, + }if pengajuan_tempo.dokumen_tdp else '', + 'dokumen_skdp': + { + 'name': pengajuan_tempo.dokumen_skdp.name, + 'base64': pengajuan_tempo.dokumen_skdp.datas.decode('utf-8'), + 'format': pengajuan_tempo.dokumen_skdp.mimetype, + }if pengajuan_tempo.dokumen_skdp else '', + 'dokumen_skt': + { + 'name': pengajuan_tempo.dokumen_skt.name, + 'base64': pengajuan_tempo.dokumen_skt.datas.decode('utf-8'), + 'format': pengajuan_tempo.dokumen_skt.mimetype, + }if pengajuan_tempo.dokumen_skt else '', + 'dokumen_akta_perubahan': { + 'name': pengajuan_tempo.dokumen_akta_perubahan.name, + 'base64': pengajuan_tempo.dokumen_akta_perubahan.datas.decode('utf-8'), + 'format': pengajuan_tempo.dokumen_akta_perubahan.mimetype, + } if pengajuan_tempo.dokumen_akta_perubahan else '', + 'dokumen_ktp_dirut': { + 'name': pengajuan_tempo.dokumen_ktp_dirut.name, + 'base64': pengajuan_tempo.dokumen_ktp_dirut.datas.decode('utf-8'), + 'format': pengajuan_tempo.dokumen_ktp_dirut.mimetype, + } if pengajuan_tempo.dokumen_ktp_dirut else '', + 'dokumen_akta_pendirian': { + 'name': pengajuan_tempo.dokumen_akta_pendirian.name, + 'base64': pengajuan_tempo.dokumen_akta_pendirian.datas.decode('utf-8'), + 'format': pengajuan_tempo.dokumen_akta_pendirian.mimetype, + } if pengajuan_tempo.dokumen_akta_pendirian else '', + 'dokumen_laporan_keuangan': { + 'name': pengajuan_tempo.dokumen_laporan_keuangan.name, + 'base64': pengajuan_tempo.dokumen_laporan_keuangan.datas.decode('utf-8'), + 'format': pengajuan_tempo.dokumen_laporan_keuangan.mimetype, + } if pengajuan_tempo.dokumen_laporan_keuangan else '', + 'dokumen_foto_kantor': { + 'name': pengajuan_tempo.dokumen_foto_kantor.name, + 'base64': pengajuan_tempo.dokumen_foto_kantor.datas.decode('utf-8'), + 'format': pengajuan_tempo.dokumen_foto_kantor.mimetype, + } if pengajuan_tempo.dokumen_foto_kantor else '', + 'dokumen_tempat_bekerja': { + 'name': pengajuan_tempo.dokumen_tempat_bekerja.name, + 'base64': pengajuan_tempo.dokumen_tempat_bekerja.datas.decode('utf-8'), + 'format': pengajuan_tempo.dokumen_tempat_bekerja.mimetype, + } if pengajuan_tempo.dokumen_tempat_bekerja else '', + } + + return data
\ No newline at end of file diff --git a/indoteknik_api/models/res_users.py b/indoteknik_api/models/res_users.py index 77aeeef7..2021b0bb 100644 --- a/indoteknik_api/models/res_users.py +++ b/indoteknik_api/models/res_users.py @@ -1,5 +1,5 @@ from odoo import models - +from odoo.http import request class ResUsers(models.Model): _inherit = 'res.users' @@ -15,8 +15,14 @@ class ResUsers(models.Model): 'director': 3 } partner_tempo = False + is_tempo_request = request.env['user.pengajuan.tempo.request'].search([('user_company_id', '=', main_partner.id)], limit=1) + tempo_progres = ( + 'review' if is_tempo_request.state_tempo in ('draft', 'approval_sales', 'approval_finance') else + 'rejected' if is_tempo_request.state_tempo == 'reject' else + 'approve' if is_tempo_request.state_tempo == 'approval_director' else '' + ) if main_partner: - partner_tempo = main_partner.get_check_tempo_partner() + partner_tempo = True if 'tempo' in main_partner.get_check_payment_term().lower() else False data = { 'id': res_user.id, @@ -36,7 +42,8 @@ class ResUsers(models.Model): 'so_approval': main_partner.use_so_approval, 'only_ready_stock': main_partner.use_only_ready_stock }, - 'partner_tempo': partner_tempo + 'partner_tempo': partner_tempo, + 'tempo_progres': tempo_progres } return data |
