From b5150361d4ad027a72d7d3a87664b73bc2ab3473 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 7 Feb 2023 14:04:31 +0700 Subject: add line no in sales order --- indoteknik_custom/models/sale_order.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 7d7eb86c..e85454da 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -67,6 +67,14 @@ class SaleOrder(models.Model): ('authorize', 'Authorize'), ], string='Payment Status', help='Payment Gateway Status / Midtrans / Web, https://docs.midtrans.com/en/after-payment/status-cycle') + def calculate_line_no(self): + line_no = 0 + for line in self.order_line: + if line.product_id.type == 'product': + line_no += 1 + line.line_no = line_no + # _logger.info('Calculate PO Line No %s' % line.id) + def calculate_so_status_beginning(self): so_state = ['sale'] sales = self.env['sale.order'].search([ @@ -331,6 +339,7 @@ class SaleOrderLine(models.Model): domain=['|', ('active', '=', False), ('active', '=', True)]) delivery_amt_line = fields.Float('DeliveryAmtLine', compute='compute_delivery_amt_line') fee_third_party_line = fields.Float('FeeThirdPartyLine', compute='compute_fee_third_party_line', default=0) + line_no = fields.Integer('No', default=0) def compute_item_margin(self): for line in self: -- cgit v1.2.3 From bd01d7a842c8b6e4aea6a2fc3615a9d57fbcd470 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 9 Feb 2023 08:24:36 +0700 Subject: fix due date after dunning run --- indoteknik_custom/models/dunning_run.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/dunning_run.py b/indoteknik_custom/models/dunning_run.py index ed5d7bb5..ee0669ca 100644 --- a/indoteknik_custom/models/dunning_run.py +++ b/indoteknik_custom/models/dunning_run.py @@ -1,5 +1,6 @@ from odoo import models, api, fields from odoo.exceptions import AccessError, UserError, ValidationError +from datetime import timedelta import logging _logger = logging.getLogger(__name__) @@ -30,10 +31,24 @@ class DunningRun(models.Model): invoice = line.invoice_id if not invoice.date_kirim_tukar_faktur: invoice.date_kirim_tukar_faktur = self.date_kirim_tukar_faktur + tukar_date = self.date_kirim_tukar_faktur + term = invoice.invoice_payment_term_id + add_days = 0 + for line in term.line_ids: + add_days += line.days + due_date = tukar_date + timedelta(days=add_days) + invoice.invoice_date_due = due_date if not invoice.resi_tukar_faktur: invoice.resi_tukar_faktur = self.resi_tukar_faktur if not invoice.date_terima_tukar_faktur: invoice.date_terima_tukar_faktur = self.date_terima_tukar_faktur + tukar_date = self.date_terima_tukar_faktur + term = invoice.invoice_payment_term_id + add_days = 0 + for line in term.line_ids: + add_days += line.days + due_date = tukar_date + timedelta(days=add_days) + invoice.invoice_date_due = due_date if not invoice.shipper_faktur_id: invoice.shipper_faktur_id = self.shipper_faktur_id -- cgit v1.2.3 From b0de64ae769148a009d0a08a957c5c35dee174a9 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 10 Feb 2023 10:35:55 +0700 Subject: add notification in dunning run --- indoteknik_custom/models/dunning_run.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/dunning_run.py b/indoteknik_custom/models/dunning_run.py index ee0669ca..98689550 100644 --- a/indoteknik_custom/models/dunning_run.py +++ b/indoteknik_custom/models/dunning_run.py @@ -23,6 +23,7 @@ class DunningRun(models.Model): date_terima_tukar_faktur = fields.Date(string='Terima Faktur') shipper_faktur_id = fields.Many2one('delivery.carrier', string='Shipper Faktur') is_validated = fields.Boolean(string='Validated') + notification = fields.Char(string='Notification') def copy_date_faktur(self): if not self.is_validated: @@ -51,12 +52,14 @@ class DunningRun(models.Model): invoice.invoice_date_due = due_date if not invoice.shipper_faktur_id: invoice.shipper_faktur_id = self.shipper_faktur_id + self.notification = 'Berhasil copy tanggal terima faktur ke setiap invoice %s' % self.date_terima_tukar_faktur def validate_dunning(self): if not self.dunning_line: raise UserError('Dunning Line masih kosong, generate dulu') else: self.is_validated = True + self.notification = 'Jangan lupa klik Copy Date jika sudah ada tanggal kirim / tanggal terima faktur' def generate_dunning_line(self): if self.is_validated: -- cgit v1.2.3 From 337e769c7eab63275b4114f48e789bdcf808bdf1 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 10 Feb 2023 11:04:07 +0700 Subject: add line no in so / po and stock picking --- indoteknik_custom/models/purchase_order.py | 2 ++ indoteknik_custom/models/sale_order.py | 1 + indoteknik_custom/models/stock_picking.py | 23 ++++++++++++++++++----- 3 files changed, 21 insertions(+), 5 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index b4d671b6..2f3d2ec4 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -169,6 +169,8 @@ class PurchaseOrder(models.Model): self.approval_status = 'approved' self.po_status = 'menunggu' + self.calculate_line_no() + return res def po_approve(self): diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index e85454da..f21554f7 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -281,6 +281,7 @@ class SaleOrder(models.Model): raise UserError("Harus diapprove oleh Manager") else: order.approval_status = 'approved' + order.calculate_line_no() return res diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 8a0ad71e..180e2500 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -95,13 +95,25 @@ class StockPicking(models.Model): pick.approval_return_status = 'pengajuan1' def calculate_line_no(self): - line_no = 0 for picking in self: for line in picking.move_ids_without_package: - if line.product_id.type == 'product': - line_no += 1 - line.line_no = line_no - # _logger.info('Calculate PO Line No %s' % line.id) + # order_lines = picking.group_id.order_line + name = picking.group_id.name + if picking.group_id.sale_id: + order = self.env['sale.order'].search([('name', '=', name)], limit=1) + else: + order = self.env['purchase.order'].search([('name', '=', name)], limit=1) + + order_lines = order.order_line + set_line = 0 + + for order_line in order_lines: + if line.product_id == order_line.product_id: + set_line = order_line.line_no + break + else: + continue + line.line_no = set_line def _compute_summary_qty(self): sum_qty_detail = sum_qty_operation = count_line_detail = count_line_operation = 0 @@ -153,6 +165,7 @@ class StockPicking(models.Model): self.approval_status = 'approved' res = super(StockPicking, self).button_validate() + self.calculate_line_no() return res @api.model -- cgit v1.2.3 From 5381de8a6be24465f33a44ae8c33ab9f4832d44d Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 10 Feb 2023 11:43:53 +0700 Subject: fix dunning run --- indoteknik_custom/models/dunning_run.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/dunning_run.py b/indoteknik_custom/models/dunning_run.py index 98689550..8e5b2c19 100644 --- a/indoteknik_custom/models/dunning_run.py +++ b/indoteknik_custom/models/dunning_run.py @@ -30,7 +30,7 @@ class DunningRun(models.Model): raise UserError('Harus di validate dulu') for line in self.dunning_line: invoice = line.invoice_id - if not invoice.date_kirim_tukar_faktur: + if not invoice.date_kirim_tukar_faktur and self.date_kirim_tukar_faktur: invoice.date_kirim_tukar_faktur = self.date_kirim_tukar_faktur tukar_date = self.date_kirim_tukar_faktur term = invoice.invoice_payment_term_id @@ -41,7 +41,7 @@ class DunningRun(models.Model): invoice.invoice_date_due = due_date if not invoice.resi_tukar_faktur: invoice.resi_tukar_faktur = self.resi_tukar_faktur - if not invoice.date_terima_tukar_faktur: + if not invoice.date_terima_tukar_faktur and self.date_terima_tukar_faktur: invoice.date_terima_tukar_faktur = self.date_terima_tukar_faktur tukar_date = self.date_terima_tukar_faktur term = invoice.invoice_payment_term_id -- cgit v1.2.3 From a695077283db234296e79c392638211dfb7fc263 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 10 Feb 2023 14:21:51 +0700 Subject: only accounting can create bill from purchase order --- indoteknik_custom/models/purchase_order.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 2f3d2ec4..0ef6a9f2 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -38,6 +38,12 @@ class PurchaseOrder(models.Model): summary_qty_receipt = fields.Float('Summary Qty Receipt', compute='_compute_summary_qty') count_line_product = fields.Float('Total Item', compute='compute_count_line_product') + def action_create_invoice(self): + res = super(PurchaseOrder, self).action_create_invoice() + if not self.env.user.is_accounting: + raise UserError('Hanya Accounting yang bisa membuat Bill') + return res + def calculate_line_no(self): line_no = 0 for line in self.order_line: -- cgit v1.2.3