From 907db76e2edfa56186c188e319fdd4bc59383769 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 25 Oct 2024 14:01:57 +0700 Subject: add pengajuan tempo --- indoteknik_custom/models/pengajuan_tempo.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 indoteknik_custom/models/pengajuan_tempo.py diff --git a/indoteknik_custom/models/pengajuan_tempo.py b/indoteknik_custom/models/pengajuan_tempo.py new file mode 100644 index 00000000..908843c7 --- /dev/null +++ b/indoteknik_custom/models/pengajuan_tempo.py @@ -0,0 +1,11 @@ +from odoo import models, fields +from datetime import datetime, timedelta + + +class PengajuanTempo(models.Model): + _inherit = "pengajuan.tempo" + + name = fields.Char(string="Nama Perusahaan") + street = fields.Char(string="Alamat Perusahaan") + site_id = fields.Many2one('res.partner.site', string='Site') + mobile = fields.Char(string="No. Telfon Perusahaan") -- cgit v1.2.3 From 4588b8df03628821dce6eb6029ac4bcd5065aba8 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Sat, 26 Oct 2024 14:01:20 +0700 Subject: add pengajuan tempo --- indoteknik_custom/models/res_partner.py | 127 +++++++++++++++++++------ indoteknik_custom/security/ir.model.access.csv | 1 + indoteknik_custom/views/res_partner.xml | 73 ++++++++++++++ 3 files changed, 173 insertions(+), 28 deletions(-) diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index 25db16d0..bf7c45ad 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -2,14 +2,88 @@ from odoo import models, fields, api from odoo.exceptions import UserError, ValidationError from datetime import datetime + class GroupPartner(models.Model): _name = 'group.partner' name = fields.Char(string='Name') +class PengajuanTempoSupplier(models.Model): + _name = 'pengajuan.tempo.supplier' + + # Fields untuk tabel supplier + name_supplier = fields.Char(string="Nama Supplier") + pic_name = fields.Char(string="PIC") + phone = fields.Char(string="Telepon") + tempo_duration = fields.Char(string="Durasi Tempo") + credit_limit = fields.Char(string="Credit Limit") + pengajuan_tempo_id = fields.Many2one('new.pengajuan.tempo', string="Pengajuan Tempo", ondelete='cascade') + +class NewPengajuanTempo(models.Model): + _name = 'new.pengajuan.tempo' + _inherit = 'pengajuan.tempo.supplier' + + # 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') + + # Referensi + # supplier_ids = fields.One2many('pengajuan.tempo.supplier',) + # category_id = fields.Many2one('product.public.category', string='Category Level 1') + supplier_ids = fields.One2many('pengajuan.tempo.supplier', 'pengajuan_tempo_id', string="Suppliers") + + + class ResPartner(models.Model): - _inherit = 'res.partner' + _name = 'res.partner' + _inherit = ['res.partner', 'new.pengajuan.tempo'] + # Relasi ke web.pengajuan.tempo + pengajuan_tempo_id = fields.Many2one('web.pengajuan.tempo', string="Pengajuan Tempo") reference_number = fields.Char(string="Reference Number") company_type_id = fields.Many2one('res.partner.company_type', string='Company Type') custom_pricelist_id = fields.Many2one('product.pricelist', string='Price Matrix') @@ -25,7 +99,7 @@ class ResPartner(models.Model): digital_invoice_tax = fields.Boolean(string="Digital Invoice & Faktur Pajak") is_potential = fields.Boolean(string='Potential') pakta_integritas = fields.Boolean(string='Pakta Integritas') - + use_so_approval = fields.Boolean(string='Use SO Approval') use_only_ready_stock = fields.Boolean(string='Use Only Ready Stock') web_role = fields.Selection([ @@ -66,23 +140,22 @@ class ResPartner(models.Model): if partner.company_type == 'person' and not partner.parent_id: partner.alamat_lengkap_text = partner.street # if partner.company_type == 'person' and partner.parent_id: - # partner.alamat_lengkap_text = partner.parent_id.alamat_lengkap_text - + # partner.alamat_lengkap_text = partner.parent_id.alamat_lengkap_text - alamat_lengkap_text = fields.Text(string="Alamat Lengkap", required=False , tracking=3) + alamat_lengkap_text = fields.Text(string="Alamat Lengkap", required=False, tracking=3) def write(self, vals): res = super(ResPartner, self).write(vals) - # - # # if 'property_payment_term_id' in vals: - # # if not self.env.user.is_accounting and vals['property_payment_term_id'] != 26: - # # raise UserError('Hanya Finance Accounting yang dapat merubah payment term') - # - # # group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id - # # users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) - # # if self.env.user.id not in users_in_group.mapped('id'): - # # raise UserError('You name it') - # + # + # # if 'property_payment_term_id' in vals: + # # if not self.env.user.is_accounting and vals['property_payment_term_id'] != 26: + # # raise UserError('Hanya Finance Accounting yang dapat merubah payment term') + # + # # group_id = self.env.ref('indoteknik_custom.group_role_merchandiser').id + # # users_in_group = self.env['res.users'].search([('groups_id', 'in', [group_id])]) + # # if self.env.user.id not in users_in_group.mapped('id'): + # # raise UserError('You name it') + # return res def write(self, vals): @@ -139,7 +212,8 @@ class ResPartner(models.Model): # res = super(ResPartner, self).write(vals) # return res - @api.depends('company_type', 'parent_id', 'npwp', 'sppkp', 'nama_wajib_pajak','alamat_lengkap_text', 'industry_id', 'company_type_id') + @api.depends('company_type', 'parent_id', 'npwp', 'sppkp', 'nama_wajib_pajak', 'alamat_lengkap_text', 'industry_id', + 'company_type_id') def _related_fields(self): for partner in self: if partner.company_type == 'person' and partner.parent_id: @@ -156,7 +230,7 @@ class ResPartner(models.Model): for rec in self: rec.user_payment_terms_sales = self.env.user.id rec.date_payment_terms_sales = datetime.utcnow() - + @api.constrains('property_supplier_payment_term_id') def updated_by_payment_term(self): for rec in self: @@ -175,15 +249,15 @@ class ResPartner(models.Model): rec.state_id = site.state_id rec.country_id = site.country_id rec.zip = site.zip - + def get_main_parent(self): partner = self - + while partner.parent_id: partner = partner.parent_id - + return partner - + def _compute_main_parent_id(self): for partner in self: partner.main_parent_id = partner.get_main_parent() @@ -195,14 +269,14 @@ class ResPartner(models.Model): partner_child_ids += [x['id'] for x in partner.parent_id.child_ids] partner_child_ids += [partner.parent_id.id] return partner_child_ids - + def get_approve_partner_ids(self, type=False): parent = self.parent_id or self partners = self.search([('parent_id', '=', parent.id), ('web_role', '!=', False)]) - + if type == 'email_comma_sep': return ",".join([x.email for x in partners]) - + return partners @api.constrains('kota_id') @@ -213,11 +287,8 @@ class ResPartner(models.Model): def unlink(self): if self._name == 'res.partner': raise UserError('Maaf anda tidak bisa delete contact') - + @api.onchange('customer_type') def _onchange_customer_type(self): if self.customer_type == 'nonpkp': self.npwp = '00.000.000.0-000.000' - - - diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 553047e6..398a3067 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -143,3 +143,4 @@ access_vendor_approval_line,access.vendor.approval.line,model_vendor_approval_li access_vit_kota,access.vit.kota,model_vit_kota,,1,1,1,1 access_v_brand_product_category,access.v.brand.product.category,model_v_brand_product_category,,1,1,1,1 access_web_find_page,access.web.find.page,model_web_find_page,,1,1,1,1 +access_pengajuan_tempo_supplier,access_pengajuan_tempo_supplier,model_pengajuan_tempo_supplier,base.group_user,1,1,1,1 \ No newline at end of file diff --git a/indoteknik_custom/views/res_partner.xml b/indoteknik_custom/views/res_partner.xml index 6d02a86b..278f6d44 100644 --- a/indoteknik_custom/views/res_partner.xml +++ b/indoteknik_custom/views/res_partner.xml @@ -71,6 +71,79 @@ 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3 From d8c12d085edbd81d974555780b16421c7b155f7f Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 31 Oct 2024 13:49:23 +0700 Subject: update pengajuan tempo final --- indoteknik_api/controllers/api_v1/partner.py | 225 ++++++++++++++++++++- indoteknik_custom/__manifest__.py | 2 + indoteknik_custom/models/__init__.py | 3 + indoteknik_custom/models/pengajuan_tempo.py | 11 - indoteknik_custom/models/res_partner.py | 103 +++++++--- indoteknik_custom/models/user_pengajuan_tempo.py | 148 ++++++++++++++ .../models/user_pengajuan_tempo_line.py | 14 ++ .../models/user_pengajuan_tempo_request.py | 184 +++++++++++++++++ indoteknik_custom/security/ir.model.access.csv | 4 +- indoteknik_custom/views/res_partner.xml | 129 +++++++----- indoteknik_custom/views/user_pengajuan_tempo.xml | 129 ++++++++++++ .../views/user_pengajuan_tempo_line.xml | 42 ++++ .../views/user_pengajuan_tempo_request.xml | 67 ++++++ 13 files changed, 966 insertions(+), 95 deletions(-) delete mode 100644 indoteknik_custom/models/pengajuan_tempo.py create mode 100644 indoteknik_custom/models/user_pengajuan_tempo.py create mode 100644 indoteknik_custom/models/user_pengajuan_tempo_line.py create mode 100644 indoteknik_custom/models/user_pengajuan_tempo_request.py create mode 100644 indoteknik_custom/views/user_pengajuan_tempo.xml create mode 100644 indoteknik_custom/views/user_pengajuan_tempo_line.xml create mode 100644 indoteknik_custom/views/user_pengajuan_tempo_request.xml diff --git a/indoteknik_api/controllers/api_v1/partner.py b/indoteknik_api/controllers/api_v1/partner.py index a7925a02..27ba186f 100644 --- a/indoteknik_api/controllers/api_v1/partner.py +++ b/indoteknik_api/controllers/api_v1/partner.py @@ -2,6 +2,9 @@ from .. import controller from odoo import http from odoo.http import request +import json +import base64 +import mimetypes class Partner(controller.Controller): _name = 'res.partner' @@ -226,8 +229,228 @@ class Partner(controller.Controller): 'amount_due': result_tempo, 'remaining_limit': remaining_limit } - + return self.response(data) + @http.route(prefix + 'partner/pengajuan_tempo', auth='public', methods=['POST'], csrf=False) + @controller.Controller.must_authorized() + def write_pengajuan_tempo(self, **kw): + user_id = int(kw.get('user_id')) + user = request.env['res.users'].search([('id', '=', user_id)], limit=1) + company_name = kw.get('name') + partner_id = request.env['res.partner'].search([('name', 'like', company_name)], limit=1) + + params = self.get_request_params(kw, { + + # informasi perusahaan + # 'name': ['required', 'alias:name_tempo'], + 'industry_id': ['required', 'alias:industry_id_tempo'], + 'street': ['required', 'alias:street_tempo'], + 'state': ['required', 'alias:state_id_tempo'], + 'city': ['required', 'alias:city_id_tempo'], + 'zip': ['required', 'alias:zip_tempo'], + 'mobile': ['required', 'alias:mobile_tempo'], + 'bankName': ['required', 'alias:bank_name_tempo'], + 'accountName': ['required', 'alias:account_name_tempo'], + 'accountNumber': ['required', 'alias:account_number_tempo'], + 'website': ['alias:website_tempo'], + 'estimasi': ['required', 'alias:estimasi_tempo'], + 'tempoDuration': ['required', 'alias:tempo_duration'], + 'tempoLimit': ['required', 'alias:tempo_limit'], + + # informasi perusahaan + 'direkturName': ['required', 'alias:direktur_name'], + 'direkturMobile': ['required', 'alias:direktur_mobile'], + 'direkturEmail': ['required', 'alias:direktur_email'], + 'purchasingName': ['required', 'alias:purchasing_name'], + 'purchasingMobile': ['required', 'alias:purchasing_mobile'], + 'purchasingEmail': ['required', 'alias:purchasing_email'], + 'financeName': ['required', 'alias:finance_name'], + 'financeMobile': ['required', 'alias:finance_mobile'], + 'financeEmail': ['required', 'alias:finance_email'], + + # Pengiriman + 'PICName': ['required', 'alias:pic_name'], + 'streetPengiriman': ['required', 'alias:street_pengiriman'], + 'statePengiriman': ['required', 'alias:state_id_pengiriman'], + 'cityPengiriman': ['required', 'alias:city_id_pengiriman'], + 'zipPengiriman': ['required', 'alias:zip_pengiriman'], + 'invoicePic': ['required', 'alias:invoice_pic'], + 'streetInvoice': ['required', 'alias:street_invoice'], + 'stateInvoice': ['required', 'alias:state_id_invoice'], + 'cityInvoice': ['required', 'alias:city_id_invoice'], + }) + if not params['valid']: + return self.response(code=400, description=params) + pengajuan_tempo = request.env['user.pengajuan.tempo'].create([params['value']]) + + if partner_id: + pengajuan_tempo.name_tempo = partner_id + + form_supplier_data = kw.get('formSupplier') + + if form_supplier_data: + try: + form_supplier_data = json.loads(form_supplier_data) + + for item in form_supplier_data: + supplier_name = item.get("supplier") + pic_name = item.get("pic") + phone = item.get("telepon") + tempo_duration = item.get("durasiTempo") + credit_limit = item.get("creditLimit") + + 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, + 'credit_limit': credit_limit, + } + new_supplier_data = request.env['user.pengajuan.tempo.line'].create(new_data) + + except json.JSONDecodeError: + return http.Response(status=400, json_body={'error': 'Invalid JSON format for formSupplier'}) + category_produk_ids = kw.get('categoryProduk') + category_ids = list(map(int, category_produk_ids.split(','))) + + pengajuan_tempo.category_produk_ids = [(6, 0, category_ids)] + every_weekday = True if kw.get('everyWeekday') == "true" else False + every_weekday_input = kw.get('everyWeekdayInput') + every_week = True if kw.get('everyWeek') == 'true' else False + every_week_input = kw.get('everyWeekInput') + tukar_invoice = True if kw.get('tukarInvoice') == 'true' else False + tukar_invoice_input = kw.get('tukarInvoiceInput') + jadwal_tukar_invoice = "" + if every_weekday: + jadwal_tukar_invoice += f"setiap hari {every_weekday_input}" + if every_week: + jadwal_tukar_invoice += f", setiap {every_week_input}" + if tukar_invoice or tukar_invoice_input: + jadwal_tukar_invoice += f", {tukar_invoice_input}" + + pengajuan_tempo.tukar_invoice = jadwal_tukar_invoice + + every_weekday_pembayaran = True if kw.get('everyWeekdayPembayaran') == 'true' else False + every_weekday_input_pembayaran = kw.get('everyWeekdayInputPembayaran') + every_week_pembayaran = True if kw.get('everyWeekPembayaran') == 'true' else False + every_week_input_pembayaran = kw.get('everyWeekInputPembayaran') + tukar_invoice_pembayaran = True if kw.get('tukarInvoicePembayaran') == 'true' else False + tukar_invoice_input_pembayaran = kw.get('tukarInvoiceInputPembayaran') + jadwal_tukar_invoice_pembayaran = "" + if every_weekday_pembayaran: + jadwal_tukar_invoice_pembayaran += f"setiap hari {every_weekday_input_pembayaran}" + if every_week_pembayaran: + jadwal_tukar_invoice_pembayaran += f", setiap {every_week_input_pembayaran}" + if tukar_invoice_pembayaran or tukar_invoice_input_pembayaran: + jadwal_tukar_invoice_pembayaran += f", {tukar_invoice_input_pembayaran}" + + pengajuan_tempo.jadwal_bayar = jadwal_tukar_invoice_pembayaran + + dokumen_kirim = [ + 'Surat Tanda Terima Barang (STTB)', + 'Good Receipt (GR)', + 'Surat Terima Barang (STB)', + 'Lembar Penerimaan Barang (LPB)' + ] + + dokumen_kirim_barang_ids = kw.get('dokumenPengiriman') + dokumen_kirim_barang_input = kw.get('dokumenPengirimanInput', '') + dokumen_kirim_barang = [] + + if dokumen_kirim_barang_ids: + dokumen_kirim_ids = list(map(int, dokumen_kirim_barang_ids.split(','))) + dokumen_kirim_barang = [dokumen_kirim[i] for i in dokumen_kirim_ids if 0 <= i < len(dokumen_kirim)] + + if dokumen_kirim_barang_input: + input_items = [item.strip() for item in dokumen_kirim_barang_input.split(',')] + dokumen_kirim_barang.extend(item for item in input_items if item and item not in dokumen_kirim_barang) + + pengajuan_tempo.dokumen_pengiriman = ', '.join(dokumen_kirim_barang) + + dokumen = [ + 'Invoice Pembelian', + 'Surat Jalan', + 'Berita Acara Serah Terima (BAST)', + 'Faktur Pajak', + 'Good Receipt (GR)' + ] + + dokumen_invoice_ids = kw.get('dokumenPengirimanInvoice') + dokumen_invoice_input = kw.get('dokumenPengirimanInvoiceInput', '') + dokumen_invoice = "" + + if dokumen_kirim_barang_ids: + dokumen_ids = list(map(int, dokumen_invoice_ids.split(','))) + dokumen_invoice = [dokumen[i] for i in dokumen_ids if 0 <= i < len(dokumen)] + if dokumen_invoice_input: + input_items = [item.strip() for item in dokumen_invoice_input.split(',')] + dokumen_invoice.extend(item for item in input_items if item and item not in dokumen_invoice) + + pengajuan_tempo.dokumen_invoice = ', '.join(dokumen_invoice) + + form_dokumen_data = kw.get('formDocs') + if form_dokumen_data: + try: + form_dokumen = json.loads(form_dokumen_data) + + for dokumen in form_dokumen: + if dokumen['details']['base64'] != '': + mimetype, _ = mimetypes.guess_type(dokumen['details']['name']) + mimetype = mimetype or 'application/octet-stream' + data = base64.b64decode(dokumen['details']['base64']) + sppkp_attachment = request.env['ir.attachment'].create({ + 'name': dokumen['details']['name'], + 'type': 'binary', + 'datas': base64.b64encode(data), + 'res_model': 'user.pengajuan.tempo', + 'res_id': pengajuan_tempo.id, + 'mimetype': mimetype + }) + + if dokumen['documentName'] == 'dokumenNib' and dokumen['details']['base64'] != '': + pengajuan_tempo.dokumen_nib = [(4, sppkp_attachment.id)] + + elif dokumen['documentName'] == 'dokumenNpwp' and dokumen['details']['base64'] != '': + pengajuan_tempo.dokumen_npwp = [(4, sppkp_attachment.id)] + + elif dokumen['documentName'] == 'dokumenSppkp' and dokumen['details']['base64'] != '': + pengajuan_tempo.dokumen_sppkp = [(4, sppkp_attachment.id)] + + elif dokumen['documentName'] == 'dokumenAktaPerubahan' and dokumen['details']['base64'] != '': + pengajuan_tempo.dokumen_akta_perubahan = [(4, sppkp_attachment.id)] + + elif dokumen['documentName'] == 'dokumenKtpDirut' and dokumen['details']['base64'] != '': + pengajuan_tempo.dokumen_ktp_dirut = [(4, sppkp_attachment.id)] + + elif dokumen['documentName'] == 'dokumenAktaPendirian' and dokumen['details']['base64'] != '': + pengajuan_tempo.dokumen_akta_pendirian = [(4, sppkp_attachment.id)] + + elif dokumen['documentName'] == 'dokumenLaporanKeuangan' and dokumen['details']['base64'] != '': + pengajuan_tempo.dokumen_laporan_keuangan = [(4, sppkp_attachment.id)] + + elif dokumen['documentName'] == 'dokumenFotoKantor' and dokumen['details']['base64'] != '': + pengajuan_tempo.dokumen_foto_kantor = [(4, sppkp_attachment.id)] + + else: + pengajuan_tempo.dokumen_tempat_bekerja = [(4, sppkp_attachment.id)] + + formatted_text = ''.join([' ' + char if char.isupper() and i != 0 else char for i, char in enumerate(dokumen['documentName'])]) + teks = formatted_text.strip().title() + pengajuan_tempo.message_post(body=teks, attachment_ids=[sppkp_attachment.id]) + + except json.JSONDecodeError: + return http.Response(status=400, json_body={'error': 'Invalid JSON format for formDokumen'}) + + tempo_request = request.env['user.pengajuan.tempo.request'].create({ + 'user_id': user.partner_id.id, + 'pengajuan_tempo_id': pengajuan_tempo.id, + 'user_input': partner_id.name + }) + return self.response({ + 'id': user_id, + }) diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index c8a658b5..2ec5e720 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -30,6 +30,7 @@ 'views/web_logging/user_activity_log.xml', 'views/web_logging/web_utm_source.xml', 'views/user_company_request.xml', + 'views/user_pengajuan_tempo_request.xml', 'views/vit_kelurahan.xml', 'views/vit_kecamatan.xml', 'views/vit_kota.xml', @@ -145,6 +146,7 @@ 'views/approval_unreserve.xml', 'views/vendor_approval.xml', 'views/find_page.xml', + 'views/user_pengajuan_tempo.xml', 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index e62fbb4a..a2a445bc 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -34,6 +34,7 @@ from . import stock_picking_type from . import stock_picking from . import stock_vendor from . import user_company_request +from . import user_pengajuan_tempo_request from . import users from . import website_brand_homepage from . import website_categories_homepage @@ -131,3 +132,5 @@ from . import approval_unreserve from . import vendor_approval from . import partner from . import find_page +from . import user_pengajuan_tempo_line +from . import user_pengajuan_tempo \ No newline at end of file diff --git a/indoteknik_custom/models/pengajuan_tempo.py b/indoteknik_custom/models/pengajuan_tempo.py deleted file mode 100644 index 908843c7..00000000 --- a/indoteknik_custom/models/pengajuan_tempo.py +++ /dev/null @@ -1,11 +0,0 @@ -from odoo import models, fields -from datetime import datetime, timedelta - - -class PengajuanTempo(models.Model): - _inherit = "pengajuan.tempo" - - name = fields.Char(string="Nama Perusahaan") - street = fields.Char(string="Alamat Perusahaan") - site_id = fields.Many2one('res.partner.site', string='Site') - mobile = fields.Char(string="No. Telfon Perusahaan") diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index bf7c45ad..c2b54dd9 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -8,23 +8,74 @@ class GroupPartner(models.Model): name = fields.Char(string='Name') -class PengajuanTempoSupplier(models.Model): - _name = 'pengajuan.tempo.supplier' - # Fields untuk tabel supplier - name_supplier = fields.Char(string="Nama Supplier") - pic_name = fields.Char(string="PIC") - phone = fields.Char(string="Telepon") - tempo_duration = fields.Char(string="Durasi Tempo") - credit_limit = fields.Char(string="Credit Limit") - pengajuan_tempo_id = fields.Many2one('new.pengajuan.tempo', string="Pengajuan Tempo", ondelete='cascade') +# 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 NewPengajuanTempo(models.Model): - _name = 'new.pengajuan.tempo' - _inherit = 'pengajuan.tempo.supplier' + + +class ResPartner(models.Model): + _inherit = 'res.partner' + + # Referensi + supplier_ids = fields.One2many('user.pengajuan.tempo.line', 'pengajuan_tempo_partner', string="Suppliers") # informasi perusahaan - name_tempo = fields.Char(string="Nama Perusahaan") + name_tempo = fields.Many2one( + 'res.partner', string='Nama Perusahaan', + tracking=True, # Menambahkan 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') @@ -38,7 +89,8 @@ class NewPengajuanTempo(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): @@ -63,7 +115,6 @@ class NewPengajuanTempo(models.Model): 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') @@ -71,19 +122,17 @@ class NewPengajuanTempo(models.Model): dokumen_pengiriman = fields.Char(string='Dokumen saat Pengiriman Barang') dokumen_invoice = fields.Char(string='Dokumen yang dilampirkan saat Pengiriman Invoice') - # Referensi - # supplier_ids = fields.One2many('pengajuan.tempo.supplier',) - # category_id = fields.Many2one('product.public.category', string='Category Level 1') - supplier_ids = fields.One2many('pengajuan.tempo.supplier', 'pengajuan_tempo_id', string="Suppliers") - - - -class ResPartner(models.Model): - _name = 'res.partner' - _inherit = ['res.partner', 'new.pengajuan.tempo'] + # Dokumen + dokumen_nib = fields.Many2one('ir.attachment', string="NIB (SIUP/TDP/SKDP)", tracking=3, readonly=True,) + dokumen_npwp = fields.Many2one('ir.attachment', string="NPWP Perusahaan", tracking=3, readonly=True) + dokumen_sppkp = fields.Many2one('ir.attachment', string="SPPKP Perusahaan", tracking=3, readonly=True) + dokumen_akta_perubahan = fields.Many2one('ir.attachment', string="Akta Perubahan", tracking=3, readonly=True) + dokumen_ktp_dirut = fields.Many2one('ir.attachment', string="KTP Dirut/Direktur", tracking=3, readonly=True) + dokumen_akta_pendirian = fields.Many2one('ir.attachment', string="Akta Pendirian", tracking=3, readonly=True) + dokumen_laporan_keuangan = fields.Many2one('ir.attachment', string="Laporan Keuangan", tracking=3, readonly=True) + dokumen_foto_kantor = fields.Many2one('ir.attachment', string=" Foto Kantor (Tampak Depan)", tracking=3, readonly=True) + dokumen_tempat_bekerja = fields.Many2one('ir.attachment', string="Tempat Bekerja", tracking=3, readonly=True) - # Relasi ke web.pengajuan.tempo - pengajuan_tempo_id = fields.Many2one('web.pengajuan.tempo', string="Pengajuan Tempo") reference_number = fields.Char(string="Reference Number") company_type_id = fields.Many2one('res.partner.company_type', string='Company Type') custom_pricelist_id = fields.Many2one('product.pricelist', string='Price Matrix') diff --git a/indoteknik_custom/models/user_pengajuan_tempo.py b/indoteknik_custom/models/user_pengajuan_tempo.py new file mode 100644 index 00000000..42380fe9 --- /dev/null +++ b/indoteknik_custom/models/user_pengajuan_tempo.py @@ -0,0 +1,148 @@ +from odoo import models, fields, api +from datetime import datetime, timedelta + + +# class IrAttachment(models.Model): +# _inherit = 'ir.attachment' +# +# @api.model +# def create(self, vals): +# attachment = super(IrAttachment, self).create(vals) +# if attachment: +# base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url') +# attachment.url = f"/web/content/{attachment.id}" +# return attachment + + +class UserPengajuanTempo(models.Model): + _name = 'user.pengajuan.tempo' + _inherit = ['mail.thread', 'mail.activity.mixin'] + partner_id = fields.Char() + + # informasi perusahaan + # name_tempo = fields.Many2one( + # 'res.partner', string='Nama Perusahaan', + # readonly=True, required=True, + # states={'draft': [('readonly', False)], 'sent': [('readonly', False)], 'sale': [('readonly', False)]}, + # domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", + # tracking=True, # Menambahkan tracking=True + # ) + name_tempo = fields.Many2one( + 'res.partner', string='Nama Perusahaan', + tracking=True, # Menambahkan 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') + 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") + 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') + + # Referensi + supplier_ids = fields.One2many('user.pengajuan.tempo.line', 'pengajuan_tempo_id', string="Suppliers") + + #Dokumen + dokumen_nib = fields.Many2many('ir.attachment', 'pengajuan_dokumen_nib_rel', string="NIB (SIUP/TDP/SKDP)", tracking=3, track_visibility="onchange") + dokumen_npwp = fields.Many2many('ir.attachment', 'pengajuan_dokumen_npwp_rel', string="NPWP Perusahaan", tracking=3) + dokumen_sppkp = fields.Many2many('ir.attachment', 'pengajuan_dokumen_sppkp_rel', string="SPPKP Perusahaan", tracking=3) + dokumen_akta_perubahan = fields.Many2many('ir.attachment', 'pengajuan_dokumen_akta_perubahan_rel', + string="Akta Perubahan", tracking=3) + dokumen_ktp_dirut = fields.Many2many('ir.attachment', 'pengajuan_dokumen_ktp_dirut_rel', + string="KTP Dirut/Direktur", tracking=3) + dokumen_akta_pendirian = fields.Many2many('ir.attachment', 'pengajuan_dokumen_angkta_pendirian_rel', + string="Akta Pendirian", tracking=3) + dokumen_laporan_keuangan = fields.Many2many('ir.attachment', 'pengajuan_dokumen_laporan_keuangan_rel', + string="Laporan Keuangan", tracking=3) + dokumen_foto_kantor = fields.Many2many('ir.attachment', 'pengajuan_dokumen_foto_kantor_rel', + string=" Foto Kantor (Tampak Depan)", tracking=3) + dokumen_tempat_bekerja = fields.Many2many('ir.attachment', 'pengajuan_dokumen_tempat_bekerja_rel', + string="Tempat Bekerja", tracking=3) + # + # def _compute_attachment_url(self): + # if self.id: + # return { + # 'type': 'ir.actions.act_url', + # 'url': 'http://localhost:8069/web/content/' % (self.id), + # 'target': 'user', + # } + # base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url') + # for record in self: + # # Buat URL list untuk attachment yang ada di dokumen_nib + # record.attachment_urls = [(attachment.id, f"{base_url}/web/content/{attachment.id}") for attachment in + # record.dokumen_nib] + # + # @api.model + # def create(self, vals): + # # Tangani pembuatan baru + # record = super(userPengajuanTempo, self).create(vals) + # if vals.get('dokumen_nib'): + # attachment_names = ', '.join(self.env['ir.attachment'].browse(vals['dokumen_nib'][0][2]).mapped('name')) + # record.message_post(body=f"Files added to NIB: {attachment_names}") + # return record + # + # def write(self, vals): + # # Ambil attachment sebelumnya + # for record in self: + # previous_files = record.dokumen_nib + # res = super(userPengajuanTempo, record).write(vals) + # + # if 'dokumen_nib' in vals: + # new_files = record.dokumen_nib + # + # # Periksa perbedaan antara file lama dan file baru + # added_files = new_files - previous_files + # removed_files = previous_files - new_files + # + # # Buat pesan log berdasarkan perubahan + # messages = [] + # if added_files: + # added_names = ', '.join(added_files.mapped('name')) + # messages.append(f"Files added to NIB: {added_names}") + # if removed_files: + # removed_names = ', '.join(removed_files.mapped('name')) + # messages.append(f"Files removed from NIB: {removed_names}") + # + # # Post pesan ke log note jika ada perubahan + # if messages: + # record.message_post(body="
".join(messages)) + # + # return res + diff --git a/indoteknik_custom/models/user_pengajuan_tempo_line.py b/indoteknik_custom/models/user_pengajuan_tempo_line.py new file mode 100644 index 00000000..7571bd41 --- /dev/null +++ b/indoteknik_custom/models/user_pengajuan_tempo_line.py @@ -0,0 +1,14 @@ +from odoo import models, fields + + +class PengajuanTempoLine(models.Model): + _name = 'user.pengajuan.tempo.line' + + # 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") + credit_limit = fields.Char(string="Credit Limit") \ No newline at end of file diff --git a/indoteknik_custom/models/user_pengajuan_tempo_request.py b/indoteknik_custom/models/user_pengajuan_tempo_request.py new file mode 100644 index 00000000..6c04ab7c --- /dev/null +++ b/indoteknik_custom/models/user_pengajuan_tempo_request.py @@ -0,0 +1,184 @@ +from odoo import models, fields, api +from odoo.exceptions import UserError +from odoo.http import request + +class UserPengajuanTempoRequest(models.Model): + _name = 'user.pengajuan.tempo.request' + _rec_name = 'user_id' + + user_id = fields.Many2one('res.partner', string='User') + user_company_id = fields.Many2one('res.partner', string='Company') + user_input = fields.Char(string='User Input') + is_approve = fields.Selection([ + ('approved', 'Approve'), + ('rejected', 'Reject'), + ], string='Approval') + similar_company_ids = fields.Many2many('res.partner', compute="_compute_similar_companies", string="Similar Companies") + pengajuan_tempo_id = fields.Many2one('user.pengajuan.tempo', string='Form Tempo') + + @api.depends('user_input') + def _compute_similar_companies(self): + for record in self: + if record.user_input: + record.similar_company_ids = [(6, 0, self.get_similar_companies(record.user_input))] + else: + record.similar_company_ids = [(6, 0, [])] + + # def get_similar_companies(self, user_input): + # query = """ + # SELECT id + # FROM res_partner + # WHERE levenshtein(name::text, %s) < 3 + # ORDER BY levenshtein(name::text, %s) ASC + # """ + # self.env.cr.execute(query, (user_input, user_input)) + # return [row[0] for row in self.env.cr.fetchall()] + + def get_similar_companies(self, user_input): + query = """ + SELECT id + FROM res_partner + WHERE (name ILIKE %s OR levenshtein(name::text, %s) < 3) + AND active = TRUE AND is_company = TRUE + ORDER BY levenshtein(name::text, %s) ASC + """ + # Menggunakan '%' untuk mencocokkan nama perusahaan sebagian + self.env.cr.execute(query, ('%' + user_input + '%', user_input, user_input)) + company_ids = [row[0] for row in self.env.cr.fetchall()] + return company_ids + + internal_input = fields.Char(string='Internal Input') + company_type = fields.Char(string='Company Type', compute='_compute_company_type') + + @api.depends('user_company_id.customer_type') + def _compute_company_type(self): + for record in self: + if record.user_company_id.customer_type == 'nonpkp': + record.company_type = 'Non PKP' + elif record.user_company_id.customer_type == 'pkp': + record.company_type = 'PKP' + else: + record.company_type = 'company type belum di set' + + def write(self, vals): + user = self.get_user_by_email(self.user_id.email) + user.parent_name = self.user_input + is_approve = vals.get('is_approve') + is_internal_input = vals.get('internal_input') + company_id = '' + if not self.user_company_id: + company_id = request.env['res.partner'].search([('id', '=', vals.get('user_company_id'))], limit=1) + if self.is_approve and is_approve: + raise UserError('Tidak dapat mengubah approval yang sudah diisi') + + if is_internal_input: + if self.user_company_id.nama_wajib_pajak == self.user_company_id.name: + self.user_company_id.nama_wajib_pajak = is_internal_input + self.user_company_id.name = is_internal_input + + if not self.is_approve and is_approve: + if is_approve == 'approved': + self.pengajuan_tempo_id.partner_id = self.user_id.id + # informasi perusahaan + company_id.name_tempo = self.pengajuan_tempo_id.name_tempo + company_id.industry_id_tempo = self.pengajuan_tempo_id.industry_id_tempo + company_id.street_tempo = self.pengajuan_tempo_id.street_tempo + company_id.state_id_tempo = self.pengajuan_tempo_id.state_id_tempo + company_id.city_id_tempo = self.pengajuan_tempo_id.city_id_tempo + company_id.zip_tempo = self.pengajuan_tempo_id.zip_tempo + company_id.mobile_tempo = self.pengajuan_tempo_id.mobile_tempo + company_id.bank_name_tempo = self.pengajuan_tempo_id.bank_name_tempo + company_id.account_name_tempo = self.pengajuan_tempo_id.account_name_tempo + company_id.account_number_tempo = self.pengajuan_tempo_id.account_number_tempo + company_id.website_tempo = self.pengajuan_tempo_id.website_tempo + company_id.estimasi_tempo = self.pengajuan_tempo_id.estimasi_tempo + company_id.tempo_duration = self.pengajuan_tempo_id.tempo_duration + company_id.tempo_limit = self.pengajuan_tempo_id.tempo_limit + company_id.category_produk_ids = self.pengajuan_tempo_id.category_produk_ids + + # Kontak Perusahaan + company_id.direktur_name = self.pengajuan_tempo_id.direktur_name + company_id.direktur_mobile = self.pengajuan_tempo_id.direktur_mobile + company_id.direktur_email = self.pengajuan_tempo_id.direktur_email + company_id.purchasing_name = self.pengajuan_tempo_id.purchasing_name + company_id.purchasing_mobile = self.pengajuan_tempo_id.purchasing_mobile + company_id.purchasing_email = self.pengajuan_tempo_id.purchasing_email + company_id.finance_name = self.pengajuan_tempo_id.finance_name + company_id.finance_mobile = self.pengajuan_tempo_id.finance_mobile + company_id.finance_email = self.pengajuan_tempo_id.finance_email + + # Pengiriman + company_id.pic_name = self.pengajuan_tempo_id.pic_name + company_id.street_pengiriman = self.pengajuan_tempo_id.street_pengiriman + company_id.state_id_pengiriman = self.pengajuan_tempo_id.state_id_pengiriman + company_id.city_id_pengiriman = self.pengajuan_tempo_id.city_id_pengiriman + company_id.zip_pengiriman = self.pengajuan_tempo_id.zip_pengiriman + company_id.invoice_pic = self.pengajuan_tempo_id.invoice_pic + company_id.street_invoice = self.pengajuan_tempo_id.street_invoice + company_id.state_id_invoice = self.pengajuan_tempo_id.state_id_invoice + company_id.city_id_invoice = self.pengajuan_tempo_id.city_id_invoice + company_id.tukar_invoice = self.pengajuan_tempo_id.tukar_invoice + company_id.jadwal_bayar = self.pengajuan_tempo_id.jadwal_bayar + company_id.dokumen_pengiriman = self.pengajuan_tempo_id.dokumen_pengiriman + company_id.dokumen_invoice = self.pengajuan_tempo_id.dokumen_invoice + + # Referensi + company_id.supplier_ids = self.pengajuan_tempo_id.supplier_ids + + # Dokumen + company_id.dokumen_nib = self.pengajuan_tempo_id.dokumen_nib + if company_id.dokumen_nib: + company_id.message_post(body='Dokumen NIB', attachment_ids=[company_id.dokumen_nib.id]) + + company_id.dokumen_npwp = self.pengajuan_tempo_id.dokumen_npwp + if company_id.dokumen_npwp: + company_id.message_post(body='Dokumen NPWP', attachment_ids=[company_id.dokumen_npwp.id]) + + company_id.dokumen_sppkp = self.pengajuan_tempo_id.dokumen_sppkp + if company_id.dokumen_sppkp: + company_id.message_post(body='Dokumen SPPKP', attachment_ids=[company_id.dokumen_sppkp.id]) + + company_id.dokumen_akta_perubahan = self.pengajuan_tempo_id.dokumen_akta_perubahan + if company_id.dokumen_akta_perubahan: + company_id.message_post(body='Dokumen Akta Perubahan', + attachment_ids=[company_id.dokumen_akta_perubahan.id]) + + company_id.dokumen_ktp_dirut = self.pengajuan_tempo_id.dokumen_ktp_dirut + if company_id.dokumen_ktp_dirut: + company_id.message_post(body='Dokumen Ktp Dirut', + attachment_ids=[company_id.dokumen_ktp_dirut.id]) + + company_id.dokumen_akta_pendirian = self.pengajuan_tempo_id.dokumen_akta_pendirian + if company_id.dokumen_akta_pendirian: + company_id.message_post(body='Dokumen Akta Pendirian', + attachment_ids=[company_id.dokumen_akta_pendirian.id]) + + company_id.dokumen_laporan_keuangan = self.pengajuan_tempo_id.dokumen_laporan_keuangan + if company_id.dokumen_laporan_keuangan: + company_id.message_post(body='Dokumen Laporan Keuangan', + attachment_ids=[company_id.dokumen_laporan_keuangan.id]) + + company_id.dokumen_foto_kantor = self.pengajuan_tempo_id.dokumen_foto_kantor + if company_id.dokumen_foto_kantor: + company_id.message_post(body='Dokumen Foto Kantor', + attachment_ids=[company_id.dokumen_foto_kantor.id]) + + company_id.dokumen_tempat_bekerja = self.pengajuan_tempo_id.dokumen_tempat_bekerja + if company_id.dokumen_tempat_bekerja: + company_id.message_post(body='Dokumen Tempat Bekerja', + attachment_ids=[company_id.dokumen_tempat_bekerja.id]) + # self.user_company_id.active = True + # user.send_company_request_approve_mail() + else: + new_company = self.env['res.partner'].create({ + 'name': self.user_input + }) + # self.user_id.parent_id = new_company.id + # user.send_company_request_reject_mail() + return super(UserPengajuanTempoRequest, self).write(vals) + + def get_user_by_email(self, email): + return request.env['res.users'].search([ + ('login', '=', email), + ('active', 'in', [True, False]) + ]) \ No newline at end of file diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 398a3067..1369a03a 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -44,6 +44,7 @@ access_wati_notification,access.wati.notification,model_wati_notification,,1,1,1 access_wati_api,access.wati.api,model_wati_api,,1,1,1,1 access_wati_contact,access.wati.contact,model_wati_contact,,1,1,1,1 access_user_company_request,access.user.company.request,model_user_company_request,,1,1,1,1 +access_user_pengajuan_tempo_request,access.user.pengajuan.tempo.request,model_user_pengajuan_tempo_request,,1,1,1,1 access_res_partner_company_type,access.res.partner.company_type,model_res_partner_company_type,,1,1,1,1 access_uangmuka_penjualan,access.uangmuka.penjualan,model_uangmuka_penjualan,,1,1,1,1 access_uangmuka_pembelian,access.uangmuka.pembelian,model_uangmuka_pembelian,,1,1,1,1 @@ -143,4 +144,5 @@ access_vendor_approval_line,access.vendor.approval.line,model_vendor_approval_li access_vit_kota,access.vit.kota,model_vit_kota,,1,1,1,1 access_v_brand_product_category,access.v.brand.product.category,model_v_brand_product_category,,1,1,1,1 access_web_find_page,access.web.find.page,model_web_find_page,,1,1,1,1 -access_pengajuan_tempo_supplier,access_pengajuan_tempo_supplier,model_pengajuan_tempo_supplier,base.group_user,1,1,1,1 \ No newline at end of file +access_User_pengajuan_tempo_line,access.user.pengajuan.tempo.line,model_user_pengajuan_tempo_line,,1,1,1,1 +access_user_pengajuan_tempo,access.user.pengajuan.tempo,model_user_pengajuan_tempo,,1,1,1,1 \ No newline at end of file diff --git a/indoteknik_custom/views/res_partner.xml b/indoteknik_custom/views/res_partner.xml index 278f6d44..cc6b2357 100644 --- a/indoteknik_custom/views/res_partner.xml +++ b/indoteknik_custom/views/res_partner.xml @@ -73,16 +73,17 @@ - - - + + + + - - - - - - + + + + + + @@ -91,56 +92,74 @@ - - + + + + + + - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/indoteknik_custom/views/user_pengajuan_tempo.xml b/indoteknik_custom/views/user_pengajuan_tempo.xml new file mode 100644 index 00000000..9874d79d --- /dev/null +++ b/indoteknik_custom/views/user_pengajuan_tempo.xml @@ -0,0 +1,129 @@ + + + + user.pengajuan.tempo.form + user.pengajuan.tempo + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+
+
+ + + + user.pengajuan.tempo.tree + user.pengajuan.tempo + + + + + + + + + + + + + Pengajuan Tempo + user.pengajuan.tempo + tree,form + + + + + +
diff --git a/indoteknik_custom/views/user_pengajuan_tempo_line.xml b/indoteknik_custom/views/user_pengajuan_tempo_line.xml new file mode 100644 index 00000000..60b510bc --- /dev/null +++ b/indoteknik_custom/views/user_pengajuan_tempo_line.xml @@ -0,0 +1,42 @@ + + + user_pengajuan.tempo.line.tree + user_pengajuan.tempo.line + + + + + + + + + + + + + pengajuan.tempo.line.form + pengajuan.tempo.line + +
+ + + + + + + +
+
+
+ + + + Pengajuan Tempo Lines + pengajuan.tempo.line + tree,form + + + + + +
diff --git a/indoteknik_custom/views/user_pengajuan_tempo_request.xml b/indoteknik_custom/views/user_pengajuan_tempo_request.xml new file mode 100644 index 00000000..19d00d44 --- /dev/null +++ b/indoteknik_custom/views/user_pengajuan_tempo_request.xml @@ -0,0 +1,67 @@ + + + + user.pengajuan.tempo.request.tree + user.pengajuan.tempo.request + + + + + + + + + + + + + + + + user.pengajuan.tempo.request.form + user.pengajuan.tempo.request + +
+ + + + + + + + + + + + + + +
+
+
+ + + User Pengajuan Tempo Request + ir.actions.act_window + user.pengajuan.tempo.request + tree,form + + + +
\ No newline at end of file -- cgit v1.2.3 From 414ced359c181c612b302376cb740c7f5c02075f Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 31 Oct 2024 16:06:40 +0700 Subject: update pengajuan tempo fix suplier ids --- indoteknik_api/controllers/api_v1/partner.py | 7 +- indoteknik_custom/models/res_partner.py | 174 +++++++++++++-------- indoteknik_custom/models/user_pengajuan_tempo.py | 2 +- .../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") -- cgit v1.2.3 From be2bc04768f9f423c66a612f4f183d20e70a3145 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 1 Nov 2024 13:50:41 +0700 Subject: update pengajuan tempo api --- indoteknik_api/controllers/api_v1/partner.py | 103 +++++++++++++++------------ 1 file changed, 59 insertions(+), 44 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/partner.py b/indoteknik_api/controllers/api_v1/partner.py index 2ddd4437..921afac9 100644 --- a/indoteknik_api/controllers/api_v1/partner.py +++ b/indoteknik_api/controllers/api_v1/partner.py @@ -242,60 +242,72 @@ class Partner(controller.Controller): @controller.Controller.must_authorized() def write_pengajuan_tempo(self, **kw): user_id = int(kw.get('user_id')) + id = int(kw.get('id')) + tempo_request = kw.get('tempo_request',False) + pengajuan_tempo = request.env['user.pengajuan.tempo'].search([('id', '=', id)], limit=1) user = request.env['res.users'].search([('id', '=', user_id)], limit=1) - company_name = kw.get('name') + company_name = kw.get('name', pengajuan_tempo.name_tempo.name) partner_id = request.env['res.partner'].search([('name', 'like', company_name)], limit=1) params = self.get_request_params(kw, { # informasi perusahaan # 'name': ['required', 'alias:name_tempo'], - 'industry_id': ['required', 'alias:industry_id_tempo'], - 'street': ['required', 'alias:street_tempo'], - 'state': ['required', 'alias:state_id_tempo'], - 'city': ['required', 'alias:city_id_tempo'], - 'zip': ['required', 'alias:zip_tempo'], - 'mobile': ['required', 'alias:mobile_tempo'], - 'bankName': ['required', 'alias:bank_name_tempo'], - 'accountName': ['required', 'alias:account_name_tempo'], - 'accountNumber': ['required', 'alias:account_number_tempo'], + 'industry_id': ['alias:industry_id_tempo'], + 'street': ['alias:street_tempo'], + 'state': ['alias:state_id_tempo'], + 'city': ['alias:city_id_tempo'], + 'zip': ['alias:zip_tempo'], + 'mobile': ['alias:mobile_tempo'], + 'bankName': ['alias:bank_name_tempo'], + 'accountName': ['alias:account_name_tempo'], + 'accountNumber': ['alias:account_number_tempo'], 'website': ['alias:website_tempo'], - 'estimasi': ['required', 'alias:estimasi_tempo'], - 'tempoDuration': ['required', 'alias:tempo_duration'], - 'tempoLimit': ['required', 'alias:tempo_limit'], + 'estimasi': ['alias:estimasi_tempo'], + 'tempoDuration': ['alias:tempo_duration'], + 'tempoLimit': ['alias:tempo_limit'], # informasi perusahaan - 'direkturName': ['required', 'alias:direktur_name'], - 'direkturMobile': ['required', 'alias:direktur_mobile'], - 'direkturEmail': ['required', 'alias:direktur_email'], - 'purchasingName': ['required', 'alias:purchasing_name'], - 'purchasingMobile': ['required', 'alias:purchasing_mobile'], - 'purchasingEmail': ['required', 'alias:purchasing_email'], - 'financeName': ['required', 'alias:finance_name'], - 'financeMobile': ['required', 'alias:finance_mobile'], - 'financeEmail': ['required', 'alias:finance_email'], + 'direkturName': ['alias:direktur_name'], + 'direkturMobile': ['alias:direktur_mobile'], + 'direkturEmail': ['alias:direktur_email'], + 'purchasingName': ['alias:purchasing_name'], + 'purchasingMobile': ['alias:purchasing_mobile'], + 'purchasingEmail': ['alias:purchasing_email'], + 'financeName': ['alias:finance_name'], + 'financeMobile': ['alias:finance_mobile'], + 'financeEmail': ['alias:finance_email'], # Pengiriman - 'PICName': ['required', 'alias:pic_name'], - 'streetPengiriman': ['required', 'alias:street_pengiriman'], - 'statePengiriman': ['required', 'alias:state_id_pengiriman'], - 'cityPengiriman': ['required', 'alias:city_id_pengiriman'], - 'zipPengiriman': ['required', 'alias:zip_pengiriman'], - 'invoicePic': ['required', 'alias:invoice_pic'], - 'streetInvoice': ['required', 'alias:street_invoice'], - 'stateInvoice': ['required', 'alias:state_id_invoice'], - 'cityInvoice': ['required', 'alias:city_id_invoice'], + 'PICName': ['alias:pic_name'], + 'streetPengiriman': ['alias:street_pengiriman'], + 'statePengiriman': ['alias:state_id_pengiriman'], + 'cityPengiriman': ['alias:city_id_pengiriman'], + 'zipPengiriman': ['alias:zip_pengiriman'], + 'invoicePic': ['alias:invoice_pic'], + 'streetInvoice': ['alias:street_invoice'], + 'stateInvoice': ['alias:state_id_invoice'], + 'cityInvoice': ['alias:city_id_invoice'], }) if not params['valid']: return self.response(code=400, description=params) - pengajuan_tempo = request.env['user.pengajuan.tempo'].create([params['value']]) + # Filter data baru yang dikirim (non-kosong) + new_data = {key: value for key, value in params['value'].items() if value} + + if pengajuan_tempo: + # Jika pengajuan_tempo sudah ada, hanya write data baru yang non-kosong + pengajuan_tempo.write(new_data) + else: + # Jika belum ada, buat record baru + pengajuan_tempo = request.env['user.pengajuan.tempo'].create(new_data) + pengajuan_tempo.partner_id = user_id if partner_id: pengajuan_tempo.name_tempo = partner_id - form_supplier_data = kw.get('formSupplier') + form_supplier_data = kw.get('formSupplier', False) if form_supplier_data: try: @@ -324,10 +336,12 @@ class Partner(controller.Controller): except json.JSONDecodeError: return http.Response(status=400, json_body={'error': 'Invalid JSON format for formSupplier'}) - category_produk_ids = kw.get('categoryProduk') - category_ids = list(map(int, category_produk_ids.split(','))) + category_produk_ids = kw.get('categoryProduk', False) + category_ids = '' + if category_produk_ids: + category_ids = list(map(int, category_produk_ids.split(','))) + pengajuan_tempo.category_produk_ids = [(6, 0, category_ids)] - pengajuan_tempo.category_produk_ids = [(6, 0, category_ids)] every_weekday = True if kw.get('everyWeekday') == "true" else False every_weekday_input = kw.get('everyWeekdayInput') every_week = True if kw.get('everyWeek') == 'true' else False @@ -402,7 +416,7 @@ class Partner(controller.Controller): pengajuan_tempo.dokumen_invoice = ', '.join(dokumen_invoice) - form_dokumen_data = kw.get('formDocs') + form_dokumen_data = kw.get('formDocs', False) if form_dokumen_data: try: form_dokumen = json.loads(form_dokumen_data) @@ -454,12 +468,13 @@ class Partner(controller.Controller): except json.JSONDecodeError: return http.Response(status=400, json_body={'error': 'Invalid JSON format for formDokumen'}) - - tempo_request = request.env['user.pengajuan.tempo.request'].create({ - 'user_id': user.partner_id.id, - 'pengajuan_tempo_id': pengajuan_tempo.id, - 'user_input': partner_id.name - }) + if tempo_request: + tempo_request = request.env['user.pengajuan.tempo.request'].create({ + 'user_id': user.partner_id.id, + 'pengajuan_tempo_id': pengajuan_tempo.id, + 'user_input': partner_id.name + }) return self.response({ - 'id': user_id, + 'id': pengajuan_tempo.id, + 'user_id': user_id, }) -- cgit v1.2.3 From 28227477f85b590b642f2d516d094f1f1c59f37f Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 14 Nov 2024 10:01:38 +0700 Subject: add data --- indoteknik_api/controllers/api_v1/partner.py | 1 + 1 file changed, 1 insertion(+) diff --git a/indoteknik_api/controllers/api_v1/partner.py b/indoteknik_api/controllers/api_v1/partner.py index 921afac9..e5f8d71c 100644 --- a/indoteknik_api/controllers/api_v1/partner.py +++ b/indoteknik_api/controllers/api_v1/partner.py @@ -232,6 +232,7 @@ class Partner(controller.Controller): data = { 'name': partner.name, + 'payment_term': partner.property_payment_term_id.name, 'amount_due': result_tempo, 'remaining_limit': remaining_limit } -- cgit v1.2.3 From dbbca494e13edce7ec6947b7bca6559b93c289f4 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 15 Nov 2024 14:20:46 +0700 Subject: pengajuan tempo api change --- indoteknik_api/models/account_move.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/indoteknik_api/models/account_move.py b/indoteknik_api/models/account_move.py index 23a7076c..0855da2f 100644 --- a/indoteknik_api/models/account_move.py +++ b/indoteknik_api/models/account_move.py @@ -21,6 +21,8 @@ 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, } if isinstance(object, datetime.date): data['invoice_date'] = account_move.invoice_date.strftime('%d/%m/%Y') @@ -35,7 +37,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': [], } -- cgit v1.2.3 From 528a737f696b371faa4ede6e5044c84ad3e4785e Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Sat, 16 Nov 2024 09:15:42 +0700 Subject: ppn 12% --- indoteknik_custom/models/logbook_bill.py | 2 +- indoteknik_custom/models/purchase_pricelist.py | 4 ++-- indoteknik_custom/models/sale_order.py | 10 +++++----- indoteknik_custom/models/sale_order_line.py | 6 +++--- indoteknik_custom/models/stock_move.py | 2 +- indoteknik_custom/models/website_user_cart.py | 6 +++--- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/indoteknik_custom/models/logbook_bill.py b/indoteknik_custom/models/logbook_bill.py index bb956092..3c33aeb7 100644 --- a/indoteknik_custom/models/logbook_bill.py +++ b/indoteknik_custom/models/logbook_bill.py @@ -22,7 +22,7 @@ class LogbookBill(models.TransientModel): ('product_id', '=', line.product_id.id), ], order='id desc', limit=1) total += line.quantity_done * po.price_unit - total_with_tax = total * 1.11 + total_with_tax = total * 1.12 return total_with_tax diff --git a/indoteknik_custom/models/purchase_pricelist.py b/indoteknik_custom/models/purchase_pricelist.py index e5b35d7f..c543070a 100755 --- a/indoteknik_custom/models/purchase_pricelist.py +++ b/indoteknik_custom/models/purchase_pricelist.py @@ -48,9 +48,9 @@ class PurchasePricelist(models.Model): def _constrains_include_price(self): price, taxes = self._get_valid_price() - # When have tax is excluded or empty tax, then multiply by 1.11 + # When have tax is excluded or empty tax, then multiply by 1.12 if (taxes and not taxes.price_include) or not taxes: - price *= 1.11 + price *= 1.12 self.include_price = price diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 80e111a8..756c69cf 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -1170,7 +1170,7 @@ class SaleOrder(models.Model): line_voucher = used_discount * line_contribution line_voucher_item = line_voucher / line.product_uom_qty - line_price_unit = line.price_unit / 1.11 if any(tax.id == 23 for tax in line.tax_id) else line.price_unit + line_price_unit = line.price_unit / 1.12 if any(tax.id == 23 for tax in line.tax_id) else line.price_unit line_discount_item = line_price_unit * line.discount / 100 + line_voucher_item line_voucher_item = line_discount_item / line_price_unit * 100 @@ -1283,13 +1283,13 @@ class SaleOrder(models.Model): if last_so and rec_purchase_price != last_so.purchase_price: rec_taxes = self.env['account.tax'].search([('id', '=', rec_taxes_id)], limit=1) if rec_taxes.price_include: - selling_price = (rec_purchase_price / 1.11) / (1 - (last_so.item_percent_margin_without_deduction / 100)) + selling_price = (rec_purchase_price / 1.12) / (1 - (last_so.item_percent_margin_without_deduction / 100)) else: selling_price = rec_purchase_price / (1 - (last_so.item_percent_margin_without_deduction / 100)) tax_id = last_so.tax_id for tax in tax_id: if tax.price_include: - selling_price = selling_price + (selling_price*11/100) + selling_price = selling_price + (selling_price*12/100) else: selling_price = selling_price discount = 0 @@ -1305,13 +1305,13 @@ class SaleOrder(models.Model): elif last_so and rec_vendor_id == order_line.vendor_id.id and rec_purchase_price != last_so.purchase_price: rec_taxes = self.env['account.tax'].search([('id', '=', rec_taxes_id)], limit=1) if rec_taxes.price_include: - selling_price = (rec_purchase_price / 1.11) / (1 - (last_so.item_percent_margin_without_deduction / 100)) + selling_price = (rec_purchase_price / 1.12) / (1 - (last_so.item_percent_margin_without_deduction / 100)) else: selling_price = rec_purchase_price / (1 - (last_so.item_percent_margin_without_deduction / 100)) tax_id = last_so.tax_id for tax in tax_id: if tax.price_include: - selling_price = selling_price + (selling_price*11/100) + selling_price = selling_price + (selling_price*12/100) else: selling_price = selling_price discount = 0 diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index 04fafa69..c5fd9222 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -96,7 +96,7 @@ class SaleOrderLine(models.Model): purchase_price = line.purchase_price if line.purchase_tax_id.price_include: - purchase_price = line.purchase_price / 1.11 + purchase_price = line.purchase_price / 1.12 purchase_price = purchase_price * line.product_uom_qty margin_per_item = sales_price - purchase_price @@ -124,7 +124,7 @@ class SaleOrderLine(models.Model): purchase_price = line.purchase_price if line.purchase_tax_id.price_include: - purchase_price = line.purchase_price / 1.11 + purchase_price = line.purchase_price / 1.12 purchase_price = purchase_price * line.product_uom_qty margin_per_item = sales_price - purchase_price @@ -175,7 +175,7 @@ class SaleOrderLine(models.Model): # # tax_id = last_so.tax_id # if rec_vendor_id == self.vendor_id and rec_purchase_price != last_so.purchase_price: # if rec_taxes.price_include: - # selling_price = (rec_purchase_price/1.11) / (1-(last_so.line_item_margin / 100)) + # selling_price = (rec_purchase_price/1.12) / (1-(last_so.line_item_margin / 100)) # else: # selling_price = rec_purchase_price / (1-(last_so.line_item_margin / 100)) # tax_id = last_so.tax_id diff --git a/indoteknik_custom/models/stock_move.py b/indoteknik_custom/models/stock_move.py index ac2e3cc0..0b7734fb 100644 --- a/indoteknik_custom/models/stock_move.py +++ b/indoteknik_custom/models/stock_move.py @@ -91,7 +91,7 @@ class StockMove(models.Model): # 440 is static id for "PPN Keluaran" on account.account model debit_account_id = self.picking_id.account_id.id if self.picking_id.account_id.id else 538 - tax = cost * (11 / 100) + tax = cost * (12 / 100) move_lines = self._prepare_account_move_line(qty, cost, credit_account_id, debit_account_id, description) move_lines += self._prepare_account_move_line(qty, tax, 440, debit_account_id, description) diff --git a/indoteknik_custom/models/website_user_cart.py b/indoteknik_custom/models/website_user_cart.py index 494f32f3..a0c3e393 100644 --- a/indoteknik_custom/models/website_user_cart.py +++ b/indoteknik_custom/models/website_user_cart.py @@ -163,7 +163,7 @@ class WebsiteUserCart(models.Model): voucher_shipping_info = voucher_shipping.apply(order_line) discount_voucher_shipping = voucher_shipping_info['discount']['all'] - tax = round(subtotal * 0.11) + tax = round(subtotal * 0.12) grand_total = subtotal + tax total_weight = sum(x['weight'] * x['quantity'] for x in products) total_weight = round(total_weight, 2) @@ -240,7 +240,7 @@ class WebsiteUserCart(models.Model): total_voucher += voucher_product if total_discount > 0: - ppn = total_discount * 0.11 + ppn = total_discount * 0.12 return { 'total_discount': self.format_currency(total_discount), 'total_voucher': self.format_currency(total_voucher), @@ -352,7 +352,7 @@ class WebsiteUserCart(models.Model): discounted_price = fixed_price - (fixed_price * discount / 100) - final_price = discounted_price / 1.11 + final_price = discounted_price / 1.12 return { 'price': final_price, -- cgit v1.2.3 From 755e36e6fed87f787c2a0d31f4318a6eae97e55c Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 18 Nov 2024 13:42:09 +0700 Subject: add pengajuan tempo sales order id --- indoteknik_api/models/account_move.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/indoteknik_api/models/account_move.py b/indoteknik_api/models/account_move.py index 0855da2f..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 @@ -23,6 +24,7 @@ class AccountMove(models.Model): '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') -- cgit v1.2.3 From 5667449f58ecdf5803a28944e503ae1611cc8416 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Sat, 23 Nov 2024 11:56:24 +0700 Subject: update tempo --- indoteknik_api/controllers/api_v1/partner.py | 33 ++++++++++-- indoteknik_api/models/__init__.py | 1 + indoteknik_api/models/res_partner.py | 68 ++++++++++++++++++++++++ indoteknik_custom/models/user_pengajuan_tempo.py | 2 +- 4 files changed, 100 insertions(+), 4 deletions(-) create mode 100644 indoteknik_api/models/res_partner.py diff --git a/indoteknik_api/controllers/api_v1/partner.py b/indoteknik_api/controllers/api_v1/partner.py index e5f8d71c..9325d9aa 100644 --- a/indoteknik_api/controllers/api_v1/partner.py +++ b/indoteknik_api/controllers/api_v1/partner.py @@ -211,6 +211,32 @@ class Partner(controller.Controller): }) return self.response(data) + + @http.route(prefix + 'partner/payment_term', auth='public', methods=['GET', 'OPTIONS']) + @controller.Controller.must_authorized() + def get_partner_payment_term(self): + partner_industry = request.env['account.payment.term'].search([]) + data = [] + for industry in partner_industry: + if 'tempo' in industry.name.lower(): + data.append({ + 'id': industry.id, + 'name': industry.name + }) + + return self.response(data) + + @http.route(prefix + 'partner/detail-tempo/', auth='public', methods=['GET', 'OPTIONS']) + @controller.Controller.must_authorized() + def get_partner_detail_tempo(self, **kw): + params = self.get_request_params(kw, { + 'id': ['required', 'number'] + }) + pengajuan_tempo = request.env['user.pengajuan.tempo'].search([('name_tempo', '=', params['value']['id'])], limit=1) + if not pengajuan_tempo: + return self.response(code=404, description='pengajuan tempo not found') + pengajuan_tempo = request.env['res.partner'].api_single_response(pengajuan_tempo) + return self.response(pengajuan_tempo) @http.route(prefix + 'check//tempo', auth='public', methods=['GET', 'OPTIONS']) @controller.Controller.must_authorized() @@ -244,8 +270,9 @@ class Partner(controller.Controller): def write_pengajuan_tempo(self, **kw): user_id = int(kw.get('user_id')) id = int(kw.get('id')) + section = kw.get('section') tempo_request = kw.get('tempo_request',False) - pengajuan_tempo = request.env['user.pengajuan.tempo'].search([('id', '=', id)], limit=1) + pengajuan_tempo = request.env['user.pengajuan.tempo'].search([('name_tempo', '=', user_id)], limit=1) user = request.env['res.users'].search([('id', '=', user_id)], limit=1) company_name = kw.get('name', pengajuan_tempo.name_tempo.name) partner_id = request.env['res.partner'].search([('name', 'like', company_name)], limit=1) @@ -254,7 +281,7 @@ class Partner(controller.Controller): # informasi perusahaan # 'name': ['required', 'alias:name_tempo'], - 'industry_id': ['alias:industry_id_tempo'], + 'industryId': ['alias:industry_id_tempo'], 'street': ['alias:street_tempo'], 'state': ['alias:state_id_tempo'], 'city': ['alias:city_id_tempo'], @@ -469,7 +496,7 @@ class Partner(controller.Controller): except json.JSONDecodeError: return http.Response(status=400, json_body={'error': 'Invalid JSON format for formDokumen'}) - if tempo_request: + if 'konfirmasi' in section.lower(): tempo_request = request.env['user.pengajuan.tempo.request'].create({ 'user_id': user.partner_id.id, 'pengajuan_tempo_id': pengajuan_tempo.id, 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/res_partner.py b/indoteknik_api/models/res_partner.py new file mode 100644 index 00000000..8ea8d301 --- /dev/null +++ b/indoteknik_api/models/res_partner.py @@ -0,0 +1,68 @@ +from odoo import models + + +class ResPartner(models.Model): + _inherit = 'res.partner' + + def api_single_response(self, res_partner, with_detail=''): + config = self.env['ir.config_parameter'] + + partner = res_partner.partner_id + data = { + 'name' : res_partner.name_tempo.name, + 'industry_id' : res_partner.industry_id_tempo.id, + 'street' : res_partner.street_tempo, + 'state' : res_partner.state_id_tempo.id, + 'city' : res_partner.city_id_tempo.id, + 'zip' : res_partner.zip_tempo, + 'mobile' : res_partner.mobile_tempo, + 'bank_name' : res_partner.bank_name_tempo, + 'account_name' : res_partner.account_name_tempo, + 'account_number' : res_partner.account_number_tempo, + 'website' : res_partner.website_tempo if res_partner.website_tempo else '', + 'estimasi' : res_partner.estimasi_tempo, + 'tempo_duration' : res_partner.tempo_duration.id, + 'tempo_limit' : res_partner.tempo_limit, + 'category_produk': ','.join([str(cat.id) for cat in res_partner.category_produk_ids]) if res_partner.category_produk_ids else '', + + # Kontak Perusahaan + 'direktur_name' : res_partner.direktur_name if res_partner.direktur_name else '', + 'direktur_mobile' : res_partner.direktur_mobile if res_partner.direktur_mobile else '', + 'direktur_email' : res_partner.direktur_email if res_partner.direktur_email else '', + 'purchasing_name' : res_partner.purchasing_name if res_partner.purchasing_name else '', + 'purchasing_mobile' : res_partner.purchasing_mobile if res_partner.purchasing_mobile else '', + 'purchasing_email' : res_partner.purchasing_email if res_partner.purchasing_email else '', + 'finance_name' : res_partner.finance_name if res_partner.finance_name else '', + 'finance_mobile' : res_partner.finance_mobile if res_partner.finance_mobile else '', + 'finance_email' : res_partner.finance_email if res_partner.finance_email else '', + + # Pengiriman + 'PIC_name' : res_partner.pic_name if res_partner.pic_name else '', + 'street_pengiriman' : res_partner.street_pengiriman if res_partner.street_pengiriman else '', + 'state_id_pengiriman' : res_partner.state_id_pengiriman.id if res_partner.state_id_pengiriman else '', + 'city_id_pengiriman' : res_partner.city_id_pengiriman.id if res_partner.city_id_pengiriman else '', + 'zip_pengiriman' : res_partner.zip_pengiriman if res_partner.zip_pengiriman else '', + 'invoice_pic' : res_partner.invoice_pic if res_partner.invoice_pic else '', + 'street_invoice' : res_partner.street_invoice if res_partner.street_invoice else '', + 'state_id_invoice' : res_partner.state_id_invoice.id if res_partner.state_id_invoice else '', + 'city_id_invoice' : res_partner.city_id_invoice.id if res_partner.city_id_invoice else '', + 'tukar_invoice' : res_partner.tukar_invoice if res_partner.tukar_invoice else '', + 'jadwal_bayar' : res_partner.jadwal_bayar if res_partner.jadwal_bayar else '', + 'dokumen_pengiriman' : res_partner.dokumen_pengiriman if res_partner.dokumen_pengiriman else '', + 'dokumen_invoice' : res_partner.dokumen_invoice if res_partner.dokumen_invoice else '', + + 'supplier_ids': res_partner.supplier_ids if res_partner.supplier_ids else '', + + # Dokumen + 'dokumen_nib': res_partner.dokumen_nib if res_partner.dokumen_nib else '', + 'dokumen_npwp': res_partner.dokumen_npwp if res_partner.dokumen_npwp else '', + 'dokumen_sppkp': res_partner.dokumen_sppkp if res_partner.dokumen_sppkp else '', + 'dokumen_akta_perubahan': res_partner.dokumen_akta_perubahan if res_partner.dokumen_akta_perubahan else '', + 'dokumen_ktp_dirut': res_partner.dokumen_ktp_dirut if res_partner.dokumen_ktp_dirut else '', + 'dokumen_akta_pendirian': res_partner.dokumen_akta_pendirian if res_partner.dokumen_akta_pendirian else '', + 'dokumen_laporan_keuangan': res_partner.dokumen_laporan_keuangan if res_partner.dokumen_laporan_keuangan else '', + 'dokumen_foto_kantor': res_partner.dokumen_foto_kantor if res_partner.dokumen_foto_kantor else '', + 'dokumen_tempat_bekerja': res_partner.dokumen_tempat_bekerja if res_partner.dokumen_tempat_bekerja else '', + } + + return data \ No newline at end of file diff --git a/indoteknik_custom/models/user_pengajuan_tempo.py b/indoteknik_custom/models/user_pengajuan_tempo.py index 47e99dbf..763f302e 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo.py +++ b/indoteknik_custom/models/user_pengajuan_tempo.py @@ -42,7 +42,7 @@ class UserPengajuanTempo(models.Model): 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_duration = fields.Many2one('account.payment.term', 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()) -- cgit v1.2.3 From c78bd0f71238b85752b9f97e8e687a197f544b53 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 25 Nov 2024 10:04:44 +0700 Subject: update pengajuan tempo --- indoteknik_api/controllers/api_v1/partner.py | 18 +++++++++--------- indoteknik_api/models/res_partner.py | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/partner.py b/indoteknik_api/controllers/api_v1/partner.py index 9325d9aa..5534eb9b 100644 --- a/indoteknik_api/controllers/api_v1/partner.py +++ b/indoteknik_api/controllers/api_v1/partner.py @@ -383,8 +383,8 @@ class Partner(controller.Controller): jadwal_tukar_invoice += f", setiap {every_week_input}" if tukar_invoice or tukar_invoice_input: jadwal_tukar_invoice += f", {tukar_invoice_input}" - - pengajuan_tempo.tukar_invoice = jadwal_tukar_invoice + if jadwal_tukar_invoice: + pengajuan_tempo.tukar_invoice = jadwal_tukar_invoice every_weekday_pembayaran = True if kw.get('everyWeekdayPembayaran') == 'true' else False every_weekday_input_pembayaran = kw.get('everyWeekdayInputPembayaran') @@ -399,8 +399,8 @@ class Partner(controller.Controller): jadwal_tukar_invoice_pembayaran += f", setiap {every_week_input_pembayaran}" if tukar_invoice_pembayaran or tukar_invoice_input_pembayaran: jadwal_tukar_invoice_pembayaran += f", {tukar_invoice_input_pembayaran}" - - pengajuan_tempo.jadwal_bayar = jadwal_tukar_invoice_pembayaran + if jadwal_tukar_invoice_pembayaran: + pengajuan_tempo.jadwal_bayar = jadwal_tukar_invoice_pembayaran dokumen_kirim = [ 'Surat Tanda Terima Barang (STTB)', @@ -420,8 +420,8 @@ class Partner(controller.Controller): if dokumen_kirim_barang_input: input_items = [item.strip() for item in dokumen_kirim_barang_input.split(',')] dokumen_kirim_barang.extend(item for item in input_items if item and item not in dokumen_kirim_barang) - - pengajuan_tempo.dokumen_pengiriman = ', '.join(dokumen_kirim_barang) + if dokumen_kirim_barang: + pengajuan_tempo.dokumen_pengiriman = ', '.join(dokumen_kirim_barang) dokumen = [ 'Invoice Pembelian', @@ -435,14 +435,14 @@ class Partner(controller.Controller): dokumen_invoice_input = kw.get('dokumenPengirimanInvoiceInput', '') dokumen_invoice = "" - if dokumen_kirim_barang_ids: + if dokumen_invoice_ids: dokumen_ids = list(map(int, dokumen_invoice_ids.split(','))) dokumen_invoice = [dokumen[i] for i in dokumen_ids if 0 <= i < len(dokumen)] if dokumen_invoice_input: input_items = [item.strip() for item in dokumen_invoice_input.split(',')] dokumen_invoice.extend(item for item in input_items if item and item not in dokumen_invoice) - - pengajuan_tempo.dokumen_invoice = ', '.join(dokumen_invoice) + if dokumen_invoice: + pengajuan_tempo.dokumen_invoice = ', '.join(dokumen_invoice) form_dokumen_data = kw.get('formDocs', False) if form_dokumen_data: diff --git a/indoteknik_api/models/res_partner.py b/indoteknik_api/models/res_partner.py index 8ea8d301..32d66d69 100644 --- a/indoteknik_api/models/res_partner.py +++ b/indoteknik_api/models/res_partner.py @@ -49,7 +49,7 @@ class ResPartner(models.Model): 'tukar_invoice' : res_partner.tukar_invoice if res_partner.tukar_invoice else '', 'jadwal_bayar' : res_partner.jadwal_bayar if res_partner.jadwal_bayar else '', 'dokumen_pengiriman' : res_partner.dokumen_pengiriman if res_partner.dokumen_pengiriman else '', - 'dokumen_invoice' : res_partner.dokumen_invoice if res_partner.dokumen_invoice else '', + 'dokumen_pengiriman_invoice' : res_partner.dokumen_invoice if res_partner.dokumen_invoice else '', 'supplier_ids': res_partner.supplier_ids if res_partner.supplier_ids else '', -- cgit v1.2.3 From ad01e57b8f321f1c9f2830a98fa91d25e2c848d7 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 25 Nov 2024 17:04:20 +0700 Subject: update api pengajuan tempo --- indoteknik_api/controllers/api_v1/partner.py | 3 +- indoteknik_api/models/res_partner.py | 65 ++++++++++++++++++++++------ 2 files changed, 53 insertions(+), 15 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/partner.py b/indoteknik_api/controllers/api_v1/partner.py index 5534eb9b..dccda601 100644 --- a/indoteknik_api/controllers/api_v1/partner.py +++ b/indoteknik_api/controllers/api_v1/partner.py @@ -270,7 +270,6 @@ class Partner(controller.Controller): def write_pengajuan_tempo(self, **kw): user_id = int(kw.get('user_id')) id = int(kw.get('id')) - section = kw.get('section') tempo_request = kw.get('tempo_request',False) pengajuan_tempo = request.env['user.pengajuan.tempo'].search([('name_tempo', '=', user_id)], limit=1) user = request.env['res.users'].search([('id', '=', user_id)], limit=1) @@ -496,7 +495,7 @@ class Partner(controller.Controller): except json.JSONDecodeError: return http.Response(status=400, json_body={'error': 'Invalid JSON format for formDokumen'}) - if 'konfirmasi' in section.lower(): + if tempo_request: tempo_request = request.env['user.pengajuan.tempo.request'].create({ 'user_id': user.partner_id.id, 'pengajuan_tempo_id': pengajuan_tempo.id, diff --git a/indoteknik_api/models/res_partner.py b/indoteknik_api/models/res_partner.py index 32d66d69..4099a094 100644 --- a/indoteknik_api/models/res_partner.py +++ b/indoteknik_api/models/res_partner.py @@ -1,5 +1,5 @@ from odoo import models - +import json class ResPartner(models.Model): _inherit = 'res.partner' @@ -8,6 +8,35 @@ class ResPartner(models.Model): config = self.env['ir.config_parameter'] partner = res_partner.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 res_partner.dokumen_pengiriman : + res_partner_dokumen_pengiriman = res_partner.dokumen_pengiriman + mapping_dokumen = {item[0]: item[1] for item in dokumen_kirim} + dokumen_pengiriman_list = [dokumen.strip() for dokumen in res_partner_dokumen_pengiriman.split(',')] + dokumen_pengiriman = [mapping_dokumen.get(dokumen, '4') for dokumen in dokumen_pengiriman_list] + + dokumen = [ + ['Invoice Pembelian','0'], + ['Surat Jalan','1'], + ['Berita Acara Serah Terima (BAST)','2'], + ['Faktur Pajak','3'], + ['Good Receipt (GR)','4'] + ] + dokumen_invoice = [] + if res_partner.dokumen_invoice: + res_partner_dokumen_invoice = res_partner.dokumen_invoice + mapping_dokumen = {item[0]: item[1] for item in dokumen} + dokumen_invoice_list = [dokumen.strip() for dokumen in res_partner_dokumen_invoice.split(',')] + dokumen_invoice = [mapping_dokumen.get(dokumen, '4') for dokumen in dokumen_invoice_list] + + data = { 'name' : res_partner.name_tempo.name, 'industry_id' : res_partner.industry_id_tempo.id, @@ -48,21 +77,31 @@ class ResPartner(models.Model): 'city_id_invoice' : res_partner.city_id_invoice.id if res_partner.city_id_invoice else '', 'tukar_invoice' : res_partner.tukar_invoice if res_partner.tukar_invoice else '', 'jadwal_bayar' : res_partner.jadwal_bayar if res_partner.jadwal_bayar else '', - 'dokumen_pengiriman' : res_partner.dokumen_pengiriman if res_partner.dokumen_pengiriman else '', - 'dokumen_pengiriman_invoice' : res_partner.dokumen_invoice if res_partner.dokumen_invoice else '', + 'dokumen_pengiriman' : ','.join(dokumen_pengiriman) if dokumen_pengiriman else '', + 'dokumen_pengiriman_invoice' : ','.join(dokumen_invoice) if dokumen_invoice else '', - 'supplier_ids': res_partner.supplier_ids if res_partner.supplier_ids else '', + '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 res_partner.supplier_ids + ] if res_partner.supplier_ids else '' # Dokumen - 'dokumen_nib': res_partner.dokumen_nib if res_partner.dokumen_nib else '', - 'dokumen_npwp': res_partner.dokumen_npwp if res_partner.dokumen_npwp else '', - 'dokumen_sppkp': res_partner.dokumen_sppkp if res_partner.dokumen_sppkp else '', - 'dokumen_akta_perubahan': res_partner.dokumen_akta_perubahan if res_partner.dokumen_akta_perubahan else '', - 'dokumen_ktp_dirut': res_partner.dokumen_ktp_dirut if res_partner.dokumen_ktp_dirut else '', - 'dokumen_akta_pendirian': res_partner.dokumen_akta_pendirian if res_partner.dokumen_akta_pendirian else '', - 'dokumen_laporan_keuangan': res_partner.dokumen_laporan_keuangan if res_partner.dokumen_laporan_keuangan else '', - 'dokumen_foto_kantor': res_partner.dokumen_foto_kantor if res_partner.dokumen_foto_kantor else '', - 'dokumen_tempat_bekerja': res_partner.dokumen_tempat_bekerja if res_partner.dokumen_tempat_bekerja else '', + # 'dokumen_nib': res_partner.dokumen_nib if res_partner.dokumen_nib else '', + # 'dokumen_npwp': res_partner.dokumen_npwp if res_partner.dokumen_npwp else '', + # 'dokumen_sppkp': res_partner.dokumen_sppkp if res_partner.dokumen_sppkp else '', + # 'dokumen_akta_perubahan': res_partner.dokumen_akta_perubahan if res_partner.dokumen_akta_perubahan else '', + # 'dokumen_ktp_dirut': res_partner.dokumen_ktp_dirut if res_partner.dokumen_ktp_dirut else '', + # 'dokumen_akta_pendirian': res_partner.dokumen_akta_pendirian if res_partner.dokumen_akta_pendirian else '', + # 'dokumen_laporan_keuangan': res_partner.dokumen_laporan_keuangan if res_partner.dokumen_laporan_keuangan else '', + # 'dokumen_foto_kantor': res_partner.dokumen_foto_kantor if res_partner.dokumen_foto_kantor else '', + # 'dokumen_tempat_bekerja': res_partner.dokumen_tempat_bekerja if res_partner.dokumen_tempat_bekerja else '', } return data \ No newline at end of file -- cgit v1.2.3 From c5d2edf1a1e905d270e5cd1e5b6ed0cb5fa0bba1 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 26 Nov 2024 08:59:14 +0700 Subject: uptade pengajuan tempo --- indoteknik_api/controllers/api_v1/partner.py | 2 ++ indoteknik_api/models/res_partner.py | 3 ++- indoteknik_custom/models/user_pengajuan_tempo.py | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/indoteknik_api/controllers/api_v1/partner.py b/indoteknik_api/controllers/api_v1/partner.py index dccda601..2ff17ffe 100644 --- a/indoteknik_api/controllers/api_v1/partner.py +++ b/indoteknik_api/controllers/api_v1/partner.py @@ -315,6 +315,8 @@ class Partner(controller.Controller): 'streetInvoice': ['alias:street_invoice'], 'stateInvoice': ['alias:state_id_invoice'], 'cityInvoice': ['alias:city_id_invoice'], + 'isSameAddrees':['alias:is_same_address'], + 'isSameAddreesStreet': ['alias:is_same_address_street'], }) if not params['valid']: diff --git a/indoteknik_api/models/res_partner.py b/indoteknik_api/models/res_partner.py index 4099a094..9b9f87d4 100644 --- a/indoteknik_api/models/res_partner.py +++ b/indoteknik_api/models/res_partner.py @@ -79,7 +79,8 @@ class ResPartner(models.Model): 'jadwal_bayar' : res_partner.jadwal_bayar if res_partner.jadwal_bayar else '', 'dokumen_pengiriman' : ','.join(dokumen_pengiriman) if dokumen_pengiriman else '', 'dokumen_pengiriman_invoice' : ','.join(dokumen_invoice) if dokumen_invoice else '', - + 'is_same_address': res_partner.is_same_address if res_partner.is_same_address else False, + 'res_partner.is_same_address': res_partner.is_same_address_street if res_partner.is_same_address_street else False, 'supplier_ids': [ { 'id': supplier.id, diff --git a/indoteknik_custom/models/user_pengajuan_tempo.py b/indoteknik_custom/models/user_pengajuan_tempo.py index 763f302e..d8a6d106 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo.py +++ b/indoteknik_custom/models/user_pengajuan_tempo.py @@ -75,6 +75,8 @@ class UserPengajuanTempo(models.Model): 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') + is_same_address = fields.Boolean(string="Same Address pengiriman invoicr dan alamat pengiriman barang") + is_same_address_street = fields.Boolean(string="Same Address pengiriman barang dan alamat bisnis") # Referensi supplier_ids = fields.Many2many('user.pengajuan.tempo.line', string="Suppliers") -- cgit v1.2.3 From bf3e780400a8f26ae6284e78372d05f999fac021 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 26 Nov 2024 16:09:02 +0700 Subject: CR company request --- indoteknik_custom/models/user_company_request.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/user_company_request.py b/indoteknik_custom/models/user_company_request.py index dd9a35c1..4aa2683a 100644 --- a/indoteknik_custom/models/user_company_request.py +++ b/indoteknik_custom/models/user_company_request.py @@ -64,6 +64,7 @@ class UserCompanyRequest(models.Model): user.parent_name = self.user_input is_approve = vals.get('is_approve') is_internal_input = vals.get('internal_input') + is_company_id = vals.get('user_company_id') if self.is_approve and is_approve: raise UserError('Tidak dapat mengubah approval yang sudah diisi') @@ -71,10 +72,21 @@ class UserCompanyRequest(models.Model): if self.user_company_id.nama_wajib_pajak == self.user_company_id.name: self.user_company_id.nama_wajib_pajak = is_internal_input self.user_company_id.name = is_internal_input + if is_company_id: + self.user_company_id.customer_type = is_company_id.customer_type + self.user_company_id.npwp = is_company_id.npwp + self.user_company_id.sppkp = is_company_id.sppkp + self.user_company_id.nama_wajib_pajak = is_company_id.nama_wajib_pajak + self.user_company_id.alamat_lengkap_text = is_company_id.alamat_lengkap_text + self.user_company_id.industry_id.id = is_company_id.industry_id.id + self.user_company_id.company_type_id.id = is_company_id.company_type_id.id + self.user_company_id.user_id = is_company_id.user_id + self.user_company_id.property_account_receivable_id = is_company_id.property_account_receivable_id + self.user_company_id.property_account_payable_id = is_company_id.property_account_payable_id if not self.is_approve and is_approve: if is_approve == 'approved': - self.user_id.parent_id = vals.get('user_company_id') if vals.get('user_company_id') else self.user_company_id.id + self.user_id.parent_id = is_company_id if is_company_id else self.user_company_id.id self.user_id.customer_type = self.user_company_id.customer_type self.user_id.npwp = self.user_company_id.npwp self.user_id.sppkp = self.user_company_id.sppkp -- cgit v1.2.3 From 07aef813e0b6dc413fdf08ac56b9d0ffed24fc68 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 28 Nov 2024 16:53:36 +0700 Subject: update code --- indoteknik_custom/models/user_company_request.py | 46 +++++++++++++----------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/indoteknik_custom/models/user_company_request.py b/indoteknik_custom/models/user_company_request.py index 4aa2683a..ea5ca09e 100644 --- a/indoteknik_custom/models/user_company_request.py +++ b/indoteknik_custom/models/user_company_request.py @@ -72,31 +72,35 @@ class UserCompanyRequest(models.Model): if self.user_company_id.nama_wajib_pajak == self.user_company_id.name: self.user_company_id.nama_wajib_pajak = is_internal_input self.user_company_id.name = is_internal_input + user_company_id = [] if is_company_id: - self.user_company_id.customer_type = is_company_id.customer_type - self.user_company_id.npwp = is_company_id.npwp - self.user_company_id.sppkp = is_company_id.sppkp - self.user_company_id.nama_wajib_pajak = is_company_id.nama_wajib_pajak - self.user_company_id.alamat_lengkap_text = is_company_id.alamat_lengkap_text - self.user_company_id.industry_id.id = is_company_id.industry_id.id - self.user_company_id.company_type_id.id = is_company_id.company_type_id.id - self.user_company_id.user_id = is_company_id.user_id - self.user_company_id.property_account_receivable_id = is_company_id.property_account_receivable_id - self.user_company_id.property_account_payable_id = is_company_id.property_account_payable_id + user_company_id = request.env['res.partner'].search([('id', '=', is_company_id)], limit=1) + # self.user_company_id.customer_type = self.similar_company_ids.customer_type + # self.user_company_id.npwp = self.similar_company_ids.npwp + # self.user_company_id.sppkp = self.similar_company_ids.sppkp + # self.user_company_id.nama_wajib_pajak = self.similar_company_ids.nama_wajib_pajak + # self.user_company_id.alamat_lengkap_text = self.similar_company_ids.alamat_lengkap_text + # self.user_company_id.industry_id = self.similar_company_ids.industry_id + # self.user_company_id.company_type_id = self.similar_company_ids.company_type_id + # self.user_company_id.user_id = self.similar_company_ids.user_id + # self.user_company_id.property_account_receivable_id = self.similar_company_ids.property_account_receivable_id + # self.user_company_id.property_account_payable_id = self.similar_company_ids.property_account_payable_id if not self.is_approve and is_approve: if is_approve == 'approved': - self.user_id.parent_id = is_company_id if is_company_id else self.user_company_id.id - self.user_id.customer_type = self.user_company_id.customer_type - self.user_id.npwp = self.user_company_id.npwp - self.user_id.sppkp = self.user_company_id.sppkp - self.user_id.nama_wajib_pajak = self.user_company_id.nama_wajib_pajak - self.user_id.alamat_lengkap_text = self.user_company_id.alamat_lengkap_text - self.user_id.industry_id = self.user_company_id.industry_id.id - self.user_id.company_type_id = self.user_company_id.company_type_id.id - self.user_id.user_id = self.user_company_id.user_id - self.user_id.property_account_receivable_id = self.user_company_id.property_account_receivable_id - self.user_id.property_account_payable_id = self.user_company_id.property_account_payable_id + self.user_id.parent_id = user_company_id.id if user_company_id.id else self.user_company_id.id + self.user_id.customer_type = user_company_id.customer_type + self.user_id.npwp = user_company_id.npwp + self.user_id.sppkp = user_company_id.sppkp + self.user_id.nama_wajib_pajak = user_company_id.nama_wajib_pajak + self.user_id.alamat_lengkap_text = user_company_id.alamat_lengkap_text + self.user_id.industry_id = user_company_id.industry_id.id + self.user_id.company_type_id = user_company_id.company_type_id.id + self.user_id.user_id = user_company_id.user_id + self.user_id.property_account_receivable_id = user_company_id.property_account_receivable_id + self.user_id.property_account_payable_id = user_company_id.property_account_payable_id + self.user_id.property_payment_term_id = user_company_id.property_payment_term_id + self.user_id.property_supplier_payment_term_id = user_company_id.property_supplier_payment_term_id self.user_company_id.active = True user.send_company_request_approve_mail() else: -- cgit v1.2.3 From e3724de1677288345db05b9934f5197d11c1a713 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 29 Nov 2024 11:27:56 +0700 Subject: pengajuan tempo --- .../models/user_pengajuan_tempo_request.py | 57 ---------------------- .../views/user_pengajuan_tempo_request.xml | 9 ---- 2 files changed, 66 deletions(-) diff --git a/indoteknik_custom/models/user_pengajuan_tempo_request.py b/indoteknik_custom/models/user_pengajuan_tempo_request.py index 6c04ab7c..438d48cc 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo_request.py +++ b/indoteknik_custom/models/user_pengajuan_tempo_request.py @@ -7,75 +7,18 @@ class UserPengajuanTempoRequest(models.Model): _rec_name = 'user_id' user_id = fields.Many2one('res.partner', string='User') - user_company_id = fields.Many2one('res.partner', string='Company') - user_input = fields.Char(string='User Input') is_approve = fields.Selection([ ('approved', 'Approve'), ('rejected', 'Reject'), ], string='Approval') - similar_company_ids = fields.Many2many('res.partner', compute="_compute_similar_companies", string="Similar Companies") pengajuan_tempo_id = fields.Many2one('user.pengajuan.tempo', string='Form Tempo') - - @api.depends('user_input') - def _compute_similar_companies(self): - for record in self: - if record.user_input: - record.similar_company_ids = [(6, 0, self.get_similar_companies(record.user_input))] - else: - record.similar_company_ids = [(6, 0, [])] - - # def get_similar_companies(self, user_input): - # query = """ - # SELECT id - # FROM res_partner - # WHERE levenshtein(name::text, %s) < 3 - # ORDER BY levenshtein(name::text, %s) ASC - # """ - # self.env.cr.execute(query, (user_input, user_input)) - # return [row[0] for row in self.env.cr.fetchall()] - - def get_similar_companies(self, user_input): - query = """ - SELECT id - FROM res_partner - WHERE (name ILIKE %s OR levenshtein(name::text, %s) < 3) - AND active = TRUE AND is_company = TRUE - ORDER BY levenshtein(name::text, %s) ASC - """ - # Menggunakan '%' untuk mencocokkan nama perusahaan sebagian - self.env.cr.execute(query, ('%' + user_input + '%', user_input, user_input)) - company_ids = [row[0] for row in self.env.cr.fetchall()] - return company_ids - - internal_input = fields.Char(string='Internal Input') - company_type = fields.Char(string='Company Type', compute='_compute_company_type') - - @api.depends('user_company_id.customer_type') - def _compute_company_type(self): - for record in self: - if record.user_company_id.customer_type == 'nonpkp': - record.company_type = 'Non PKP' - elif record.user_company_id.customer_type == 'pkp': - record.company_type = 'PKP' - else: - record.company_type = 'company type belum di set' - def write(self, vals): user = self.get_user_by_email(self.user_id.email) - user.parent_name = self.user_input is_approve = vals.get('is_approve') - is_internal_input = vals.get('internal_input') company_id = '' - if not self.user_company_id: - company_id = request.env['res.partner'].search([('id', '=', vals.get('user_company_id'))], limit=1) if self.is_approve and is_approve: raise UserError('Tidak dapat mengubah approval yang sudah diisi') - if is_internal_input: - if self.user_company_id.nama_wajib_pajak == self.user_company_id.name: - self.user_company_id.nama_wajib_pajak = is_internal_input - self.user_company_id.name = is_internal_input - if not self.is_approve and is_approve: if is_approve == 'approved': self.pengajuan_tempo_id.partner_id = self.user_id.id diff --git a/indoteknik_custom/views/user_pengajuan_tempo_request.xml b/indoteknik_custom/views/user_pengajuan_tempo_request.xml index 19d00d44..3b08799c 100644 --- a/indoteknik_custom/views/user_pengajuan_tempo_request.xml +++ b/indoteknik_custom/views/user_pengajuan_tempo_request.xml @@ -7,16 +7,12 @@ - - - - @@ -32,17 +28,12 @@ - - - - - -- cgit v1.2.3 From 07c14fedc459106189d040e7724e6d7f81051658 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 29 Nov 2024 13:00:05 +0700 Subject: update pengajuan tempo --- indoteknik_api/controllers/api_v1/partner.py | 1 - 1 file changed, 1 deletion(-) diff --git a/indoteknik_api/controllers/api_v1/partner.py b/indoteknik_api/controllers/api_v1/partner.py index 2ff17ffe..088f6f5b 100644 --- a/indoteknik_api/controllers/api_v1/partner.py +++ b/indoteknik_api/controllers/api_v1/partner.py @@ -501,7 +501,6 @@ class Partner(controller.Controller): tempo_request = request.env['user.pengajuan.tempo.request'].create({ 'user_id': user.partner_id.id, 'pengajuan_tempo_id': pengajuan_tempo.id, - 'user_input': partner_id.name }) return self.response({ 'id': pengajuan_tempo.id, -- cgit v1.2.3 From 6fbfe31167e6eb66d4995374dadb14774026e8c7 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 2 Dec 2024 09:31:13 +0700 Subject: pengajuan tempo update --- indoteknik_api/controllers/api_v1/partner.py | 34 ++- indoteknik_api/controllers/api_v1/user.py | 16 +- indoteknik_api/models/res_users.py | 15 +- indoteknik_custom/models/res_partner.py | 7 +- indoteknik_custom/models/res_users.py | 5 + indoteknik_custom/models/solr/apache_solr.py | 2 +- indoteknik_custom/models/user_pengajuan_tempo.py | 15 ++ .../models/user_pengajuan_tempo_request.py | 261 +++++++++++++-------- indoteknik_custom/views/res_users.xml | 2 + indoteknik_custom/views/user_pengajuan_tempo.xml | 205 ++++++++++++++++ .../views/user_pengajuan_tempo_request.xml | 30 ++- 11 files changed, 460 insertions(+), 132 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/partner.py b/indoteknik_api/controllers/api_v1/partner.py index 088f6f5b..19c73aec 100644 --- a/indoteknik_api/controllers/api_v1/partner.py +++ b/indoteknik_api/controllers/api_v1/partner.py @@ -265,16 +265,29 @@ class Partner(controller.Controller): return self.response(data) + @http.route(prefix + 'check//tempo_progress', auth='public', methods=['GET', 'OPTIONS']) + @controller.Controller.must_authorized() + def get_check_tempo_partner_progres(self, **kw): + partner_id = int(kw.get('partner_id')) + partner = request.env['res.partner'].search([('id', '=', partner_id)], limit=1) + pengajuan_tempo = request.env['user.pengajuan.tempo'].search([('name_tempo', '=', partner.id)], limit=1) + if not pengajuan_tempo: + return self.response(code=404, description='Partner not found') + + data = True if pengajuan_tempo.id else False + return self.response(data) + @http.route(prefix + 'partner/pengajuan_tempo', auth='public', methods=['POST'], csrf=False) @controller.Controller.must_authorized() def write_pengajuan_tempo(self, **kw): + id = int(kw.get('partner_id')) user_id = int(kw.get('user_id')) - id = int(kw.get('id')) - tempo_request = kw.get('tempo_request',False) + tempo_request = True if kw.get('tempo_request') == 'true' else False pengajuan_tempo = request.env['user.pengajuan.tempo'].search([('name_tempo', '=', user_id)], limit=1) - user = request.env['res.users'].search([('id', '=', user_id)], limit=1) + user = request.env['res.partner'].search([('id', '=', id)], limit=1) company_name = kw.get('name', pengajuan_tempo.name_tempo.name) partner_id = request.env['res.partner'].search([('name', 'like', company_name)], limit=1) + user_account = self.get_user_by_email(user.user_id.email) params = self.get_request_params(kw, { @@ -499,10 +512,23 @@ class Partner(controller.Controller): return http.Response(status=400, json_body={'error': 'Invalid JSON format for formDokumen'}) if tempo_request: tempo_request = request.env['user.pengajuan.tempo.request'].create({ - 'user_id': user.partner_id.id, + 'user_id': user.id, 'pengajuan_tempo_id': pengajuan_tempo.id, + 'user_company_id': partner_id.id, + 'tempo_duration': pengajuan_tempo.tempo_duration.id, + 'tempo_limit': pengajuan_tempo.tempo_limit, }) + pengajuan_tempo.user_id = user_account.id + template = pengajuan_tempo.env.ref('indoteknik_custom.mail_template_user_cart_reminder_to_checkout') + template.send_mail(pengajuan_tempo.id, force_send=True) + # user_account.send_activation_mail() return self.response({ 'id': pengajuan_tempo.id, 'user_id': user_id, }) + + def get_user_by_email(self, email): + return request.env['res.users'].search([ + ('login', '=', email), + ('active', 'in', [True, False]) + ]) \ No newline at end of file diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py index 3be874fa..f83937ea 100644 --- a/indoteknik_api/controllers/api_v1/user.py +++ b/indoteknik_api/controllers/api_v1/user.py @@ -179,7 +179,7 @@ class User(controller.Controller): if result: match_company_name = result[0] - match_company_id = result[2] + match_company_id = result[1] # Create a user company request request.env['user.company.request'].create({ @@ -403,6 +403,20 @@ class User(controller.Controller): 'user': self.response_with_token(user) }) + @http.route(prefix + 'user//after_request_tempo', auth='public', methods=['PUT', 'OPTIONS'], csrf=False) + @controller.Controller.must_authorized() + def update_user_tempo(self, **kw): + id = kw.get('id') + + user = request.env['res.users'].search([('id', '=', id)], limit=1) + if not user: + return self.response(code=404, description='User not found') + + + return self.response({ + 'user': self.response_with_token(user, payment_tempo='Review') + }) + @http.route(prefix + 'user//address', auth='public', methods=['GET', 'OPTIONS']) @controller.Controller.must_authorized() def get_user_address_by_id(self, **kw): diff --git a/indoteknik_api/models/res_users.py b/indoteknik_api/models/res_users.py index 52a044dc..40933957 100644 --- a/indoteknik_api/models/res_users.py +++ b/indoteknik_api/models/res_users.py @@ -1,10 +1,10 @@ from odoo import models - +from odoo.http import request class ResUsers(models.Model): _inherit = 'res.users' - def api_single_response(self, res_user, with_detail=''): + def api_single_response(self, res_user, with_detail='', payment_tempo= ''): config = self.env['ir.config_parameter'] partner = res_user.partner_id @@ -14,9 +14,13 @@ class ResUsers(models.Model): 'manager': 2, 'director': 3 } - partner_tempo = False + partner_tempo = '' + is_tempo_request = request.env['user.pengajuan.tempo.request'].search([('name_tempo', '=', partner.id)], limit=1) + tempo_progres = 'review' if is_tempo_request else '' if main_partner: - partner_tempo = main_partner.get_check_tempo_partner() + partner_tempo = main_partner.get_check_payment_term() + if payment_tempo: + tempo_progres = payment_tempo data = { 'id': res_user.id, @@ -36,7 +40,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 diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index f01ea481..b21b1965 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -406,13 +406,10 @@ class ResPartner(models.Model): if self.customer_type == 'nonpkp': self.npwp = '00.000.000.0-000.000' - def get_check_tempo_partner(self): + def get_check_payment_term(self): self.ensure_one() partner = self.parent_id or self - if not partner.property_payment_term_id or 'Tempo' not in partner.property_payment_term_id.name: - return False - else: - return True + return partner.property_payment_term_id.name if partner.property_payment_term_id.id else 'Cash Before Delivery (C.B.D)' diff --git a/indoteknik_custom/models/res_users.py b/indoteknik_custom/models/res_users.py index 5e16aad1..fb9e8bfb 100755 --- a/indoteknik_custom/models/res_users.py +++ b/indoteknik_custom/models/res_users.py @@ -46,6 +46,11 @@ class ResUsers(models.Model): for user in self: template.send_mail(user.id, force_send=True) + def send_company_request_tempo_review(self): + template = self.env.ref('indoteknik_custom.mail_template_res_user_company_tempo_review') + for user in self: + template.send_mail(user.id, force_send=True) + def get_activation_token_url(self): base_url = self.env['ir.config_parameter'].get_param('site.base.url') return f'{base_url}/register?activation=token&token={self.activation_token}' diff --git a/indoteknik_custom/models/solr/apache_solr.py b/indoteknik_custom/models/solr/apache_solr.py index 6560c9b5..d111c1c1 100644 --- a/indoteknik_custom/models/solr/apache_solr.py +++ b/indoteknik_custom/models/solr/apache_solr.py @@ -22,7 +22,7 @@ class ApacheSolr(models.Model): url = '' if env == 'development': - url = 'http://192.168.23.5:8983/solr/' + url = 'http://localhost:8983/solr/' elif env == 'production': url = 'http://34.101.189.218:8983/solr/' diff --git a/indoteknik_custom/models/user_pengajuan_tempo.py b/indoteknik_custom/models/user_pengajuan_tempo.py index d8a6d106..006bbb55 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo.py +++ b/indoteknik_custom/models/user_pengajuan_tempo.py @@ -18,6 +18,9 @@ class UserPengajuanTempo(models.Model): _name = 'user.pengajuan.tempo' _inherit = ['mail.thread', 'mail.activity.mixin'] partner_id = fields.Char() + _description = 'User Pengajuan Tempo' + + name = fields.Char(string='Name', required=True) # informasi perusahaan # name_tempo = fields.Many2one( @@ -31,6 +34,7 @@ class UserPengajuanTempo(models.Model): 'res.partner', string='Nama Perusahaan', tracking=True, # Menambahkan tracking=True ) + user_id = fields.Many2one('res.users', string='User') 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') @@ -97,6 +101,17 @@ class UserPengajuanTempo(models.Model): string=" Foto Kantor (Tampak Depan)", tracking=3) dokumen_tempat_bekerja = fields.Many2many('ir.attachment', 'pengajuan_dokumen_tempat_bekerja_rel', string="Tempat Bekerja", tracking=3) + + @api.depends('name', 'name_tempo') + def name_get(self): + result = [] + for record in self: + if record.name_tempo: + display_name = f"DETAIL FORM TEMPO - {record.name_tempo.name}" + else: + display_name = "DETAIL FORM TEMPO" + result.append((record.id, display_name)) + return result # # def _compute_attachment_url(self): # if self.id: diff --git a/indoteknik_custom/models/user_pengajuan_tempo_request.py b/indoteknik_custom/models/user_pengajuan_tempo_request.py index 438d48cc..b7526238 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo_request.py +++ b/indoteknik_custom/models/user_pengajuan_tempo_request.py @@ -4,118 +4,171 @@ from odoo.http import request class UserPengajuanTempoRequest(models.Model): _name = 'user.pengajuan.tempo.request' + _inherit = ['mail.thread', 'mail.activity.mixin'] _rec_name = 'user_id' user_id = fields.Many2one('res.partner', string='User') - is_approve = fields.Selection([ - ('approved', 'Approve'), - ('rejected', 'Reject'), - ], string='Approval') + user_company_id = fields.Many2one('res.partner', string='Company') pengajuan_tempo_id = fields.Many2one('user.pengajuan.tempo', string='Form Tempo') + tempo_duration = fields.Many2one('account.payment.term', string='Durasi Tempo') + tempo_limit = fields.Char(string='Limit Tempo') + state_tempo = fields.Selection([ + ('draft', 'Pengajuan Tempo'), + ('approval_sales', 'Approved by Sales Manager'), + ('approval_finance', 'Approved by Finance'), + ('approval_director', 'Approved by Director'), + ], string='Status', readonly=True, copy=False, index=True, track_visibility='onchange', default='draft') + + @api.onchange('tempo_duration') + def _tempo_duration_change(self): + for tempo in self: + if tempo.env.user.id not in (7, 377): + raise UserError("Durasi tempo hanya bisa di ubah oleh Sales Manager atau Direktur") + + @api.onchange('tempo_limit') + def _tempo_limit_change(self): + for tempo in self: + if tempo.env.user.id not in (7, 377): + raise UserError("Limit tempo hanya bisa di ubah oleh Sales Manager atau Direktur") + + def button_approve(self): + for tempo in self: + if tempo.state_tempo == 'draft': + if tempo.env.user.id in (688, 28, 7): + raise UserError("Pengajuan tempo harus di approve oleh sales manager terlebih dahulu") + else: + # if tempo.env.user.id != 377: + if tempo.env.user.id != 25: + raise UserError("Pengajuan tempo hanya bisa di approve oleh sales manager") + else: + tempo.state_tempo = 'approval_sales' + + elif tempo.state_tempo == 'approval_sales': + if tempo.env.user.id == 7: + raise UserError("Pengajuan tempo harus di approve oleh Finence terlebih dahulu") + else: + # if tempo.env.user.id not in (688, 28): + if tempo.env.user.id not in (101): + raise UserError("Pengajuan tempo hanya bisa di approve oleh Finence") + else: + tempo.state_tempo = 'approval_finance' + + elif tempo.state_tempo == 'approval_finance': + # if tempo.env.user.id != 7: + if tempo.env.user.id != 12182: + raise UserError("Pengajuan tempo hanya bisa di approve oleh Direktur") + else: + tempo.state_tempo = 'approval_director' + + + + res = super(UserPengajuanTempoRequest, self).button_approve() + return res + def write(self, vals): user = self.get_user_by_email(self.user_id.email) - is_approve = vals.get('is_approve') - company_id = '' - if self.is_approve and is_approve: - raise UserError('Tidak dapat mengubah approval yang sudah diisi') - - if not self.is_approve and is_approve: - if is_approve == 'approved': - self.pengajuan_tempo_id.partner_id = self.user_id.id - # informasi perusahaan - company_id.name_tempo = self.pengajuan_tempo_id.name_tempo - company_id.industry_id_tempo = self.pengajuan_tempo_id.industry_id_tempo - company_id.street_tempo = self.pengajuan_tempo_id.street_tempo - company_id.state_id_tempo = self.pengajuan_tempo_id.state_id_tempo - company_id.city_id_tempo = self.pengajuan_tempo_id.city_id_tempo - company_id.zip_tempo = self.pengajuan_tempo_id.zip_tempo - company_id.mobile_tempo = self.pengajuan_tempo_id.mobile_tempo - company_id.bank_name_tempo = self.pengajuan_tempo_id.bank_name_tempo - company_id.account_name_tempo = self.pengajuan_tempo_id.account_name_tempo - company_id.account_number_tempo = self.pengajuan_tempo_id.account_number_tempo - company_id.website_tempo = self.pengajuan_tempo_id.website_tempo - company_id.estimasi_tempo = self.pengajuan_tempo_id.estimasi_tempo - company_id.tempo_duration = self.pengajuan_tempo_id.tempo_duration - company_id.tempo_limit = self.pengajuan_tempo_id.tempo_limit - company_id.category_produk_ids = self.pengajuan_tempo_id.category_produk_ids - - # Kontak Perusahaan - company_id.direktur_name = self.pengajuan_tempo_id.direktur_name - company_id.direktur_mobile = self.pengajuan_tempo_id.direktur_mobile - company_id.direktur_email = self.pengajuan_tempo_id.direktur_email - company_id.purchasing_name = self.pengajuan_tempo_id.purchasing_name - company_id.purchasing_mobile = self.pengajuan_tempo_id.purchasing_mobile - company_id.purchasing_email = self.pengajuan_tempo_id.purchasing_email - company_id.finance_name = self.pengajuan_tempo_id.finance_name - company_id.finance_mobile = self.pengajuan_tempo_id.finance_mobile - company_id.finance_email = self.pengajuan_tempo_id.finance_email - - # Pengiriman - company_id.pic_name = self.pengajuan_tempo_id.pic_name - company_id.street_pengiriman = self.pengajuan_tempo_id.street_pengiriman - company_id.state_id_pengiriman = self.pengajuan_tempo_id.state_id_pengiriman - company_id.city_id_pengiriman = self.pengajuan_tempo_id.city_id_pengiriman - company_id.zip_pengiriman = self.pengajuan_tempo_id.zip_pengiriman - company_id.invoice_pic = self.pengajuan_tempo_id.invoice_pic - company_id.street_invoice = self.pengajuan_tempo_id.street_invoice - company_id.state_id_invoice = self.pengajuan_tempo_id.state_id_invoice - company_id.city_id_invoice = self.pengajuan_tempo_id.city_id_invoice - company_id.tukar_invoice = self.pengajuan_tempo_id.tukar_invoice - company_id.jadwal_bayar = self.pengajuan_tempo_id.jadwal_bayar - company_id.dokumen_pengiriman = self.pengajuan_tempo_id.dokumen_pengiriman - company_id.dokumen_invoice = self.pengajuan_tempo_id.dokumen_invoice - - # Referensi - company_id.supplier_ids = self.pengajuan_tempo_id.supplier_ids - - # Dokumen - company_id.dokumen_nib = self.pengajuan_tempo_id.dokumen_nib - if company_id.dokumen_nib: - company_id.message_post(body='Dokumen NIB', attachment_ids=[company_id.dokumen_nib.id]) - - company_id.dokumen_npwp = self.pengajuan_tempo_id.dokumen_npwp - if company_id.dokumen_npwp: - company_id.message_post(body='Dokumen NPWP', attachment_ids=[company_id.dokumen_npwp.id]) - - company_id.dokumen_sppkp = self.pengajuan_tempo_id.dokumen_sppkp - if company_id.dokumen_sppkp: - company_id.message_post(body='Dokumen SPPKP', attachment_ids=[company_id.dokumen_sppkp.id]) - - company_id.dokumen_akta_perubahan = self.pengajuan_tempo_id.dokumen_akta_perubahan - if company_id.dokumen_akta_perubahan: - company_id.message_post(body='Dokumen Akta Perubahan', - attachment_ids=[company_id.dokumen_akta_perubahan.id]) - - company_id.dokumen_ktp_dirut = self.pengajuan_tempo_id.dokumen_ktp_dirut - if company_id.dokumen_ktp_dirut: - company_id.message_post(body='Dokumen Ktp Dirut', - attachment_ids=[company_id.dokumen_ktp_dirut.id]) - - company_id.dokumen_akta_pendirian = self.pengajuan_tempo_id.dokumen_akta_pendirian - if company_id.dokumen_akta_pendirian: - company_id.message_post(body='Dokumen Akta Pendirian', - attachment_ids=[company_id.dokumen_akta_pendirian.id]) - - company_id.dokumen_laporan_keuangan = self.pengajuan_tempo_id.dokumen_laporan_keuangan - if company_id.dokumen_laporan_keuangan: - company_id.message_post(body='Dokumen Laporan Keuangan', - attachment_ids=[company_id.dokumen_laporan_keuangan.id]) - - company_id.dokumen_foto_kantor = self.pengajuan_tempo_id.dokumen_foto_kantor - if company_id.dokumen_foto_kantor: - company_id.message_post(body='Dokumen Foto Kantor', - attachment_ids=[company_id.dokumen_foto_kantor.id]) - - company_id.dokumen_tempat_bekerja = self.pengajuan_tempo_id.dokumen_tempat_bekerja - if company_id.dokumen_tempat_bekerja: - company_id.message_post(body='Dokumen Tempat Bekerja', - attachment_ids=[company_id.dokumen_tempat_bekerja.id]) + is_approve = True if self.state_tempo == 'approval_director' else False + # if self.is_approve and is_approve: + # raise UserError('Tidak dapat mengubah approval yang sudah diisi') + + if is_approve: + self.pengajuan_tempo_id.partner_id = self.user_id.id + # informasi perusahaan + self.user_company_id.name_tempo = self.pengajuan_tempo_id.name_tempo + self.user_company_id.industry_id_tempo = self.pengajuan_tempo_id.industry_id_tempo + self.user_company_id.street_tempo = self.pengajuan_tempo_id.street_tempo + self.user_company_id.state_id_tempo = self.pengajuan_tempo_id.state_id_tempo + self.user_company_id.city_id_tempo = self.pengajuan_tempo_id.city_id_tempo + self.user_company_id.zip_tempo = self.pengajuan_tempo_id.zip_tempo + self.user_company_id.mobile_tempo = self.pengajuan_tempo_id.mobile_tempo + self.user_company_id.bank_name_tempo = self.pengajuan_tempo_id.bank_name_tempo + self.user_company_id.account_name_tempo = self.pengajuan_tempo_id.account_name_tempo + self.user_company_id.account_number_tempo = self.pengajuan_tempo_id.account_number_tempo + self.user_company_id.website_tempo = self.pengajuan_tempo_id.website_tempo + self.user_company_id.estimasi_tempo = self.pengajuan_tempo_id.estimasi_tempo + self.user_company_id.tempo_duration = vals.get('tempo_duration') if vals.get('tempo_duration') else self.pengajuan_tempo_id.tempo_duration + self.user_company_id.tempo_limit = vals.get('tempo_limit') if vals.get('tempo_limit') else self.pengajuan_tempo_id.tempo_limit + self.user_company_id.category_produk_ids = self.pengajuan_tempo_id.category_produk_ids + + # Kontak Perusahaan + self.user_company_id.direktur_name = self.pengajuan_tempo_id.direktur_name + self.user_company_id.direktur_mobile = self.pengajuan_tempo_id.direktur_mobile + self.user_company_id.direktur_email = self.pengajuan_tempo_id.direktur_email + self.user_company_id.purchasing_name = self.pengajuan_tempo_id.purchasing_name + self.user_company_id.purchasing_mobile = self.pengajuan_tempo_id.purchasing_mobile + self.user_company_id.purchasing_email = self.pengajuan_tempo_id.purchasing_email + self.user_company_id.finance_name = self.pengajuan_tempo_id.finance_name + self.user_company_id.finance_mobile = self.pengajuan_tempo_id.finance_mobile + self.user_company_id.finance_email = self.pengajuan_tempo_id.finance_email + + # Pengiriman + self.user_company_id.pic_name = self.pengajuan_tempo_id.pic_name + self.user_company_id.street_pengiriman = self.pengajuan_tempo_id.street_pengiriman + self.user_company_id.state_id_pengiriman = self.pengajuan_tempo_id.state_id_pengiriman + self.user_company_id.city_id_pengiriman = self.pengajuan_tempo_id.city_id_pengiriman + self.user_company_id.zip_pengiriman = self.pengajuan_tempo_id.zip_pengiriman + self.user_company_id.invoice_pic = self.pengajuan_tempo_id.invoice_pic + self.user_company_id.street_invoice = self.pengajuan_tempo_id.street_invoice + self.user_company_id.state_id_invoice = self.pengajuan_tempo_id.state_id_invoice + self.user_company_id.city_id_invoice = self.pengajuan_tempo_id.city_id_invoice + self.user_company_id.tukar_invoice = self.pengajuan_tempo_id.tukar_invoice + self.user_company_id.jadwal_bayar = self.pengajuan_tempo_id.jadwal_bayar + self.user_company_id.dokumen_pengiriman = self.pengajuan_tempo_id.dokumen_pengiriman + self.user_company_id.dokumen_invoice = self.pengajuan_tempo_id.dokumen_invoice + + # Referensi + self.user_company_id.supplier_ids = self.pengajuan_tempo_id.supplier_ids + + # Dokumen + self.user_company_id.dokumen_nib = self.pengajuan_tempo_id.dokumen_nib + if self.user_company_id.dokumen_nib: + self.user_company_id.message_post(body='Dokumen NIB', attachment_ids=[self.user_company_id.dokumen_nib.id]) + + self.user_company_id.dokumen_npwp = self.pengajuan_tempo_id.dokumen_npwp + if self.user_company_id.dokumen_npwp: + self.user_company_id.message_post(body='Dokumen NPWP', attachment_ids=[self.user_company_id.dokumen_npwp.id]) + + self.user_company_id.dokumen_sppkp = self.pengajuan_tempo_id.dokumen_sppkp + if self.user_company_id.dokumen_sppkp: + self.user_company_id.message_post(body='Dokumen SPPKP', attachment_ids=[self.user_company_id.dokumen_sppkp.id]) + + self.user_company_id.dokumen_akta_perubahan = self.pengajuan_tempo_id.dokumen_akta_perubahan + if self.user_company_id.dokumen_akta_perubahan: + self.user_company_id.message_post(body='Dokumen Akta Perubahan', + attachment_ids=[self.user_company_id.dokumen_akta_perubahan.id]) + + self.user_company_id.dokumen_ktp_dirut = self.pengajuan_tempo_id.dokumen_ktp_dirut + if self.user_company_id.dokumen_ktp_dirut: + self.user_company_id.message_post(body='Dokumen Ktp Dirut', + attachment_ids=[self.user_company_id.dokumen_ktp_dirut.id]) + + self.user_company_id.dokumen_akta_pendirian = self.pengajuan_tempo_id.dokumen_akta_pendirian + if self.user_company_id.dokumen_akta_pendirian: + self.user_company_id.message_post(body='Dokumen Akta Pendirian', + attachment_ids=[self.user_company_id.dokumen_akta_pendirian.id]) + + self.user_company_id.dokumen_laporan_keuangan = self.pengajuan_tempo_id.dokumen_laporan_keuangan + if self.user_company_id.dokumen_laporan_keuangan: + self.user_company_id.message_post(body='Dokumen Laporan Keuangan', + attachment_ids=[self.user_company_id.dokumen_laporan_keuangan.id]) + + self.user_company_id.dokumen_foto_kantor = self.pengajuan_tempo_id.dokumen_foto_kantor + if self.user_company_id.dokumen_foto_kantor: + self.user_company_id.message_post(body='Dokumen Foto Kantor', + attachment_ids=[self.user_company_id.dokumen_foto_kantor.id]) + + self.user_company_id.dokumen_tempat_bekerja = self.pengajuan_tempo_id.dokumen_tempat_bekerja + if self.user_company_id.dokumen_tempat_bekerja: + self.user_company_id.message_post(body='Dokumen Tempat Bekerja', + attachment_ids=[self.user_company_id.dokumen_tempat_bekerja.id]) # self.user_company_id.active = True # user.send_company_request_approve_mail() - else: - new_company = self.env['res.partner'].create({ - 'name': self.user_input - }) + self.user_company_id.property_payment_term_id = self.pengajuan_tempo_id.tempo_duration.id + self.user_company_id.active_limit = True + self.user_company_id.warning_stage = self.pengajuan_tempo_id.tempo_limit - (int(self.pengajuan_tempo_id.tempo_limit)/2) + self.user_company_id.blocking_stage = self.pengajuan_tempo_id.tempo_limit + template = self.env.ref('indoteknik_custom.mail_template_user_cart_reminder_to_checkout') + template.send_mail(latest_cart.id, force_send=True) # self.user_id.parent_id = new_company.id # user.send_company_request_reject_mail() return super(UserPengajuanTempoRequest, self).write(vals) diff --git a/indoteknik_custom/views/res_users.xml b/indoteknik_custom/views/res_users.xml index 39b9d43e..d7a6b2dd 100644 --- a/indoteknik_custom/views/res_users.xml +++ b/indoteknik_custom/views/res_users.xml @@ -254,5 +254,7 @@ + + \ No newline at end of file diff --git a/indoteknik_custom/views/user_pengajuan_tempo.xml b/indoteknik_custom/views/user_pengajuan_tempo.xml index 9874d79d..5b8ed293 100644 --- a/indoteknik_custom/views/user_pengajuan_tempo.xml +++ b/indoteknik_custom/views/user_pengajuan_tempo.xml @@ -116,6 +116,211 @@ + + Users: Company Request Tempo Review + + Permohonan Tempo Anda Sedang Ditinjau + "Indoteknik.com" <noreply@indoteknik.com> + noreply@indoteknik.com + ${object.user_id.login | safe} + + + +
+ + + + + + + + + + + + +
+ + + + + + + + +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + +
Hai. ${object.name_tempo.name},
Terima kasih atas kepercayaan Anda memilih indoteknik.com. Kami telah menerima permohonan pemayaran tempo Anda.
Saat ini, tim kami sedang melakukan peninjauan terhadap permohonan Anda. Proses peninjauan ini membutuhkan waktu.
Kami akan informasikan kembali mengenai hasil peninjauan pembayaran tempo anda melalui email ini.
Hormat kami,
PT. INDOTEKNIK DOTCOM GEMILANG
+ Indoteknik +
+
+
+
+
+
+
+ + + Users: Company Tempo Reject + + Mohon Maaf Pengajuan Tempo anda kami Tolak + "Indoteknik.com" <noreply@indoteknik.com> + noreply@indoteknik.com + ${object.user_id.login | safe} + + + +
+ + + + + + + + + + + + +
+ + + + + + + + +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + +
Hai. ${object.name_tempo.name},
Kami sampaikan dengan sangat menyesal bahwa pengajuan permohonan tempo pembayaran Anda yang diajukan pada tanggal ${format_date(object.create_date, 'dd MMMM yyyy')} tidak dapat kami setujui.
Keputusan ini telah kami pertimbangkan secara matang berdasarkan beberapa faktor, termasuk [alasan penolakan, misal: riwayat pembayaran, profil kredit, atau kebijakan perusahaan].
Kami memahami bahwa hal ini mungkin mengecewakan. Namun, kami berharap Anda dapat memahami kebijakan perusahaan kami.
Terima kasih atas pengertiannya.
Hormat kami,
PT. INDOTEKNIK DOTCOM GEMILANG
+ Indoteknik +
+
+
+
+
+
+
+ + + Users: Company Tempo Approved + + Pengajuan Tempo kamu di Indoteknik.com Telah Disetujui! + "Indoteknik.com" <noreply@indoteknik.com> + noreply@indoteknik.com + ${object.user_id.login | safe} + + + +
+ + + + + + + + + + + + +
+ + + + + + + + +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + +
Hai. ${object.name_tempo.name},
Kabar baik! Kami dengan senang hati menginformasikan bahwa pengajuan tempo pembayaran kamui di Indoteknik.com telah disetujui dengan detail sebagai berikut.
Limit Pembayaran Tempo : Rp ${object.format_currency(object.tempo_limit)}
Durasi Pembayaran Tempo : ${object.tempo_duration.name}
Kamu dapat melakukan pembayaran sesuai dengan jangka waktu yang telah disepakati. Detail lengkap mengenai transaksi kamu, termasuk tanggal jatuh tempo & Pengajuan Kenaikan Limit Tempo, dapat kamu lihat di akun Profile Indoteknik.com.
Terima kasih atas kepercayaan kamu kepada Indoteknik.com.
Hormat kami,
PT. INDOTEKNIK DOTCOM GEMILANG
+ Indoteknik +
+
+
+
+
+
+
+ Pengajuan Tempo diff --git a/indoteknik_custom/views/user_pengajuan_tempo_request.xml b/indoteknik_custom/views/user_pengajuan_tempo_request.xml index 3b08799c..4a8243da 100644 --- a/indoteknik_custom/views/user_pengajuan_tempo_request.xml +++ b/indoteknik_custom/views/user_pengajuan_tempo_request.xml @@ -7,12 +7,6 @@ - @@ -23,17 +17,29 @@ user.pengajuan.tempo.request
+
+
- + + -- cgit v1.2.3 From cf6581d8a9ddfd5a7e3c1c2d7aa5aab8b96f4813 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 3 Dec 2024 13:22:55 +0700 Subject: pengajuan tempo --- indoteknik_api/controllers/api_v1/user.py | 2 +- indoteknik_api/models/res_users.py | 4 +- indoteknik_custom/models/user_pengajuan_tempo.py | 2 + .../models/user_pengajuan_tempo_request.py | 156 +++++++++--- indoteknik_custom/security/ir.model.access.csv | 4 +- indoteknik_custom/views/user_pengajuan_tempo.xml | 71 +++--- .../views/user_pengajuan_tempo_request.xml | 261 ++++++++++++++++++++- 7 files changed, 419 insertions(+), 81 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py index f83937ea..51dae0a2 100644 --- a/indoteknik_api/controllers/api_v1/user.py +++ b/indoteknik_api/controllers/api_v1/user.py @@ -179,7 +179,7 @@ class User(controller.Controller): if result: match_company_name = result[0] - match_company_id = result[1] + match_company_id = result[2] # Create a user company request request.env['user.company.request'].create({ diff --git a/indoteknik_api/models/res_users.py b/indoteknik_api/models/res_users.py index 40933957..15aaa5a7 100644 --- a/indoteknik_api/models/res_users.py +++ b/indoteknik_api/models/res_users.py @@ -15,8 +15,8 @@ class ResUsers(models.Model): 'director': 3 } partner_tempo = '' - is_tempo_request = request.env['user.pengajuan.tempo.request'].search([('name_tempo', '=', partner.id)], limit=1) - tempo_progres = 'review' if is_tempo_request else '' + 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 '' if main_partner: partner_tempo = main_partner.get_check_payment_term() if payment_tempo: diff --git a/indoteknik_custom/models/user_pengajuan_tempo.py b/indoteknik_custom/models/user_pengajuan_tempo.py index 006bbb55..b527fa4c 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo.py +++ b/indoteknik_custom/models/user_pengajuan_tempo.py @@ -112,6 +112,8 @@ class UserPengajuanTempo(models.Model): display_name = "DETAIL FORM TEMPO" result.append((record.id, display_name)) return result + + # # def _compute_attachment_url(self): # if self.id: diff --git a/indoteknik_custom/models/user_pengajuan_tempo_request.py b/indoteknik_custom/models/user_pengajuan_tempo_request.py index b7526238..2d4875fb 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo_request.py +++ b/indoteknik_custom/models/user_pengajuan_tempo_request.py @@ -1,7 +1,43 @@ -from odoo import models, fields, api +from odoo import models, fields, api, _ from odoo.exceptions import UserError from odoo.http import request +class RejectReasonWizard(models.TransientModel): + _name = 'reject.reason.wizard' + _description = 'Wizard for Reject Reason' + + request_id = fields.Many2one('user.pengajuan.tempo.request', string='Request') + reason_reject = fields.Text(string='Reason for Rejection', required=True) + + def confirm_reject(self): + tempo = self.request_id + if tempo: + tempo.write({'reason_reject': self.reason_reject}) + tempo.state_tempo = 'reject' + template = self.env.ref('indoteknik_custom.mail_template_res_user_company_tempo_reject') + template.send_mail(tempo.id, force_send=True) + return {'type': 'ir.actions.act_window_close'} +class ConfirmApprovalWizard(models.TransientModel): + _name = 'confirm.approval.wizard' + _description = 'Wizard Konfirmasi Approval' + + tempo_id = fields.Many2one('user.pengajuan.tempo.request', string='Tempo', required=True) + + def confirm_approval(self): + tempo = self.tempo_id + if tempo.state_tempo == 'draft': + tempo.state_tempo = 'approval_sales' + template = self.env.ref('indoteknik_custom.mail_template_res_user_company_tempo_approved_by_sales') + template.send_mail(tempo.id, force_send=True) + elif tempo.state_tempo == 'approval_sales': + tempo.state_tempo = 'approval_finance' + template = self.env.ref('indoteknik_custom.mail_template_res_user_company_tempo_to_aprove_director') + template.send_mail(tempo.id, force_send=True) + elif tempo.state_tempo == 'approval_finance': + tempo.state_tempo = 'approval_director' + + + class UserPengajuanTempoRequest(models.Model): _name = 'user.pengajuan.tempo.request' _inherit = ['mail.thread', 'mail.activity.mixin'] @@ -10,26 +46,28 @@ class UserPengajuanTempoRequest(models.Model): user_id = fields.Many2one('res.partner', string='User') user_company_id = fields.Many2one('res.partner', string='Company') pengajuan_tempo_id = fields.Many2one('user.pengajuan.tempo', string='Form Tempo') - tempo_duration = fields.Many2one('account.payment.term', string='Durasi Tempo') - tempo_limit = fields.Char(string='Limit Tempo') + tempo_duration = fields.Many2one('account.payment.term', string='Durasi Tempo', tracking=3, ) + tempo_limit = fields.Char(string='Limit Tempo', tracking=3) state_tempo = fields.Selection([ ('draft', 'Pengajuan Tempo'), ('approval_sales', 'Approved by Sales Manager'), ('approval_finance', 'Approved by Finance'), ('approval_director', 'Approved by Director'), + ('reject', 'Rejected'), ], string='Status', readonly=True, copy=False, index=True, track_visibility='onchange', default='draft') + reason_reject = fields.Char(string='Limit Tempo') @api.onchange('tempo_duration') - def _tempo_duration_change(self): + def _tempo_duration_change(self, vals): for tempo in self: if tempo.env.user.id not in (7, 377): raise UserError("Durasi tempo hanya bisa di ubah oleh Sales Manager atau Direktur") @api.onchange('tempo_limit') - def _tempo_limit_change(self): + def _onchange_tempo_limit(self): for tempo in self: - if tempo.env.user.id not in (7, 377): - raise UserError("Limit tempo hanya bisa di ubah oleh Sales Manager atau Direktur") + if tempo.env.user.id not in (7, 377, 12182): + raise UserError("Limit tempo hanya bisa diubah oleh Sales Manager atau Direktur") def button_approve(self): for tempo in self: @@ -38,39 +76,84 @@ class UserPengajuanTempoRequest(models.Model): raise UserError("Pengajuan tempo harus di approve oleh sales manager terlebih dahulu") else: # if tempo.env.user.id != 377: - if tempo.env.user.id != 25: + if tempo.env.user.id != 12182: raise UserError("Pengajuan tempo hanya bisa di approve oleh sales manager") else: - tempo.state_tempo = 'approval_sales' + return { + 'type': 'ir.actions.act_window', + 'name': 'Konfirmasi Approve', + 'res_model': 'confirm.approval.wizard', + 'view_mode': 'form', + 'target': 'new', + 'context': { + 'default_tempo_id': tempo.id, + }, + } elif tempo.state_tempo == 'approval_sales': if tempo.env.user.id == 7: raise UserError("Pengajuan tempo harus di approve oleh Finence terlebih dahulu") else: # if tempo.env.user.id not in (688, 28): - if tempo.env.user.id not in (101): + if tempo.env.user.id not in (101,288,28,12182): raise UserError("Pengajuan tempo hanya bisa di approve oleh Finence") else: - tempo.state_tempo = 'approval_finance' + return { + 'type': 'ir.actions.act_window', + 'name': 'Konfirmasi Approve', + 'res_model': 'confirm.approval.wizard', + 'view_mode': 'form', + 'target': 'new', + 'context': { + 'default_tempo_id': tempo.id, + }, + } elif tempo.state_tempo == 'approval_finance': # if tempo.env.user.id != 7: if tempo.env.user.id != 12182: raise UserError("Pengajuan tempo hanya bisa di approve oleh Direktur") else: - tempo.state_tempo = 'approval_director' - + return { + 'type': 'ir.actions.act_window', + 'name': 'Konfirmasi Approve', + 'res_model': 'confirm.approval.wizard', + 'view_mode': 'form', + 'target': 'new', + 'context': { + 'default_tempo_id': tempo.id, + }, + } - - res = super(UserPengajuanTempoRequest, self).button_approve() - return res + def button_reject(self): + return { + 'type': 'ir.actions.act_window', + 'name': _('Reject Reason'), + 'res_model': 'reject.reason.wizard', + 'view_mode': 'form', + 'target': 'new', + 'context': {'default_request_id': self.id}, + } def write(self, vals): - user = self.get_user_by_email(self.user_id.email) - is_approve = True if self.state_tempo == 'approval_director' else False + is_approve = True if self.state_tempo == 'approval_director' or vals.get('state_tempo') == 'approval_director' else False # if self.is_approve and is_approve: # raise UserError('Tidak dapat mengubah approval yang sudah diisi') + limit_tempo = '' + if vals.get('tempo_limit'): + limit_tempo = vals.get('tempo_limit') + elif self.tempo_limit: + limit_tempo = self.tempo_limit + else: + limit_tempo = self.pengajuan_tempo_id.tempo_limit + tempo_duration = '' + if vals.get('tempo_duration'): + tempo_duration = vals.get('tempo_duration') + elif self.tempo_duration: + tempo_duration = self.tempo_duration + else: + tempo_duration = self.pengajuan_tempo_id.tempo_duration if is_approve: self.pengajuan_tempo_id.partner_id = self.user_id.id # informasi perusahaan @@ -86,8 +169,8 @@ class UserPengajuanTempoRequest(models.Model): self.user_company_id.account_number_tempo = self.pengajuan_tempo_id.account_number_tempo self.user_company_id.website_tempo = self.pengajuan_tempo_id.website_tempo self.user_company_id.estimasi_tempo = self.pengajuan_tempo_id.estimasi_tempo - self.user_company_id.tempo_duration = vals.get('tempo_duration') if vals.get('tempo_duration') else self.pengajuan_tempo_id.tempo_duration - self.user_company_id.tempo_limit = vals.get('tempo_limit') if vals.get('tempo_limit') else self.pengajuan_tempo_id.tempo_limit + self.user_company_id.tempo_duration = tempo_duration + self.user_company_id.tempo_limit = limit_tempo self.user_company_id.category_produk_ids = self.pengajuan_tempo_id.category_produk_ids # Kontak Perusahaan @@ -120,44 +203,44 @@ class UserPengajuanTempoRequest(models.Model): self.user_company_id.supplier_ids = self.pengajuan_tempo_id.supplier_ids # Dokumen - self.user_company_id.dokumen_nib = self.pengajuan_tempo_id.dokumen_nib + self.user_company_id.dokumen_nib = self.pengajuan_tempo_id.dokumen_nib[0] if self.user_company_id.dokumen_nib: self.user_company_id.message_post(body='Dokumen NIB', attachment_ids=[self.user_company_id.dokumen_nib.id]) - self.user_company_id.dokumen_npwp = self.pengajuan_tempo_id.dokumen_npwp + self.user_company_id.dokumen_npwp = self.pengajuan_tempo_id.dokumen_npwp[0] if self.user_company_id.dokumen_npwp: self.user_company_id.message_post(body='Dokumen NPWP', attachment_ids=[self.user_company_id.dokumen_npwp.id]) - self.user_company_id.dokumen_sppkp = self.pengajuan_tempo_id.dokumen_sppkp + self.user_company_id.dokumen_sppkp = self.pengajuan_tempo_id.dokumen_sppkp[0] if self.user_company_id.dokumen_sppkp: self.user_company_id.message_post(body='Dokumen SPPKP', attachment_ids=[self.user_company_id.dokumen_sppkp.id]) - self.user_company_id.dokumen_akta_perubahan = self.pengajuan_tempo_id.dokumen_akta_perubahan + self.user_company_id.dokumen_akta_perubahan = self.pengajuan_tempo_id.dokumen_akta_perubahan[0] if self.pengajuan_tempo_id.dokumen_akta_perubahan else [] if self.user_company_id.dokumen_akta_perubahan: self.user_company_id.message_post(body='Dokumen Akta Perubahan', attachment_ids=[self.user_company_id.dokumen_akta_perubahan.id]) - self.user_company_id.dokumen_ktp_dirut = self.pengajuan_tempo_id.dokumen_ktp_dirut + self.user_company_id.dokumen_ktp_dirut = self.pengajuan_tempo_id.dokumen_ktp_dirut[0] if self.pengajuan_tempo_id.dokumen_ktp_dirut else [] if self.user_company_id.dokumen_ktp_dirut: self.user_company_id.message_post(body='Dokumen Ktp Dirut', attachment_ids=[self.user_company_id.dokumen_ktp_dirut.id]) - self.user_company_id.dokumen_akta_pendirian = self.pengajuan_tempo_id.dokumen_akta_pendirian + self.user_company_id.dokumen_akta_pendirian = self.pengajuan_tempo_id.dokumen_akta_pendirian[0] if self.pengajuan_tempo_id.dokumen_akta_pendirian else [] if self.user_company_id.dokumen_akta_pendirian: self.user_company_id.message_post(body='Dokumen Akta Pendirian', attachment_ids=[self.user_company_id.dokumen_akta_pendirian.id]) - self.user_company_id.dokumen_laporan_keuangan = self.pengajuan_tempo_id.dokumen_laporan_keuangan + self.user_company_id.dokumen_laporan_keuangan = self.pengajuan_tempo_id.dokumen_laporan_keuangan[0] if self.pengajuan_tempo_id.dokumen_laporan_keuangan else [] if self.user_company_id.dokumen_laporan_keuangan: self.user_company_id.message_post(body='Dokumen Laporan Keuangan', attachment_ids=[self.user_company_id.dokumen_laporan_keuangan.id]) - self.user_company_id.dokumen_foto_kantor = self.pengajuan_tempo_id.dokumen_foto_kantor + self.user_company_id.dokumen_foto_kantor = self.pengajuan_tempo_id.dokumen_foto_kantor[0] if self.pengajuan_tempo_id.dokumen_foto_kantor else [] if self.user_company_id.dokumen_foto_kantor: self.user_company_id.message_post(body='Dokumen Foto Kantor', attachment_ids=[self.user_company_id.dokumen_foto_kantor.id]) - self.user_company_id.dokumen_tempat_bekerja = self.pengajuan_tempo_id.dokumen_tempat_bekerja + self.user_company_id.dokumen_tempat_bekerja = self.pengajuan_tempo_id.dokumen_tempat_bekerja[0] if self.pengajuan_tempo_id.dokumen_tempat_bekerja else [] if self.user_company_id.dokumen_tempat_bekerja: self.user_company_id.message_post(body='Dokumen Tempat Bekerja', attachment_ids=[self.user_company_id.dokumen_tempat_bekerja.id]) @@ -165,10 +248,13 @@ class UserPengajuanTempoRequest(models.Model): # user.send_company_request_approve_mail() self.user_company_id.property_payment_term_id = self.pengajuan_tempo_id.tempo_duration.id self.user_company_id.active_limit = True - self.user_company_id.warning_stage = self.pengajuan_tempo_id.tempo_limit - (int(self.pengajuan_tempo_id.tempo_limit)/2) + self.user_company_id.warning_stage = float(self.pengajuan_tempo_id.tempo_limit) - (float(self.pengajuan_tempo_id.tempo_limit)/2) self.user_company_id.blocking_stage = self.pengajuan_tempo_id.tempo_limit - template = self.env.ref('indoteknik_custom.mail_template_user_cart_reminder_to_checkout') - template.send_mail(latest_cart.id, force_send=True) + # template = self.env.ref('indoteknik_custom.mail_template_res_user_company_tempo_approved') + # tempo = self.pengajuan_tempo_id + # template.send_mail(tempo.id, force_send=True) + template = self.env.ref('indoteknik_custom.mail_template_res_user_company_tempo_approved') + template.send_mail(self.id, force_send=True) # self.user_id.parent_id = new_company.id # user.send_company_request_reject_mail() return super(UserPengajuanTempoRequest, self).write(vals) @@ -177,4 +263,8 @@ class UserPengajuanTempoRequest(models.Model): return request.env['res.users'].search([ ('login', '=', email), ('active', 'in', [True, False]) - ]) \ No newline at end of file + ]) + + def format_currency(self, number): + number = int(number) + return "{:,}".format(number).replace(',', '.') \ No newline at end of file diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index baf50c5c..e55bd2d9 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -150,4 +150,6 @@ access_va_multi_approve,access.va.multi.approve,model_va_multi_approve,,1,1,1,1 access_va_multi_reject,access.va.multi.reject,model_va_multi_reject,,1,1,1,1 access_User_pengajuan_tempo_line,access.user.pengajuan.tempo.line,model_user_pengajuan_tempo_line,,1,1,1,1 -access_user_pengajuan_tempo,access.user.pengajuan.tempo,model_user_pengajuan_tempo,,1,1,1,1 \ No newline at end of file +access_user_pengajuan_tempo,access.user.pengajuan.tempo,model_user_pengajuan_tempo,,1,1,1,1 +access_reject_reason_wizard,reject.reason.wizard,model_reject_reason_wizard,,1,1,1,0 +access_confirm_approval_wizard,confirm.approval.wizard,model_confirm_approval_wizard,,1,1,1,0 diff --git a/indoteknik_custom/views/user_pengajuan_tempo.xml b/indoteknik_custom/views/user_pengajuan_tempo.xml index 5b8ed293..30d75fe8 100644 --- a/indoteknik_custom/views/user_pengajuan_tempo.xml +++ b/indoteknik_custom/views/user_pengajuan_tempo.xml @@ -96,8 +96,8 @@
- -
+ +
@@ -121,7 +121,7 @@ Permohonan Tempo Anda Sedang Ditinjau "Indoteknik.com" <noreply@indoteknik.com> - noreply@indoteknik.com + sales@indoteknik.com ${object.user_id.login | safe} @@ -152,7 +152,7 @@
- + @@ -162,8 +162,8 @@ - @@ -183,13 +183,14 @@ - - Users: Company Tempo Reject + + Users: Company New Tempo To Sales - Mohon Maaf Pengajuan Tempo anda kami Tolak + Pengajuan Tempo Harus di Periksa! "Indoteknik.com" <noreply@indoteknik.com> - noreply@indoteknik.com - ${object.user_id.login | safe} + sales@indoteknik.com + + sapiabon768@gmail.com
Hai. ${object.name_tempo.name},
Terima kasih atas kepercayaan Anda memilih indoteknik.com. Kami telah menerima permohonan pemayaran tempo Anda.
Terima kasih atas kepercayaan Anda memilih indoteknik.com. Kami telah menerima permohonan pembayaran tempo Anda.
Saat ini, tim kami sedang melakukan peninjauan terhadap permohonan Anda. Proses peninjauan ini membutuhkan waktu.
Kami akan informasikan kembali mengenai hasil peninjauan pembayaran tempo anda melalui email ini.
Hormat kami,
PT. INDOTEKNIK DOTCOM GEMILANG
- Indoteknik + + Indoteknik
@@ -217,21 +218,20 @@
- + - - - - - + - + + + + - @@ -250,14 +250,14 @@
Hai. ${object.name_tempo.name},
Halo Manager Tim Sales, Novita Mayasari.
Kami sampaikan dengan sangat menyesal bahwa pengajuan permohonan tempo pembayaran Anda yang diajukan pada tanggal ${format_date(object.create_date, 'dd MMMM yyyy')} tidak dapat kami setujui.
Keputusan ini telah kami pertimbangkan secara matang berdasarkan beberapa faktor, termasuk [alasan penolakan, misal: riwayat pembayaran, profil kredit, atau kebijakan perusahaan].
Kami memahami bahwa hal ini mungkin mengecewakan. Namun, kami berharap Anda dapat memahami kebijakan perusahaan kami.
Kami sampaikan informasi bahwa saat ini terdapat pengajuan Pembayaran Tempo dari ${object.name_tempo.name} melalui website Indoteknik.com.
Terima kasih atas pengertiannya.
Mohon dapat segera melakukan pengecekan dan evaluasi terhadap data perusahaan yang telah dilampirkan tersebut agar proses pengajuan dapat diproses lebih lanjut.
Terima kasih atas perhatian dan kerjasamanya.
Hormat kami,
PT. INDOTEKNIK DOTCOM GEMILANG
- Indoteknik + + Indoteknik
- - - Users: Company Tempo Approved - - Pengajuan Tempo kamu di Indoteknik.com Telah Disetujui! + + Users: Company Tempo Approved By Sales + + Pengajuan Tempo Harus di Periksa! "Indoteknik.com" <noreply@indoteknik.com> - noreply@indoteknik.com - ${object.user_id.login | safe} + sales@indoteknik.com + + sapiabon768@gmail.com + + - + -- cgit v1.2.3 From 02eacd54387953f42a884a22544e2f7c94081536 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 9 Dec 2024 15:04:12 +0700 Subject: update pengajuan tempo --- indoteknik_api/controllers/api_v1/partner.py | 21 +- indoteknik_custom/models/res_partner.py | 5 +- indoteknik_custom/models/user_pengajuan_tempo.py | 53 ----- .../models/user_pengajuan_tempo_request.py | 244 ++++++++++++++++++++- .../views/user_pengajuan_tempo_request.xml | 162 +++++++++++--- 5 files changed, 383 insertions(+), 102 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/partner.py b/indoteknik_api/controllers/api_v1/partner.py index d8464add..fcf7e4db 100644 --- a/indoteknik_api/controllers/api_v1/partner.py +++ b/indoteknik_api/controllers/api_v1/partner.py @@ -428,6 +428,15 @@ class Partner(controller.Controller): dokumen_invoice = kw.get('dokumenPengirimanInvoice', '') if dokumen_invoice: pengajuan_tempo.dokumen_invoice = dokumen_invoice + user_tempo_request = [] + if tempo_request: + user_tempo_request = request.env['user.pengajuan.tempo.request'].create({ + 'user_id': user.id, + 'pengajuan_tempo_id': pengajuan_tempo.id, + 'user_company_id': partner_id.id, + 'tempo_duration': pengajuan_tempo.tempo_duration.id, + 'tempo_limit': pengajuan_tempo.tempo_limit, + }) form_dokumen_data = kw.get('formDocs', False) if form_dokumen_data: @@ -479,18 +488,14 @@ class Partner(controller.Controller): enumerate(dokumen['documentName'])]) teks = formatted_text.strip().title() pengajuan_tempo.message_post(body=teks, attachment_ids=[sppkp_attachment.id]) + if tempo_request: + user_tempo_request.message_post(body=teks, attachment_ids=[sppkp_attachment.id]) except json.JSONDecodeError: return http.Response(status=400, json_body={'error': 'Invalid JSON format for formDokumen'}) - if tempo_request: - tempo_request = request.env['user.pengajuan.tempo.request'].create({ - 'user_id': user.id, - 'pengajuan_tempo_id': pengajuan_tempo.id, - 'user_company_id': partner_id.id, - 'tempo_duration': pengajuan_tempo.tempo_duration.id, - 'tempo_limit': pengajuan_tempo.tempo_limit, - }) + + pengajuan_tempo.user_id = user_account.id template = pengajuan_tempo.env.ref('indoteknik_custom.mail_template_res_user_company_request_tempo_review') template.send_mail(pengajuan_tempo.id, force_send=True) diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index d2395dc5..835ac65d 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -36,7 +36,7 @@ class ResPartner(models.Model): 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_duration = fields.Many2one('account.payment.term', 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()) @@ -309,6 +309,9 @@ class ResPartner(models.Model): 'dokumen_laporan_keuangan': vals.get('dokumen_laporan_keuangan'), 'dokumen_foto_kantor': vals.get('dokumen_foto_kantor'), 'dokumen_tempat_bekerja': vals.get('dokumen_tempat_bekerja'), + + # internal_notes + 'comment': vals.get('comment') } # 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 046c4cc7..b347e75e 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo.py +++ b/indoteknik_custom/models/user_pengajuan_tempo.py @@ -118,56 +118,3 @@ class UserPengajuanTempo(models.Model): display_name = "DETAIL FORM TEMPO" result.append((record.id, display_name)) return result - - - # - # def _compute_attachment_url(self): - # if self.id: - # return { - # 'type': 'ir.actions.act_url', - # 'url': 'http://localhost:8069/web/content/' % (self.id), - # 'target': 'user', - # } - # base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url') - # for record in self: - # # Buat URL list untuk attachment yang ada di dokumen_nib - # record.attachment_urls = [(attachment.id, f"{base_url}/web/content/{attachment.id}") for attachment in - # record.dokumen_nib] - # - # @api.model - # def create(self, vals): - # # Tangani pembuatan baru - # record = super(userPengajuanTempo, self).create(vals) - # if vals.get('dokumen_nib'): - # attachment_names = ', '.join(self.env['ir.attachment'].browse(vals['dokumen_nib'][0][2]).mapped('name')) - # record.message_post(body=f"Files added to NIB: {attachment_names}") - # return record - # - # def write(self, vals): - # # Ambil attachment sebelumnya - # for record in self: - # previous_files = record.dokumen_nib - # res = super(userPengajuanTempo, record).write(vals) - # - # if 'dokumen_nib' in vals: - # new_files = record.dokumen_nib - # - # # Periksa perbedaan antara file lama dan file baru - # added_files = new_files - previous_files - # removed_files = previous_files - new_files - # - # # Buat pesan log berdasarkan perubahan - # messages = [] - # if added_files: - # added_names = ', '.join(added_files.mapped('name')) - # messages.append(f"Files added to NIB: {added_names}") - # if removed_files: - # removed_names = ', '.join(removed_files.mapped('name')) - # messages.append(f"Files removed from NIB: {removed_names}") - # - # # Post pesan ke log note jika ada perubahan - # if messages: - # record.message_post(body="
".join(messages)) - # - # return res - diff --git a/indoteknik_custom/models/user_pengajuan_tempo_request.py b/indoteknik_custom/models/user_pengajuan_tempo_request.py index 74eda31f..832c21af 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo_request.py +++ b/indoteknik_custom/models/user_pengajuan_tempo_request.py @@ -57,6 +57,225 @@ class UserPengajuanTempoRequest(models.Model): ], string='Status', readonly=True, copy=False, index=True, track_visibility='onchange', default='draft') reason_reject = fields.Char(string='Limit Tempo') + # informasi perusahaan + name_tempo = fields.Many2one('res.partner', string='Nama Perusahaan', related='pengajuan_tempo_id.name_tempo', store=True, tracking=True, readonly=False) + industry_id_tempo = fields.Many2one('res.partner.industry', 'Customer Industry', related='pengajuan_tempo_id.industry_id_tempo',store=True, tracking=True, readonly=False) + street_tempo = fields.Char(string="Alamat Perusahaan", related='pengajuan_tempo_id.street_tempo', store=True, tracking=True, readonly=False) + state_id_tempo = fields.Many2one('res.country.state', string='State', related='pengajuan_tempo_id.state_id_tempo', store=True, tracking=True, readonly=False) + city_id_tempo = fields.Many2one('vit.kota', string='City', related='pengajuan_tempo_id.city_id_tempo', store=True, tracking=True, readonly=False) + zip_tempo = fields.Char(string="Zip", related='pengajuan_tempo_id.zip_tempo', store=True, tracking=True, readonly=False) + mobile_tempo = fields.Char(string="No. Telfon Perusahaan", related='pengajuan_tempo_id.mobile_tempo', store=True, tracking=True, readonly=False) + bank_name_tempo = fields.Char(string="Nama Bank", related='pengajuan_tempo_id.bank_name_tempo', store=True, tracking=True, readonly=False) + account_name_tempo = fields.Char(string="Nama Rekening", related='pengajuan_tempo_id.account_name_tempo', store=True, tracking=True, readonly=False) + account_number_tempo = fields.Char(string="Nomor Rekening Bank", related='pengajuan_tempo_id.account_number_tempo', store=True, tracking=True, readonly=False) + website_tempo = fields.Char(string='Website', related='pengajuan_tempo_id.website_tempo', store=True, tracking=True, readonly=False) + estimasi_tempo = fields.Char(string='Estimasi Pembelian Pertahun', related='pengajuan_tempo_id.estimasi_tempo', store=True, tracking=True, readonly=False) + tempo_duration_origin = fields.Many2one('account.payment.term', string='Durasi Tempo', related='pengajuan_tempo_id.tempo_duration', store=True, tracking=True, readonly=False) + tempo_limit_origin = fields.Char(string='Limit Tempo', related='pengajuan_tempo_id.tempo_limit' , store=True, tracking=True, readonly=False) + category_produk_ids = fields.Many2many('product.public.category', string='Kategori Produk yang Digunakan', related='pengajuan_tempo_id.category_produk_ids', readonly=False) + + # Kontak Perusahaan + direktur_name = fields.Char(string='Nama Lengkap Direktur', related='pengajuan_tempo_id.direktur_name', store=True, readonly=False) + direktur_mobile = fields.Char(string='No. Telpon Direktur', related='pengajuan_tempo_id.direktur_mobile', store=True, readonly=False) + direktur_email = fields.Char(string='Email Direktur', related='pengajuan_tempo_id.direktur_email', store=True, readonly=False) + purchasing_name = fields.Char(string='Nama Purchasing', related='pengajuan_tempo_id.purchasing_name', store=True, readonly=False) + purchasing_mobile = fields.Char(string='No. Telpon Purchasing', related='pengajuan_tempo_id.purchasing_mobile', store=True, readonly=False) + purchasing_email = fields.Char(string='Email Purchasing', related='pengajuan_tempo_id.purchasing_email', store=True, readonly=False) + finance_name = fields.Char(string='Nama Finance', related='pengajuan_tempo_id.finance_name', store=True, readonly=False) + finance_mobile = fields.Char(string='No. Telpon Finance', related='pengajuan_tempo_id.finance_mobile', store=True, readonly=False) + finance_email = fields.Char(string='Email Finance', related='pengajuan_tempo_id.finance_email', store=True, readonly=False) + + # Pengiriman + pic_tittle = fields.Char(string='Tittle PIC Penerimaan Barang', related='pengajuan_tempo_id.pic_tittle', store=True, readonly=False) + pic_name = fields.Char(string='Nama PIC Penerimaan Barang', related='pengajuan_tempo_id.pic_name', store=True, readonly=False) + street_pengiriman = fields.Char(string="Alamat Perusahaan", related='pengajuan_tempo_id.street_pengiriman', store=True, readonly=False) + state_id_pengiriman = fields.Many2one('res.country.state', string='State', related='pengajuan_tempo_id.state_id_pengiriman', store=True, readonly=False) + city_id_pengiriman = fields.Many2one('vit.kota', string='City', related='pengajuan_tempo_id.city_id_pengiriman', store=True, readonly=False) + zip_pengiriman = fields.Char(string="Zip", related='pengajuan_tempo_id.zip_pengiriman', store=True, readonly=False) + invoice_pic_tittle = fields.Char(string='Tittle PIC Penerimaan Invoice', related='pengajuan_tempo_id.invoice_pic_tittle', store=True, readonly=False) + invoice_pic = fields.Char(string='Nama PIC Penerimaan Invoice', related='pengajuan_tempo_id.invoice_pic', store=True, readonly=False) + street_invoice = fields.Char(string="Alamat Perusahaan", related='pengajuan_tempo_id.street_invoice', store=True, readonly=False) + state_id_invoice = fields.Many2one('res.country.state', string='State', related='pengajuan_tempo_id.state_id_invoice', store=True, readonly=False) + city_id_invoice = fields.Many2one('vit.kota', string='City', related='pengajuan_tempo_id.city_id_invoice', store=True, readonly=False) + tukar_invoice = fields.Char(string='Jadwal Penukaran Invoice', related='pengajuan_tempo_id.tukar_invoice', store=True, readonly=False) + jadwal_bayar = fields.Char(string='Jadwal Pembayaran', related='pengajuan_tempo_id.jadwal_bayar', store=True, readonly=False) + dokumen_pengiriman = fields.Char(string='Dokumen saat Pengiriman Barang', related='pengajuan_tempo_id.dokumen_pengiriman', store=True, readonly=False) + dokumen_pengiriman_input = fields.Char(string='Dokumen saat Pengiriman Barang input', related='pengajuan_tempo_id.dokumen_pengiriman_input', store=True, readonly=False) + dokumen_invoice = fields.Char(string='Dokumen yang dilampirkan saat Pengiriman Invoice', related='pengajuan_tempo_id.dokumen_invoice', store=True, readonly=False) + is_same_address = fields.Boolean(string="Same Address pengiriman invoicr dan alamat pengiriman barang", related='pengajuan_tempo_id.is_same_address', store=True, readonly=False) + is_same_address_street = fields.Boolean(string="Same Address pengiriman barang dan alamat bisnis", related='pengajuan_tempo_id.is_same_address_street', store=True, readonly=False) + + #Referensi + supplier_ids = fields.Many2many('user.pengajuan.tempo.line',related='pengajuan_tempo_id.supplier_ids', string="Suppliers", readonly=False) + + # Dokumen + dokumen_nib = fields.Many2many( + 'ir.attachment', + 'pengajuan_dokumen_nib_rel', + string="NIB (SIUP/TDP/SKDP)", + related='pengajuan_tempo_id.dokumen_nib', + readonly=False, + tracking=3, + track_visibility="onchange" + ) + + dokumen_npwp = fields.Many2many( + 'ir.attachment', + 'pengajuan_dokumen_npwp_rel', + string="NPWP Perusahaan", + related='pengajuan_tempo_id.dokumen_npwp', + readonly=False, + tracking=3 + ) + + dokumen_sppkp = fields.Many2many( + 'ir.attachment', + 'pengajuan_dokumen_sppkp_rel', + string="SPPKP Perusahaan", + related='pengajuan_tempo_id.dokumen_sppkp', + readonly=False, + tracking=3 + ) + + dokumen_akta_perubahan = fields.Many2many( + 'ir.attachment', + 'pengajuan_dokumen_akta_perubahan_rel', + string="Akta Perubahan", + related='pengajuan_tempo_id.dokumen_akta_perubahan', + readonly=False, + tracking=3 + ) + + dokumen_ktp_dirut = fields.Many2many( + 'ir.attachment', + 'pengajuan_dokumen_ktp_dirut_rel', + string="KTP Dirut/Direktur", + related='pengajuan_tempo_id.dokumen_ktp_dirut', + readonly=False, + tracking=3 + ) + + dokumen_akta_pendirian = fields.Many2many( + 'ir.attachment', + 'pengajuan_dokumen_angkta_pendirian_rel', + string="Akta Pendirian", + related='pengajuan_tempo_id.dokumen_akta_pendirian', + readonly=False, + tracking=3 + ) + + dokumen_laporan_keuangan = fields.Many2many( + 'ir.attachment', + 'pengajuan_dokumen_laporan_keuangan_rel', + string="Laporan Keuangan", + related='pengajuan_tempo_id.dokumen_laporan_keuangan', + readonly=False, + tracking=3 + ) + + dokumen_foto_kantor = fields.Many2many( + 'ir.attachment', + 'pengajuan_dokumen_foto_kantor_rel', + string="Foto Kantor (Tampak Depan)", + related='pengajuan_tempo_id.dokumen_foto_kantor', + readonly=False, + tracking=3 + ) + + dokumen_tempat_bekerja = fields.Many2many( + 'ir.attachment', + 'pengajuan_dokumen_tempat_bekerja_rel', + string="Tempat Bekerja", + related='pengajuan_tempo_id.dokumen_tempat_bekerja', + readonly=False, + tracking=3 + ) + + @api.onchange('name_tempo', 'industry_id_tempo', 'street_tempo', 'state_id_tempo', 'city_id_tempo', 'zip_tempo', + 'mobile_tempo', 'bank_name_tempo', 'account_name_tempo', 'account_number_tempo', 'website_tempo', + 'estimasi_tempo', 'tempo_duration_origin', 'tempo_limit_origin', 'category_produk_ids') + def _onchange_related_fields(self): + if self.pengajuan_tempo_id: + # Perbarui nilai di pengajuan_tempo_id + self.pengajuan_tempo_id.name_tempo = self.name_tempo + self.pengajuan_tempo_id.industry_id_tempo = self.industry_id_tempo + self.pengajuan_tempo_id.street_tempo = self.street_tempo + self.pengajuan_tempo_id.state_id_tempo = self.state_id_tempo + self.pengajuan_tempo_id.city_id_tempo = self.city_id_tempo + self.pengajuan_tempo_id.zip_tempo = self.zip_tempo + self.pengajuan_tempo_id.mobile_tempo = self.mobile_tempo + self.pengajuan_tempo_id.bank_name_tempo = self.bank_name_tempo + self.pengajuan_tempo_id.account_name_tempo = self.account_name_tempo + self.pengajuan_tempo_id.account_number_tempo = self.account_number_tempo + self.pengajuan_tempo_id.website_tempo = self.website_tempo + self.pengajuan_tempo_id.estimasi_tempo = self.estimasi_tempo + self.pengajuan_tempo_id.tempo_duration = self.tempo_duration_origin + self.pengajuan_tempo_id.tempo_limit = self.tempo_limit_origin + self.pengajuan_tempo_id.category_produk_ids = self.category_produk_ids + + @api.onchange('direktur_name', 'direktur_mobile', 'direktur_email', 'purchasing_name', 'purchasing_mobile', + 'purchasing_email', 'finance_name', 'finance_mobile', 'finance_email') + def _onchange_related_fields_kontak(self): + if self.pengajuan_tempo_id: + # Perbarui nilai di pengajuan_tempo_id + self.pengajuan_tempo_id.direktur_name = self.direktur_name + self.pengajuan_tempo_id.direktur_mobile = self.direktur_mobile + self.pengajuan_tempo_id.direktur_email = self.direktur_email + self.pengajuan_tempo_id.purchasing_name = self.purchasing_name + self.pengajuan_tempo_id.purchasing_mobile = self.purchasing_mobile + self.pengajuan_tempo_id.purchasing_email = self.purchasing_email + self.pengajuan_tempo_id.finance_name = self.finance_name + self.pengajuan_tempo_id.finance_mobile = self.finance_mobile + self.pengajuan_tempo_id.finance_email = self.finance_email + + @api.onchange('pic_tittle', 'pic_name', 'street_pengiriman', 'state_id_pengiriman', 'city_id_pengiriman', + 'zip_pengiriman', + 'invoice_pic_tittle', 'invoice_pic', 'street_invoice', 'state_id_invoice', 'city_id_invoice', + 'tukar_invoice', 'jadwal_bayar', 'dokumen_pengiriman', 'dokumen_pengiriman_input', 'dokumen_invoice', + 'is_same_address', 'is_same_address_street') + def _onchange_related_fields_pengiriman(self): + if self.pengajuan_tempo_id: + # Perbarui nilai di pengajuan_tempo_id + self.pengajuan_tempo_id.pic_tittle = self.pic_tittle + self.pengajuan_tempo_id.pic_name = self.pic_name + self.pengajuan_tempo_id.street_pengiriman = self.street_pengiriman + self.pengajuan_tempo_id.state_id_pengiriman = self.state_id_pengiriman + self.pengajuan_tempo_id.city_id_pengiriman = self.city_id_pengiriman + self.pengajuan_tempo_id.zip_pengiriman = self.zip_pengiriman + self.pengajuan_tempo_id.invoice_pic_tittle = self.invoice_pic_tittle + self.pengajuan_tempo_id.invoice_pic = self.invoice_pic + self.pengajuan_tempo_id.street_invoice = self.street_invoice + self.pengajuan_tempo_id.state_id_invoice = self.state_id_invoice + self.pengajuan_tempo_id.city_id_invoice = self.city_id_invoice + self.pengajuan_tempo_id.tukar_invoice = self.tukar_invoice + self.pengajuan_tempo_id.jadwal_bayar = self.jadwal_bayar + self.pengajuan_tempo_id.dokumen_pengiriman = self.dokumen_pengiriman + self.pengajuan_tempo_id.dokumen_pengiriman_input = self.dokumen_pengiriman_input + self.pengajuan_tempo_id.dokumen_invoice = self.dokumen_invoice + self.pengajuan_tempo_id.is_same_address = self.is_same_address + self.pengajuan_tempo_id.is_same_address_street = self.is_same_address_street + + @api.onchange('supplier_ids') + def _onchange_supplier_ids(self): + if self.pengajuan_tempo_id: + self.pengajuan_tempo_id.supplier_ids = self.supplier_ids + + @api.onchange('dokumen_nib', 'dokumen_npwp', 'dokumen_sppkp', 'dokumen_akta_perubahan', + 'dokumen_ktp_dirut', 'dokumen_akta_pendirian', 'dokumen_laporan_keuangan', + 'dokumen_foto_kantor', 'dokumen_tempat_bekerja') + def _onchange_related_fields_dokumen(self): + if self.pengajuan_tempo_id: + # Perbarui nilai di pengajuan_tempo_id + self.pengajuan_tempo_id.dokumen_nib = self.dokumen_nib + self.pengajuan_tempo_id.dokumen_npwp = self.dokumen_npwp + self.pengajuan_tempo_id.dokumen_sppkp = self.dokumen_sppkp + self.pengajuan_tempo_id.dokumen_akta_perubahan = self.dokumen_akta_perubahan + self.pengajuan_tempo_id.dokumen_ktp_dirut = self.dokumen_ktp_dirut + self.pengajuan_tempo_id.dokumen_akta_pendirian = self.dokumen_akta_pendirian + self.pengajuan_tempo_id.dokumen_laporan_keuangan = self.dokumen_laporan_keuangan + self.pengajuan_tempo_id.dokumen_foto_kantor = self.dokumen_foto_kantor + self.pengajuan_tempo_id.dokumen_tempat_bekerja = self.dokumen_tempat_bekerja + @api.onchange('tempo_duration') def _tempo_duration_change(self, vals): for tempo in self: @@ -71,6 +290,8 @@ class UserPengajuanTempoRequest(models.Model): def button_approve(self): for tempo in self: + if not self.tempo_limit: + raise UserError("Limit Tempo harus di isi terlebih dahulu") if tempo.state_tempo == 'draft': if tempo.env.user.id in (688, 28, 7): raise UserError("Pengajuan tempo harus di approve oleh sales manager terlebih dahulu") @@ -169,7 +390,7 @@ class UserPengajuanTempoRequest(models.Model): self.user_company_id.account_number_tempo = self.pengajuan_tempo_id.account_number_tempo self.user_company_id.website_tempo = self.pengajuan_tempo_id.website_tempo self.user_company_id.estimasi_tempo = self.pengajuan_tempo_id.estimasi_tempo - self.user_company_id.tempo_duration = tempo_duration + self.user_company_id.tempo_duration = tempo_duration.id self.user_company_id.tempo_limit = limit_tempo self.user_company_id.category_produk_ids = self.pengajuan_tempo_id.category_produk_ids @@ -188,18 +409,21 @@ class UserPengajuanTempoRequest(models.Model): contacts_data = [ { "type": "contact", + 'title': 6 if self.pengajuan_tempo_id.direktur_tittle == 'Bpk' else 7, "name": self.pengajuan_tempo_id.direktur_name, "email": self.pengajuan_tempo_id.direktur_email, "phone": self.pengajuan_tempo_id.direktur_mobile, }, { "type": "contact", + 'title': 6 if self.pengajuan_tempo_id.purchasing_tittle == 'Bpk' else 7, "name": self.pengajuan_tempo_id.purchasing_name, "email": self.pengajuan_tempo_id.purchasing_email, "phone": self.pengajuan_tempo_id.purchasing_mobile, }, { "type": "contact", + 'title': 6 if self.pengajuan_tempo_id.finance_tittle == 'Bpk' else 7, "name": self.pengajuan_tempo_id.finance_name, "email": self.pengajuan_tempo_id.finance_email, "phone": self.pengajuan_tempo_id.finance_mobile, @@ -209,7 +433,7 @@ class UserPengajuanTempoRequest(models.Model): "name": self.pengajuan_tempo_id.pic_name, "street": self.pengajuan_tempo_id.street_pengiriman, "state_id": self.pengajuan_tempo_id.state_id_pengiriman.id, - "city_id": self.pengajuan_tempo_id.city_id_pengiriman.id, + "city": self.pengajuan_tempo_id.city_id_pengiriman.id, "zip": self.pengajuan_tempo_id.zip_pengiriman, }, { @@ -217,7 +441,7 @@ class UserPengajuanTempoRequest(models.Model): "name": self.pengajuan_tempo_id.invoice_pic, "street": self.pengajuan_tempo_id.street_invoice, "state_id": self.pengajuan_tempo_id.state_id_invoice.id, - "city_id": self.pengajuan_tempo_id.city_id_invoice.id, + "city": self.pengajuan_tempo_id.city_id_invoice.id, }, ] @@ -293,8 +517,18 @@ class UserPengajuanTempoRequest(models.Model): # user.send_company_request_approve_mail() self.user_company_id.property_payment_term_id = self.pengajuan_tempo_id.tempo_duration.id self.user_company_id.active_limit = True - self.user_company_id.warning_stage = float(self.pengajuan_tempo_id.tempo_limit) - (float(self.pengajuan_tempo_id.tempo_limit)/2) - self.user_company_id.blocking_stage = self.pengajuan_tempo_id.tempo_limit + self.user_company_id.warning_stage = float(limit_tempo) - (float(limit_tempo)/2) + self.user_company_id.blocking_stage = limit_tempo + + # Internal Notes + comment = [] + if self.pengajuan_tempo_id.tukar_invoice: + comment.append(f"Jadwal Tukar Invoice: {self.pengajuan_tempo_id.tukar_invoice}") + if self.pengajuan_tempo_id.jadwal_bayar: + comment.append(f"Jadwal Pembayaran: {self.pengajuan_tempo_id.jadwal_bayar}") + self.user_company_id.comment = "\n".join(comment) + + # template = self.env.ref('indoteknik_custom.mail_template_res_user_company_tempo_approved') # tempo = self.pengajuan_tempo_id # template.send_mail(tempo.id, force_send=True) diff --git a/indoteknik_custom/views/user_pengajuan_tempo_request.xml b/indoteknik_custom/views/user_pengajuan_tempo_request.xml index 2a3fc745..0e6b6c71 100644 --- a/indoteknik_custom/views/user_pengajuan_tempo_request.xml +++ b/indoteknik_custom/views/user_pengajuan_tempo_request.xml @@ -8,47 +8,139 @@ + - user.pengajuan.tempo.request.form - user.pengajuan.tempo.request - -
-
-
- + user.pengajuan.tempo.request.form + user.pengajuan.tempo.request + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + - - -
- -
- -
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ + + + @@ -192,9 +284,9 @@
- + - + -- cgit v1.2.3 From 9dbae80871e94f439ea1b6c3cf6a13cab9221532 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 10 Dec 2024 10:27:44 +0700 Subject: barcode product --- indoteknik_custom/models/product_template.py | 43 +++++++++++++++++++++++++++- indoteknik_custom/models/stock_move.py | 12 ++++++++ indoteknik_custom/views/product_template.xml | 6 ++++ indoteknik_custom/views/stock_picking.xml | 1 + 4 files changed, 61 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 6fb8c7a0..ebf81811 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -5,7 +5,9 @@ import logging import requests import json import re +import qrcode, base64 from bs4 import BeautifulSoup +from io import BytesIO _logger = logging.getLogger(__name__) @@ -58,10 +60,30 @@ class ProductTemplate(models.Model): ('sp', 'Spare Part'), ('acc', 'Accessories') ], string='Kind of', copy=False) - sni = fields.Boolean(string='SNI') + sni = fields.Boolean(string='SNI') tkdn = fields.Boolean(string='TKDN') short_spesification = fields.Char(string='Short Spesification') merchandise_ok = fields.Boolean(string='Product Promotion') + print_barcode = fields.Boolean(string='Print Barcode', default="True") + qr_code = fields.Binary("QR Code", compute='_compute_qr_code') + + def _compute_qr_code(self): + for rec in self.product_variant_ids: + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=5, + border=4, + ) + qr.add_data(rec.display_name) + qr.make(fit=True) + img = qr.make_image(fill_color="black", back_color="white") + + buffer = BytesIO() + img.save(buffer, format="PNG") + qr_code_img = base64.b64encode(buffer.getvalue()).decode() + + rec.qr_code = qr_code_img @api.constrains('name', 'internal_reference', 'x_manufacture') def required_public_categ_ids(self): @@ -379,6 +401,25 @@ class ProductProduct(models.Model): qty_rpo = fields.Float(string='Qty RPO', compute='_get_qty_rpo') plafon_qty = fields.Float(string='Max Plafon', compute='_get_plafon_qty_product') merchandise_ok = fields.Boolean(string='Product Promotion') + qr_code_variant = fields.Binary("QR Code Variant", compute='_compute_qr_code_variant') + + def _compute_qr_code_variant(self): + for rec in self.product_variant_ids: + qr = qrcode.QRCode( + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=5, + border=4, + ) + qr.add_data(rec.display_name) + qr.make(fit=True) + img = qr.make_image(fill_color="black", back_color="white") + + buffer = BytesIO() + img.save(buffer, format="PNG") + qr_code_img = base64.b64encode(buffer.getvalue()).decode() + + rec.qr_code_variant = qr_code_img def _get_clean_website_description(self): for rec in self: diff --git a/indoteknik_custom/models/stock_move.py b/indoteknik_custom/models/stock_move.py index ac2e3cc0..8214a057 100644 --- a/indoteknik_custom/models/stock_move.py +++ b/indoteknik_custom/models/stock_move.py @@ -7,6 +7,18 @@ class StockMove(models.Model): line_no = fields.Integer('No', default=0) sale_id = fields.Many2one('sale.order', string='SO') + print_barcode = fields.Boolean( + string="Print Barcode", + default=lambda self: self.product_id.print_barcode, + ) + + def write(self, vals): + res = super(StockMove, self).write(vals) + if 'print_barcode' in vals: + for line in self: + if line.product_id: + line.product_id.print_barcode = vals['print_barcode'] + return res def _do_unreserve(self, product=None, quantity=False): moves_to_unreserve = OrderedSet() diff --git a/indoteknik_custom/views/product_template.xml b/indoteknik_custom/views/product_template.xml index b6599137..93ea11a2 100755 --- a/indoteknik_custom/views/product_template.xml +++ b/indoteknik_custom/views/product_template.xml @@ -20,6 +20,7 @@ + 0 @@ -29,6 +30,10 @@
@@ -285,23 +285,20 @@
- + - - + + + - - - - - + - diff --git a/indoteknik_custom/views/user_pengajuan_tempo_request.xml b/indoteknik_custom/views/user_pengajuan_tempo_request.xml index 4a8243da..17ae526c 100644 --- a/indoteknik_custom/views/user_pengajuan_tempo_request.xml +++ b/indoteknik_custom/views/user_pengajuan_tempo_request.xml @@ -25,13 +25,13 @@ class="oe_highlight" /> - - - - - - - +
Hai. ${object.name_tempo.name},
Halo Tim Finance Indoteknik,
Kabar baik! Kami dengan senang hati menginformasikan bahwa pengajuan tempo pembayaran kamui di Indoteknik.com telah disetujui dengan detail sebagai berikut.
Limit Pembayaran Tempo : Rp ${object.format_currency(object.tempo_limit)}
Kami informasikan bahwa pengajuan tempo dari ${object.pengajuan_tempo_id.name_tempo.name} telah disetujui oleh Manager Divisi Sales.
Untuk kelancaran proses selanjutnya, kami mohon kesediaannya untuk melakukan pengecekan ulang terhadap pengajuan tempo tersebut.
Durasi Pembayaran Tempo : ${object.tempo_duration.name}
Kamu dapat melakukan pembayaran sesuai dengan jangka waktu yang telah disepakati. Detail lengkap mengenai transaksi kamu, termasuk tanggal jatuh tempo & Pengajuan Kenaikan Limit Tempo, dapat kamu lihat di akun Profile Indoteknik.com.
Terima kasih atas kepercayaan kamu kepada Indoteknik.com.
Terima kasih atas perhatian dan kerjasamanya.
Hormat kami,
PT. INDOTEKNIK DOTCOM GEMILANG
- Indoteknik + + Indoteknik
+ +
+ + + + + + + + + + + + +
+ + + + + + + + +
+ +
+
+
+
+ + + + + + + + + + + + + + + +
Halo Pak Akbar,
Kami sampaikan informasi bahwa saat ini terdapat pengajuan Pembayaran Tempo dari ${object.pengajuan_tempo_id.name_tempo.name} telah melalui tahap persetujuan awal dari Manager Sales & diverifikasi oleh ${object.write_uid.name} dari tim Finance.
Untuk proses persetujuan akhir, mohon Bapak dapat segera meninjau dan mengevaluasi atas pengajuan terhadap data yang telah diberikan oleh ${object.pengajuan_tempo_id.name_tempo.name}.
Hormat kami,
PT. INDOTEKNIK DOTCOM GEMILANG
+ Indoteknik +
+
+
+
+
+ + + + Users: Company Tempo Approved + + Pengajuan Tempo kamu di Indoteknik.com Telah Disetujui! + "Indoteknik.com" <noreply@indoteknik.com> + sales@indoteknik.com + ${object.pengajuan_tempo_id.user_id.login | safe} + + + +
+ + + + + + + + + + + + +
+ + + + + + + + +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + +
Hai. ${object.pengajuan_tempo_id.name_tempo.name},
Kabar baik! Kami dengan senang hati menginformasikan bahwa pengajuan tempo pembayaran kamu di Indoteknik.com telah disetujui dengan detail sebagai berikut.
Limit Pembayaran Tempo : Rp ${object.format_currency(object.pengajuan_tempo_id.tempo_limit)}
Durasi Pembayaran Tempo : ${object.pengajuan_tempo_id.tempo_duration.name}
Kamu dapat melakukan pembayaran sesuai dengan jangka waktu yang telah disepakati. Detail lengkap mengenai transaksi kamu, termasuk tanggal jatuh tempo & Pengajuan Kenaikan Limit Tempo, dapat kamu lihat di akun Profile Indoteknik.com .
Terima kasih atas kepercayaan kamu kepada Indoteknik.com.
Hormat kami,
PT. INDOTEKNIK DOTCOM GEMILANG
+ Indoteknik +
+
+
+
+
+
+
+ + Users: Company Tempo Reject + + Mohon Maaf Pengajuan Tempo anda kami Tolak + "Indoteknik.com" <noreply@indoteknik.com> + sales@indoteknik.com + ${object.pengajuan_tempo_id.user_id.login | safe} + + + + +
+ + + + + + + + + + + + +
+ + + + + + + + +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + +
Hai. ${object.pengajuan_tempo_id.name_tempo.name},
Kami sampaikan dengan sangat menyesal bahwa pengajuan permohonan tempo pembayaran Anda yang diajukan pada tanggal ${format_date(object.pengajuan_tempo_id.create_date, 'dd MMMM yyyy')} tidak dapat kami setujui.
Keputusan ini telah kami pertimbangkan secara matang berdasarkan beberapa faktor, diantaranya alasan tidak disetujuinya adalah ${object.reason_reject}
Kami memahami bahwa hal ini mungkin mengecewakan. Namun, kami berharap Anda dapat memahami kebijakan perusahaan kami.
Terima kasih atas pengertiannya.
Hormat kami,
PT. INDOTEKNIK DOTCOM GEMILANG
+ Indoteknik +
+
+
+
+
+
+
+ + User Pengajuan Tempo Request ir.actions.act_window -- cgit v1.2.3 From 0aad5455df5d36ef87ab1cbd52030a3cf0bef1d8 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 4 Dec 2024 10:58:46 +0700 Subject: update code pengajuan tempo --- indoteknik_api/controllers/api_v1/partner.py | 29 ++--- indoteknik_api/controllers/api_v1/user.py | 4 +- indoteknik_api/models/res_partner.py | 142 ++++++++++++++--------- indoteknik_api/models/res_users.py | 4 +- indoteknik_custom/models/user_company_request.py | 26 ++--- 5 files changed, 117 insertions(+), 88 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/partner.py b/indoteknik_api/controllers/api_v1/partner.py index 19c73aec..0522e8e1 100644 --- a/indoteknik_api/controllers/api_v1/partner.py +++ b/indoteknik_api/controllers/api_v1/partner.py @@ -284,10 +284,10 @@ class Partner(controller.Controller): user_id = int(kw.get('user_id')) tempo_request = True if kw.get('tempo_request') == 'true' else False pengajuan_tempo = request.env['user.pengajuan.tempo'].search([('name_tempo', '=', user_id)], limit=1) - user = request.env['res.partner'].search([('id', '=', id)], limit=1) + user = request.env['res.partner'].search([('id', '=', user_id)], limit=1) company_name = kw.get('name', pengajuan_tempo.name_tempo.name) partner_id = request.env['res.partner'].search([('name', 'like', company_name)], limit=1) - user_account = self.get_user_by_email(user.user_id.email) + user_account = self.get_user_by_email(user.email) params = self.get_request_params(kw, { @@ -374,7 +374,7 @@ class Partner(controller.Controller): 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]}) + pengajuan_tempo.write({'supplier_ids': [(6, 0, supplier_ids_to_add)]}) except json.JSONDecodeError: return http.Response(status=400, json_body={'error': 'Invalid JSON format for formSupplier'}) @@ -477,31 +477,31 @@ class Partner(controller.Controller): 'mimetype': mimetype }) - if dokumen['documentName'] == 'dokumenNib' and dokumen['details']['base64'] != '': + if dokumen['documentName'] == 'dokumenNib' and dokumen['details']['base64'] != '' : pengajuan_tempo.dokumen_nib = [(4, sppkp_attachment.id)] - elif dokumen['documentName'] == 'dokumenNpwp' and dokumen['details']['base64'] != '': + elif dokumen['documentName'] == 'dokumenNpwp' and dokumen['details']['base64'] != '' : pengajuan_tempo.dokumen_npwp = [(4, sppkp_attachment.id)] - elif dokumen['documentName'] == 'dokumenSppkp' and dokumen['details']['base64'] != '': + elif dokumen['documentName'] == 'dokumenSppkp' and dokumen['details']['base64'] != '' : pengajuan_tempo.dokumen_sppkp = [(4, sppkp_attachment.id)] - elif dokumen['documentName'] == 'dokumenAktaPerubahan' and dokumen['details']['base64'] != '': + elif dokumen['documentName'] == 'dokumenAktaPerubahan' and dokumen['details']['base64'] != '' : pengajuan_tempo.dokumen_akta_perubahan = [(4, sppkp_attachment.id)] - elif dokumen['documentName'] == 'dokumenKtpDirut' and dokumen['details']['base64'] != '': + elif dokumen['documentName'] == 'dokumenKtpDirut' and dokumen['details']['base64'] != '' : pengajuan_tempo.dokumen_ktp_dirut = [(4, sppkp_attachment.id)] - elif dokumen['documentName'] == 'dokumenAktaPendirian' and dokumen['details']['base64'] != '': + elif dokumen['documentName'] == 'dokumenAktaPendirian' and dokumen['details']['base64'] != '' : pengajuan_tempo.dokumen_akta_pendirian = [(4, sppkp_attachment.id)] - elif dokumen['documentName'] == 'dokumenLaporanKeuangan' and dokumen['details']['base64'] != '': + elif dokumen['documentName'] == 'dokumenLaporanKeuangan' and dokumen['details']['base64'] != '' : pengajuan_tempo.dokumen_laporan_keuangan = [(4, sppkp_attachment.id)] - elif dokumen['documentName'] == 'dokumenFotoKantor' and dokumen['details']['base64'] != '': + elif dokumen['documentName'] == 'dokumenFotoKantor' and dokumen['details']['base64'] != '' : pengajuan_tempo.dokumen_foto_kantor = [(4, sppkp_attachment.id)] - else: + elif dokumen['documentName'] == 'dokumen_tempat_bekerja' and dokumen['details']['base64'] != '' : pengajuan_tempo.dokumen_tempat_bekerja = [(4, sppkp_attachment.id)] formatted_text = ''.join([' ' + char if char.isupper() and i != 0 else char for i, char in enumerate(dokumen['documentName'])]) @@ -519,9 +519,10 @@ class Partner(controller.Controller): 'tempo_limit': pengajuan_tempo.tempo_limit, }) pengajuan_tempo.user_id = user_account.id - template = pengajuan_tempo.env.ref('indoteknik_custom.mail_template_user_cart_reminder_to_checkout') + template = pengajuan_tempo.env.ref('indoteknik_custom.mail_template_res_user_company_request_tempo_review') template.send_mail(pengajuan_tempo.id, force_send=True) - # user_account.send_activation_mail() + template2 = pengajuan_tempo.env.ref('indoteknik_custom.mail_template_res_user_company_new_tempo_to_sales') + template2.send_mail(pengajuan_tempo.id, force_send=True) return self.response({ 'id': pengajuan_tempo.id, 'user_id': user_id, diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py index 51dae0a2..addf2c9f 100644 --- a/indoteknik_api/controllers/api_v1/user.py +++ b/indoteknik_api/controllers/api_v1/user.py @@ -405,7 +405,7 @@ class User(controller.Controller): @http.route(prefix + 'user//after_request_tempo', auth='public', methods=['PUT', 'OPTIONS'], csrf=False) @controller.Controller.must_authorized() - def update_user_tempo(self, **kw): + def update_user_tempo_after_request(self, **kw): id = kw.get('id') user = request.env['res.users'].search([('id', '=', id)], limit=1) @@ -414,7 +414,7 @@ class User(controller.Controller): return self.response({ - 'user': self.response_with_token(user, payment_tempo='Review') + 'user': self.response_with_token(user) }) @http.route(prefix + 'user//address', auth='public', methods=['GET', 'OPTIONS']) diff --git a/indoteknik_api/models/res_partner.py b/indoteknik_api/models/res_partner.py index 9b9f87d4..7b3c8d47 100644 --- a/indoteknik_api/models/res_partner.py +++ b/indoteknik_api/models/res_partner.py @@ -4,10 +4,10 @@ import json class ResPartner(models.Model): _inherit = 'res.partner' - def api_single_response(self, res_partner, with_detail=''): + def api_single_response(self, pengajuan_tempo, with_detail=''): config = self.env['ir.config_parameter'] - partner = res_partner.partner_id + partner = pengajuan_tempo.partner_id dokumen_kirim = [ ['Surat Tanda Terima Barang (STTB)', '0'], @@ -16,10 +16,10 @@ class ResPartner(models.Model): ['Lembar Penerimaan Barang (LPB)', '3'] ] dokumen_pengiriman = [] - if res_partner.dokumen_pengiriman : - res_partner_dokumen_pengiriman = res_partner.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 res_partner_dokumen_pengiriman.split(',')] + 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] dokumen = [ @@ -30,57 +30,57 @@ class ResPartner(models.Model): ['Good Receipt (GR)','4'] ] dokumen_invoice = [] - if res_partner.dokumen_invoice: - res_partner_dokumen_invoice = res_partner.dokumen_invoice + if pengajuan_tempo.dokumen_invoice: + pengajuan_tempo_dokumen_invoice = pengajuan_tempo.dokumen_invoice mapping_dokumen = {item[0]: item[1] for item in dokumen} - dokumen_invoice_list = [dokumen.strip() for dokumen in res_partner_dokumen_invoice.split(',')] + dokumen_invoice_list = [dokumen.strip() for dokumen in pengajuan_tempo_dokumen_invoice.split(',')] dokumen_invoice = [mapping_dokumen.get(dokumen, '4') for dokumen in dokumen_invoice_list] data = { - 'name' : res_partner.name_tempo.name, - 'industry_id' : res_partner.industry_id_tempo.id, - 'street' : res_partner.street_tempo, - 'state' : res_partner.state_id_tempo.id, - 'city' : res_partner.city_id_tempo.id, - 'zip' : res_partner.zip_tempo, - 'mobile' : res_partner.mobile_tempo, - 'bank_name' : res_partner.bank_name_tempo, - 'account_name' : res_partner.account_name_tempo, - 'account_number' : res_partner.account_number_tempo, - 'website' : res_partner.website_tempo if res_partner.website_tempo else '', - 'estimasi' : res_partner.estimasi_tempo, - 'tempo_duration' : res_partner.tempo_duration.id, - 'tempo_limit' : res_partner.tempo_limit, - 'category_produk': ','.join([str(cat.id) for cat in res_partner.category_produk_ids]) if res_partner.category_produk_ids else '', + '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, + '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, + '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_name' : res_partner.direktur_name if res_partner.direktur_name else '', - 'direktur_mobile' : res_partner.direktur_mobile if res_partner.direktur_mobile else '', - 'direktur_email' : res_partner.direktur_email if res_partner.direktur_email else '', - 'purchasing_name' : res_partner.purchasing_name if res_partner.purchasing_name else '', - 'purchasing_mobile' : res_partner.purchasing_mobile if res_partner.purchasing_mobile else '', - 'purchasing_email' : res_partner.purchasing_email if res_partner.purchasing_email else '', - 'finance_name' : res_partner.finance_name if res_partner.finance_name else '', - 'finance_mobile' : res_partner.finance_mobile if res_partner.finance_mobile else '', - 'finance_email' : res_partner.finance_email if res_partner.finance_email 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_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_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_name' : res_partner.pic_name if res_partner.pic_name else '', - 'street_pengiriman' : res_partner.street_pengiriman if res_partner.street_pengiriman else '', - 'state_id_pengiriman' : res_partner.state_id_pengiriman.id if res_partner.state_id_pengiriman else '', - 'city_id_pengiriman' : res_partner.city_id_pengiriman.id if res_partner.city_id_pengiriman else '', - 'zip_pengiriman' : res_partner.zip_pengiriman if res_partner.zip_pengiriman else '', - 'invoice_pic' : res_partner.invoice_pic if res_partner.invoice_pic else '', - 'street_invoice' : res_partner.street_invoice if res_partner.street_invoice else '', - 'state_id_invoice' : res_partner.state_id_invoice.id if res_partner.state_id_invoice else '', - 'city_id_invoice' : res_partner.city_id_invoice.id if res_partner.city_id_invoice else '', - 'tukar_invoice' : res_partner.tukar_invoice if res_partner.tukar_invoice else '', - 'jadwal_bayar' : res_partner.jadwal_bayar if res_partner.jadwal_bayar 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 '', + 'zip_pengiriman' : pengajuan_tempo.zip_pengiriman if pengajuan_tempo.zip_pengiriman 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 '', + '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_invoice' : ','.join(dokumen_invoice) if dokumen_invoice else '', - 'is_same_address': res_partner.is_same_address if res_partner.is_same_address else False, - 'res_partner.is_same_address': res_partner.is_same_address_street if res_partner.is_same_address_street else False, + '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, @@ -90,19 +90,49 @@ class ResPartner(models.Model): 'credit_limit': supplier.credit_limit, 'durasi_tempo': supplier.tempo_duration } - for supplier in res_partner.supplier_ids - ] if res_partner.supplier_ids else '' + for supplier in pengajuan_tempo.supplier_ids + ] if pengajuan_tempo.supplier_ids else '', # Dokumen - # 'dokumen_nib': res_partner.dokumen_nib if res_partner.dokumen_nib else '', - # 'dokumen_npwp': res_partner.dokumen_npwp if res_partner.dokumen_npwp else '', - # 'dokumen_sppkp': res_partner.dokumen_sppkp if res_partner.dokumen_sppkp else '', - # 'dokumen_akta_perubahan': res_partner.dokumen_akta_perubahan if res_partner.dokumen_akta_perubahan else '', - # 'dokumen_ktp_dirut': res_partner.dokumen_ktp_dirut if res_partner.dokumen_ktp_dirut else '', - # 'dokumen_akta_pendirian': res_partner.dokumen_akta_pendirian if res_partner.dokumen_akta_pendirian else '', - # 'dokumen_laporan_keuangan': res_partner.dokumen_laporan_keuangan if res_partner.dokumen_laporan_keuangan else '', - # 'dokumen_foto_kantor': res_partner.dokumen_foto_kantor if res_partner.dokumen_foto_kantor else '', - # 'dokumen_tempat_bekerja': res_partner.dokumen_tempat_bekerja if res_partner.dokumen_tempat_bekerja else '', + 'dokumen_nib': + { + 'name': pengajuan_tempo.dokumen_nib.name, + 'base64': pengajuan_tempo.dokumen_nib.local_url, + } + if pengajuan_tempo.dokumen_nib else '', + 'dokumen_npwp': + { + 'name': pengajuan_tempo.dokumen_npwp.name, + 'base64': pengajuan_tempo.dokumen_npwp.local_url, + } if pengajuan_tempo.dokumen_npwp else '', + 'dokumen_sppkp': { + 'name': pengajuan_tempo.dokumen_sppkp.name, + 'base64': pengajuan_tempo.dokumen_sppkp.local_url, + } if pengajuan_tempo.dokumen_sppkp else '', + 'dokumen_akta_perubahan': { + 'name': pengajuan_tempo.dokumen_akta_perubahan.name, + 'base64': pengajuan_tempo.dokumen_akta_perubahan.local_url, + } if pengajuan_tempo.dokumen_akta_perubahan else '', + 'dokumen_ktp_dirut': { + 'name': pengajuan_tempo.dokumen_ktp_dirut.name, + 'base64': pengajuan_tempo.dokumen_ktp_dirut.local_url, + } if pengajuan_tempo.dokumen_ktp_dirut else '', + 'dokumen_akta_pendirian': { + 'name': pengajuan_tempo.dokumen_akta_pendirian.name, + 'base64': pengajuan_tempo.dokumen_akta_pendirian.local_url, + } if pengajuan_tempo.dokumen_akta_pendirian else '', + 'dokumen_laporan_keuangan': { + 'name': pengajuan_tempo.dokumen_laporan_keuangan.name, + 'base64': pengajuan_tempo.dokumen_laporan_keuangan.local_url, + } if pengajuan_tempo.dokumen_laporan_keuangan else '', + 'dokumen_foto_kantor': { + 'name': pengajuan_tempo.dokumen_foto_kantor.name, + 'base64': pengajuan_tempo.dokumen_foto_kantor.local_url, + } if pengajuan_tempo.dokumen_foto_kantor else '', + 'dokumen_tempat_bekerja': { + 'name': pengajuan_tempo.dokumen_tempat_bekerja.name, + 'base64': pengajuan_tempo.dokumen_tempat_bekerja.local_url, + } 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 15aaa5a7..0c7dd96f 100644 --- a/indoteknik_api/models/res_users.py +++ b/indoteknik_api/models/res_users.py @@ -4,7 +4,7 @@ from odoo.http import request class ResUsers(models.Model): _inherit = 'res.users' - def api_single_response(self, res_user, with_detail='', payment_tempo= ''): + def api_single_response(self, res_user, with_detail=''): config = self.env['ir.config_parameter'] partner = res_user.partner_id @@ -19,8 +19,6 @@ class ResUsers(models.Model): tempo_progres = 'review' if is_tempo_request.state_tempo in ('draft','approval_sales','approval_finance') else '' if main_partner: partner_tempo = main_partner.get_check_payment_term() - if payment_tempo: - tempo_progres = payment_tempo data = { 'id': res_user.id, diff --git a/indoteknik_custom/models/user_company_request.py b/indoteknik_custom/models/user_company_request.py index ea5ca09e..3de3d751 100644 --- a/indoteknik_custom/models/user_company_request.py +++ b/indoteknik_custom/models/user_company_request.py @@ -88,19 +88,19 @@ class UserCompanyRequest(models.Model): if not self.is_approve and is_approve: if is_approve == 'approved': - self.user_id.parent_id = user_company_id.id if user_company_id.id else self.user_company_id.id - self.user_id.customer_type = user_company_id.customer_type - self.user_id.npwp = user_company_id.npwp - self.user_id.sppkp = user_company_id.sppkp - self.user_id.nama_wajib_pajak = user_company_id.nama_wajib_pajak - self.user_id.alamat_lengkap_text = user_company_id.alamat_lengkap_text - self.user_id.industry_id = user_company_id.industry_id.id - self.user_id.company_type_id = user_company_id.company_type_id.id - self.user_id.user_id = user_company_id.user_id - self.user_id.property_account_receivable_id = user_company_id.property_account_receivable_id - self.user_id.property_account_payable_id = user_company_id.property_account_payable_id - self.user_id.property_payment_term_id = user_company_id.property_payment_term_id - self.user_id.property_supplier_payment_term_id = user_company_id.property_supplier_payment_term_id + self.user_id.parent_id = user_company_id if user_company_id else self.user_company_id + self.user_id.customer_type = user_company_id.customer_type if user_company_id else self.user_company_id.customer_type + self.user_id.npwp = user_company_id.npwp if user_company_id else self.user_company_id.npwp + self.user_id.sppkp = user_company_id.sppkp if user_company_id else self.user_company_id.sppkp + self.user_id.nama_wajib_pajak = user_company_id.nama_wajib_pajak if user_company_id else self.user_company_id.nama_wajib_pajak + self.user_id.alamat_lengkap_text = user_company_id.alamat_lengkap_text if user_company_id else self.user_company_id.alamat_lengkap_text + self.user_id.industry_id = user_company_id.industry_id.id if user_company_id else self.user_company_id.industry_id + self.user_id.company_type_id = user_company_id.company_type_id.id if user_company_id else self.user_company_id.company_type_id + self.user_id.user_id = user_company_id.user_id if user_company_id else self.user_company_id.user_id + self.user_id.property_account_receivable_id = user_company_id.property_account_receivable_id if user_company_id else self.user_company_id.property_account_receivable_id + self.user_id.property_account_payable_id = user_company_id.property_account_payable_id if user_company_id else self.user_company_id.property_account_payable_id + self.user_id.property_payment_term_id = user_company_id.property_payment_term_id if user_company_id else self.user_company_id.property_payment_term_id + self.user_id.property_supplier_payment_term_id = user_company_id.property_supplier_payment_term_id if user_company_id else self.user_company_id.property_supplier_payment_term_id self.user_company_id.active = True user.send_company_request_approve_mail() else: -- cgit v1.2.3 From af85c0d2248728fe33675dcec6e513eefd6553a4 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 6 Dec 2024 17:08:46 +0700 Subject: update pengajuan tempo --- indoteknik_api/controllers/api_v1/partner.py | 97 ++++++++-------------- indoteknik_api/models/res_partner.py | 23 ++--- indoteknik_api/models/res_users.py | 6 +- indoteknik_custom/models/res_partner.py | 3 + indoteknik_custom/models/user_pengajuan_tempo.py | 6 ++ .../models/user_pengajuan_tempo_request.py | 45 ++++++++++ indoteknik_custom/views/res_partner.xml | 1 + indoteknik_custom/views/user_pengajuan_tempo.xml | 1 + .../views/user_pengajuan_tempo_request.xml | 6 +- 9 files changed, 107 insertions(+), 81 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/partner.py b/indoteknik_api/controllers/api_v1/partner.py index 0522e8e1..d8464add 100644 --- a/indoteknik_api/controllers/api_v1/partner.py +++ b/indoteknik_api/controllers/api_v1/partner.py @@ -308,22 +308,27 @@ class Partner(controller.Controller): 'tempoLimit': ['alias:tempo_limit'], # informasi perusahaan + 'direkturTittle': ['alias:direktur_tittle'], 'direkturName': ['alias:direktur_name'], 'direkturMobile': ['alias:direktur_mobile'], 'direkturEmail': ['alias:direktur_email'], + 'purchasingTittle': ['alias:purchasing_tittle'], 'purchasingName': ['alias:purchasing_name'], 'purchasingMobile': ['alias:purchasing_mobile'], 'purchasingEmail': ['alias:purchasing_email'], + 'financeTittle': ['alias:finance_tittle'], 'financeName': ['alias:finance_name'], 'financeMobile': ['alias:finance_mobile'], 'financeEmail': ['alias:finance_email'], # Pengiriman + 'PICTittle': ['alias:pic_tittle'], 'PICName': ['alias:pic_name'], 'streetPengiriman': ['alias:street_pengiriman'], 'statePengiriman': ['alias:state_id_pengiriman'], 'cityPengiriman': ['alias:city_id_pengiriman'], 'zipPengiriman': ['alias:zip_pengiriman'], + 'invoicePicTittle': ['alias:invoice_pic_tittle'], 'invoicePic': ['alias:invoice_pic'], 'streetInvoice': ['alias:street_invoice'], 'stateInvoice': ['alias:state_id_invoice'], @@ -384,37 +389,13 @@ class Partner(controller.Controller): category_ids = list(map(int, category_produk_ids.split(','))) pengajuan_tempo.category_produk_ids = [(6, 0, category_ids)] - every_weekday = True if kw.get('everyWeekday') == "true" else False - every_weekday_input = kw.get('everyWeekdayInput') - every_week = True if kw.get('everyWeek') == 'true' else False - every_week_input = kw.get('everyWeekInput') - tukar_invoice = True if kw.get('tukarInvoice') == 'true' else False tukar_invoice_input = kw.get('tukarInvoiceInput') - jadwal_tukar_invoice = "" - if every_weekday: - jadwal_tukar_invoice += f"setiap hari {every_weekday_input}" - if every_week: - jadwal_tukar_invoice += f", setiap {every_week_input}" - if tukar_invoice or tukar_invoice_input: - jadwal_tukar_invoice += f", {tukar_invoice_input}" - if jadwal_tukar_invoice: - pengajuan_tempo.tukar_invoice = jadwal_tukar_invoice - - every_weekday_pembayaran = True if kw.get('everyWeekdayPembayaran') == 'true' else False - every_weekday_input_pembayaran = kw.get('everyWeekdayInputPembayaran') - every_week_pembayaran = True if kw.get('everyWeekPembayaran') == 'true' else False - every_week_input_pembayaran = kw.get('everyWeekInputPembayaran') - tukar_invoice_pembayaran = True if kw.get('tukarInvoicePembayaran') == 'true' else False + if tukar_invoice_input: + pengajuan_tempo.tukar_invoice = tukar_invoice_input + tukar_invoice_input_pembayaran = kw.get('tukarInvoiceInputPembayaran') - jadwal_tukar_invoice_pembayaran = "" - if every_weekday_pembayaran: - jadwal_tukar_invoice_pembayaran += f"setiap hari {every_weekday_input_pembayaran}" - if every_week_pembayaran: - jadwal_tukar_invoice_pembayaran += f", setiap {every_week_input_pembayaran}" - if tukar_invoice_pembayaran or tukar_invoice_input_pembayaran: - jadwal_tukar_invoice_pembayaran += f", {tukar_invoice_input_pembayaran}" - if jadwal_tukar_invoice_pembayaran: - pengajuan_tempo.jadwal_bayar = jadwal_tukar_invoice_pembayaran + if tukar_invoice_input_pembayaran: + pengajuan_tempo.jadwal_bayar = tukar_invoice_input_pembayaran dokumen_kirim = [ 'Surat Tanda Terima Barang (STTB)', @@ -431,11 +412,10 @@ class Partner(controller.Controller): dokumen_kirim_ids = list(map(int, dokumen_kirim_barang_ids.split(','))) dokumen_kirim_barang = [dokumen_kirim[i] for i in dokumen_kirim_ids if 0 <= i < len(dokumen_kirim)] - if dokumen_kirim_barang_input: - input_items = [item.strip() for item in dokumen_kirim_barang_input.split(',')] - dokumen_kirim_barang.extend(item for item in input_items if item and item not in dokumen_kirim_barang) if dokumen_kirim_barang: pengajuan_tempo.dokumen_pengiriman = ', '.join(dokumen_kirim_barang) + if dokumen_kirim_barang_input: + pengajuan_tempo.dokumen_pengiriman_input = dokumen_kirim_barang_input dokumen = [ 'Invoice Pembelian', @@ -445,18 +425,9 @@ class Partner(controller.Controller): 'Good Receipt (GR)' ] - dokumen_invoice_ids = kw.get('dokumenPengirimanInvoice') - dokumen_invoice_input = kw.get('dokumenPengirimanInvoiceInput', '') - dokumen_invoice = "" - - if dokumen_invoice_ids: - dokumen_ids = list(map(int, dokumen_invoice_ids.split(','))) - dokumen_invoice = [dokumen[i] for i in dokumen_ids if 0 <= i < len(dokumen)] - if dokumen_invoice_input: - input_items = [item.strip() for item in dokumen_invoice_input.split(',')] - dokumen_invoice.extend(item for item in input_items if item and item not in dokumen_invoice) + dokumen_invoice = kw.get('dokumenPengirimanInvoice', '') if dokumen_invoice: - pengajuan_tempo.dokumen_invoice = ', '.join(dokumen_invoice) + pengajuan_tempo.dokumen_invoice = dokumen_invoice form_dokumen_data = kw.get('formDocs', False) if form_dokumen_data: @@ -477,37 +448,39 @@ class Partner(controller.Controller): 'mimetype': mimetype }) - if dokumen['documentName'] == 'dokumenNib' and dokumen['details']['base64'] != '' : - pengajuan_tempo.dokumen_nib = [(4, sppkp_attachment.id)] + if dokumen['documentName'] == 'dokumenNib': + pengajuan_tempo.dokumen_nib = [(6, 0, [sppkp_attachment.id])] - elif dokumen['documentName'] == 'dokumenNpwp' and dokumen['details']['base64'] != '' : - pengajuan_tempo.dokumen_npwp = [(4, sppkp_attachment.id)] + elif dokumen['documentName'] == 'dokumenNpwp': + pengajuan_tempo.dokumen_npwp = [(6, 0, [sppkp_attachment.id])] - elif dokumen['documentName'] == 'dokumenSppkp' and dokumen['details']['base64'] != '' : - pengajuan_tempo.dokumen_sppkp = [(4, sppkp_attachment.id)] + elif dokumen['documentName'] == 'dokumenSppkp': + pengajuan_tempo.dokumen_sppkp = [(6, 0, [sppkp_attachment.id])] - elif dokumen['documentName'] == 'dokumenAktaPerubahan' and dokumen['details']['base64'] != '' : - pengajuan_tempo.dokumen_akta_perubahan = [(4, sppkp_attachment.id)] + elif dokumen['documentName'] == 'dokumenAktaPerubahan': + pengajuan_tempo.dokumen_akta_perubahan = [(6, 0, [sppkp_attachment.id])] - elif dokumen['documentName'] == 'dokumenKtpDirut' and dokumen['details']['base64'] != '' : - pengajuan_tempo.dokumen_ktp_dirut = [(4, sppkp_attachment.id)] + elif dokumen['documentName'] == 'dokumenKtpDirut': + pengajuan_tempo.dokumen_ktp_dirut = [(6, 0, [sppkp_attachment.id])] - elif dokumen['documentName'] == 'dokumenAktaPendirian' and dokumen['details']['base64'] != '' : - pengajuan_tempo.dokumen_akta_pendirian = [(4, sppkp_attachment.id)] + elif dokumen['documentName'] == 'dokumenAktaPendirian': + pengajuan_tempo.dokumen_akta_pendirian = [(6, 0, [sppkp_attachment.id])] - elif dokumen['documentName'] == 'dokumenLaporanKeuangan' and dokumen['details']['base64'] != '' : - pengajuan_tempo.dokumen_laporan_keuangan = [(4, sppkp_attachment.id)] + elif dokumen['documentName'] == 'dokumenLaporanKeuangan': + pengajuan_tempo.dokumen_laporan_keuangan = [(6, 0, [sppkp_attachment.id])] - elif dokumen['documentName'] == 'dokumenFotoKantor' and dokumen['details']['base64'] != '' : - pengajuan_tempo.dokumen_foto_kantor = [(4, sppkp_attachment.id)] + elif dokumen['documentName'] == 'dokumenFotoKantor': + pengajuan_tempo.dokumen_foto_kantor = [(6, 0, [sppkp_attachment.id])] - elif dokumen['documentName'] == 'dokumen_tempat_bekerja' and dokumen['details']['base64'] != '' : - pengajuan_tempo.dokumen_tempat_bekerja = [(4, sppkp_attachment.id)] + elif dokumen['documentName'] == 'dokumenTempatBekerja': + pengajuan_tempo.dokumen_tempat_bekerja = [(6, 0, [sppkp_attachment.id])] - formatted_text = ''.join([' ' + char if char.isupper() and i != 0 else char for i, char in enumerate(dokumen['documentName'])]) + formatted_text = ''.join([' ' + char if char.isupper() and i != 0 else char for i, char in + enumerate(dokumen['documentName'])]) teks = formatted_text.strip().title() pengajuan_tempo.message_post(body=teks, attachment_ids=[sppkp_attachment.id]) + except json.JSONDecodeError: return http.Response(status=400, json_body={'error': 'Invalid JSON format for formDokumen'}) if tempo_request: diff --git a/indoteknik_api/models/res_partner.py b/indoteknik_api/models/res_partner.py index 7b3c8d47..f73101db 100644 --- a/indoteknik_api/models/res_partner.py +++ b/indoteknik_api/models/res_partner.py @@ -22,21 +22,6 @@ class ResPartner(models.Model): 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] - dokumen = [ - ['Invoice Pembelian','0'], - ['Surat Jalan','1'], - ['Berita Acara Serah Terima (BAST)','2'], - ['Faktur Pajak','3'], - ['Good Receipt (GR)','4'] - ] - dokumen_invoice = [] - if pengajuan_tempo.dokumen_invoice: - pengajuan_tempo_dokumen_invoice = pengajuan_tempo.dokumen_invoice - mapping_dokumen = {item[0]: item[1] for item in dokumen} - dokumen_invoice_list = [dokumen.strip() for dokumen in pengajuan_tempo_dokumen_invoice.split(',')] - dokumen_invoice = [mapping_dokumen.get(dokumen, '4') for dokumen in dokumen_invoice_list] - - data = { 'name' : pengajuan_tempo.name_tempo.name, 'industry_id' : pengajuan_tempo.industry_id_tempo.id, @@ -55,22 +40,27 @@ class ResPartner(models.Model): '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 '', '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 '', @@ -78,7 +68,8 @@ class ResPartner(models.Model): '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_invoice' : ','.join(dokumen_invoice) if dokumen_invoice else '', + 'dokumen_pengiriman_input' : pengajuan_tempo.dokumen_pengiriman_input if pengajuan_tempo.dokumen_pengiriman_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': [ diff --git a/indoteknik_api/models/res_users.py b/indoteknik_api/models/res_users.py index 0c7dd96f..93204a96 100644 --- a/indoteknik_api/models/res_users.py +++ b/indoteknik_api/models/res_users.py @@ -16,7 +16,11 @@ class ResUsers(models.Model): } partner_tempo = '' 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 '' + 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_payment_term() diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index b21b1965..d2395dc5 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -68,6 +68,7 @@ class ResPartner(models.Model): 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_pengiriman_input = fields.Char(string='Dokumen saat Pengiriman Barang input') dokumen_invoice = fields.Char(string='Dokumen yang dilampirkan saat Pengiriman Invoice') # Dokumen @@ -238,6 +239,7 @@ class ResPartner(models.Model): 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_pengiriman_input'] = vals.get('dokumen_pengiriman_input', self.dokumen_pengiriman_input) vals['dokumen_invoice'] = vals.get('dokumen_invoice', self.dokumen_invoice) # Dokumen @@ -296,6 +298,7 @@ class ResPartner(models.Model): 'tukar_invoice': vals.get('tukar_invoice'), 'jadwal_bayar': vals.get('jadwal_bayar'), 'dokumen_pengiriman': vals.get('dokumen_pengiriman'), + 'dokumen_pengiriman_input': vals.get('dokumen_pengiriman_input'), 'dokumen_invoice': vals.get('dokumen_invoice'), 'dokumen_nib': vals.get('dokumen_nib'), 'dokumen_npwp': vals.get('dokumen_npwp'), diff --git a/indoteknik_custom/models/user_pengajuan_tempo.py b/indoteknik_custom/models/user_pengajuan_tempo.py index b527fa4c..046c4cc7 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo.py +++ b/indoteknik_custom/models/user_pengajuan_tempo.py @@ -55,22 +55,27 @@ class UserPengajuanTempo(models.Model): return [('parent_id', '=', False)] # Kontak Perusahaan + direktur_tittle = fields.Char(string='tittle Direktur') direktur_name = fields.Char(string='Nama Lengkap Direktur') direktur_mobile = fields.Char(string='No. Telpon Direktur') direktur_email = fields.Char(string='Email Direktur') + purchasing_tittle = fields.Char(string='tittle Purchasing') purchasing_name = fields.Char(string='Nama Purchasing') purchasing_mobile = fields.Char(string='No. Telpon Purchasing') purchasing_email = fields.Char(string='Email Purchasing') + finance_tittle = fields.Char(string='tittle Finance') finance_name = fields.Char(string='Nama Finance') finance_mobile = fields.Char(string='No. Telpon Finance') finance_email = fields.Char(string='Email Finance') # Pengiriman + pic_tittle = fields.Char(string='Tittle PIC Penerimaan Barang') 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_tittle = fields.Char(string='Tittle PIC Penerimaan Invoice') invoice_pic = fields.Char(string='Nama PIC Penerimaan Invoice') street_invoice = fields.Char(string="Alamat Perusahaan") state_id_invoice = fields.Many2one('res.country.state', string='State') @@ -78,6 +83,7 @@ class UserPengajuanTempo(models.Model): 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_pengiriman_input = fields.Char(string='Dokumen saat Pengiriman Barang input') dokumen_invoice = fields.Char(string='Dokumen yang dilampirkan saat Pengiriman Invoice') is_same_address = fields.Boolean(string="Same Address pengiriman invoicr dan alamat pengiriman barang") is_same_address_street = fields.Boolean(string="Same Address pengiriman barang dan alamat bisnis") diff --git a/indoteknik_custom/models/user_pengajuan_tempo_request.py b/indoteknik_custom/models/user_pengajuan_tempo_request.py index 2d4875fb..74eda31f 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo_request.py +++ b/indoteknik_custom/models/user_pengajuan_tempo_request.py @@ -184,6 +184,50 @@ class UserPengajuanTempoRequest(models.Model): self.user_company_id.finance_mobile = self.pengajuan_tempo_id.finance_mobile self.user_company_id.finance_email = self.pengajuan_tempo_id.finance_email + # Data untuk kontak baru + contacts_data = [ + { + "type": "contact", + "name": self.pengajuan_tempo_id.direktur_name, + "email": self.pengajuan_tempo_id.direktur_email, + "phone": self.pengajuan_tempo_id.direktur_mobile, + }, + { + "type": "contact", + "name": self.pengajuan_tempo_id.purchasing_name, + "email": self.pengajuan_tempo_id.purchasing_email, + "phone": self.pengajuan_tempo_id.purchasing_mobile, + }, + { + "type": "contact", + "name": self.pengajuan_tempo_id.finance_name, + "email": self.pengajuan_tempo_id.finance_email, + "phone": self.pengajuan_tempo_id.finance_mobile, + }, + { + "type": "delivery", + "name": self.pengajuan_tempo_id.pic_name, + "street": self.pengajuan_tempo_id.street_pengiriman, + "state_id": self.pengajuan_tempo_id.state_id_pengiriman.id, + "city_id": self.pengajuan_tempo_id.city_id_pengiriman.id, + "zip": self.pengajuan_tempo_id.zip_pengiriman, + }, + { + "type": "invoice", + "name": self.pengajuan_tempo_id.invoice_pic, + "street": self.pengajuan_tempo_id.street_invoice, + "state_id": self.pengajuan_tempo_id.state_id_invoice.id, + "city_id": self.pengajuan_tempo_id.city_id_invoice.id, + }, + ] + + # 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 + }) + # Pengiriman self.user_company_id.pic_name = self.pengajuan_tempo_id.pic_name self.user_company_id.street_pengiriman = self.pengajuan_tempo_id.street_pengiriman @@ -197,6 +241,7 @@ class UserPengajuanTempoRequest(models.Model): self.user_company_id.tukar_invoice = self.pengajuan_tempo_id.tukar_invoice self.user_company_id.jadwal_bayar = self.pengajuan_tempo_id.jadwal_bayar self.user_company_id.dokumen_pengiriman = self.pengajuan_tempo_id.dokumen_pengiriman + self.user_company_id.dokumen_pengiriman_input = self.pengajuan_tempo_id.dokumen_pengiriman_input self.user_company_id.dokumen_invoice = self.pengajuan_tempo_id.dokumen_invoice # Referensi diff --git a/indoteknik_custom/views/res_partner.xml b/indoteknik_custom/views/res_partner.xml index 6ce340f3..91298319 100644 --- a/indoteknik_custom/views/res_partner.xml +++ b/indoteknik_custom/views/res_partner.xml @@ -141,6 +141,7 @@ + diff --git a/indoteknik_custom/views/user_pengajuan_tempo.xml b/indoteknik_custom/views/user_pengajuan_tempo.xml index 30d75fe8..a6360136 100644 --- a/indoteknik_custom/views/user_pengajuan_tempo.xml +++ b/indoteknik_custom/views/user_pengajuan_tempo.xml @@ -65,6 +65,7 @@ + diff --git a/indoteknik_custom/views/user_pengajuan_tempo_request.xml b/indoteknik_custom/views/user_pengajuan_tempo_request.xml index 17ae526c..2a3fc745 100644 --- a/indoteknik_custom/views/user_pengajuan_tempo_request.xml +++ b/indoteknik_custom/views/user_pengajuan_tempo_request.xml @@ -39,7 +39,7 @@ - + @@ -265,9 +265,11 @@
Keputusan ini telah kami pertimbangkan secara matang berdasarkan beberapa faktor, diantaranya alasan tidak disetujuinya adalah ${object.reason_reject}
Kami memahami bahwa hal ini mungkin mengecewakan. Namun, kami berharap Anda dapat memahami kebijakan perusahaan kami.
Jangan khawatir anda dapat melakukan pembelian dengan metode pembayaran CBD (Cash Before Delivery) di website indoteknik.com.
Terima kasih atas pengertiannya.
Terima kasih atas Perhatian & Pengertiannya.
Hormat kami,
PT. INDOTEKNIK DOTCOM GEMILANG
Hai. ${object.pengajuan_tempo_id.name_tempo.name},
Kabar baik! Kami dengan senang hati menginformasikan bahwa pengajuan tempo pembayaran kamu di Indoteknik.com telah disetujui dengan detail sebagai berikut.
Limit Pembayaran Tempo : Rp ${object.format_currency(object.pengajuan_tempo_id.tempo_limit)}
Limit Pembayaran Tempo : Rp ${object.format_currency(object.user_id.tempo_limit)}
Durasi Pembayaran Tempo : ${object.pengajuan_tempo_id.tempo_duration.name}
Durasi Pembayaran Tempo : ${object.user_id.tempo_duration.name}
Kamu dapat melakukan pembayaran sesuai dengan jangka waktu yang telah disepakati. Detail lengkap mengenai transaksi kamu, termasuk tanggal jatuh tempo & Pengajuan Kenaikan Limit Tempo, dapat kamu lihat di akun Profile Indoteknik.com .
@@ -322,7 +324,7 @@ Mohon Maaf Pengajuan Tempo anda kami Tolak "Indoteknik.com" <noreply@indoteknik.com> sales@indoteknik.com - ${object.pengajuan_tempo_id.user_id.login | safe} + ${object.user_id.email | safe} -- cgit v1.2.3 From 61427e249985af385de6619e8b362d249a68c688 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 13 Dec 2024 14:14:49 +0700 Subject: update pengajuan tempo --- indoteknik_api/controllers/api_v1/partner.py | 57 ++++++++-- indoteknik_api/models/res_partner.py | 41 ++++++- indoteknik_custom/models/res_partner.py | 40 ++++++- indoteknik_custom/models/user_pengajuan_tempo.py | 36 ++++-- .../models/user_pengajuan_tempo_request.py | 122 +++++++++++++++++---- indoteknik_custom/views/res_partner.xml | 18 ++- indoteknik_custom/views/user_pengajuan_tempo.xml | 20 +++- .../views/user_pengajuan_tempo_request.xml | 27 +++-- 8 files changed, 290 insertions(+), 71 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/partner.py b/indoteknik_api/controllers/api_v1/partner.py index ebf5de08..c0088d38 100644 --- a/indoteknik_api/controllers/api_v1/partner.py +++ b/indoteknik_api/controllers/api_v1/partner.py @@ -138,6 +138,8 @@ class Partner(controller.Controller): 'npwp': [], 'alamat_lengkap_text': [], 'street': [], + 'email': [], + 'mobile': [] }) # Mengambil id_user dari request @@ -297,6 +299,8 @@ class Partner(controller.Controller): 'street': ['alias:street_tempo'], 'state': ['alias:state_id_tempo'], 'city': ['alias:city_id_tempo'], + 'district': ['alias:district_id_tempo'], + 'subDistrict': ['alias:subDistrict_id_tempo'], 'zip': ['alias:zip_tempo'], 'mobile': ['alias:mobile_tempo'], 'bankName': ['alias:bank_name_tempo'], @@ -304,6 +308,8 @@ class Partner(controller.Controller): 'accountNumber': ['alias:account_number_tempo'], 'website': ['alias:website_tempo'], 'estimasi': ['alias:estimasi_tempo'], + 'portal': ['alias:portal'], + 'bersedia': ['alias:bersedia'], 'tempoDuration': ['alias:tempo_duration'], 'tempoLimit': ['alias:tempo_limit'], @@ -327,27 +333,38 @@ class Partner(controller.Controller): 'streetPengiriman': ['alias:street_pengiriman'], 'statePengiriman': ['alias:state_id_pengiriman'], 'cityPengiriman': ['alias:city_id_pengiriman'], + 'districtPengiriman': ['alias:district_id_pengiriman'], + 'subDistrictPengiriman': ['alias:subDistrict_id_pengiriman'], 'zipPengiriman': ['alias:zip_pengiriman'], 'invoicePicTittle': ['alias:invoice_pic_tittle'], 'invoicePic': ['alias:invoice_pic'], 'streetInvoice': ['alias:street_invoice'], 'stateInvoice': ['alias:state_id_invoice'], 'cityInvoice': ['alias:city_id_invoice'], + 'districtInvoice': ['alias:district_id_invoice'], + 'subDistrictInvoice': ['alias:subDistrict_id_invoice'], + 'zipInvoice': ['alias:zip_invoice'], + 'isSameAddrees':['alias:is_same_address'], + 'isSameAddreesStreet':['alias:is_same_address_street'], }) - # Konversi nilai 'true' ke boolean True - is_same_address = kw.get('isSameAddrees', 'false').lower() == 'true' - is_same_address_street = kw.get('isSameAddreesStreet', 'false').lower() == 'true' - - # Tambahkan nilai yang dikonversi ke params - if kw.get('isSameAddrees') != '': - params['value']['is_same_address'] = is_same_address - if kw.get('isSameAddreesStreet') != '': - params['value']['is_same_address_street'] = is_same_address_street + # # Konversi nilai 'true' ke boolean True + # is_same_address = kw.get('isSameAddrees', 'false').lower() == 'true' + # is_same_address_street = kw.get('isSameAddreesStreet', 'false').lower() == 'true' + # + # # Tambahkan nilai yang dikonversi ke params + # if 'isSameAddress' in kw: + # params['value']['is_same_address'] = is_same_address + # if 'is_same_address_street' in kw: + # params['value']['is_same_address_street'] = is_same_address_street if not params['valid']: return self.response(code=400, description=params) - + if params['value']['portal']: + if params['value']['portal'] == 'ada': + params['value']['portal'] = True + else: + params['value']['portal'] = False # Filter data baru yang dikirim (non-kosong, boolean False tetap masuk) new_data = {key: value for key, value in params['value'].items() if value != ''} @@ -413,13 +430,17 @@ class Partner(controller.Controller): ] dokumen_kirim_barang_ids = kw.get('dokumenPengiriman') + dokumen_kirim_input = kw.get('dokumenKirimInput', '') dokumen_kirim_barang_input = kw.get('dokumenPengirimanInput', '') dokumen_kirim_barang = [] if dokumen_kirim_barang_ids: dokumen_kirim_ids = list(map(int, dokumen_kirim_barang_ids.split(','))) dokumen_kirim_barang = [dokumen_kirim[i] for i in dokumen_kirim_ids if 0 <= i < len(dokumen_kirim)] - + if dokumen_kirim_input: + input_items = [item.strip() for item in dokumen_kirim_input.split(',')] + dokumen_kirim_barang.extend(item for item in input_items if item and item not in dokumen_kirim_barang) + pengajuan_tempo.dokumen_kirim_input = dokumen_kirim_input if dokumen_kirim_barang: pengajuan_tempo.dokumen_pengiriman = ', '.join(dokumen_kirim_barang) if dokumen_kirim_barang_input: @@ -468,6 +489,18 @@ class Partner(controller.Controller): if dokumen['documentName'] == 'dokumenNib': pengajuan_tempo.dokumen_nib = [(6, 0, [sppkp_attachment.id])] + elif dokumen['documentName'] == 'dokumenSiup': + pengajuan_tempo.dokumen_siup = [(6, 0, [sppkp_attachment.id])] + + elif dokumen['documentName'] == 'dokumenTdp': + pengajuan_tempo.dokumen_tdp = [(6, 0, [sppkp_attachment.id])] + + elif dokumen['documentName'] == 'dokumenSkdp': + pengajuan_tempo.dokumen_skdp = [(6, 0, [sppkp_attachment.id])] + + elif dokumen['documentName'] == 'dokumenSkt': + pengajuan_tempo.dokumen_skt = [(6, 0, [sppkp_attachment.id])] + elif dokumen['documentName'] == 'dokumenNpwp': pengajuan_tempo.dokumen_npwp = [(6, 0, [sppkp_attachment.id])] @@ -503,7 +536,7 @@ class Partner(controller.Controller): except json.JSONDecodeError: return http.Response(status=400, json_body={'error': 'Invalid JSON format for formDokumen'}) - + if tempo_request: # pengajuan_tempo.user_id = id template = pengajuan_tempo.env.ref('indoteknik_custom.mail_template_res_user_company_request_tempo_review') template.send_mail(pengajuan_tempo.id, force_send=True) diff --git a/indoteknik_api/models/res_partner.py b/indoteknik_api/models/res_partner.py index f73101db..258d8143 100644 --- a/indoteknik_api/models/res_partner.py +++ b/indoteknik_api/models/res_partner.py @@ -28,6 +28,8 @@ class ResPartner(models.Model): '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, @@ -35,6 +37,8 @@ class ResPartner(models.Model): '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 '', @@ -59,16 +63,22 @@ class ResPartner(models.Model): '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, @@ -85,12 +95,6 @@ class ResPartner(models.Model): ] if pengajuan_tempo.supplier_ids else '', # Dokumen - 'dokumen_nib': - { - 'name': pengajuan_tempo.dokumen_nib.name, - 'base64': pengajuan_tempo.dokumen_nib.local_url, - } - if pengajuan_tempo.dokumen_nib else '', 'dokumen_npwp': { 'name': pengajuan_tempo.dokumen_npwp.name, @@ -100,6 +104,31 @@ class ResPartner(models.Model): 'name': pengajuan_tempo.dokumen_sppkp.name, 'base64': pengajuan_tempo.dokumen_sppkp.local_url, } if pengajuan_tempo.dokumen_sppkp else '', + 'dokumen_nib': + { + 'name': pengajuan_tempo.dokumen_nib.name, + 'base64': pengajuan_tempo.dokumen_nib.local_url, + }if pengajuan_tempo.dokumen_nib else '', + 'dokumen_siup': + { + 'name': pengajuan_tempo.dokumen_siup.name, + 'base64': pengajuan_tempo.dokumen_siup.local_url, + }if pengajuan_tempo.dokumen_siup else '', + 'dokumen_tdp': + { + 'name': pengajuan_tempo.dokumen_tdp.name, + 'base64': pengajuan_tempo.dokumen_tdp.local_url, + }if pengajuan_tempo.dokumen_tdp else '', + 'dokumen_skdp': + { + 'name': pengajuan_tempo.dokumen_skdp.name, + 'base64': pengajuan_tempo.dokumen_skdp.local_url, + }if pengajuan_tempo.dokumen_skdp else '', + 'dokumen_skt': + { + 'name': pengajuan_tempo.dokumen_skt.name, + 'base64': pengajuan_tempo.dokumen_skt.local_url, + }if pengajuan_tempo.dokumen_skt else '', 'dokumen_akta_perubahan': { 'name': pengajuan_tempo.dokumen_akta_perubahan.name, 'base64': pengajuan_tempo.dokumen_akta_perubahan.local_url, diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index 835ac65d..93125bb9 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -35,6 +35,7 @@ class ResPartner(models.Model): account_name_tempo = fields.Char(string="Nama Rekening") account_number_tempo = fields.Char(string="Nomor Rekening Bank") website_tempo = fields.Char(string='Website') + portal = fields.Boolean(string='Portal Website') estimasi_tempo = fields.Char(string='Estimasi Pembelian Pertahun') tempo_duration = fields.Many2one('account.payment.term', string='Durasi Tempo') tempo_limit = fields.Char(string='Limit Tempo') @@ -60,21 +61,30 @@ class ResPartner(models.Model): 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') + district_id_pengiriman = fields.Many2one('vit.kecamatan', string='Kecamatan') + subDistrict_id_pengiriman = fields.Many2one('vit.kelurahan', string='Kelurahan') zip_pengiriman = fields.Char(string="Zip") invoice_pic = fields.Char(string='Nama PIC Penerimaan Invoice') street_invoice = fields.Char(string="Alamat Perusahaan") state_id_invoice = fields.Many2one('res.country.state', string='State') city_id_invoice = fields.Many2one('vit.kota', string='City') + district_id_invoice = fields.Many2one('vit.kecamatan', string='Kecamatan') + subDistrict_id_invoice = fields.Many2one('vit.kelurahan', string='Kelurahan') + zip_invoice = fields.Char(string="Zip") 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_pengiriman_input = fields.Char(string='Dokumen saat Pengiriman Barang input') + dokumen_pengiriman = fields.Char(string='Dokumen Tanda Terima yang Diberikan Pada Saat Pengiriman Barang') + dokumen_pengiriman_input = fields.Char(string='Dokumen yang Dibawa Saat Pengiriman Barang') dokumen_invoice = fields.Char(string='Dokumen yang dilampirkan saat Pengiriman Invoice') # Dokumen - dokumen_nib = fields.Many2one('ir.attachment', string="NIB (SIUP/TDP/SKDP)", tracking=3, readonly=True,) dokumen_npwp = fields.Many2one('ir.attachment', string="NPWP Perusahaan", tracking=3, readonly=True) dokumen_sppkp = fields.Many2one('ir.attachment', string="SPPKP Perusahaan", tracking=3, readonly=True) + dokumen_nib = fields.Many2one('ir.attachment', string="NIB (SIUP/TDP/SKDP)", tracking=3, readonly=True,) + dokumen_siup = fields.Many2many('ir.attachment', 'pengajuan_dokumen_siup_rel', string="SIUP Perusahaan", tracking=True) + dokumen_tdp = fields.Many2many('ir.attachment', 'pengajuan_dokumen_tdp_rel', string="TDP Perusahaan", tracking=True) + dokumen_skdp = fields.Many2many('ir.attachment', 'pengajuan_dokumen_skdp_rel', string="SKDP Perusahaan",tracking=True) + dokumen_skt = fields.Many2many('ir.attachment', 'pengajuan_dokumen_skt_rel', string="SKT Perusahaan", tracking=True) dokumen_akta_perubahan = fields.Many2one('ir.attachment', string="Akta Perubahan", tracking=3, readonly=True) dokumen_ktp_dirut = fields.Many2one('ir.attachment', string="KTP Dirut/Direktur", tracking=3, readonly=True) dokumen_akta_pendirian = fields.Many2one('ir.attachment', string="Akta Pendirian", tracking=3, readonly=True) @@ -210,6 +220,7 @@ class ResPartner(models.Model): 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['portal'] = vals.get('portal', self.portal) 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) @@ -231,11 +242,16 @@ class ResPartner(models.Model): 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['district_id_pengiriman'] = vals.get('district_id_pengiriman', self.district_id_pengiriman) + vals['subDistrict_id_pengiriman'] = vals.get('subDistrict_id_pengiriman', self.subDistrict_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['district_id_invoice'] = vals.get('district_id_invoice', self.district_id_invoice) + vals['subDistrict_id_invoice'] = vals.get('subDistrict_id_invoice', self.subDistrict_id_invoice) + vals['zip_invoice'] = vals.get('zip_invoice', self.zip_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) @@ -243,9 +259,13 @@ class ResPartner(models.Model): 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_nib'] = vals.get('dokumen_nib', self.dokumen_nib) + vals['dokumen_siup'] = vals.get('dokumen_siup', self.dokumen_siup) + vals['dokumen_tdp'] = vals.get('dokumen_tdp', self.dokumen_tdp) + vals['dokumen_skdp'] = vals.get('dokumen_skdp', self.dokumen_skdp) + vals['dokumen_skt'] = vals.get('dokumen_skt', self.dokumen_skt) 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) @@ -273,6 +293,7 @@ class ResPartner(models.Model): 'account_name_tempo': vals.get('account_name_tempo'), 'account_number_tempo': vals.get('account_number_tempo'), 'website_tempo': vals.get('website_tempo'), + 'portal': vals.get('portal'), 'estimasi_tempo': vals.get('estimasi_tempo'), 'tempo_duration': vals.get('tempo_duration'), 'tempo_limit': vals.get('tempo_limit'), @@ -290,19 +311,28 @@ class ResPartner(models.Model): 'street_pengiriman': vals.get('street_pengiriman'), 'state_id_pengiriman': vals.get('state_id_pengiriman'), 'city_id_pengiriman': vals.get('city_id_pengiriman'), + 'district_id_pengiriman': vals.get('district_id_pengiriman'), + 'subDistrict_id_pengiriman': vals.get('subDistrict_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'), + 'district_id_invoice': vals.get('district_id_invoice'), + 'subDistrict_id_invoice': vals.get('subDistrict_id_invoice'), + 'zip_invoice': vals.get('zip_invoice'), 'tukar_invoice': vals.get('tukar_invoice'), 'jadwal_bayar': vals.get('jadwal_bayar'), 'dokumen_pengiriman': vals.get('dokumen_pengiriman'), 'dokumen_pengiriman_input': vals.get('dokumen_pengiriman_input'), '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_nib': vals.get('dokumen_nib'), + 'dokumen_siup': vals.get('dokumen_siup'), + 'dokumen_tdp': vals.get('dokumen_tdp'), + 'dokumen_skdp': vals.get('dokumen_skdp'), + 'dokumen_skt': vals.get('dokumen_skt'), 'dokumen_akta_perubahan': vals.get('dokumen_akta_perubahan'), 'dokumen_ktp_dirut': vals.get('dokumen_ktp_dirut'), 'dokumen_akta_pendirian': vals.get('dokumen_akta_pendirian'), diff --git a/indoteknik_custom/models/user_pengajuan_tempo.py b/indoteknik_custom/models/user_pengajuan_tempo.py index b347e75e..3d8fcb4f 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo.py +++ b/indoteknik_custom/models/user_pengajuan_tempo.py @@ -39,12 +39,16 @@ class UserPengajuanTempo(models.Model): 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') + district_id_tempo = fields.Many2one('vit.kecamatan', string='Kecamatan') + subDistrict_id_tempo = fields.Many2one('vit.kelurahan', string='Kelurahan') 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') + portal = fields.Boolean(string='Portal Website') + bersedia = fields.Char(string='Website') estimasi_tempo = fields.Char(string='Estimasi Pembelian Pertahun') tempo_duration = fields.Many2one('account.payment.term', string='Durasi Tempo') tempo_limit = fields.Char(string='Limit Tempo') @@ -74,16 +78,22 @@ class UserPengajuanTempo(models.Model): 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') + district_id_pengiriman = fields.Many2one('vit.kecamatan', string='Kecamatan') + subDistrict_id_pengiriman = fields.Many2one('vit.kelurahan', string='Kelurahan') zip_pengiriman = fields.Char(string="Zip") invoice_pic_tittle = fields.Char(string='Tittle PIC Penerimaan Invoice') invoice_pic = fields.Char(string='Nama PIC Penerimaan Invoice') street_invoice = fields.Char(string="Alamat Perusahaan") state_id_invoice = fields.Many2one('res.country.state', string='State') city_id_invoice = fields.Many2one('vit.kota', string='City') + district_id_invoice = fields.Many2one('vit.kecamatan', string='Kecamatan') + subDistrict_id_invoice = fields.Many2one('vit.kelurahan', string='Kelurahan') + zip_invoice = fields.Char(string="Zip") 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_pengiriman_input = fields.Char(string='Dokumen saat Pengiriman Barang input') + dokumen_pengiriman = fields.Char(string='Dokumen Tanda Terima yang Diberikan Pada Saat Pengiriman Barang') + dokumen_kirim_input = fields.Char(string='Dokumen lain yang diterima saat pengiriman barang') + dokumen_pengiriman_input = fields.Char(string='Dokumen yang Dibawa Saat Pengiriman Barang') dokumen_invoice = fields.Char(string='Dokumen yang dilampirkan saat Pengiriman Invoice') is_same_address = fields.Boolean(string="Same Address pengiriman invoicr dan alamat pengiriman barang") is_same_address_street = fields.Boolean(string="Same Address pengiriman barang dan alamat bisnis") @@ -92,21 +102,25 @@ class UserPengajuanTempo(models.Model): 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") - dokumen_npwp = fields.Many2many('ir.attachment', 'pengajuan_dokumen_npwp_rel', string="NPWP Perusahaan", tracking=3) - dokumen_sppkp = fields.Many2many('ir.attachment', 'pengajuan_dokumen_sppkp_rel', string="SPPKP Perusahaan", tracking=3) + dokumen_nib = fields.Many2many('ir.attachment', 'pengajuan_dokumen_nib_rel', string="NIB", tracking=True, track_visibility="onchange") + dokumen_npwp = fields.Many2many('ir.attachment', 'pengajuan_dokumen_npwp_rel', string="NPWP Perusahaan", tracking=True) + dokumen_sppkp = fields.Many2many('ir.attachment', 'pengajuan_dokumen_sppkp_rel', string="SPPKP Perusahaan", tracking=True) + dokumen_siup = fields.Many2many('ir.attachment', 'pengajuan_dokumen_siup_rel', string="SIUP Perusahaan", tracking=True) + dokumen_tdp = fields.Many2many('ir.attachment', 'pengajuan_dokumen_tdp_rel', string="TDP Perusahaan", tracking=True) + dokumen_skdp = fields.Many2many('ir.attachment', 'pengajuan_dokumen_skdp_rel', string="SKDP Perusahaan", tracking=True) + dokumen_skt = fields.Many2many('ir.attachment', 'pengajuan_dokumen_skt_rel', string="SKT Perusahaan", tracking=True) dokumen_akta_perubahan = fields.Many2many('ir.attachment', 'pengajuan_dokumen_akta_perubahan_rel', - string="Akta Perubahan", tracking=3) + string="Akta Perubahan", tracking=True) dokumen_ktp_dirut = fields.Many2many('ir.attachment', 'pengajuan_dokumen_ktp_dirut_rel', - string="KTP Dirut/Direktur", tracking=3) + string="KTP Dirut/Direktur", tracking=True) dokumen_akta_pendirian = fields.Many2many('ir.attachment', 'pengajuan_dokumen_angkta_pendirian_rel', - string="Akta Pendirian", tracking=3) + string="Akta Pendirian", tracking=True) dokumen_laporan_keuangan = fields.Many2many('ir.attachment', 'pengajuan_dokumen_laporan_keuangan_rel', - string="Laporan Keuangan", tracking=3) + string="Laporan Keuangan", tracking=True) dokumen_foto_kantor = fields.Many2many('ir.attachment', 'pengajuan_dokumen_foto_kantor_rel', - string=" Foto Kantor (Tampak Depan)", tracking=3) + string=" Foto Kantor (Tampak Depan)", tracking=True) dokumen_tempat_bekerja = fields.Many2many('ir.attachment', 'pengajuan_dokumen_tempat_bekerja_rel', - string="Tempat Bekerja", tracking=3) + string="Tempat Bekerja", tracking=True) @api.depends('name', 'name_tempo') def name_get(self): diff --git a/indoteknik_custom/models/user_pengajuan_tempo_request.py b/indoteknik_custom/models/user_pengajuan_tempo_request.py index 452e4763..c181ab68 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo_request.py +++ b/indoteknik_custom/models/user_pengajuan_tempo_request.py @@ -69,6 +69,7 @@ class UserPengajuanTempoRequest(models.Model): account_name_tempo = fields.Char(string="Nama Rekening", related='pengajuan_tempo_id.account_name_tempo', store=True, tracking=True, readonly=False) account_number_tempo = fields.Char(string="Nomor Rekening Bank", related='pengajuan_tempo_id.account_number_tempo', store=True, tracking=True, readonly=False) website_tempo = fields.Char(string='Website', related='pengajuan_tempo_id.website_tempo', store=True, tracking=True, readonly=False) + portal = fields.Boolean(string='Portal Website', related='pengajuan_tempo_id.portal', store=True, tracking=True, readonly=False) estimasi_tempo = fields.Char(string='Estimasi Pembelian Pertahun', related='pengajuan_tempo_id.estimasi_tempo', store=True, tracking=True, readonly=False) tempo_duration_origin = fields.Many2one('account.payment.term', string='Durasi Tempo', related='pengajuan_tempo_id.tempo_duration', store=True, tracking=True, readonly=False, domain=[('id', 'in', [24, 25, 29, 32])]) tempo_limit_origin = fields.Char(string='Limit Tempo', related='pengajuan_tempo_id.tempo_limit' , store=True, tracking=True, readonly=False) @@ -91,16 +92,21 @@ class UserPengajuanTempoRequest(models.Model): street_pengiriman = fields.Char(string="Alamat Perusahaan", related='pengajuan_tempo_id.street_pengiriman', store=True, readonly=False) state_id_pengiriman = fields.Many2one('res.country.state', string='State', related='pengajuan_tempo_id.state_id_pengiriman', store=True, readonly=False) city_id_pengiriman = fields.Many2one('vit.kota', string='City', related='pengajuan_tempo_id.city_id_pengiriman', store=True, readonly=False) + district_id_pengiriman = fields.Many2one('vit.kecamatan', string='Kecamatan',related='pengajuan_tempo_id.district_id_pengiriman', store=True, readonly=False) + subDistrict_id_pengiriman = fields.Many2one('vit.kelurahan', string='Kelurahan', related='pengajuan_tempo_id.subDistrict_id_pengiriman', store=True, readonly=False) zip_pengiriman = fields.Char(string="Zip", related='pengajuan_tempo_id.zip_pengiriman', store=True, readonly=False) invoice_pic_tittle = fields.Char(string='Tittle PIC Penerimaan Invoice', related='pengajuan_tempo_id.invoice_pic_tittle', store=True, readonly=False) invoice_pic = fields.Char(string='Nama PIC Penerimaan Invoice', related='pengajuan_tempo_id.invoice_pic', store=True, readonly=False) street_invoice = fields.Char(string="Alamat Perusahaan", related='pengajuan_tempo_id.street_invoice', store=True, readonly=False) state_id_invoice = fields.Many2one('res.country.state', string='State', related='pengajuan_tempo_id.state_id_invoice', store=True, readonly=False) city_id_invoice = fields.Many2one('vit.kota', string='City', related='pengajuan_tempo_id.city_id_invoice', store=True, readonly=False) + district_id_invoice = fields.Many2one('vit.kecamatan', string='Kecamatan', related='pengajuan_tempo_id.district_id_invoice', store=True, readonly=False) + subDistrict_id_invoice = fields.Many2one('vit.kelurahan', string='Kelurahan', related='pengajuan_tempo_id.subDistrict_id_invoice', store=True, readonly=False) + zip_invoice = fields.Char(string="Zip", related='pengajuan_tempo_id.zip_invoice', store=True, readonly=False) tukar_invoice = fields.Char(string='Jadwal Penukaran Invoice', related='pengajuan_tempo_id.tukar_invoice', store=True, readonly=False) jadwal_bayar = fields.Char(string='Jadwal Pembayaran', related='pengajuan_tempo_id.jadwal_bayar', store=True, readonly=False) - dokumen_pengiriman = fields.Char(string='Dokumen saat Pengiriman Barang', related='pengajuan_tempo_id.dokumen_pengiriman', store=True, readonly=False) - dokumen_pengiriman_input = fields.Char(string='Dokumen saat Pengiriman Barang input', related='pengajuan_tempo_id.dokumen_pengiriman_input', store=True, readonly=False) + dokumen_pengiriman = fields.Char(string='Dokumen Tanda Terima yang Diberikan Pada Saat Pengiriman Barang', related='pengajuan_tempo_id.dokumen_pengiriman', store=True, readonly=False) + dokumen_pengiriman_input = fields.Char(string='Dokumen yang dibawa saat pengiriman barang', related='pengajuan_tempo_id.dokumen_pengiriman_input', store=True, readonly=False) dokumen_invoice = fields.Char(string='Dokumen yang dilampirkan saat Pengiriman Invoice', related='pengajuan_tempo_id.dokumen_invoice', store=True, readonly=False) is_same_address = fields.Boolean(string="Same Address pengiriman invoicr dan alamat pengiriman barang", related='pengajuan_tempo_id.is_same_address', store=True, readonly=False) is_same_address_street = fields.Boolean(string="Same Address pengiriman barang dan alamat bisnis", related='pengajuan_tempo_id.is_same_address_street', store=True, readonly=False) @@ -109,16 +115,6 @@ class UserPengajuanTempoRequest(models.Model): supplier_ids = fields.Many2many('user.pengajuan.tempo.line',related='pengajuan_tempo_id.supplier_ids', string="Suppliers", readonly=False) # Dokumen - dokumen_nib = fields.Many2many( - 'ir.attachment', - 'pengajuan_dokumen_nib_rel', - string="NIB (SIUP/TDP/SKDP)", - related='pengajuan_tempo_id.dokumen_nib', - readonly=False, - tracking=3, - track_visibility="onchange" - ) - dokumen_npwp = fields.Many2many( 'ir.attachment', 'pengajuan_dokumen_npwp_rel', @@ -136,6 +132,53 @@ class UserPengajuanTempoRequest(models.Model): readonly=False, tracking=3 ) + dokumen_nib = fields.Many2many( + 'ir.attachment', + 'pengajuan_dokumen_nib_rel', + string="NIB", + related='pengajuan_tempo_id.dokumen_nib', + readonly=False, + tracking=3, + track_visibility="onchange" + ) + dokumen_siup = fields.Many2many( + 'ir.attachment', + 'pengajuan_dokumen_siup_rel', + string="SIUP", + related='pengajuan_tempo_id.dokumen_siup', + readonly=False, + tracking=3, + track_visibility="onchange" + ) + + dokumen_tdp = fields.Many2many( + 'ir.attachment', + 'pengajuan_dokumen_tdp_rel', + string="TDP", + related='pengajuan_tempo_id.dokumen_tdp', + readonly=False, + tracking=3, + track_visibility="onchange" + ) + dokumen_skdp = fields.Many2many( + 'ir.attachment', + 'pengajuan_dokumen_skdp_rel', + string="SKDP", + related='pengajuan_tempo_id.dokumen_skdp', + readonly=False, + tracking=3, + track_visibility="onchange" + ) + + dokumen_skt = fields.Many2many( + 'ir.attachment', + 'pengajuan_dokumen_skt_rel', + string="SKT", + related='pengajuan_tempo_id.dokumen_skt', + readonly=False, + tracking=3, + track_visibility="onchange" + ) dokumen_akta_perubahan = fields.Many2many( 'ir.attachment', @@ -208,6 +251,7 @@ class UserPengajuanTempoRequest(models.Model): self.pengajuan_tempo_id.account_name_tempo = self.account_name_tempo self.pengajuan_tempo_id.account_number_tempo = self.account_number_tempo self.pengajuan_tempo_id.website_tempo = self.website_tempo + self.pengajuan_tempo_id.portal = self.portal self.pengajuan_tempo_id.estimasi_tempo = self.estimasi_tempo self.pengajuan_tempo_id.tempo_duration = self.tempo_duration_origin self.pengajuan_tempo_id.tempo_limit = self.tempo_limit_origin @@ -229,8 +273,9 @@ class UserPengajuanTempoRequest(models.Model): self.pengajuan_tempo_id.finance_email = self.finance_email @api.onchange('pic_tittle', 'pic_name', 'street_pengiriman', 'state_id_pengiriman', 'city_id_pengiriman', - 'zip_pengiriman', + 'zip_pengiriman', 'district_id_pengiriman', 'subDistrict_id_pengiriman' 'invoice_pic_tittle', 'invoice_pic', 'street_invoice', 'state_id_invoice', 'city_id_invoice', + 'district_id_invoice', 'subDistrict_id_invoice', 'zip_invoice', 'tukar_invoice', 'jadwal_bayar', 'dokumen_pengiriman', 'dokumen_pengiriman_input', 'dokumen_invoice', 'is_same_address', 'is_same_address_street') def _onchange_related_fields_pengiriman(self): @@ -241,12 +286,17 @@ class UserPengajuanTempoRequest(models.Model): self.pengajuan_tempo_id.street_pengiriman = self.street_pengiriman self.pengajuan_tempo_id.state_id_pengiriman = self.state_id_pengiriman self.pengajuan_tempo_id.city_id_pengiriman = self.city_id_pengiriman + self.pengajuan_tempo_id.district_id_pengiriman = self.district_id_pengiriman + self.pengajuan_tempo_id.subDistrict_id_pengiriman = self.subDistrict_id_pengiriman self.pengajuan_tempo_id.zip_pengiriman = self.zip_pengiriman self.pengajuan_tempo_id.invoice_pic_tittle = self.invoice_pic_tittle self.pengajuan_tempo_id.invoice_pic = self.invoice_pic self.pengajuan_tempo_id.street_invoice = self.street_invoice self.pengajuan_tempo_id.state_id_invoice = self.state_id_invoice self.pengajuan_tempo_id.city_id_invoice = self.city_id_invoice + self.pengajuan_tempo_id.district_id_invoice = self.district_id_invoice + self.pengajuan_tempo_id.subDistrict_id_invoice = self.subDistrict_id_invoice + self.pengajuan_tempo_id.zip_invoice = self.zip_invoice self.pengajuan_tempo_id.tukar_invoice = self.tukar_invoice self.pengajuan_tempo_id.jadwal_bayar = self.jadwal_bayar self.pengajuan_tempo_id.dokumen_pengiriman = self.dokumen_pengiriman @@ -262,11 +312,16 @@ class UserPengajuanTempoRequest(models.Model): @api.onchange('dokumen_nib', 'dokumen_npwp', 'dokumen_sppkp', 'dokumen_akta_perubahan', 'dokumen_ktp_dirut', 'dokumen_akta_pendirian', 'dokumen_laporan_keuangan', - 'dokumen_foto_kantor', 'dokumen_tempat_bekerja') + 'dokumen_foto_kantor', 'dokumen_tempat_bekerja', 'dokumen_skdp', 'dokumen_skt', 'dokumen_siup', + 'dokumen_tdp') def _onchange_related_fields_dokumen(self): if self.pengajuan_tempo_id: # Perbarui nilai di pengajuan_tempo_id self.pengajuan_tempo_id.dokumen_nib = self.dokumen_nib + self.pengajuan_tempo_id.dokumen_siup = self.dokumen_siup + self.pengajuan_tempo_id.dokumen_tdp = self.dokumen_tdp + self.pengajuan_tempo_id.dokumen_skdp = self.dokumen_skdp + self.pengajuan_tempo_id.dokumen_skt = self.dokumen_skt self.pengajuan_tempo_id.dokumen_npwp = self.dokumen_npwp self.pengajuan_tempo_id.dokumen_sppkp = self.dokumen_sppkp self.pengajuan_tempo_id.dokumen_akta_perubahan = self.dokumen_akta_perubahan @@ -388,6 +443,7 @@ class UserPengajuanTempoRequest(models.Model): self.user_company_id.account_name_tempo = self.pengajuan_tempo_id.account_name_tempo self.user_company_id.account_number_tempo = self.pengajuan_tempo_id.account_number_tempo self.user_company_id.website_tempo = self.pengajuan_tempo_id.website_tempo + self.user_company_id.portal = self.pengajuan_tempo_id.portal self.user_company_id.estimasi_tempo = self.pengajuan_tempo_id.estimasi_tempo self.user_company_id.tempo_duration = tempo_duration.id self.user_company_id.tempo_limit = limit_tempo @@ -432,7 +488,9 @@ class UserPengajuanTempoRequest(models.Model): "name": self.pengajuan_tempo_id.pic_name, "street": self.pengajuan_tempo_id.street_pengiriman, "state_id": self.pengajuan_tempo_id.state_id_pengiriman.id, - "city": self.pengajuan_tempo_id.city_id_pengiriman.id, + "kota_id": self.pengajuan_tempo_id.city_id_pengiriman.id, + "kecamatan_id": self.pengajuan_tempo_id.district_id_pengiriman.id, + "kelurahan_id": self.pengajuan_tempo_id.subDistrict_id_pengiriman.id, "zip": self.pengajuan_tempo_id.zip_pengiriman, }, { @@ -440,7 +498,10 @@ class UserPengajuanTempoRequest(models.Model): "name": self.pengajuan_tempo_id.invoice_pic, "street": self.pengajuan_tempo_id.street_invoice, "state_id": self.pengajuan_tempo_id.state_id_invoice.id, - "city": self.pengajuan_tempo_id.city_id_invoice.id, + "kota_id": self.pengajuan_tempo_id.city_id_invoice.id, + "kecamatan_id": self.pengajuan_tempo_id.district_id_invoice.id, + "kelurahan_id": self.pengajuan_tempo_id.subDistrict_id_invoice.id, + "zip": self.pengajuan_tempo_id.zip_invoice.id, }, ] @@ -456,11 +517,16 @@ class UserPengajuanTempoRequest(models.Model): self.user_company_id.street_pengiriman = self.pengajuan_tempo_id.street_pengiriman self.user_company_id.state_id_pengiriman = self.pengajuan_tempo_id.state_id_pengiriman self.user_company_id.city_id_pengiriman = self.pengajuan_tempo_id.city_id_pengiriman + self.user_company_id.district_id_pengiriman = self.pengajuan_tempo_id.district_id_pengiriman + self.user_company_id.subDistrict_id_pengiriman = self.pengajuan_tempo_id.subDistrict_id_pengiriman self.user_company_id.zip_pengiriman = self.pengajuan_tempo_id.zip_pengiriman self.user_company_id.invoice_pic = self.pengajuan_tempo_id.invoice_pic self.user_company_id.street_invoice = self.pengajuan_tempo_id.street_invoice self.user_company_id.state_id_invoice = self.pengajuan_tempo_id.state_id_invoice self.user_company_id.city_id_invoice = self.pengajuan_tempo_id.city_id_invoice + self.user_company_id.district_id_invoice = self.pengajuan_tempo_id.district_id_invoice + self.user_company_id.subDistrict_id_invoice = self.pengajuan_tempo_id.subDistrict_id_invoice + self.user_company_id.zip_invoice = self.pengajuan_tempo_id.zip_invoice self.user_company_id.tukar_invoice = self.pengajuan_tempo_id.tukar_invoice self.user_company_id.jadwal_bayar = self.pengajuan_tempo_id.jadwal_bayar self.user_company_id.dokumen_pengiriman = self.pengajuan_tempo_id.dokumen_pengiriman @@ -471,10 +537,6 @@ class UserPengajuanTempoRequest(models.Model): self.user_company_id.supplier_ids = self.pengajuan_tempo_id.supplier_ids # Dokumen - self.user_company_id.dokumen_nib = self.pengajuan_tempo_id.dokumen_nib[0] - if self.user_company_id.dokumen_nib: - self.user_company_id.message_post(body='Dokumen NIB', attachment_ids=[self.user_company_id.dokumen_nib.id]) - self.user_company_id.dokumen_npwp = self.pengajuan_tempo_id.dokumen_npwp[0] if self.user_company_id.dokumen_npwp: self.user_company_id.message_post(body='Dokumen NPWP', attachment_ids=[self.user_company_id.dokumen_npwp.id]) @@ -483,6 +545,26 @@ class UserPengajuanTempoRequest(models.Model): if self.user_company_id.dokumen_sppkp: self.user_company_id.message_post(body='Dokumen SPPKP', attachment_ids=[self.user_company_id.dokumen_sppkp.id]) + self.user_company_id.dokumen_nib = self.pengajuan_tempo_id.dokumen_nib[0] + if self.user_company_id.dokumen_nib: + self.user_company_id.message_post(body='Dokumen NIB', attachment_ids=[self.user_company_id.dokumen_nib.id]) + + self.user_company_id.dokumen_siup = self.pengajuan_tempo_id.dokumen_siup[0] + if self.user_company_id.dokumen_siup: + self.user_company_id.message_post(body='dokumen SIUP', attachment_ids=[self.user_company_id.dokumen_siup.id]) + + self.user_company_id.dokumen_tdp = self.pengajuan_tempo_id.dokumen_tdp[0] + if self.user_company_id.dokumen_tdp: + self.user_company_id.message_post(body='dokumen TDP', attachment_ids=[self.user_company_id.dokumen_tdp.id]) + + self.user_company_id.dokumen_skdp = self.pengajuan_tempo_id.dokumen_skdp[0] + if self.user_company_id.dokumen_skdp: + self.user_company_id.message_post(body='dokumen SKDP', attachment_ids=[self.user_company_id.dokumen_skdp.id]) + + self.user_company_id.dokumen_skt = self.pengajuan_tempo_id.dokumen_skt[0] + if self.user_company_id.dokumen_skt: + self.user_company_id.message_post(body='dokumen SKT', attachment_ids=[self.user_company_id.dokumen_skt.id]) + self.user_company_id.dokumen_akta_perubahan = self.pengajuan_tempo_id.dokumen_akta_perubahan[0] if self.pengajuan_tempo_id.dokumen_akta_perubahan else [] if self.user_company_id.dokumen_akta_perubahan: self.user_company_id.message_post(body='Dokumen Akta Perubahan', diff --git a/indoteknik_custom/views/res_partner.xml b/indoteknik_custom/views/res_partner.xml index 91298319..b1ec1d07 100644 --- a/indoteknik_custom/views/res_partner.xml +++ b/indoteknik_custom/views/res_partner.xml @@ -96,6 +96,7 @@ + @@ -129,6 +130,8 @@ + + @@ -136,6 +139,9 @@ + + + @@ -160,16 +166,20 @@ - + + + + + + + + - - - diff --git a/indoteknik_custom/views/user_pengajuan_tempo.xml b/indoteknik_custom/views/user_pengajuan_tempo.xml index a6360136..5b9e51cc 100644 --- a/indoteknik_custom/views/user_pengajuan_tempo.xml +++ b/indoteknik_custom/views/user_pengajuan_tempo.xml @@ -14,12 +14,15 @@ + + + @@ -53,6 +56,8 @@ + + @@ -60,6 +65,9 @@ + + + @@ -84,16 +92,20 @@ - + + + + + + + + - - -
diff --git a/indoteknik_custom/views/user_pengajuan_tempo_request.xml b/indoteknik_custom/views/user_pengajuan_tempo_request.xml index 25907a67..2d21ae6c 100644 --- a/indoteknik_custom/views/user_pengajuan_tempo_request.xml +++ b/indoteknik_custom/views/user_pengajuan_tempo_request.xml @@ -91,6 +91,8 @@ + + @@ -98,6 +100,9 @@ + + + @@ -119,17 +124,21 @@ - - + + + + + + + + + - - - @@ -252,7 +261,7 @@ Users: Company Tempo Approved - Pengajuan Tempo kamu di Indoteknik.com Telah Disetujui! + Pengajuan Tempo Anda di Indoteknik.com Telah Disetujui! "Indoteknik.com" <noreply@indoteknik.com> sales@indoteknik.com ${object.user_id.email | safe} @@ -285,15 +294,15 @@
- + - + - + -- cgit v1.2.3 From 5343cbd0bfceb6bd50dbbed55a1de4b116f5fef4 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 13 Dec 2024 15:53:20 +0700 Subject: update code --- indoteknik_custom/models/res_partner.py | 8 ++++---- indoteknik_custom/models/stock_picking.py | 13 +++++++++++++ indoteknik_custom/models/user_pengajuan_tempo_request.py | 2 +- indoteknik_custom/views/res_partner.xml | 8 ++++---- indoteknik_custom/views/stock_picking.xml | 2 ++ 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/indoteknik_custom/models/res_partner.py b/indoteknik_custom/models/res_partner.py index 93125bb9..57fab403 100644 --- a/indoteknik_custom/models/res_partner.py +++ b/indoteknik_custom/models/res_partner.py @@ -81,10 +81,10 @@ class ResPartner(models.Model): dokumen_npwp = fields.Many2one('ir.attachment', string="NPWP Perusahaan", tracking=3, readonly=True) dokumen_sppkp = fields.Many2one('ir.attachment', string="SPPKP Perusahaan", tracking=3, readonly=True) dokumen_nib = fields.Many2one('ir.attachment', string="NIB (SIUP/TDP/SKDP)", tracking=3, readonly=True,) - dokumen_siup = fields.Many2many('ir.attachment', 'pengajuan_dokumen_siup_rel', string="SIUP Perusahaan", tracking=True) - dokumen_tdp = fields.Many2many('ir.attachment', 'pengajuan_dokumen_tdp_rel', string="TDP Perusahaan", tracking=True) - dokumen_skdp = fields.Many2many('ir.attachment', 'pengajuan_dokumen_skdp_rel', string="SKDP Perusahaan",tracking=True) - dokumen_skt = fields.Many2many('ir.attachment', 'pengajuan_dokumen_skt_rel', string="SKT Perusahaan", tracking=True) + dokumen_siup = fields.Many2one('ir.attachment', string="SIUP Perusahaan", tracking=3, readonly=True) + dokumen_tdp = fields.Many2one('ir.attachment', string="TDP Perusahaan", tracking=3, readonly=True) + dokumen_skdp = fields.Many2one('ir.attachment', string="SKDP Perusahaan",tracking=True, readonly=True) + dokumen_skt = fields.Many2one('ir.attachment', string="SKT Perusahaan", tracking=True, readonly=True) dokumen_akta_perubahan = fields.Many2one('ir.attachment', string="Akta Perubahan", tracking=3, readonly=True) dokumen_ktp_dirut = fields.Many2one('ir.attachment', string="KTP Dirut/Direktur", tracking=3, readonly=True) dokumen_akta_pendirian = fields.Many2one('ir.attachment', string="Akta Pendirian", tracking=3, readonly=True) diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index e6506a0b..e25704f4 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -115,6 +115,19 @@ class StockPicking(models.Model): ], string='Status Reserve', readonly=True, tracking=True, help="The current state of the stock picking.") notee = fields.Text(string="Note") + @api.model + def _compute_dokumen_tanda_terima(self): + for picking in self: + picking.dokumen_tanda_terima = picking.partner_id.dokumen_pengiriman + + @api.model + def _compute_dokumen_pengiriman(self): + for picking in self: + picking.dokumen_pengiriman = picking.partner_id.dokumen_pengiriman_input + + dokumen_tanda_terima = fields.Char(string='Dokumen Tanda Terima yang Diberikan Pada Saat Pengiriman Barang', readonly=True, compute=_compute_dokumen_tanda_terima) + dokumen_pengiriman = fields.Char(string='Dokumen yang Dibawa Saat Pengiriman Barang', readonly=True, compute=_compute_dokumen_pengiriman) + # Envio Tracking Section envio_id = fields.Char(string="Envio ID", readonly=True) envio_code = fields.Char(string="Envio Code", readonly=True) diff --git a/indoteknik_custom/models/user_pengajuan_tempo_request.py b/indoteknik_custom/models/user_pengajuan_tempo_request.py index c181ab68..707c8482 100644 --- a/indoteknik_custom/models/user_pengajuan_tempo_request.py +++ b/indoteknik_custom/models/user_pengajuan_tempo_request.py @@ -501,7 +501,7 @@ class UserPengajuanTempoRequest(models.Model): "kota_id": self.pengajuan_tempo_id.city_id_invoice.id, "kecamatan_id": self.pengajuan_tempo_id.district_id_invoice.id, "kelurahan_id": self.pengajuan_tempo_id.subDistrict_id_invoice.id, - "zip": self.pengajuan_tempo_id.zip_invoice.id, + "zip": self.pengajuan_tempo_id.zip_invoice, }, ] diff --git a/indoteknik_custom/views/res_partner.xml b/indoteknik_custom/views/res_partner.xml index b1ec1d07..96cfcd62 100644 --- a/indoteknik_custom/views/res_partner.xml +++ b/indoteknik_custom/views/res_partner.xml @@ -169,10 +169,10 @@ - - - - + + + + diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index 562be8d9..57291316 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -65,6 +65,8 @@ + + -- cgit v1.2.3 From 7cbb05cfb2de23562c153156448d0beadbeaf742 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Mon, 16 Dec 2024 08:27:17 +0700 Subject: perbaiki code flash sale --- indoteknik_api/controllers/api_v1/flash_sale.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/indoteknik_api/controllers/api_v1/flash_sale.py b/indoteknik_api/controllers/api_v1/flash_sale.py index 00b1f2e0..6c4ad8c0 100644 --- a/indoteknik_api/controllers/api_v1/flash_sale.py +++ b/indoteknik_api/controllers/api_v1/flash_sale.py @@ -20,6 +20,7 @@ class FlashSale(controller.Controller): query = [ ('pricelist_id', '=', pricelist.id) ] + formatted_end_date = pricelist.end_date.strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z' if pricelist.end_date else None data.append({ 'pricelist_id': pricelist.id, 'option': pricelist.flashsale_option, @@ -29,6 +30,7 @@ class FlashSale(controller.Controller): 'banner_mobile': request.env['ir.attachment'].api_image('product.pricelist', 'banner_mobile', pricelist.id), 'banner_top': request.env['ir.attachment'].api_image('product.pricelist', 'banner_top', pricelist.id), 'duration': pricelist._remaining_time_in_second(), + 'end_date': formatted_end_date, 'product_total': request.env['product.pricelist.item'].search_count(query), }) return self.response(data) -- cgit v1.2.3 From cac17b71c07892411128a00f158a45af19344e98 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 16 Dec 2024 10:16:23 +0700 Subject: add check kredit limit on ask approve so --- indoteknik_custom/models/sale_order.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 7fc6d96a..f5e7e8a1 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -758,6 +758,7 @@ class SaleOrder(models.Model): raise UserError("Salesperson sudah tidak aktif, mohon diisi yang benar pada data SO dan Contact") def sale_order_approve(self): + self.check_credit_limit() if self.validate_different_vendor() and not self.vendor_approval: return self._create_notification_action('Notification', 'Terdapat Vendor yang berbeda dengan MD Vendor') self.check_due() @@ -890,6 +891,37 @@ class SaleOrder(models.Model): 'email_to': salesperson_email, }).send() + def check_credit_limit(self): + for rec in self: + outstanding_amount = rec.outstanding_amount + check_credit_limit = False + ###### + block_stage = 0 + if rec.partner_id.parent_id: + if rec.partner_id.parent_id.active_limit and rec.partner_id.parent_id.enable_credit_limit: + check_credit_limit = True + else: + if rec.partner_id.active_limit and rec.partner_id.enable_credit_limit: + check_credit_limit = True + + term_days = 0 + for term_line in rec.payment_term_id.line_ids: + term_days += term_line.days + if term_days == 0: + check_credit_limit = False + + if check_credit_limit: + if rec.partner_id.parent_id: + block_stage = rec.partner_id.parent_id.blocking_stage or 0 + else: + block_stage = rec.partner_id.blocking_stage or 0 + + if (outstanding_amount + rec.amount_total) >= block_stage: + if block_stage != 0: + remaining_credit_limit = block_stage - outstanding_amount + raise UserError(_("%s is in Blocking Stage, Remaining credit limit is %s, from %s and outstanding %s") + % (rec.partner_id.name, remaining_credit_limit, block_stage, outstanding_amount)) + def validate_different_vendor(self): if self.vendor_approval_id.filtered(lambda v: v.state == 'draft'): draft_names = ", ".join(self.vendor_approval_id.filtered(lambda v: v.state == 'draft').mapped('number')) -- cgit v1.2.3 From 97d9a59c82be9052815be6039327148f07d98514 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 17 Dec 2024 10:13:13 +0700 Subject: add new condition on po --- indoteknik_custom/models/purchase_order.py | 4 +++- indoteknik_custom/views/purchase_order.xml | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 9388ae4c..0e39d12a 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -74,6 +74,7 @@ class PurchaseOrder(models.Model): approve_by = fields.Many2one('res.users', string='Approve By') exclude_incoming = fields.Boolean(string='Exclude Incoming', default=False, help='Centang jika tidak mau masuk perhitungan Incoming Qty') + not_update_purchasepricelist = fields.Boolean(string='Not Update Purchase Pricelist?') def _compute_total_margin_match(self): for purchase in self: @@ -620,7 +621,8 @@ class PurchaseOrder(models.Model): raise UserError("Tidak ada link dengan SO, harus approval Merchandise") send_email = False - self.add_product_to_pricelist() + if not self.not_update_purchasepricelist: + self.add_product_to_pricelist() for line in self.order_line: if not line.product_id.purchase_ok: raise UserError("Terdapat barang yang tidak bisa diproses") diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index 0e6b6792..d22c3b5c 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -41,6 +41,7 @@ + -- cgit v1.2.3 From 7a6542e7aab868a40eb83298b95d971e19acf15a Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 17 Dec 2024 13:16:20 +0700 Subject: update pengajuan tempo dokumen --- indoteknik_api/models/res_partner.py | 42 +++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/indoteknik_api/models/res_partner.py b/indoteknik_api/models/res_partner.py index 258d8143..0e09fbc6 100644 --- a/indoteknik_api/models/res_partner.py +++ b/indoteknik_api/models/res_partner.py @@ -1,5 +1,6 @@ from odoo import models import json +import base64 class ResPartner(models.Model): _inherit = 'res.partner' @@ -21,7 +22,6 @@ class ResPartner(models.Model): 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, @@ -93,65 +93,77 @@ class ResPartner(models.Model): } 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.local_url, + '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.local_url, + '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.local_url, + '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.local_url, + '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.local_url, + '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.local_url, + '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.local_url, + '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.local_url, + '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.local_url, + '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.local_url, + '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.local_url, + '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.local_url, + '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.local_url, + 'base64': pengajuan_tempo.dokumen_tempat_bekerja.datas.decode('utf-8'), + 'format': pengajuan_tempo.dokumen_tempat_bekerja.mimetype, } if pengajuan_tempo.dokumen_tempat_bekerja else '', } -- cgit v1.2.3 From d3abcb6d9efeb6fc48ab05df1da7e06175d04dea Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 17 Dec 2024 17:22:35 +0700 Subject: add approval stephan --- indoteknik_custom/models/requisition.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/indoteknik_custom/models/requisition.py b/indoteknik_custom/models/requisition.py index 32a9f94f..c972b485 100644 --- a/indoteknik_custom/models/requisition.py +++ b/indoteknik_custom/models/requisition.py @@ -82,11 +82,11 @@ class Requisition(models.Model): state = ['done', 'sale'] if self.sale_order_id.state in state: raise UserError('SO sudah Confirm, akan berakibat double Purchase melalui PJ') - if self.env.user.id not in [377, 19]: + if self.env.user.id not in [377, 19, 28]: raise UserError('Hanya Vita dan Darren Yang Bisa Approve') - if self.env.user.id == 377: + if self.env.user.id == 377 or self.env.user.id == 28: self.sales_approve = True - elif self.env.user.id == 19: + elif self.env.user.id == 19 or self.env.user.id == 28: if not self.sales_approve: raise UserError('Vita Belum Approve') self.merchandise_approve = True -- cgit v1.2.3 From 01d85b9f0d8fc70c35eaa13a154f3443fc35f1c6 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 18 Dec 2024 10:25:09 +0700 Subject: new field qr code variant --- indoteknik_custom/models/stock_move.py | 9 +++++++++ indoteknik_custom/views/stock_picking.xml | 14 ++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/indoteknik_custom/models/stock_move.py b/indoteknik_custom/models/stock_move.py index 8214a057..e1d4e74c 100644 --- a/indoteknik_custom/models/stock_move.py +++ b/indoteknik_custom/models/stock_move.py @@ -11,6 +11,15 @@ class StockMove(models.Model): string="Print Barcode", default=lambda self: self.product_id.print_barcode, ) + qr_code_variant = fields.Binary("QR Code Variant", compute='_compute_qr_code_variant') + + def _compute_qr_code_variant(self): + for rec in self: + if rec.print_barcode and rec.print_barcode == True and rec.product_id and rec.product_id.qr_code_variant: + rec.qr_code_variant = rec.product_id.qr_code_variant + else: + rec.qr_code_variant = False + def write(self, vals): res = super(StockMove, self).write(vals) diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index 20fc709e..fab83885 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -121,6 +121,7 @@ + @@ -169,11 +170,24 @@ + + + stock.move.line.operations.tree.inherit stock.move.line -- cgit v1.2.3 From 9b305f2f64e61d3197be53e69f7dfc8bbacc224c Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 18 Dec 2024 13:43:47 +0700 Subject: push --- indoteknik_custom/views/res_partner.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/views/res_partner.xml b/indoteknik_custom/views/res_partner.xml index 1b164161..7b13fef7 100644 --- a/indoteknik_custom/views/res_partner.xml +++ b/indoteknik_custom/views/res_partner.xml @@ -75,7 +75,7 @@ - 1 + 0 1 -- cgit v1.2.3 From d35c2dce88a87bc05d30c4935d51d7d58aa5d37d Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 19 Dec 2024 10:33:53 +0700 Subject: fix qr code variant --- indoteknik_custom/models/product_template.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 00e756c9..9007dd71 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -404,12 +404,17 @@ class ProductProduct(models.Model): qr_code_variant = fields.Binary("QR Code Variant", compute='_compute_qr_code_variant') def _compute_qr_code_variant(self): - for rec in self.product_variant_ids: + for rec in self: + # Skip inactive variants + if not rec.active: + rec.qr_code_variant = False # Clear the QR Code for archived variants + continue + qr = qrcode.QRCode( - version=1, - error_correction=qrcode.constants.ERROR_CORRECT_L, - box_size=5, - border=4, + version=1, + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=5, + border=4, ) qr.add_data(rec.display_name) qr.make(fit=True) -- cgit v1.2.3 From 90ec56c6fc35b554ce8780b696d3321817bad93c Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 30 Dec 2024 11:37:21 +0700 Subject: ppn 12% --- indoteknik_custom/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 756c69cf..5b1c757b 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -1170,7 +1170,7 @@ class SaleOrder(models.Model): line_voucher = used_discount * line_contribution line_voucher_item = line_voucher / line.product_uom_qty - line_price_unit = line.price_unit / 1.12 if any(tax.id == 23 for tax in line.tax_id) else line.price_unit + line_price_unit = line.price_unit / 1.12 if any(tax.id == 217 for tax in line.tax_id) else line.price_unit line_discount_item = line_price_unit * line.discount / 100 + line_voucher_item line_voucher_item = line_discount_item / line_price_unit * 100 -- cgit v1.2.3 From 63a4c4aca3c3c1594ab72679b3cb44c873f5da5e Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 30 Dec 2024 11:47:39 +0700 Subject: ppn 12% --- indoteknik_api/models/product_product.py | 20 ++++++++++---------- indoteknik_custom/models/promotion/sale_order.py | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/indoteknik_api/models/product_product.py b/indoteknik_api/models/product_product.py index 386ddb6a..d7c0c66b 100644 --- a/indoteknik_api/models/product_product.py +++ b/indoteknik_api/models/product_product.py @@ -138,39 +138,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) @@ -228,7 +228,7 @@ class ProductProduct(models.Model): def _get_pricelist_tier(self, tier_number): config_param_name = f'product.pricelist.tier{tier_number}' product_pricelist_tier = int(self.env['ir.config_parameter'].get_param(config_param_name)) - default_divide_tax = float(1.11) + default_divide_tax = float(1.12) base_price = discount = price = 0 pricelist_item = self.env['product.pricelist.item'].search([ ('pricelist_id', '=', int(product_pricelist_tier)), @@ -272,12 +272,12 @@ class ProductProduct(models.Model): base_price = 0 if base_pricelist: base_price = base_pricelist.computed_price - # base_price = base_pricelist.computed_price / 1.11 + # base_price = base_pricelist.computed_price / 1.12 discount = 0 price_flashsale = 0 - default_divide_tax = float(1.11) - default_tax = float(11) + default_divide_tax = float(1.12) + default_tax = float(12) if item.price_discount > 0: discount = item.price_discount price_flashsale = base_price - (base_price * discount // 100) diff --git a/indoteknik_custom/models/promotion/sale_order.py b/indoteknik_custom/models/promotion/sale_order.py index be820c6f..f1cd777f 100644 --- a/indoteknik_custom/models/promotion/sale_order.py +++ b/indoteknik_custom/models/promotion/sale_order.py @@ -36,7 +36,7 @@ class SaleOrder(models.Model): else: all_products = self._merge_promotion_products(promotion) - promotion_price = promotion['price']['price_discount'] * line.quantity * 1.11 + promotion_price = promotion['price']['price_discount'] * line.quantity * 1.12 promotion_amt_total = sum(product['price']['price'] * product['qty'] for product in all_products) promotion_used_price = 0 -- cgit v1.2.3 From e90f1b5a714bc1a18073df18f7798d28cafab7c4 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 31 Dec 2024 09:13:28 +0700 Subject: ppn 12% --- indoteknik_api/controllers/api_v1/sale_order.py | 2 +- indoteknik_custom/models/requisition.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py index 3e182a2e..f8535199 100644 --- a/indoteknik_api/controllers/api_v1/sale_order.py +++ b/indoteknik_api/controllers/api_v1/sale_order.py @@ -394,7 +394,7 @@ class SaleOrder(controller.Controller): parameters = { 'warehouse_id': 8, 'carrier_id': 1, - 'sales_tax_id': 23, + 'sales_tax_id': 218, 'pricelist_id': user_pricelist or product_pricelist_default_discount_id, 'payment_term_id': 26, 'team_id': 2, diff --git a/indoteknik_custom/models/requisition.py b/indoteknik_custom/models/requisition.py index 32a9f94f..780f3dde 100644 --- a/indoteknik_custom/models/requisition.py +++ b/indoteknik_custom/models/requisition.py @@ -159,7 +159,7 @@ class Requisition(models.Model): offset=i * PRODUCT_PER_PO, limit=PRODUCT_PER_PO ) - tax = [22] + tax = [220] for line in lines: product = line.product_id -- cgit v1.2.3 From c971e71a19426de6c210100e2e110319df81aafa Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Thu, 2 Jan 2025 14:21:51 +0700 Subject: update pengajuan tempo menu --- indoteknik_custom/views/user_company_request.xml | 18 +++++++++++------- .../views/user_pengajuan_tempo_request.xml | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/indoteknik_custom/views/user_company_request.xml b/indoteknik_custom/views/user_company_request.xml index 1c80e923..6d5642e6 100644 --- a/indoteknik_custom/views/user_company_request.xml +++ b/indoteknik_custom/views/user_company_request.xml @@ -54,12 +54,16 @@ user.company.request tree,form + - + \ No newline at end of file diff --git a/indoteknik_custom/views/user_pengajuan_tempo_request.xml b/indoteknik_custom/views/user_pengajuan_tempo_request.xml index 2d21ae6c..7ba87184 100644 --- a/indoteknik_custom/views/user_pengajuan_tempo_request.xml +++ b/indoteknik_custom/views/user_pengajuan_tempo_request.xml @@ -409,7 +409,7 @@ -- cgit v1.2.3 From 3553599efb4046ad4788e1d2b48a3081f246c85b Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Fri, 3 Jan 2025 11:01:39 +0700 Subject: export xml faktur --- indoteknik_custom/__manifest__.py | 3 +- indoteknik_custom/models/__init__.py | 1 + indoteknik_custom/models/coretax_fatur.py | 93 ++++++++++++++++++++++++++ indoteknik_custom/security/ir.model.access.csv | 1 + indoteknik_custom/views/coretax_faktur.xml | 49 ++++++++++++++ 5 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 indoteknik_custom/models/coretax_fatur.py create mode 100644 indoteknik_custom/views/coretax_faktur.xml diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 89f62524..255fbd3d 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -8,7 +8,7 @@ 'author': 'Rafi Zadanly', 'website': '', 'images': ['assets/favicon.ico'], - 'depends': ['base', 'coupon', 'delivery', 'sale', 'sale_management', 'vit_kelurahan'], + 'depends': ['base', 'coupon', 'delivery', 'sale', 'sale_management', 'vit_kelurahan', 'vit_efaktur' ], 'data': [ 'security/ir.model.access.csv', 'views/group_partner.xml', @@ -155,6 +155,7 @@ 'report/report_invoice.xml', 'report/report_picking.xml', 'report/report_sale_order.xml', + 'views/coretax_faktur.xml', ], 'demo': [], 'css': [], diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index ad6d75dd..b698b14c 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -134,3 +134,4 @@ from . import find_page from . import approval_retur_picking from . import va_multi_approve from . import va_multi_reject +from . import coretax_fatur diff --git a/indoteknik_custom/models/coretax_fatur.py b/indoteknik_custom/models/coretax_fatur.py new file mode 100644 index 00000000..1c3af6a4 --- /dev/null +++ b/indoteknik_custom/models/coretax_fatur.py @@ -0,0 +1,93 @@ +from odoo import models, fields +import xml.etree.ElementTree as ET +from xml.dom import minidom +import base64 + +class CoretaxFaktur(models.Model): + _name = 'coretax.faktur' + _description = 'Export Faktur ke XML' + + export_file = fields.Binary(string="Export File", ) + export_filename = fields.Char(string="Export File", ) + + def generate_xml(self): + # Buat root XML + root = ET.Element('TaxInvoiceBulk', { + 'xmlns:xsi': "http://www.w3.org/2001/XMLSchema-instance", + 'xsi:noNamespaceSchemaLocation': "TaxInvoice.xsd" + }) + ET.SubElement(root, 'TIN').text = 'xxxxxxxxxxxxxxxx' + + # Tambahkan elemen ListOfTaxInvoice + list_of_tax_invoice = ET.SubElement(root, 'ListOfTaxInvoice') + + # Dapatkan data faktur + inv_obj = self.env['account.move'] + invoices = inv_obj.search([('is_efaktur_exported','!=',True), + ('state','=','posted'), + ('efaktur_id','!=', False), + ('move_type','=','out_invoice')]) + for invoice in invoices: + tax_invoice = ET.SubElement(list_of_tax_invoice, 'TaxInvoice') + + # Tambahkan elemen faktur + ET.SubElement(tax_invoice, 'TaxInvoiceDate').text = invoice.invoice_date.strftime('%Y-%m-%d') if invoice.invoice_date else '' + ET.SubElement(tax_invoice, 'TaxInvoiceOpt').text = 'Normal' + ET.SubElement(tax_invoice, 'TrxCode').text = '01' + ET.SubElement(tax_invoice, 'AddInfo') + ET.SubElement(tax_invoice, 'CustomDoc') + ET.SubElement(tax_invoice, 'RefDesc') + ET.SubElement(tax_invoice, 'FacilityStamp') + ET.SubElement(tax_invoice, 'SellerIDTKU').text = '0000000000000000000000' + ET.SubElement(tax_invoice, 'BuyerTin').text = 'xxxxxxxxxxxxxxxx' + ET.SubElement(tax_invoice, 'BuyerDocument').text = 'TIN' + ET.SubElement(tax_invoice, 'BuyerCountry').text = 'IND' + ET.SubElement(tax_invoice, 'BuyerEmail').text = invoice.partner_id.email or '' + ET.SubElement(tax_invoice, 'BuyerIDTKU').text = '0000000000000000000000' + + # Tambahkan elemen ListOfGoodService + list_of_good_service = ET.SubElement(tax_invoice, 'ListOfGoodService') + for line in invoice.invoice_line_ids: + good_service = ET.SubElement(list_of_good_service, 'GoodService') + ET.SubElement(good_service, 'Opt').text = 'A' + ET.SubElement(good_service, 'Code').text = '000000' + ET.SubElement(good_service, 'Name').text = line.name + ET.SubElement(good_service, 'Unit').text = 'UM.0001' + ET.SubElement(good_service, 'Price').text = str(line.price_unit) + ET.SubElement(good_service, 'Qty').text = str(line.quantity) + ET.SubElement(good_service, 'TotalDiscount').text = '100000' + ET.SubElement(good_service, 'TaxBase').text = str(line.price_subtotal) + ET.SubElement(good_service, 'OtherTaxBase').text = str(line.price_subtotal) + ET.SubElement(good_service, 'VATRate').text = '11' + ET.SubElement(good_service, 'VAT').text = str(line.price_total * 0.11) + ET.SubElement(good_service, 'STLGRate').text = '20' + ET.SubElement(good_service, 'STLG').text = '580000' + + # Pretty print XML + xml_str = ET.tostring(root, encoding='utf-8') + xml_pretty = minidom.parseString(xml_str).toprettyxml(indent=" ") + return xml_pretty + + def export_to_download(self): + # Generate XML content + xml_content = self.generate_xml() + + # Encode content to Base64 + xml_encoded = base64.b64encode(xml_content.encode('utf-8')) + + # Buat attachment untuk XML + attachment = self.env['ir.attachment'].create({ + 'name': 'Faktur_XML.xml', + 'type': 'binary', + 'datas': xml_encoded, + 'mimetype': 'application/xml', + 'store_fname': 'faktur_xml.xml', + }) + + # Kembalikan URL untuk download dengan header 'Content-Disposition' + return { + 'type': 'ir.actions.act_url', + 'url': '/web/content/{}'.format(attachment.id), + 'target': 'self', + 'params': {'download': True}, # Menambahkan parameter untuk memastikan file didownload + } diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 2375df9d..8e4d3a71 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -148,3 +148,4 @@ access_sales_order_fulfillment_v2,access.sales.order.fulfillment.v2,model_sales_ access_v_move_outstanding,access.v.move.outstanding,model_v_move_outstanding,,1,1,1,1 access_va_multi_approve,access.va.multi.approve,model_va_multi_approve,,1,1,1,1 access_va_multi_reject,access.va.multi.reject,model_va_multi_reject,,1,1,1,1 +access_coretax_faktur,access.coretax.faktur,model_coretax_faktur,,1,1,1,1 diff --git a/indoteknik_custom/views/coretax_faktur.xml b/indoteknik_custom/views/coretax_faktur.xml new file mode 100644 index 00000000..45eea23f --- /dev/null +++ b/indoteknik_custom/views/coretax_faktur.xml @@ -0,0 +1,49 @@ + + + + + Export Faktur Pajak Keluaran XML Version + ir.actions.act_window + coretax.faktur + form + new + + + + view coretax faktur + coretax.faktur + form + +
+

+ Klik tombol Export di bawah untuk mulai export Faktur Pajak Keluaran. + Data yang diexport adalah Customer Invoice yang berstatus Open dan belum diexport ke E-Faktur. +

+ +

+ Setelah proses export Faktur Pajak Keluaran selesai dilakukan, + download file ini: +

+ + + + +

+ Lalu import ke program E-Faktur DJP melalui menu Referensi - Pajak Keluaran - Import +

+ +
+
+ +
+
+ + +
+
\ No newline at end of file -- cgit v1.2.3 From 2a3adac9333c2bd5cb9f0dca3ba080cd3e6dfce8 Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Fri, 3 Jan 2025 11:31:46 +0700 Subject: automatic download --- indoteknik_custom/models/coretax_fatur.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/indoteknik_custom/models/coretax_fatur.py b/indoteknik_custom/models/coretax_fatur.py index 1c3af6a4..a0820fee 100644 --- a/indoteknik_custom/models/coretax_fatur.py +++ b/indoteknik_custom/models/coretax_fatur.py @@ -85,9 +85,10 @@ class CoretaxFaktur(models.Model): }) # Kembalikan URL untuk download dengan header 'Content-Disposition' - return { + response = { 'type': 'ir.actions.act_url', - 'url': '/web/content/{}'.format(attachment.id), + 'url': '/web/content/{}?download=true'.format(attachment.id), 'target': 'self', - 'params': {'download': True}, # Menambahkan parameter untuk memastikan file didownload } + + return response -- cgit v1.2.3 From 992f530f9da44716361b27e62458c82a8aca78e1 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 3 Jan 2025 14:43:27 +0700 Subject: push --- indoteknik_custom/models/coretax_fatur.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/indoteknik_custom/models/coretax_fatur.py b/indoteknik_custom/models/coretax_fatur.py index a0820fee..426fb737 100644 --- a/indoteknik_custom/models/coretax_fatur.py +++ b/indoteknik_custom/models/coretax_fatur.py @@ -16,17 +16,17 @@ class CoretaxFaktur(models.Model): 'xmlns:xsi': "http://www.w3.org/2001/XMLSchema-instance", 'xsi:noNamespaceSchemaLocation': "TaxInvoice.xsd" }) - ET.SubElement(root, 'TIN').text = 'xxxxxxxxxxxxxxxx' + ET.SubElement(root, 'TIN').text = '74.226.022.7-086.000' # Tambahkan elemen ListOfTaxInvoice list_of_tax_invoice = ET.SubElement(root, 'ListOfTaxInvoice') # Dapatkan data faktur inv_obj = self.env['account.move'] - invoices = inv_obj.search([('is_efaktur_exported','!=',True), + invoices = inv_obj.search([('is_efaktur_exported','=',True), ('state','=','posted'), ('efaktur_id','!=', False), - ('move_type','=','out_invoice')]) + ('move_type','=','out_invoice')], limit = 5) for invoice in invoices: tax_invoice = ET.SubElement(list_of_tax_invoice, 'TaxInvoice') @@ -39,7 +39,7 @@ class CoretaxFaktur(models.Model): ET.SubElement(tax_invoice, 'RefDesc') ET.SubElement(tax_invoice, 'FacilityStamp') ET.SubElement(tax_invoice, 'SellerIDTKU').text = '0000000000000000000000' - ET.SubElement(tax_invoice, 'BuyerTin').text = 'xxxxxxxxxxxxxxxx' + ET.SubElement(tax_invoice, 'BuyerTin').text = invoice.partner_id.npwp or '' ET.SubElement(tax_invoice, 'BuyerDocument').text = 'TIN' ET.SubElement(tax_invoice, 'BuyerCountry').text = 'IND' ET.SubElement(tax_invoice, 'BuyerEmail').text = invoice.partner_id.email or '' @@ -50,9 +50,9 @@ class CoretaxFaktur(models.Model): for line in invoice.invoice_line_ids: good_service = ET.SubElement(list_of_good_service, 'GoodService') ET.SubElement(good_service, 'Opt').text = 'A' - ET.SubElement(good_service, 'Code').text = '000000' + ET.SubElement(good_service, 'Code').text = line.product_id.default_code ET.SubElement(good_service, 'Name').text = line.name - ET.SubElement(good_service, 'Unit').text = 'UM.0001' + ET.SubElement(good_service, 'Unit').text = 'UM.0018' ET.SubElement(good_service, 'Price').text = str(line.price_unit) ET.SubElement(good_service, 'Qty').text = str(line.quantity) ET.SubElement(good_service, 'TotalDiscount').text = '100000' -- cgit v1.2.3 From bef3ba4c18d585bc0980942d91b5fcb4d44427e1 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 3 Jan 2025 15:27:56 +0700 Subject: push --- indoteknik_custom/models/coretax_fatur.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/indoteknik_custom/models/coretax_fatur.py b/indoteknik_custom/models/coretax_fatur.py index 426fb737..32082774 100644 --- a/indoteknik_custom/models/coretax_fatur.py +++ b/indoteknik_custom/models/coretax_fatur.py @@ -36,32 +36,32 @@ class CoretaxFaktur(models.Model): ET.SubElement(tax_invoice, 'TrxCode').text = '01' ET.SubElement(tax_invoice, 'AddInfo') ET.SubElement(tax_invoice, 'CustomDoc') - ET.SubElement(tax_invoice, 'RefDesc') + ET.SubElement(tax_invoice, 'RefDesc').text = invoice.name ET.SubElement(tax_invoice, 'FacilityStamp') - ET.SubElement(tax_invoice, 'SellerIDTKU').text = '0000000000000000000000' + ET.SubElement(tax_invoice, 'SellerIDTKU').text = '0742260227086000000000' ET.SubElement(tax_invoice, 'BuyerTin').text = invoice.partner_id.npwp or '' ET.SubElement(tax_invoice, 'BuyerDocument').text = 'TIN' ET.SubElement(tax_invoice, 'BuyerCountry').text = 'IND' ET.SubElement(tax_invoice, 'BuyerEmail').text = invoice.partner_id.email or '' - ET.SubElement(tax_invoice, 'BuyerIDTKU').text = '0000000000000000000000' + ET.SubElement(tax_invoice, 'BuyerIDTKU').text = '' # Tambahkan elemen ListOfGoodService list_of_good_service = ET.SubElement(tax_invoice, 'ListOfGoodService') for line in invoice.invoice_line_ids: good_service = ET.SubElement(list_of_good_service, 'GoodService') - ET.SubElement(good_service, 'Opt').text = 'A' + ET.SubElement(good_service, 'Opt').text = 'B' if line.product_id.type == 'service' else 'A' ET.SubElement(good_service, 'Code').text = line.product_id.default_code ET.SubElement(good_service, 'Name').text = line.name ET.SubElement(good_service, 'Unit').text = 'UM.0018' ET.SubElement(good_service, 'Price').text = str(line.price_unit) ET.SubElement(good_service, 'Qty').text = str(line.quantity) - ET.SubElement(good_service, 'TotalDiscount').text = '100000' + ET.SubElement(good_service, 'TotalDiscount').text = str(line.discount) ET.SubElement(good_service, 'TaxBase').text = str(line.price_subtotal) ET.SubElement(good_service, 'OtherTaxBase').text = str(line.price_subtotal) - ET.SubElement(good_service, 'VATRate').text = '11' + ET.SubElement(good_service, 'VATRate').text = '0,11' ET.SubElement(good_service, 'VAT').text = str(line.price_total * 0.11) - ET.SubElement(good_service, 'STLGRate').text = '20' - ET.SubElement(good_service, 'STLG').text = '580000' + ET.SubElement(good_service, 'STLGRate').text = '' + ET.SubElement(good_service, 'STLG').text = '' # Pretty print XML xml_str = ET.tostring(root, encoding='utf-8') -- cgit v1.2.3 From 02d27a0e871dd4949c9382000843cd35dd3db3f8 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 8 Jan 2025 09:48:07 +0700 Subject: automatic email bill, api lalamove --- indoteknik_custom/models/purchase_order.py | 44 +++++-- indoteknik_custom/models/stock_picking.py | 195 +++++++++++++++++++++++++++-- indoteknik_custom/views/stock_picking.xml | 16 +++ 3 files changed, 236 insertions(+), 19 deletions(-) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 0e39d12a..799c4db0 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -75,6 +75,28 @@ class PurchaseOrder(models.Model): exclude_incoming = fields.Boolean(string='Exclude Incoming', default=False, help='Centang jika tidak mau masuk perhitungan Incoming Qty') not_update_purchasepricelist = fields.Boolean(string='Not Update Purchase Pricelist?') + # total_cost_service = fields.Float(string='Total Cost Service') + # total_delivery_amt = fields.Float(string='Total Delivery Amt') + + # @api.onchange('total_cost_service') + # def _onchange_total_cost_service(self): + # for order in self: + # lines = order.order_line + # if lines: + # # Hitung nilai rata-rata cost_service + # per_line_cost_service = order.total_cost_service / len(lines) + # for line in lines: + # line.cost_service = per_line_cost_service + + # @api.onchange('total_delivery_amt') + # def _onchange_total_delivery_amt(self): + # for order in self: + # lines = order.order_line + # if lines: + # # Hitung nilai rata-rata delivery_amt + # per_line_delivery_amt = order.total_delivery_amt / len(lines) + # for line in lines: + # line.delivery_amt = per_line_delivery_amt def _compute_total_margin_match(self): for purchase in self: @@ -115,6 +137,7 @@ class PurchaseOrder(models.Model): 'ref': self.name, 'invoice_date': current_date, 'date': current_date, + 'invoice_origin': self.name, 'move_type': 'in_invoice' } @@ -165,6 +188,11 @@ class PurchaseOrder(models.Model): self.bills_pelunasan_id = bills.id + lognote_message = ( + f"Vendor bill created from: {self.name} ({self.partner_ref})" + ) + bills.message_post(body=lognote_message) + return { 'name': _('Account Move'), 'view_mode': 'tree,form', @@ -174,12 +202,10 @@ class PurchaseOrder(models.Model): 'domain': [('id', '=', bills.id)] } - - def create_bill_dp(self): if not self.env.user.is_accounting: raise UserError('Hanya Accounting yang bisa bikin bill dp') - + current_date = datetime.utcnow() data_bills = { 'partner_id': self.partner_id.id, @@ -187,8 +213,8 @@ class PurchaseOrder(models.Model): 'ref': self.name, 'invoice_date': current_date, 'date': current_date, + 'invoice_origin': self.name, 'move_type': 'in_invoice' - } bills = self.env['account.move'].create([data_bills]) @@ -197,14 +223,13 @@ class PurchaseOrder(models.Model): data_line_bills = { 'move_id': bills.id, - 'product_id': product_dp.id, #product down payment - 'account_id': 401, #Uang Muka persediaan barang dagang + 'product_id': product_dp.id, # product down payment + 'account_id': 401, # Uang Muka persediaan barang dagang 'quantity': 1, 'product_uom_id': 1, 'tax_ids': [line[0].taxes_id.id for line in self.order_line], } - bills_line = self.env['account.move.line'].create([data_line_bills]) self.bills_dp_id = bills.id @@ -213,6 +238,11 @@ class PurchaseOrder(models.Model): move_line.name = '[IT.121456] Down Payment' move_line.partner_id = self.partner_id.id + lognote_message = ( + f"Vendor bill created from: {self.name} ({self.partner_ref})" + ) + bills.message_post(body=lognote_message) + return { 'name': _('Account Move'), 'view_mode': 'tree,form', diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index e6506a0b..51899de9 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -6,10 +6,17 @@ from itertools import groupby import pytz, requests, json, requests from dateutil import parser import datetime - +import hmac +import hashlib +import base64 +import requests +import time +import logging +_logger = logging.getLogger(__name__) class StockPicking(models.Model): _inherit = 'stock.picking' + # check_product_lines = fields.One2many('check.product', 'picking_id', string='Check Product', auto_join=True) is_internal_use = fields.Boolean('Internal Use', help='flag which is internal use or not') account_id = fields.Many2one('account.account', string='Account') efaktur_id = fields.Many2one('vit.efaktur', string='Faktur Pajak') @@ -134,6 +141,86 @@ class StockPicking(models.Model): envio_latest_longitude = fields.Float(string="Log Longitude", readonly=True) tracking_by = fields.Many2one('res.users', string='Tracking By', readonly=True, tracking=True) + # Lalamove Section + lalamove_order_id = fields.Char(string="Lalamove Order ID", copy=False) + lalamove_address = fields.Char(string="Lalamove Address") + lalamove_name = fields.Char(string="Lalamove Name") + lalamove_phone = fields.Char(string="Lalamove Phone") + lalamove_status = fields.Char(string="Lalamove Status") + lalamove_delivered_at = fields.Datetime(string="Lalamove Delivered At") + lalamove_data = fields.Text(string="Lalamove Data", readonly=True) + lalamove_image_url = fields.Char(string="Lalamove Image URL") + lalamove_image_html = fields.Html(string="Lalamove Image", compute="_compute_lalamove_image_html") + + def _compute_lalamove_image_html(self): + for record in self: + if record.lalamove_image_url: + record.lalamove_image_html = f'' + else: + record.lalamove_image_html = "No image available." + + def action_fetch_lalamove_order(self): + pickings = self.env['stock.picking'].search([ + ('picking_type_code', '=', 'outgoing'), + ('state', '=', 'done'), + ('carrier_id', '=', 9) + ]) + for picking in pickings: + try: + order_id = picking.lalamove_order_id + apikey = self.env['ir.config_parameter'].sudo().get_param('lalamove.apikey') + secret = self.env['ir.config_parameter'].sudo().get_param('lalamove.secret') + market = self.env['ir.config_parameter'].sudo().get_param('lalamove.market', default='ID') + + order_data = picking.get_lalamove_order(order_id, apikey, secret, market) + picking.lalamove_data = order_data + except Exception as e: + _logger.error(f"Error fetching Lalamove order for picking {picking.id}: {str(e)}") + continue + + def get_lalamove_order(self, order_id, apikey, secret, market): + timestamp = str(int(time.time() * 1000)) + message = f"{timestamp}\r\nGET\r\n/v3/orders/{order_id}\r\n\r\n" + signature = hmac.new(secret.encode('utf-8'), message.encode('utf-8'), hashlib.sha256).hexdigest() + + headers = { + "Content-Type": "application/json", + "Authorization": f"hmac {apikey}:{timestamp}:{signature}", + "Market": market + } + + url = f"https://rest.lalamove.com/v3/orders/{order_id}" + response = requests.get(url, headers=headers) + + if response.status_code == 200: + data = response.json() + stops = data.get("data", {}).get("stops", []) + + for stop in stops: + pod = stop.get("POD", {}) + if pod.get("status") == "DELIVERED": + image_url = pod.get("image") # Sesuaikan jika key berbeda + self.lalamove_image_url = image_url + + address = stop.get("address") + name = stop.get("name") + phone = stop.get("phone") + delivered_at = pod.get("deliveredAt") + + delivered_at_dt = self._convert_to_datetime(delivered_at) + + self.lalamove_address = address + self.lalamove_name = name + self.lalamove_phone = phone + self.lalamove_status = pod.get("status") + self.lalamove_delivered_at = delivered_at_dt + return data + + raise UserError("No delivered data found in Lalamove response.") + else: + raise UserError(f"Error {response.status_code}: {response.text}") + + def _convert_to_wib(self, date_str): """ Mengonversi string waktu ISO 8601 ke format waktu Indonesia (WIB) @@ -661,13 +748,13 @@ class StockPicking(models.Model): if not self.env.user.is_logistic_approver and self.env.context.get('active_model') == 'stock.picking': if self.origin and 'Return of' in self.origin: raise UserError("Button ini hanya untuk Logistik") - + if self.picking_type_code == 'internal': self.check_qty_done_stock() if self._name != 'stock.picking': return super(StockPicking, self).button_validate() - + if not self.picking_code: self.picking_code = self.env['ir.sequence'].next_by_code('stock.picking.code') or '0' @@ -681,15 +768,10 @@ class StockPicking(models.Model): raise UserError("Harus di Approve oleh Accounting") if self.picking_type_id.id == 28 and not self.env.user.is_logistic_approver: - raise UserError("Harus di Approve oleh Logistik") + raise UserError("Harus di Approve oleh Logistik") if self.location_dest_id.id == 47 and not self.env.user.is_purchasing_manager: - raise UserError("Transfer ke gudang selisih harus di approve Rafly Hanggara") - - # if self.group_id.sale_id: - # if self.group_id.sale_id.payment_link_midtrans: - # if self.group_id.sale_id.payment_status != 'settlement' and self.group_id.sale_id.state == 'draft': - # raise UserError('Uang belum masuk (settlement), mohon konfirmasi ke sales atau finance') + raise UserError("Transfer ke gudang selisih harus di approve Rafly Hanggara") if self.is_internal_use: self.approval_status = 'approved' @@ -707,14 +789,57 @@ class StockPicking(models.Model): if not self.date_reserved: current_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') self.date_reserved = current_time - + self.validation_minus_onhand_quantity() self.responsible = self.env.user.id res = super(StockPicking, self).button_validate() self.calculate_line_no() self.date_done = datetime.datetime.utcnow() self.state_reserve = 'done' + + template = self.env.ref('indoteknik_custom.mail_template_invoice_po_document') + if template and self.purchase_id: + # Render email body + email_values = template.sudo().generate_email( + res_ids=[self.purchase_id.id], + fields=['body_html'] + ) + rendered_body = email_values.get(self.purchase_id.id, {}).get('body_html', '') + + # Render report dengan XML ID + report = self.env.ref('purchase.action_report_purchase_order') # Gunakan XML ID laporan + if not report: + raise UserError("Laporan dengan XML ID 'purchase.action_report_purchase_order' tidak ditemukan.") + + # Render laporan ke PDF + pdf_content, _ = report._render_qweb_pdf([self.purchase_id.id]) + report_content = base64.b64encode(pdf_content).decode('utf-8') + + # Kirim email menggunakan template + email_sent = template.sudo().send_mail(self.purchase_id.id, force_send=True) + + if email_sent: + # Buat attachment untuk laporan + attachment = self.env['ir.attachment'].create({ + 'name': self.purchase_id.name or "Laporan Invoice.pdf", + 'type': 'binary', + 'datas': report_content, + 'res_model': 'purchase.order', + 'res_id': self.purchase_id.id, + 'mimetype': 'application/pdf', + }) + + # Tambahkan isi email dan laporan ke log note + self.purchase_id.message_post( + body=rendered_body, + subject="Pengiriman Email Invoice", + message_type='comment', + subtype_xmlid="mail.mt_note", + attachment_ids=[attachment.id], + ) + return res + def action_cancel(self): if not self.env.user.is_logistic_approver and self.env.context.get('active_model') == 'stock.picking': if self.origin and 'Return of' in self.origin: @@ -858,4 +983,50 @@ class StockPicking(models.Model): formatted_fastest_eta = fastest_eta.strftime(format_time_fastest) formatted_longest_eta = longest_eta.strftime(format_time) - return f'{formatted_fastest_eta} - {formatted_longest_eta}' \ No newline at end of file + return f'{formatted_fastest_eta} - {formatted_longest_eta}' + +# class CheckProduct(models.Model): +# _name = 'check.product' +# _description = 'Check Product' +# _order = 'picking_id, id' + +# picking_id = fields.Many2one('stock.picking', string='Picking Reference', required=True, ondelete='cascade', index=True, copy=False) +# product_id = fields.Many2one('product.product', string='Product') + + +# @api.constrains('product_id') +# def check_product_validity(self): +# """ +# Validate if the product exists in the related stock.picking's move_ids_without_package +# and ensure that the product's quantity does not exceed the available product_uom_qty. +# """ +# for record in self: +# if not record.picking_id or not record.product_id: +# continue + +# # Filter move lines in the related picking for the selected product +# moves = record.picking_id.move_ids_without_package.filtered( +# lambda move: move.product_id.id == record.product_id.id +# ) + +# if not moves: +# raise UserError(( +# "The product '%s' is not available in the related stock picking's moves. " +# "Please check and try again." +# ) % record.product_id.display_name) + +# # Calculate the total entries for the product in check.product for the same picking +# product_entries_count = self.search_count([ +# ('picking_id', '=', record.picking_id.id), +# ('product_id', '=', record.product_id.id) +# ]) + +# # Sum the product_uom_qty for all relevant moves +# total_qty_in_moves = sum(moves.mapped('product_uom_qty')) + +# # Compare the count of entries against the available quantity +# if product_entries_count > total_qty_in_moves: +# raise UserError(( +# "The product '%s' exceeds the allowable quantity (%s) in the related stock picking's moves. " +# "You can only add it %s times." +# ) % (record.product_id.display_name, total_qty_in_moves, total_qty_in_moves)) diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index fab83885..9d22903e 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -61,6 +61,11 @@ type="object" attrs="{'invisible': [('carrier_id', '!=', 151)]}" /> + @@ -168,6 +173,17 @@ + + + + + + + + + + + -- cgit v1.2.3 From c5f049fd628ce1f8c6b7c65282fbfd4bb2739ebc Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Sat, 11 Jan 2025 14:44:04 +0700 Subject: delete temporary --- indoteknik_custom/views/stock_picking.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index be281983..30ef0f7a 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -84,9 +84,6 @@ - - 1 - -- cgit v1.2.3 From 20b7432d8566d25371e3a3277ed3931aa59cdf0c Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Sat, 11 Jan 2025 15:56:13 +0700 Subject: cr attrs product uom qty --- indoteknik_custom/views/stock_picking.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index be281983..e38dd0c7 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -85,7 +85,7 @@ - 1 + {'readonly': [('picking_type_code', '=', 'incoming')]} -- cgit v1.2.3 From 88a54aebe579809dcaf8d8fd9640d5c4db83f2d6 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Sat, 11 Jan 2025 16:15:08 +0700 Subject: fix bug --- indoteknik_custom/views/stock_picking.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index e38dd0c7..882e5a29 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -85,7 +85,7 @@ - {'readonly': [('picking_type_code', '=', 'incoming')]} + {'readonly': [('parent.picking_type_code', '=', 'incoming')]} -- cgit v1.2.3 From fcefddc96acc561ec13d52e734eaf04b041d4a0b Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Mon, 13 Jan 2025 11:24:08 +0700 Subject: update export xml by selected invoice --- indoteknik_custom/models/account_move.py | 32 ++++++++++++++ indoteknik_custom/models/coretax_fatur.py | 69 ++++++++++++++++++++----------- indoteknik_custom/views/account_move.xml | 8 ++++ 3 files changed, 85 insertions(+), 24 deletions(-) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 725b3c2d..42678847 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -325,3 +325,35 @@ class AccountMove(models.Model): # if rec.statement_line_id and not rec.statement_line_id.statement_id.is_edit and rec.statement_line_id.statement_id.state == 'confirm': # raise UserError('Bank Statement di Lock, Minta admin reconcile untuk unlock') # return res + + def validate_faktur_for_export(self): + invoices = self.filtered(lambda inv: not inv.is_efaktur_exported and + inv.state == 'posted' and + inv.move_type == 'out_invoice') + + invalid_invoices = self - invoices + if invalid_invoices: + invalid_ids = ", ".join(str(inv.id) for inv in invalid_invoices) + raise UserError(_( + "Faktur dengan ID berikut tidak valid untuk diekspor: {}.\n" + "Pastikan faktur dalam status 'posted', belum diekspor, dan merupakan 'out_invoice'.".format(invalid_ids) + )) + + return invoices + + def export_faktur_to_xml(self): + + valid_invoices = self.validate_faktur_for_export() + + # Panggil model coretax.faktur untuk menghasilkan XML + coretax_faktur = self.env['coretax.faktur'].create({}) + response = coretax_faktur.export_to_download(invoices=valid_invoices) + + current_time = datetime.utcnow() + # Tandai faktur sebagai sudah diekspor + valid_invoices.write({ + 'is_efaktur_exported': True, + 'date_efaktur_exported': current_time, # Set tanggal ekspor + }) + + return response diff --git a/indoteknik_custom/models/coretax_fatur.py b/indoteknik_custom/models/coretax_fatur.py index 32082774..00a8f5ab 100644 --- a/indoteknik_custom/models/coretax_fatur.py +++ b/indoteknik_custom/models/coretax_fatur.py @@ -2,6 +2,7 @@ from odoo import models, fields import xml.etree.ElementTree as ET from xml.dom import minidom import base64 +import re class CoretaxFaktur(models.Model): _name = 'coretax.faktur' @@ -9,68 +10,88 @@ class CoretaxFaktur(models.Model): export_file = fields.Binary(string="Export File", ) export_filename = fields.Char(string="Export File", ) + + def validate_and_format_number(slef, input_number): + # Hapus semua karakter non-digit + cleaned_number = re.sub(r'\D', '', input_number) + + # Hitung jumlah digit + digit_count = len(cleaned_number) + + # Jika jumlah digit kurang dari 15, tambahkan nol di depan + if digit_count < 16: + cleaned_number = cleaned_number.zfill(16) + + return cleaned_number - def generate_xml(self): + def generate_xml(self, invoices=None): # Buat root XML root = ET.Element('TaxInvoiceBulk', { 'xmlns:xsi': "http://www.w3.org/2001/XMLSchema-instance", 'xsi:noNamespaceSchemaLocation': "TaxInvoice.xsd" }) - ET.SubElement(root, 'TIN').text = '74.226.022.7-086.000' + ET.SubElement(root, 'TIN').text = '0742260227086000' # Tambahkan elemen ListOfTaxInvoice list_of_tax_invoice = ET.SubElement(root, 'ListOfTaxInvoice') # Dapatkan data faktur - inv_obj = self.env['account.move'] - invoices = inv_obj.search([('is_efaktur_exported','=',True), - ('state','=','posted'), - ('efaktur_id','!=', False), - ('move_type','=','out_invoice')], limit = 5) + # inv_obj = self.env['account.move'] + # invoices = inv_obj.search([('is_efaktur_exported','=',True), + # ('state','=','posted'), + # ('efaktur_id','!=', False), + # ('move_type','=','out_invoice')], limit = 5) + for invoice in invoices: tax_invoice = ET.SubElement(list_of_tax_invoice, 'TaxInvoice') + buyerTIN = self.validate_and_format_number(invoice.partner_id.npwp) if invoice.partner_id.npwp else '0000000000000000' + buyerIDTKU = buyerTIN.ljust(len(buyerTIN) + 6, '0') if invoice.partner_id.npwp else '000000' # Tambahkan elemen faktur ET.SubElement(tax_invoice, 'TaxInvoiceDate').text = invoice.invoice_date.strftime('%Y-%m-%d') if invoice.invoice_date else '' ET.SubElement(tax_invoice, 'TaxInvoiceOpt').text = 'Normal' - ET.SubElement(tax_invoice, 'TrxCode').text = '01' + ET.SubElement(tax_invoice, 'TrxCode').text = '04' ET.SubElement(tax_invoice, 'AddInfo') ET.SubElement(tax_invoice, 'CustomDoc') ET.SubElement(tax_invoice, 'RefDesc').text = invoice.name ET.SubElement(tax_invoice, 'FacilityStamp') ET.SubElement(tax_invoice, 'SellerIDTKU').text = '0742260227086000000000' - ET.SubElement(tax_invoice, 'BuyerTin').text = invoice.partner_id.npwp or '' - ET.SubElement(tax_invoice, 'BuyerDocument').text = 'TIN' - ET.SubElement(tax_invoice, 'BuyerCountry').text = 'IND' + ET.SubElement(tax_invoice, 'BuyerTin').text = buyerTIN + ET.SubElement(tax_invoice, 'BuyerDocument').text = 'TIN' if invoice.partner_id.npwp else 'Other ID' + ET.SubElement(tax_invoice, 'BuyerCountry').text = 'IDN' + ET.SubElement(tax_invoice, 'BuyerDocumentNumber').text = '-' + ET.SubElement(tax_invoice, 'BuyerName').text = invoice.partner_id.nama_wajib_pajak or '' + ET.SubElement(tax_invoice, 'BuyerAdress').text = invoice.partner_id.alamat_lengkap_text or '' ET.SubElement(tax_invoice, 'BuyerEmail').text = invoice.partner_id.email or '' - ET.SubElement(tax_invoice, 'BuyerIDTKU').text = '' + ET.SubElement(tax_invoice, 'BuyerIDTKU').text = buyerIDTKU # Tambahkan elemen ListOfGoodService list_of_good_service = ET.SubElement(tax_invoice, 'ListOfGoodService') for line in invoice.invoice_line_ids: + otherTaxBase = round(line.price_subtotal * (11/12)) if line.price_subtotal else 0 good_service = ET.SubElement(list_of_good_service, 'GoodService') - ET.SubElement(good_service, 'Opt').text = 'B' if line.product_id.type == 'service' else 'A' - ET.SubElement(good_service, 'Code').text = line.product_id.default_code + ET.SubElement(good_service, 'Opt').text = 'A' + ET.SubElement(good_service, 'Code') ET.SubElement(good_service, 'Name').text = line.name ET.SubElement(good_service, 'Unit').text = 'UM.0018' - ET.SubElement(good_service, 'Price').text = str(line.price_unit) + ET.SubElement(good_service, 'Price').text = str(round(line.price_subtotal/line.quantity, 2)) if line.price_subtotal else '0' ET.SubElement(good_service, 'Qty').text = str(line.quantity) - ET.SubElement(good_service, 'TotalDiscount').text = str(line.discount) - ET.SubElement(good_service, 'TaxBase').text = str(line.price_subtotal) - ET.SubElement(good_service, 'OtherTaxBase').text = str(line.price_subtotal) - ET.SubElement(good_service, 'VATRate').text = '0,11' - ET.SubElement(good_service, 'VAT').text = str(line.price_total * 0.11) - ET.SubElement(good_service, 'STLGRate').text = '' - ET.SubElement(good_service, 'STLG').text = '' + ET.SubElement(good_service, 'TotalDiscount').text = '0' + ET.SubElement(good_service, 'TaxBase').text = str(round(line.price_subtotal)) if line.price_subtotal else '0' + ET.SubElement(good_service, 'OtherTaxBase').text = str(otherTaxBase) + ET.SubElement(good_service, 'VATRate').text = '12' + ET.SubElement(good_service, 'VAT').text = str(round(otherTaxBase * 0.12, 2)) + ET.SubElement(good_service, 'STLGRate').text = '0' + ET.SubElement(good_service, 'STLG').text = '0' # Pretty print XML xml_str = ET.tostring(root, encoding='utf-8') xml_pretty = minidom.parseString(xml_str).toprettyxml(indent=" ") return xml_pretty - def export_to_download(self): + def export_to_download(self, invoices): # Generate XML content - xml_content = self.generate_xml() + xml_content = self.generate_xml(invoices) # Encode content to Base64 xml_encoded = base64.b64encode(xml_content.encode('utf-8')) diff --git a/indoteknik_custom/views/account_move.xml b/indoteknik_custom/views/account_move.xml index 2863af57..4cc35b6d 100644 --- a/indoteknik_custom/views/account_move.xml +++ b/indoteknik_custom/views/account_move.xml @@ -163,5 +163,13 @@ code action = records.open_form_multi_create_reklas_penjualan() + + + Export Faktur ke XML + + + code + action = records.export_faktur_to_xml() + \ No newline at end of file -- cgit v1.2.3 From 14a677c77defd6f5c92af2db6f128e3f7227ddf6 Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Mon, 13 Jan 2025 14:27:36 +0700 Subject: update customer non pkp --- indoteknik_custom/models/coretax_fatur.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/coretax_fatur.py b/indoteknik_custom/models/coretax_fatur.py index 00a8f5ab..2f85a97f 100644 --- a/indoteknik_custom/models/coretax_fatur.py +++ b/indoteknik_custom/models/coretax_fatur.py @@ -44,8 +44,8 @@ class CoretaxFaktur(models.Model): for invoice in invoices: tax_invoice = ET.SubElement(list_of_tax_invoice, 'TaxInvoice') - buyerTIN = self.validate_and_format_number(invoice.partner_id.npwp) if invoice.partner_id.npwp else '0000000000000000' - buyerIDTKU = buyerTIN.ljust(len(buyerTIN) + 6, '0') if invoice.partner_id.npwp else '000000' + buyerTIN = self.validate_and_format_number(invoice.partner_id.npwp) if invoice.partner_id.customer_type == 'pkp' else '0000000000000000' + buyerIDTKU = buyerTIN.ljust(len(buyerTIN) + 6, '0') if invoice.partner_id.customer_type == 'pkp' else '000000' # Tambahkan elemen faktur ET.SubElement(tax_invoice, 'TaxInvoiceDate').text = invoice.invoice_date.strftime('%Y-%m-%d') if invoice.invoice_date else '' -- cgit v1.2.3 From 8579a74d62ea1c730159fc6969fabdb44285b288 Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Mon, 13 Jan 2025 15:01:43 +0700 Subject: feedback buyrTIN --- indoteknik_custom/models/coretax_fatur.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/coretax_fatur.py b/indoteknik_custom/models/coretax_fatur.py index 2f85a97f..74f9c8b7 100644 --- a/indoteknik_custom/models/coretax_fatur.py +++ b/indoteknik_custom/models/coretax_fatur.py @@ -14,6 +14,10 @@ class CoretaxFaktur(models.Model): def validate_and_format_number(slef, input_number): # Hapus semua karakter non-digit cleaned_number = re.sub(r'\D', '', input_number) + + total_sum = sum(int(char) for char in cleaned_number) + if total_sum == 0 : + return '0000000000000000' # Hitung jumlah digit digit_count = len(cleaned_number) @@ -44,8 +48,8 @@ class CoretaxFaktur(models.Model): for invoice in invoices: tax_invoice = ET.SubElement(list_of_tax_invoice, 'TaxInvoice') - buyerTIN = self.validate_and_format_number(invoice.partner_id.npwp) if invoice.partner_id.customer_type == 'pkp' else '0000000000000000' - buyerIDTKU = buyerTIN.ljust(len(buyerTIN) + 6, '0') if invoice.partner_id.customer_type == 'pkp' else '000000' + buyerTIN = self.validate_and_format_number(invoice.partner_id.npwp) + buyerIDTKU = buyerTIN.ljust(len(buyerTIN) + 6, '0') if sum(int(char) for char in buyerTIN) > 0 else '000000' # Tambahkan elemen faktur ET.SubElement(tax_invoice, 'TaxInvoiceDate').text = invoice.invoice_date.strftime('%Y-%m-%d') if invoice.invoice_date else '' -- cgit v1.2.3 From 7c6f97ba1b4e8fb54204697a3835bcb78a1ddc6b Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Mon, 13 Jan 2025 15:25:44 +0700 Subject: udpate other id --- indoteknik_custom/models/coretax_fatur.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/coretax_fatur.py b/indoteknik_custom/models/coretax_fatur.py index 74f9c8b7..d8b9dc72 100644 --- a/indoteknik_custom/models/coretax_fatur.py +++ b/indoteknik_custom/models/coretax_fatur.py @@ -61,7 +61,7 @@ class CoretaxFaktur(models.Model): ET.SubElement(tax_invoice, 'FacilityStamp') ET.SubElement(tax_invoice, 'SellerIDTKU').text = '0742260227086000000000' ET.SubElement(tax_invoice, 'BuyerTin').text = buyerTIN - ET.SubElement(tax_invoice, 'BuyerDocument').text = 'TIN' if invoice.partner_id.npwp else 'Other ID' + ET.SubElement(tax_invoice, 'BuyerDocument').text = 'TIN' if sum(int(char) for char in buyerTIN) > 0 else 'Other ID' ET.SubElement(tax_invoice, 'BuyerCountry').text = 'IDN' ET.SubElement(tax_invoice, 'BuyerDocumentNumber').text = '-' ET.SubElement(tax_invoice, 'BuyerName').text = invoice.partner_id.nama_wajib_pajak or '' -- cgit v1.2.3 From efefae8a0bdb05f36e0aeee9d06927a55fe648a6 Mon Sep 17 00:00:00 2001 From: trisusilo48 Date: Mon, 13 Jan 2025 15:41:04 +0700 Subject: udpate buyer doc number --- indoteknik_custom/models/coretax_fatur.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/models/coretax_fatur.py b/indoteknik_custom/models/coretax_fatur.py index d8b9dc72..ff8606b1 100644 --- a/indoteknik_custom/models/coretax_fatur.py +++ b/indoteknik_custom/models/coretax_fatur.py @@ -63,7 +63,7 @@ class CoretaxFaktur(models.Model): ET.SubElement(tax_invoice, 'BuyerTin').text = buyerTIN ET.SubElement(tax_invoice, 'BuyerDocument').text = 'TIN' if sum(int(char) for char in buyerTIN) > 0 else 'Other ID' ET.SubElement(tax_invoice, 'BuyerCountry').text = 'IDN' - ET.SubElement(tax_invoice, 'BuyerDocumentNumber').text = '-' + ET.SubElement(tax_invoice, 'BuyerDocumentNumber').text = str(invoice.partner_id.id) ET.SubElement(tax_invoice, 'BuyerName').text = invoice.partner_id.nama_wajib_pajak or '' ET.SubElement(tax_invoice, 'BuyerAdress').text = invoice.partner_id.alamat_lengkap_text or '' ET.SubElement(tax_invoice, 'BuyerEmail').text = invoice.partner_id.email or '' -- cgit v1.2.3 From 262013945e9729f9cea9a17f2060ec607bc42b64 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Tue, 14 Jan 2025 08:30:38 +0700 Subject: hapus ppn 12% dari branch --- indoteknik_api/controllers/api_v1/sale_order.py | 2 +- indoteknik_api/models/product_product.py | 8 ++++---- indoteknik_custom/models/logbook_bill.py | 2 +- indoteknik_custom/models/promotion/sale_order.py | 2 +- indoteknik_custom/models/purchase_pricelist.py | 4 ++-- indoteknik_custom/models/requisition.py | 2 +- indoteknik_custom/models/sale_order.py | 10 +++++----- indoteknik_custom/models/sale_order_line.py | 6 +++--- indoteknik_custom/models/stock_move.py | 2 +- indoteknik_custom/models/website_user_cart.py | 6 +++--- 10 files changed, 22 insertions(+), 22 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py index f972fd46..8b95ade8 100644 --- a/indoteknik_api/controllers/api_v1/sale_order.py +++ b/indoteknik_api/controllers/api_v1/sale_order.py @@ -398,7 +398,7 @@ class SaleOrder(controller.Controller): parameters = { 'warehouse_id': 8, 'carrier_id': 1, - 'sales_tax_id': 218, + 'sales_tax_id': 23, 'pricelist_id': user_pricelist or product_pricelist_default_discount_id, 'payment_term_id': 26, 'team_id': 2, diff --git a/indoteknik_api/models/product_product.py b/indoteknik_api/models/product_product.py index d7e20ac3..10922186 100644 --- a/indoteknik_api/models/product_product.py +++ b/indoteknik_api/models/product_product.py @@ -229,7 +229,7 @@ class ProductProduct(models.Model): def _get_pricelist_tier(self, tier_number): config_param_name = f'product.pricelist.tier{tier_number}' product_pricelist_tier = int(self.env['ir.config_parameter'].get_param(config_param_name)) - default_divide_tax = float(1.12) + default_divide_tax = float(1.11) base_price = discount = price = 0 pricelist_item = self.env['product.pricelist.item'].search([ ('pricelist_id', '=', int(product_pricelist_tier)), @@ -273,12 +273,12 @@ class ProductProduct(models.Model): base_price = 0 if base_pricelist: base_price = base_pricelist.computed_price - # base_price = base_pricelist.computed_price / 1.12 + # base_price = base_pricelist.computed_price / 1.11 discount = 0 price_flashsale = 0 - default_divide_tax = float(1.12) - default_tax = float(12) + default_divide_tax = float(1.11) + default_tax = float(11) if item.price_discount > 0: discount = item.price_discount price_flashsale = base_price - (base_price * discount // 100) diff --git a/indoteknik_custom/models/logbook_bill.py b/indoteknik_custom/models/logbook_bill.py index 3c33aeb7..bb956092 100644 --- a/indoteknik_custom/models/logbook_bill.py +++ b/indoteknik_custom/models/logbook_bill.py @@ -22,7 +22,7 @@ class LogbookBill(models.TransientModel): ('product_id', '=', line.product_id.id), ], order='id desc', limit=1) total += line.quantity_done * po.price_unit - total_with_tax = total * 1.12 + total_with_tax = total * 1.11 return total_with_tax diff --git a/indoteknik_custom/models/promotion/sale_order.py b/indoteknik_custom/models/promotion/sale_order.py index 6cb56914..1c31d060 100644 --- a/indoteknik_custom/models/promotion/sale_order.py +++ b/indoteknik_custom/models/promotion/sale_order.py @@ -37,7 +37,7 @@ class SaleOrder(models.Model): else: all_products = self._merge_promotion_products(promotion) - promotion_price = promotion['price']['price_discount'] * line.quantity * 1.12 + promotion_price = promotion['price']['price_discount'] * line.quantity * 1.11 promotion_amt_total = sum(product['price']['price'] * product['qty'] for product in all_products) promotion_used_price = 0 diff --git a/indoteknik_custom/models/purchase_pricelist.py b/indoteknik_custom/models/purchase_pricelist.py index c543070a..e5b35d7f 100755 --- a/indoteknik_custom/models/purchase_pricelist.py +++ b/indoteknik_custom/models/purchase_pricelist.py @@ -48,9 +48,9 @@ class PurchasePricelist(models.Model): def _constrains_include_price(self): price, taxes = self._get_valid_price() - # When have tax is excluded or empty tax, then multiply by 1.12 + # When have tax is excluded or empty tax, then multiply by 1.11 if (taxes and not taxes.price_include) or not taxes: - price *= 1.12 + price *= 1.11 self.include_price = price diff --git a/indoteknik_custom/models/requisition.py b/indoteknik_custom/models/requisition.py index 78cdf80d..c972b485 100644 --- a/indoteknik_custom/models/requisition.py +++ b/indoteknik_custom/models/requisition.py @@ -159,7 +159,7 @@ class Requisition(models.Model): offset=i * PRODUCT_PER_PO, limit=PRODUCT_PER_PO ) - tax = [220] + tax = [22] for line in lines: product = line.product_id diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 2ef1f43d..7b2d9bf8 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -1218,7 +1218,7 @@ class SaleOrder(models.Model): line_voucher = used_discount * line_contribution line_voucher_item = line_voucher / line.product_uom_qty - line_price_unit = line.price_unit / 1.12 if any(tax.id == 217 for tax in line.tax_id) else line.price_unit + line_price_unit = line.price_unit / 1.11 if any(tax.id == 23 for tax in line.tax_id) else line.price_unit line_discount_item = line_price_unit * line.discount / 100 + line_voucher_item line_voucher_item = line_discount_item / line_price_unit * 100 @@ -1331,13 +1331,13 @@ class SaleOrder(models.Model): if last_so and rec_purchase_price != last_so.purchase_price: rec_taxes = self.env['account.tax'].search([('id', '=', rec_taxes_id)], limit=1) if rec_taxes.price_include: - selling_price = (rec_purchase_price / 1.12) / (1 - (last_so.item_percent_margin_without_deduction / 100)) + selling_price = (rec_purchase_price / 1.11) / (1 - (last_so.item_percent_margin_without_deduction / 100)) else: selling_price = rec_purchase_price / (1 - (last_so.item_percent_margin_without_deduction / 100)) tax_id = last_so.tax_id for tax in tax_id: if tax.price_include: - selling_price = selling_price + (selling_price*12/100) + selling_price = selling_price + (selling_price*11/100) else: selling_price = selling_price discount = 0 @@ -1353,13 +1353,13 @@ class SaleOrder(models.Model): elif last_so and rec_vendor_id == order_line.vendor_id.id and rec_purchase_price != last_so.purchase_price: rec_taxes = self.env['account.tax'].search([('id', '=', rec_taxes_id)], limit=1) if rec_taxes.price_include: - selling_price = (rec_purchase_price / 1.12) / (1 - (last_so.item_percent_margin_without_deduction / 100)) + selling_price = (rec_purchase_price / 1.11) / (1 - (last_so.item_percent_margin_without_deduction / 100)) else: selling_price = rec_purchase_price / (1 - (last_so.item_percent_margin_without_deduction / 100)) tax_id = last_so.tax_id for tax in tax_id: if tax.price_include: - selling_price = selling_price + (selling_price*12/100) + selling_price = selling_price + (selling_price*11/100) else: selling_price = selling_price discount = 0 diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index 5b990ed0..29a046fa 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -104,7 +104,7 @@ class SaleOrderLine(models.Model): purchase_price = line.purchase_price if line.purchase_tax_id.price_include: - purchase_price = line.purchase_price / 1.12 + purchase_price = line.purchase_price / 1.11 purchase_price = purchase_price * line.product_uom_qty margin_per_item = sales_price - purchase_price @@ -132,7 +132,7 @@ class SaleOrderLine(models.Model): purchase_price = line.purchase_price if line.purchase_tax_id.price_include: - purchase_price = line.purchase_price / 1.12 + purchase_price = line.purchase_price / 1.11 purchase_price = purchase_price * line.product_uom_qty margin_per_item = sales_price - purchase_price @@ -183,7 +183,7 @@ class SaleOrderLine(models.Model): # # tax_id = last_so.tax_id # if rec_vendor_id == self.vendor_id and rec_purchase_price != last_so.purchase_price: # if rec_taxes.price_include: - # selling_price = (rec_purchase_price/1.12) / (1-(last_so.line_item_margin / 100)) + # selling_price = (rec_purchase_price/1.11) / (1-(last_so.line_item_margin / 100)) # else: # selling_price = rec_purchase_price / (1-(last_so.line_item_margin / 100)) # tax_id = last_so.tax_id diff --git a/indoteknik_custom/models/stock_move.py b/indoteknik_custom/models/stock_move.py index c0ac341c..e1d4e74c 100644 --- a/indoteknik_custom/models/stock_move.py +++ b/indoteknik_custom/models/stock_move.py @@ -112,7 +112,7 @@ class StockMove(models.Model): # 440 is static id for "PPN Keluaran" on account.account model debit_account_id = self.picking_id.account_id.id if self.picking_id.account_id.id else 538 - tax = cost * (12 / 100) + tax = cost * (11 / 100) move_lines = self._prepare_account_move_line(qty, cost, credit_account_id, debit_account_id, description) move_lines += self._prepare_account_move_line(qty, tax, 440, debit_account_id, description) diff --git a/indoteknik_custom/models/website_user_cart.py b/indoteknik_custom/models/website_user_cart.py index 8da716a1..44393cf1 100644 --- a/indoteknik_custom/models/website_user_cart.py +++ b/indoteknik_custom/models/website_user_cart.py @@ -163,7 +163,7 @@ class WebsiteUserCart(models.Model): voucher_shipping_info = voucher_shipping.apply(order_line) discount_voucher_shipping = voucher_shipping_info['discount']['all'] - tax = round(subtotal * 0.12) + tax = round(subtotal * 0.11) grand_total = subtotal + tax total_weight = sum(x['weight'] * x['quantity'] for x in products) total_weight = round(total_weight, 2) @@ -240,7 +240,7 @@ class WebsiteUserCart(models.Model): total_voucher += voucher_product if total_discount > 0: - ppn = total_discount * 0.12 + ppn = total_discount * 0.11 return { 'total_discount': self.format_currency(total_discount), 'total_voucher': self.format_currency(total_voucher), @@ -352,7 +352,7 @@ class WebsiteUserCart(models.Model): discounted_price = fixed_price - (fixed_price * discount / 100) - final_price = discounted_price / 1.12 + final_price = discounted_price / 1.11 return { 'price': final_price, -- cgit v1.2.3
Hai. ${object.pengajuan_tempo_id.name_tempo.name},
Kabar baik! Kami dengan senang hati menginformasikan bahwa pengajuan tempo pembayaran kamu di Indoteknik.com telah disetujui dengan detail sebagai berikut.
Kabar baik! Kami dengan senang hati menginformasikan bahwa pengajuan tempo pembayaran anda di Indoteknik.com telah disetujui dengan detail sebagai berikut.
Limit Pembayaran Tempo : Rp ${object.format_currency(object.user_id.tempo_limit)}
Durasi Pembayaran Tempo : ${object.user_id.tempo_duration.name}
Kamu dapat melakukan pembayaran sesuai dengan jangka waktu yang telah disepakati. Detail lengkap mengenai transaksi kamu, termasuk tanggal jatuh tempo & Pengajuan Kenaikan Limit Tempo, dapat kamu lihat di akun Profile Indoteknik.com .Anda dapat melakukan pembayaran sesuai dengan jangka waktu yang telah disepakati. Detail lengkap mengenai transaksi anda, termasuk tanggal jatuh tempo & Pengajuan Kenaikan Limit Tempo, dapat anda lihat di akun Profile Indoteknik.com .
Terima kasih atas kepercayaan kamu kepada Indoteknik.com.
Terima kasih atas kepercayaan anda kepada Indoteknik.com.
Hormat kami,
PT. INDOTEKNIK DOTCOM GEMILANG