summaryrefslogtreecommitdiff
path: root/indoteknik_api/models
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2025-01-15 15:43:42 +0700
committerit-fixcomart <it@fixcomart.co.id>2025-01-15 15:43:42 +0700
commitbe1ee2092fef86e79932206cc48d5a146107ac32 (patch)
treee54a8c6ffda996f212ab1c2d03b27a32bab8ba89 /indoteknik_api/models
parent8b2897d9c72eb67382221d320d488543aea08323 (diff)
parente4ec9406cd0903db59cfed34781da55a2dba4ca3 (diff)
Merge branch 'odoo-production' into iman/switch-account
Diffstat (limited to 'indoteknik_api/models')
-rw-r--r--indoteknik_api/models/__init__.py1
-rw-r--r--indoteknik_api/models/account_move.py5
-rw-r--r--indoteknik_api/models/product_product.py12
-rw-r--r--indoteknik_api/models/product_template.py6
-rw-r--r--indoteknik_api/models/res_partner.py170
-rw-r--r--indoteknik_api/models/res_users.py17
-rw-r--r--indoteknik_api/models/sale_order.py7
7 files changed, 208 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/product_template.py b/indoteknik_api/models/product_template.py
index 75899624..e46e44d3 100644
--- a/indoteknik_api/models/product_template.py
+++ b/indoteknik_api/models/product_template.py
@@ -7,6 +7,11 @@ class ProductTemplate(models.Model):
def api_single_response(self, product_template, with_detail=''):
product_pricelist_default_discount_id = self.env['ir.config_parameter'].get_param('product.pricelist.default_discount_id')
product_pricelist_default_discount_id = int(product_pricelist_default_discount_id)
+ voucher = self.get_voucher_pastihemat(product_template.x_manufacture.id)
+ newVoucherPastiHemat = {"min_purchase": voucher.min_purchase_amount or 0,
+ "discount_type": voucher.discount_type or '',
+ "discount_amount": voucher.discount_amount or 0,
+ "max_discount": voucher.max_discount_amount or 0,}
data = {
'id': product_template.id,
'image': self.env['ir.attachment'].api_image('product.template', 'image_128', product_template.id),
@@ -18,6 +23,7 @@ class ProductTemplate(models.Model):
'weight': product_template.weight,
'manufacture': self.api_manufacture(product_template),
'categories': self.api_categories(product_template),
+ "newVoucherPastiHemat": newVoucherPastiHemat
}
if with_detail != '':
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 1691acde..713bf50c 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'
@@ -14,6 +14,15 @@ class ResUsers(models.Model):
'manager': 2,
'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 = True if 'tempo' in main_partner.get_check_payment_term().lower() else False
data = {
'id': res_user.id,
@@ -32,7 +41,9 @@ class ResUsers(models.Model):
'feature': {
'so_approval': main_partner.use_so_approval,
'only_ready_stock': main_partner.use_only_ready_stock
- }
+ },
+ 'partner_tempo': partner_tempo,
+ 'tempo_progres': tempo_progres
}
return data
@@ -70,7 +81,7 @@ class ResUsers(models.Model):
data['state_id'] = {
'id': user.state_id.id,
'name': user.state_id.name
- } or None
+ } or 0
if user.kota_id:
data['city'] = {
diff --git a/indoteknik_api/models/sale_order.py b/indoteknik_api/models/sale_order.py
index 54e1fd40..727379c5 100644
--- a/indoteknik_api/models/sale_order.py
+++ b/indoteknik_api/models/sale_order.py
@@ -39,6 +39,8 @@ class SaleOrder(models.Model):
data['status'] = 'cancel'
if sale_order.state in ['draft', 'sent']:
data['status'] = 'draft'
+ if sale_order.is_continue_transaction:
+ data['status'] = 'waiting'
if sale_order.approval_status in ['pengajuan1', 'pengajuan2']:
data['status'] = 'waiting'
if sale_order.state == 'sale':
@@ -85,6 +87,11 @@ class SaleOrder(models.Model):
}
product['quantity'] = line.product_uom_qty
product['available_quantity'] = line.product_available_quantity
+ for data_v2 in sale_order.fulfillment_line_v2:
+ product_v2 = self.env['product.product'].api_single_response(data_v2.product_id)
+ if product['id'] == product_v2['id']:
+ product['so_qty'] = data_v2.so_qty
+ product['reserved_stock_qty'] = data_v2.reserved_stock_qty
data_with_detail['products'].append(product)
for invoice in sale_order.invoice_ids:
if invoice.state == 'posted':