From 35c539953611d7e8968a23996df91738b2c6fc94 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Mon, 4 Aug 2025 12:48:11 +0700 Subject: testing --- indoteknik_custom/models/commision.py | 31 +++++++++++++++++++++++++++--- indoteknik_custom/models/cust_commision.py | 1 - 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/indoteknik_custom/models/commision.py b/indoteknik_custom/models/commision.py index 9f7df464..a900a399 100644 --- a/indoteknik_custom/models/commision.py +++ b/indoteknik_custom/models/commision.py @@ -399,6 +399,29 @@ class CustomerCommision(models.Model): # result = super(CustomerCommision, self).create(vals) # return result + def _fill_note_finance(self): + for rec in self: + if rec.status == 'approved' and rec.commision_type == 'fee': + fee_percent = rec.commision_percent or 0.0 + dpp = rec.total_dpp or 0.0 + + fee = dpp * fee_percent / 100 + pph21 = 0.5 * fee * 0.05 + fee_net = fee - pph21 + + rec.note_finance = ( + "Kelengkapan data penerima fee sudah lengkap (NPWP dan KTP)\n" + f"Perhitungan Fee ({fee_percent:.0f}%) dari nilai DPP pada Invoice terlampir sudah\n" + f"sesuai yaitu Rp {fee:,.0f}\n" + "Sesuai PMK No. 168 tahun 2023, komisi fee dikenakan PPH 21\n" + "sebesar :\n" + f"= 50% x Penghasilan Bruto x 5%\n" + f"= 50% x Rp {fee:,.0f} x 5%\n" + f"= Rp {pph21:,.0f}\n" + "Sehingga fee bersih sebesar\n" + f"= Rp {fee:,.0f} - Rp {pph21:,.0f}\n" + f"= Rp {fee_net:,.0f}" + ) def action_confirm_customer_commision(self): jakarta_tz = pytz.timezone('Asia/Jakarta') now = datetime.now(jakarta_tz) @@ -407,12 +430,12 @@ class CustomerCommision(models.Model): if not self.status or self.status == 'draft': self.status = 'pengajuan1' - elif self.status == 'pengajuan1' and self.env.user.id == 19: + elif self.status == 'pengajuan1': self.status = 'pengajuan2' self.approved_by = (self.approved_by + ', ' if self.approved_by else '') + self.env.user.name self.date_approved_sales = now_naive self.position_sales = 'Sales Manager' - elif self.status == 'pengajuan2' and self.env.user.id == 216: + elif self.status == 'pengajuan2': self.status = 'pengajuan3' self.approved_by = (self.approved_by + ', ' if self.approved_by else '') + self.env.user.name self.date_approved_marketing = now_naive @@ -422,9 +445,11 @@ class CustomerCommision(models.Model): self.approved_by = (self.approved_by + ', ' if self.approved_by else '') + self.env.user.name self.date_approved_pimpinan = now_naive self.position_pimpinan = 'Pimpinan' - elif self.status == 'pengajuan4' and self.env.user.id == 1272: + elif self.status == 'pengajuan4': for line in self.commision_lines: line.invoice_id.is_customer_commision = True + if self.commision_type == 'fee': + self._fill_note_finance() self.status = 'approved' self.approved_by = (self.approved_by + ', ' if self.approved_by else '') + self.env.user.name self.date_approved_accounting = now_naive diff --git a/indoteknik_custom/models/cust_commision.py b/indoteknik_custom/models/cust_commision.py index c3105cfd..05c68935 100644 --- a/indoteknik_custom/models/cust_commision.py +++ b/indoteknik_custom/models/cust_commision.py @@ -34,4 +34,3 @@ class CustCommision(models.Model): for rec in duplicate_partner: if self.commision_type == rec.commision_type: raise UserError('Partner already exists') - \ No newline at end of file -- cgit v1.2.3 From 4dbaaade2793487477b4d83bfb76a838931707dd Mon Sep 17 00:00:00 2001 From: Miqdad Date: Mon, 4 Aug 2025 13:31:29 +0700 Subject: testing --- indoteknik_custom/models/commision.py | 42 +++++++++++++++++------------------ 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/indoteknik_custom/models/commision.py b/indoteknik_custom/models/commision.py index a900a399..3f56b7f3 100644 --- a/indoteknik_custom/models/commision.py +++ b/indoteknik_custom/models/commision.py @@ -208,7 +208,7 @@ class CustomerCommision(models.Model): ('pending', 'Pending'), ('payment', 'Payment'), ], string='Payment Status', copy=False, readonly=True, tracking=3, default='pending') - note_finnance = fields.Text('Notes Finnance') + note_finnance = fields.Text('Notes Finance') reason_reject = fields.Char(string='Reason Reaject', tracking=True, track_visibility='onchange') approved_by = fields.Char(string='Approved By', tracking=True, track_visibility='always') @@ -401,27 +401,25 @@ class CustomerCommision(models.Model): def _fill_note_finance(self): for rec in self: - if rec.status == 'approved' and rec.commision_type == 'fee': - fee_percent = rec.commision_percent or 0.0 - dpp = rec.total_dpp or 0.0 - - fee = dpp * fee_percent / 100 - pph21 = 0.5 * fee * 0.05 - fee_net = fee - pph21 - - rec.note_finance = ( - "Kelengkapan data penerima fee sudah lengkap (NPWP dan KTP)\n" - f"Perhitungan Fee ({fee_percent:.0f}%) dari nilai DPP pada Invoice terlampir sudah\n" - f"sesuai yaitu Rp {fee:,.0f}\n" - "Sesuai PMK No. 168 tahun 2023, komisi fee dikenakan PPH 21\n" - "sebesar :\n" - f"= 50% x Penghasilan Bruto x 5%\n" - f"= 50% x Rp {fee:,.0f} x 5%\n" - f"= Rp {pph21:,.0f}\n" - "Sehingga fee bersih sebesar\n" - f"= Rp {fee:,.0f} - Rp {pph21:,.0f}\n" - f"= Rp {fee_net:,.0f}" - ) + fee_percent = rec.commision_percent or 0.0 + dpp = rec.total_dpp or 0.0 + + fee = dpp * fee_percent / 100 + pph21 = 0.5 * fee * 0.05 + fee_net = fee - pph21 + rec.note_finnance = ( + "Kelengkapan data penerima fee sudah lengkap (NPWP dan KTP)\n" + f"Perhitungan Fee ({fee_percent:.0f}%) dari nilai DPP pada Invoice terlampir sudah\n" + f"sesuai yaitu Rp {fee:,.0f}\n" + "Sesuai PMK No. 168 tahun 2023, komisi fee dikenakan PPH 21\n" + "sebesar :\n" + f"= 50% x Penghasilan Bruto x 5%\n" + f"= 50% x Rp {fee:,.0f} x 5%\n" + f"= Rp {pph21:,.0f}\n" + "Sehingga fee bersih sebesar\n" + f"= Rp {fee:,.0f} - Rp {pph21:,.0f}\n" + f"= Rp {fee_net:,.0f}" + ) def action_confirm_customer_commision(self): jakarta_tz = pytz.timezone('Asia/Jakarta') now = datetime.now(jakarta_tz) -- cgit v1.2.3 From 40cb418248b940bb28e5cc5938afed1c27eb7855 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Mon, 4 Aug 2025 13:36:58 +0700 Subject: fix --- indoteknik_custom/models/commision.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/indoteknik_custom/models/commision.py b/indoteknik_custom/models/commision.py index 3f56b7f3..6d538b83 100644 --- a/indoteknik_custom/models/commision.py +++ b/indoteknik_custom/models/commision.py @@ -428,12 +428,12 @@ class CustomerCommision(models.Model): if not self.status or self.status == 'draft': self.status = 'pengajuan1' - elif self.status == 'pengajuan1': + elif self.status == 'pengajuan1' and self.env.user.id == 19: self.status = 'pengajuan2' self.approved_by = (self.approved_by + ', ' if self.approved_by else '') + self.env.user.name self.date_approved_sales = now_naive self.position_sales = 'Sales Manager' - elif self.status == 'pengajuan2': + elif self.status == 'pengajuan2' and self.env.user.id == 216: self.status = 'pengajuan3' self.approved_by = (self.approved_by + ', ' if self.approved_by else '') + self.env.user.name self.date_approved_marketing = now_naive @@ -443,7 +443,7 @@ class CustomerCommision(models.Model): self.approved_by = (self.approved_by + ', ' if self.approved_by else '') + self.env.user.name self.date_approved_pimpinan = now_naive self.position_pimpinan = 'Pimpinan' - elif self.status == 'pengajuan4': + elif self.status == 'pengajuan4' and self.env.user.id == 1272: for line in self.commision_lines: line.invoice_id.is_customer_commision = True if self.commision_type == 'fee': -- cgit v1.2.3 From 8386a9affb5e17b09ba76702f7fb01f070a5f713 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Mon, 4 Aug 2025 14:48:36 +0700 Subject: remove vendor bill val --- indoteknik_custom/models/tukar_guling_po.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/indoteknik_custom/models/tukar_guling_po.py b/indoteknik_custom/models/tukar_guling_po.py index 92d8c9a6..21f973a2 100644 --- a/indoteknik_custom/models/tukar_guling_po.py +++ b/indoteknik_custom/models/tukar_guling_po.py @@ -281,7 +281,7 @@ class TukarGulingPO(models.Model): def write(self, vals): if self.operations.picking_type_id.id not in [75, 28]: raise UserError("❌ Tidak bisa retur bukan BU/INPUT atau BU/PUT!") - self._check_bill_on_revisi_po() + # self._check_bill_on_revisi_po() tipe = vals.get('return_type', self.return_type) if self.operations and self.operations.picking_type_id.id == 28 and tipe == 'tukar_guling': @@ -349,7 +349,7 @@ class TukarGulingPO(models.Model): def action_submit(self): self.ensure_one() - self._check_bill_on_revisi_po() + # self._check_bill_on_revisi_po() self._validate_product_lines() self._check_not_allow_tukar_guling_on_bu_input() @@ -385,7 +385,7 @@ class TukarGulingPO(models.Model): def action_approve(self): self.ensure_one() self._validate_product_lines() - self._check_bill_on_revisi_po() + # self._check_bill_on_revisi_po() self._check_not_allow_tukar_guling_on_bu_input() if not self.operations: -- cgit v1.2.3 From 569fd1188a36aa97f0681bffe650dcbb9215f504 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Mon, 4 Aug 2025 15:05:50 +0700 Subject: remove vendor bill val --- indoteknik_custom/models/tukar_guling_po.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/indoteknik_custom/models/tukar_guling_po.py b/indoteknik_custom/models/tukar_guling_po.py index 21f973a2..467fff44 100644 --- a/indoteknik_custom/models/tukar_guling_po.py +++ b/indoteknik_custom/models/tukar_guling_po.py @@ -74,19 +74,19 @@ class TukarGulingPO(models.Model): return res - @api.constrains('return_type', 'operations') - def _check_bill_on_revisi_po(self): - for record in self: - if record.return_type == 'revisi_po' and record.origin: - bills = self.env['account.move'].search([ - ('invoice_origin', 'ilike', record.origin), - ('move_type', '=', 'in_invoice'), # hanya vendor bill - ('state', 'not in', ['draft', 'cancel']) - ]) - if bills: - raise ValidationError( - _("Tidak bisa memilih Return Type 'Revisi PO' karena PO %s sudah dibuat vendor bill.") % record.origin - ) + # @api.constrains('return_type', 'operations') + # def _check_bill_on_revisi_po(self): + # for record in self: + # if record.return_type == 'revisi_po' and record.origin: + # bills = self.env['account.move'].search([ + # ('invoice_origin', 'ilike', record.origin), + # ('move_type', '=', 'in_invoice'), # hanya vendor bill + # ('state', 'not in', ['draft', 'cancel']) + # ]) + # if bills: + # raise ValidationError( + # _("Tidak bisa memilih Return Type 'Revisi PO' karena PO %s sudah dibuat vendor bill.") % record.origin + # ) @api.onchange('operations') def _onchange_operations(self): -- cgit v1.2.3 From ced09a22623e17a3f1b12ba0d98fa5975b31bf51 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Mon, 4 Aug 2025 17:01:07 +0700 Subject: rev --- indoteknik_api/controllers/api_v1/sale_order.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py index fd460ea0..2348a126 100644 --- a/indoteknik_api/controllers/api_v1/sale_order.py +++ b/indoteknik_api/controllers/api_v1/sale_order.py @@ -607,9 +607,6 @@ class SaleOrder(controller.Controller): if is_flash_sale_item: is_has_disc = True _logger.info("Item is flash sale product - marked as discounted") - elif discount_percent > 0 and not global_flash_sale: - is_has_disc = True - _logger.info(f"Item has discount {discount_percent}% - marked as discounted") elif global_flash_sale: _logger.info("Global flash sale active but item not eligible - not marked as discounted") -- cgit v1.2.3 From 519c18161bf658853908ddf7216aab504ac4c743 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 5 Aug 2025 10:53:05 +0700 Subject: add tracking on delivery amt --- 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 47018f52..94cfdc39 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -163,7 +163,7 @@ class SaleOrder(models.Model): carrier_id = fields.Many2one('delivery.carrier', string='Shipping Method', tracking=3) have_visit_service = fields.Boolean(string='Have Visit Service', compute='_have_visit_service', help='To compute is customer get visit service') - delivery_amt = fields.Float(string='Delivery Amt', copy=False) + delivery_amt = fields.Float(string='Delivery Amt', copy=False, tracking=True) shipping_cost_covered = fields.Selection([ ('indoteknik', 'Indoteknik'), ('customer', 'Customer') -- cgit v1.2.3 From eb91fb8b9cf3ebc68f6c609acbc85015ce902cab Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 5 Aug 2025 11:24:34 +0700 Subject: add payment date on invoices --- indoteknik_custom/models/account_move.py | 12 ++++++++++++ indoteknik_custom/views/account_move.xml | 1 + 2 files changed, 13 insertions(+) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 1a6fad1c..929af949 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -94,6 +94,18 @@ class AccountMove(models.Model): compute='_compute_has_refund_so', ) + payment_date = fields.Date(string="Payment Date", compute='_compute_payment_date') + + def _compute_payment_date(self): + for move in self: + accountPayment = self.env['account.payment'] + + payment = accountPayment.search([]).filtered( + lambda p: move.id in p.reconciled_invoice_ids.ids + ) + + move.payment_date = payment[0].date + # def name_get(self): # result = [] # for move in self: diff --git a/indoteknik_custom/views/account_move.xml b/indoteknik_custom/views/account_move.xml index 9b1c791b..23f2d931 100644 --- a/indoteknik_custom/views/account_move.xml +++ b/indoteknik_custom/views/account_move.xml @@ -29,6 +29,7 @@ + -- cgit v1.2.3 From d115f21b64e72af553d7c8965b9426b2802a0e3c Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 5 Aug 2025 11:52:32 +0700 Subject: fix bug --- indoteknik_custom/models/account_move.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 929af949..4be6c984 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -104,7 +104,10 @@ class AccountMove(models.Model): lambda p: move.id in p.reconciled_invoice_ids.ids ) - move.payment_date = payment[0].date + if payment: + move.payment_date = payment[0].date + else: + move.payment_date = False # def name_get(self): # result = [] -- cgit v1.2.3 From 9a94ae612d22a0dc329649e610810e7d9b6c3112 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 5 Aug 2025 14:05:49 +0700 Subject: fix bug api indoteknik delivery --- indoteknik_api/controllers/api_v1/stock_picking.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/indoteknik_api/controllers/api_v1/stock_picking.py b/indoteknik_api/controllers/api_v1/stock_picking.py index 85b0fbba..762e17c5 100644 --- a/indoteknik_api/controllers/api_v1/stock_picking.py +++ b/indoteknik_api/controllers/api_v1/stock_picking.py @@ -125,28 +125,33 @@ class StockPicking(controller.Controller): @http.route(prefix + 'stock-picking//documentation', auth='public', methods=['PUT', 'OPTIONS'], csrf=False) @controller.Controller.must_authorized() def write_partner_stock_picking_documentation(self, **kw): - scanid = int(kw.get('scanid', 0)) + scanid = kw.get('scanid', '').strip() sj_document = kw.get('sj_document', False) paket_document = kw.get('paket_document', False) - params = {'sj_documentation': sj_document, - 'paket_documentation': paket_document, - 'driver_arrival_date': datetime.utcnow(), - } + params = { + 'sj_documentation': sj_document, + 'paket_documentation': paket_document, + 'driver_arrival_date': datetime.utcnow(), + } - picking_data = request.env['stock.picking'].search([('id', '=', scanid)], limit=1) + picking_data = False + if scanid.isdigit() and int(scanid) < 2147483647: + picking_data = request.env['stock.picking'].search([('id', '=', int(scanid))], limit=1) if not picking_data: picking_data = request.env['stock.picking'].search([('picking_code', '=', scanid)], limit=1) if not picking_data: return self.response(code=404, description='picking not found') + picking_data.write(params) return self.response({ 'name': picking_data.name }) + @http.route(prefix + 'webhook/biteship', type='json', auth='public', methods=['POST'], csrf=False) def update_status_from_biteship(self, **kw): _logger.info("Biteship Webhook: Request received at controller start (type='json').") -- cgit v1.2.3 From 2d7aaf7fe387dd778731a2058dbe3210407ad803 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 5 Aug 2025 14:42:35 +0700 Subject: deactive redirect bu related --- indoteknik_custom/models/purchase_order.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 27aca0d1..103a9131 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -1083,9 +1083,9 @@ class PurchaseOrder(models.Model): # Tambahan: redirect ke BU hanya untuk single PO yang berhasil dikonfirmasi _logger.info("Jumlah PO: %s | State: %s", len(self), self.state) - if len(self) == 1: - _logger.info("Redirecting ke BU") - return self.action_view_related_bu() + # if len(self) == 1: + # _logger.info("Redirecting ke BU") + # return self.action_view_related_bu() return res -- cgit v1.2.3 From c42bdba2996d85d328897e42e7a1d86001b3a14d Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 5 Aug 2025 15:21:56 +0700 Subject: multi update receipt date --- indoteknik_custom/__manifest__.py | 1 + indoteknik_custom/models/__init__.py | 1 + .../models/update_date_planned_po_wizard.py | 14 ++++++++++++ indoteknik_custom/security/ir.model.access.csv | 3 ++- indoteknik_custom/views/purchase_order.xml | 20 +++++++++++++++++ .../views/update_date_planned_po_wizard_view.xml | 25 ++++++++++++++++++++++ 6 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 indoteknik_custom/models/update_date_planned_po_wizard.py create mode 100644 indoteknik_custom/views/update_date_planned_po_wizard_view.xml diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 2a4db273..d1ae681a 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -174,6 +174,7 @@ # 'views/tukar_guling_return_views.xml' 'views/tukar_guling_po.xml', # 'views/refund_sale_order.xml', + 'views/update_date_planned_po_wizard_view.xml', ], 'demo': [], 'css': [], diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 51d25c1f..3a9f9312 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -156,3 +156,4 @@ from . import refund_sale_order # from . import patch from . import tukar_guling from . import tukar_guling_po +from . import update_date_planned_po_wizard \ No newline at end of file diff --git a/indoteknik_custom/models/update_date_planned_po_wizard.py b/indoteknik_custom/models/update_date_planned_po_wizard.py new file mode 100644 index 00000000..a0d241c8 --- /dev/null +++ b/indoteknik_custom/models/update_date_planned_po_wizard.py @@ -0,0 +1,14 @@ +from odoo import models, fields, api + +class PurchaseOrderUpdateDateWizard(models.TransientModel): + _name = 'purchase.order.update.date.wizard' + _description = 'Wizard to Update Receipt Date on Purchase Order Lines' + + date_planned = fields.Datetime(string="New Receipt Date", required=True) + + def action_update_date(self): + active_ids = self.env.context.get('active_ids', []) + orders = self.env['purchase.order'].browse(active_ids) + for order in orders: + order.write({'date_planned': self.date_planned}) + return {'type': 'ir.actions.act_window_close'} diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 9b43bf2a..d6e44f9d 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -191,4 +191,5 @@ access_tukar_guling_all_users,tukar.guling.all.users,model_tukar_guling,base.gro access_tukar_guling_line_all_users,tukar.guling.line.all.users,model_tukar_guling_line,base.group_user,1,1,1,1 access_tukar_guling_po_all_users,tukar.guling.po.all.users,model_tukar_guling_po,base.group_user,1,1,1,1 access_tukar_guling_line_po_all_users,tukar.guling.line.po.all.users,model_tukar_guling_line_po,base.group_user,1,1,1,1 -access_tukar_guling_mapping_koli_all_users,tukar.guling.mapping.koli.all.users,model_tukar_guling_mapping_koli,base.group_user,1,1,1,1 \ No newline at end of file +access_tukar_guling_mapping_koli_all_users,tukar.guling.mapping.koli.all.users,model_tukar_guling_mapping_koli,base.group_user,1,1,1,1 +access_purchase_order_update_date_wizard,access.purchase.order.update.date.wizard,model_purchase_order_update_date_wizard,base.group_user,1,1,1,1 \ No newline at end of file diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index fedcb4f9..15cdc788 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -428,4 +428,24 @@ action = records.open_form_multi_cancel() + + + Update Receipt Date + + + code + list + + action = { + 'type': 'ir.actions.act_window', + 'res_model': 'purchase.order.update.date.wizard', + 'view_mode': 'form', + 'target': 'new', + 'context': { + 'active_ids': env.context.get('active_ids', []), + }, + } + + + \ No newline at end of file diff --git a/indoteknik_custom/views/update_date_planned_po_wizard_view.xml b/indoteknik_custom/views/update_date_planned_po_wizard_view.xml new file mode 100644 index 00000000..6b3ab991 --- /dev/null +++ b/indoteknik_custom/views/update_date_planned_po_wizard_view.xml @@ -0,0 +1,25 @@ + + + purchase.order.update.date.wizard.form + purchase.order.update.date.wizard + +
+ + + +
+
+
+
+
+ + + Update Receipt Date + purchase.order.update.date.wizard + form + new + +
+ \ No newline at end of file -- cgit v1.2.3 From 9f9081714356e87500ab05bc5a294e9ca9e526fe Mon Sep 17 00:00:00 2001 From: Miqdad Date: Wed, 6 Aug 2025 08:49:56 +0700 Subject: inv and bil return option --- indoteknik_custom/models/account_move.py | 1 + indoteknik_custom/models/tukar_guling.py | 41 ++++++++++++++++-- indoteknik_custom/models/tukar_guling_po.py | 65 ++++++++++++++++++++++------- indoteknik_custom/views/tukar_guling.xml | 3 ++ indoteknik_custom/views/tukar_guling_po.xml | 3 ++ 5 files changed, 93 insertions(+), 20 deletions(-) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 4be6c984..b03d0a80 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -18,6 +18,7 @@ _logger = logging.getLogger(__name__) class AccountMove(models.Model): _inherit = 'account.move' _description = 'Account Move' + tukar_guling_po_id = fields.Many2one('tukar.guling.po', string='Tukar Guling PO Ref') invoice_day_to_due = fields.Integer(string="Day to Due", compute="_compute_invoice_day_to_due") bill_day_to_due = fields.Date(string="Day to Due", compute="_compute_bill_day_to_due") date_send_fp = fields.Datetime(string="Tanggal Kirim Faktur Pajak") diff --git a/indoteknik_custom/models/tukar_guling.py b/indoteknik_custom/models/tukar_guling.py index 3f81393a..d511779e 100644 --- a/indoteknik_custom/models/tukar_guling.py +++ b/indoteknik_custom/models/tukar_guling.py @@ -74,6 +74,38 @@ class TukarGuling(models.Model): date_sales = fields.Datetime('Approved Date Sales', tracking=3, readonly=True) date_logistic = fields.Datetime('Approved Date Logistic', tracking=3, readonly=True) + val_inv_opt = fields.Selection([ + ('tanpa_cancel', 'Tanpa Cancel Invoice'), + ('cancel_invoice', 'Cancel Invoice'), + ], tracking=3, string='Invoice Option') + + is_has_invoice = fields.Boolean('Has Invoice?', compute='_compute_is_has_invoice', readonly=True, default=False) + + invoice_id = fields.Many2one('account.move', string='Invoice Ref', readonly=True) + + @api.depends('origin') + def _compute_is_has_invoice(self): + for rec in self: + invoices = self.env['account.move'].search([ + ('invoice_origin', 'ilike', rec.origin), + ('move_type', '=', 'out_invoice'), # hanya invoice + ('state', 'not in', ['draft', 'cancel']) + ]) + if invoices: + rec.is_has_invoice = True + rec.invoice_id = invoices + else: + rec.is_has_invoice = False + + def set_opt(self): + if not self.val_inv_opt and self.is_has_invoice == True: + raise UserError("Kalau sudah ada invoice Return Invoice Option harus diisi!") + for rec in self: + if rec.val_inv_opt == 'cancel_invoice' and self.is_has_invoice == True: + raise UserError("Tidak bisa mengubah Return karena sudah ada invoice dan belum di cancel.") + elif rec.val_inv_opt == 'tanpa_cancel' and self.is_has_invoice == True: + continue + # @api.onchange('operations') # def get_partner_id(self): # if self.operations and self.operations.partner_id and self.operations.partner_id.name: @@ -288,7 +320,6 @@ class TukarGuling(models.Model): # ('state', '!=', 'cancel') # ]) > 0 - @api.constrains('return_type', 'operations') def _check_invoice_on_revisi_so(self): for record in self: if record.return_type == 'revisi_so' and record.origin: @@ -348,7 +379,7 @@ class TukarGuling(models.Model): self.ensure_one() if self.operations.picking_type_id.id not in [29, 30]: raise UserError("❌ Picking type harus BU/OUT atau BU/PICK") - self._check_invoice_on_revisi_so() + # self._check_invoice_on_revisi_so() operasi = self.operations.picking_type_id.id tipe = self.return_type pp = vals.get('return_type', tipe) @@ -455,7 +486,7 @@ class TukarGuling(models.Model): raise UserError( _("Qty di Koli tidak sesuai dengan qty retur untuk produk %s") % line.product_id.display_name) - self._check_invoice_on_revisi_so() + # self._check_invoice_on_revisi_so() self._validate_product_lines() if self.state != 'draft': @@ -506,7 +537,7 @@ class TukarGuling(models.Model): def action_approve(self): self.ensure_one() self._validate_product_lines() - self._check_invoice_on_revisi_so() + # self._check_invoice_on_revisi_so() self._check_not_allow_tukar_guling_on_bu_pick() operasi = self.operations.picking_type_id.id @@ -546,6 +577,8 @@ class TukarGuling(models.Model): elif rec.state == 'approval_finance': if not rec.env.user.has_group('indoteknik_custom.group_role_fat'): raise UserError("Hanya Finance Manager yang boleh approve tahap ini.") + rec._check_invoice_on_revisi_so() + rec.set_opt() rec.state = 'approval_logistic' rec.date_finance = now diff --git a/indoteknik_custom/models/tukar_guling_po.py b/indoteknik_custom/models/tukar_guling_po.py index 467fff44..83aa49fe 100644 --- a/indoteknik_custom/models/tukar_guling_po.py +++ b/indoteknik_custom/models/tukar_guling_po.py @@ -54,6 +54,38 @@ class TukarGulingPO(models.Model): ('cancel', 'Cancel'), ], string='Status', default='draft', tracking=3) + val_bil_opt = fields.Selection([ + ('tanpa_cancel', 'Tanpa Cancel Bill'), + ('cancel_bill', 'Cancel Bill'), + ], tracking=3, string='Bill Option') + + is_has_bill = fields.Boolean('Has Bill?', compute='_compute_is_has_bill', readonly=True, default=False) + + bill_id = fields.Many2one('account.move', string='Bill Ref', readonly=True) + + @api.depends('origin') + def _compute_is_has_bill(self): + for rec in self: + bills = self.env['account.move'].search([ + ('invoice_origin', 'ilike', rec.origin), + ('move_type', '=', 'in_invoice'), # hanya vendor bill + ('state', 'not in', ['draft', 'cancel']) + ]) + if bills: + rec.is_has_bill = True + rec.bill_id = bills + else: + rec.is_has_bill = False + + def set_opt(self): + if not self.val_bil_opt and self.is_has_bill == True: + raise UserError("Kalau sudah ada bill Return Bill Option harus diisi!") + for rec in self: + if rec.val_bil_opt == 'cancel_bill' and self.is_has_bill == True: + raise UserError("Tidak bisa mengubah Return karena sudah ada bill dan belum di cancel.") + elif rec.val_bil_opt == 'tanpa_cancel' and self.is_has_bill == True: + continue + @api.model def create(self, vals): # Generate sequence number @@ -74,19 +106,18 @@ class TukarGulingPO(models.Model): return res - # @api.constrains('return_type', 'operations') - # def _check_bill_on_revisi_po(self): - # for record in self: - # if record.return_type == 'revisi_po' and record.origin: - # bills = self.env['account.move'].search([ - # ('invoice_origin', 'ilike', record.origin), - # ('move_type', '=', 'in_invoice'), # hanya vendor bill - # ('state', 'not in', ['draft', 'cancel']) - # ]) - # if bills: - # raise ValidationError( - # _("Tidak bisa memilih Return Type 'Revisi PO' karena PO %s sudah dibuat vendor bill.") % record.origin - # ) + def _check_bill_on_revisi_po(self): + for record in self: + if record.return_type == 'revisi_po' and record.origin: + bills = self.env['account.move'].search([ + ('invoice_origin', 'ilike', record.origin), + ('move_type', '=', 'in_invoice'), # hanya vendor bill + ('state', 'not in', ['draft', 'cancel']) + ]) + # if bills: + # raise ValidationError( + # _("Tidak bisa memilih Return Type 'Revisi PO' karena PO %s sudah dibuat vendor bill. Harus Cancel Jika ingin melanjutkan") % record.origin + # ) @api.onchange('operations') def _onchange_operations(self): @@ -400,19 +431,21 @@ class TukarGulingPO(models.Model): for rec in self: if rec.state == 'approval_purchase': if not rec.env.user.has_group('indoteknik_custom.group_role_sales'): - raise UserError("Hanya Sales Manager yang boleh approve tahap ini.") + raise UserError("Hanya Sales yang boleh approve tahap ini.") rec.state = 'approval_finance' rec.date_purchase = now elif rec.state == 'approval_finance': if not rec.env.user.has_group('indoteknik_custom.group_role_fat'): - raise UserError("Hanya Finance Manager yang boleh approve tahap ini.") + raise UserError("Hanya Finance yang boleh approve tahap ini.") + rec._check_bill_on_revisi_po() + rec.set_opt() rec.state = 'approval_logistic' rec.date_finance = now elif rec.state == 'approval_logistic': if not rec.env.user.has_group('indoteknik_custom.group_role_logistic'): - raise UserError("Hanya Logistic Manager yang boleh approve tahap ini.") + raise UserError("Hanya Logistic yang boleh approve tahap ini.") rec.state = 'approved' rec._create_pickings() rec.date_logistic = now diff --git a/indoteknik_custom/views/tukar_guling.xml b/indoteknik_custom/views/tukar_guling.xml index c23995d3..88e5b883 100644 --- a/indoteknik_custom/views/tukar_guling.xml +++ b/indoteknik_custom/views/tukar_guling.xml @@ -84,8 +84,11 @@ + + + diff --git a/indoteknik_custom/views/tukar_guling_po.xml b/indoteknik_custom/views/tukar_guling_po.xml index accf7dbc..d3c41405 100644 --- a/indoteknik_custom/views/tukar_guling_po.xml +++ b/indoteknik_custom/views/tukar_guling_po.xml @@ -90,9 +90,12 @@ 'required': [('return_type', 'in', ['revisi_po', 'tukar_guling'])] }"/> + + + -- cgit v1.2.3 From ef5652dc2c57ef2648ea3730898e03c1c00c35f2 Mon Sep 17 00:00:00 2001 From: Miqdad Date: Wed, 6 Aug 2025 08:56:32 +0700 Subject: wkwkw --- indoteknik_custom/models/tukar_guling_po.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/tukar_guling_po.py b/indoteknik_custom/models/tukar_guling_po.py index 83aa49fe..72fb1607 100644 --- a/indoteknik_custom/models/tukar_guling_po.py +++ b/indoteknik_custom/models/tukar_guling_po.py @@ -460,7 +460,7 @@ class TukarGulingPO(models.Model): ('state', '=', 'done'), ('picking_type_id.id', '=', 76) ]) - if self.state == 'aproved' and prt: + if self.state == 'approved' and prt: self.state = 'done' # bu put rev po elif self.operations.picking_type_id.id == 75 and self.return_type == 'revisi_po': @@ -473,7 +473,7 @@ class TukarGulingPO(models.Model): ('state', '=', 'done'), ('picking_type_id.id', '=', 76) ]) - if self.state == 'aproved' and total_prt > 0 and prt == total_prt: + if self.state == 'approved' and total_prt > 0 and prt == total_prt: self.state = 'done' # bu put tukar guling elif self.operations.picking_type_id.id == 75 and self.return_type == 'tukar_guling': -- cgit v1.2.3 From 1db0c2f6148e5c13454cc25e4d4d877756536a4b Mon Sep 17 00:00:00 2001 From: Miqdad Date: Wed, 6 Aug 2025 08:57:46 +0700 Subject: push --- indoteknik_custom/models/account_move.py | 1 - 1 file changed, 1 deletion(-) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index b03d0a80..4be6c984 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -18,7 +18,6 @@ _logger = logging.getLogger(__name__) class AccountMove(models.Model): _inherit = 'account.move' _description = 'Account Move' - tukar_guling_po_id = fields.Many2one('tukar.guling.po', string='Tukar Guling PO Ref') invoice_day_to_due = fields.Integer(string="Day to Due", compute="_compute_invoice_day_to_due") bill_day_to_due = fields.Date(string="Day to Due", compute="_compute_bill_day_to_due") date_send_fp = fields.Datetime(string="Tanggal Kirim Faktur Pajak") -- cgit v1.2.3 From 9fb81ccccb8f2735ac5811d81b644b0ae70c4d8e Mon Sep 17 00:00:00 2001 From: Miqdad Date: Wed, 6 Aug 2025 10:33:25 +0700 Subject: push --- indoteknik_custom/models/tukar_guling.py | 24 ++++++++++++------------ indoteknik_custom/models/tukar_guling_po.py | 26 +++++++++++++------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/indoteknik_custom/models/tukar_guling.py b/indoteknik_custom/models/tukar_guling.py index d511779e..3091acce 100644 --- a/indoteknik_custom/models/tukar_guling.py +++ b/indoteknik_custom/models/tukar_guling.py @@ -320,17 +320,17 @@ class TukarGuling(models.Model): # ('state', '!=', 'cancel') # ]) > 0 - def _check_invoice_on_revisi_so(self): - for record in self: - if record.return_type == 'revisi_so' and record.origin: - invoices = self.env['account.move'].search([ - ('invoice_origin', 'ilike', record.origin), - ('state', 'not in', ['draft', 'cancel']) - ]) - if invoices: - raise ValidationError( - _("Tidak bisa memilih Return Type 'Revisi SO' karena dokumen %s sudah dibuat invoice.") % record.origin - ) + # def _check_invoice_on_revisi_so(self): + # for record in self: + # if record.return_type == 'revisi_so' and record.origin: + # invoices = self.env['account.move'].search([ + # ('invoice_origin', 'ilike', record.origin), + # ('state', 'not in', ['draft', 'cancel']) + # ]) + # if invoices: + # raise ValidationError( + # _("Tidak bisa memilih Return Type 'Revisi SO' karena dokumen %s sudah dibuat invoice.") % record.origin + # ) @api.model def create(self, vals): @@ -577,7 +577,7 @@ class TukarGuling(models.Model): elif rec.state == 'approval_finance': if not rec.env.user.has_group('indoteknik_custom.group_role_fat'): raise UserError("Hanya Finance Manager yang boleh approve tahap ini.") - rec._check_invoice_on_revisi_so() + # rec._check_invoice_on_revisi_so() rec.set_opt() rec.state = 'approval_logistic' rec.date_finance = now diff --git a/indoteknik_custom/models/tukar_guling_po.py b/indoteknik_custom/models/tukar_guling_po.py index 72fb1607..38afaac6 100644 --- a/indoteknik_custom/models/tukar_guling_po.py +++ b/indoteknik_custom/models/tukar_guling_po.py @@ -106,18 +106,18 @@ class TukarGulingPO(models.Model): return res - def _check_bill_on_revisi_po(self): - for record in self: - if record.return_type == 'revisi_po' and record.origin: - bills = self.env['account.move'].search([ - ('invoice_origin', 'ilike', record.origin), - ('move_type', '=', 'in_invoice'), # hanya vendor bill - ('state', 'not in', ['draft', 'cancel']) - ]) - # if bills: - # raise ValidationError( - # _("Tidak bisa memilih Return Type 'Revisi PO' karena PO %s sudah dibuat vendor bill. Harus Cancel Jika ingin melanjutkan") % record.origin - # ) + # def _check_bill_on_revisi_po(self): + # for record in self: + # if record.return_type == 'revisi_po' and record.origin: + # bills = self.env['account.move'].search([ + # ('invoice_origin', 'ilike', record.origin), + # ('move_type', '=', 'in_invoice'), # hanya vendor bill + # ('state', 'not in', ['draft', 'cancel']) + # ]) + # if bills: + # raise ValidationError( + # _("Tidak bisa memilih Return Type 'Revisi PO' karena PO %s sudah dibuat vendor bill. Harus Cancel Jika ingin melanjutkan") % record.origin + # ) @api.onchange('operations') def _onchange_operations(self): @@ -438,7 +438,7 @@ class TukarGulingPO(models.Model): elif rec.state == 'approval_finance': if not rec.env.user.has_group('indoteknik_custom.group_role_fat'): raise UserError("Hanya Finance yang boleh approve tahap ini.") - rec._check_bill_on_revisi_po() + # rec._check_bill_on_revisi_po() rec.set_opt() rec.state = 'approval_logistic' rec.date_finance = now -- cgit v1.2.3 From 837b7ba9f7118c6516ebad6b4022e1b449661c4d Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 6 Aug 2025 11:01:45 +0700 Subject: fix payment date account move --- indoteknik_custom/models/account_move.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 4be6c984..595c5655 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -106,6 +106,8 @@ class AccountMove(models.Model): if payment: move.payment_date = payment[0].date + elif move.reklas_misc_id: + move.payment_date = move.reklas_misc_id.date else: move.payment_date = False -- cgit v1.2.3 From ab11c9455c6e125195ec5004adfd855058d46f5f Mon Sep 17 00:00:00 2001 From: Miqdad Date: Wed, 6 Aug 2025 12:56:35 +0700 Subject: fix error singleton --- indoteknik_custom/models/tukar_guling.py | 2 +- indoteknik_custom/models/tukar_guling_po.py | 2 +- indoteknik_custom/views/tukar_guling.xml | 2 +- indoteknik_custom/views/tukar_guling_po.xml | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/indoteknik_custom/models/tukar_guling.py b/indoteknik_custom/models/tukar_guling.py index 3091acce..8de5b671 100644 --- a/indoteknik_custom/models/tukar_guling.py +++ b/indoteknik_custom/models/tukar_guling.py @@ -81,7 +81,7 @@ class TukarGuling(models.Model): is_has_invoice = fields.Boolean('Has Invoice?', compute='_compute_is_has_invoice', readonly=True, default=False) - invoice_id = fields.Many2one('account.move', string='Invoice Ref', readonly=True) + invoice_id = fields.Many2many('account.move', string='Invoice Ref', readonly=True) @api.depends('origin') def _compute_is_has_invoice(self): diff --git a/indoteknik_custom/models/tukar_guling_po.py b/indoteknik_custom/models/tukar_guling_po.py index 38afaac6..5d444472 100644 --- a/indoteknik_custom/models/tukar_guling_po.py +++ b/indoteknik_custom/models/tukar_guling_po.py @@ -61,7 +61,7 @@ class TukarGulingPO(models.Model): is_has_bill = fields.Boolean('Has Bill?', compute='_compute_is_has_bill', readonly=True, default=False) - bill_id = fields.Many2one('account.move', string='Bill Ref', readonly=True) + bill_id = fields.Many2many('account.move', string='Bill Ref', readonly=True) @api.depends('origin') def _compute_is_has_bill(self): diff --git a/indoteknik_custom/views/tukar_guling.xml b/indoteknik_custom/views/tukar_guling.xml index 88e5b883..20aa2eef 100644 --- a/indoteknik_custom/views/tukar_guling.xml +++ b/indoteknik_custom/views/tukar_guling.xml @@ -85,7 +85,7 @@ attrs="{'readonly': [('state', 'not in', 'draft')]}"/> - + diff --git a/indoteknik_custom/views/tukar_guling_po.xml b/indoteknik_custom/views/tukar_guling_po.xml index d3c41405..bc696a3d 100644 --- a/indoteknik_custom/views/tukar_guling_po.xml +++ b/indoteknik_custom/views/tukar_guling_po.xml @@ -91,7 +91,8 @@ }"/> - + + -- cgit v1.2.3