From 70dbe185533615aaedb7f05c75a7c5530be6eb42 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 19 Jun 2023 12:01:42 +0700 Subject: add available qty while create po from requisition --- indoteknik_custom/models/requisition.py | 10 +++++++++- indoteknik_custom/views/requisition.xml | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/requisition.py b/indoteknik_custom/models/requisition.py index 5bb3272e..c1af4784 100644 --- a/indoteknik_custom/models/requisition.py +++ b/indoteknik_custom/models/requisition.py @@ -127,6 +127,12 @@ class Requisition(models.Model): # new_po = self.env['purchase.order'].create([param_header]) brand_id = product.brand_id.id count += 10 + + qty_available = product.product_id.qty_onhand_bandengan + product.product_id.qty_incoming_bandengan - product.product_id.outgoing_qty + suggest = 'harus beli' + if qty_available > product.qty_purchase: + suggest = 'masih cukup' + param_line = { 'order_id': new_po.id, 'sequence': count, @@ -134,7 +140,9 @@ class Requisition(models.Model): 'product_qty': product.qty_purchase, 'product_uom_qty': product.qty_purchase, 'price_unit': product.last_price, - 'taxes_id': product.tax_id + 'taxes_id': product.tax_id, + 'qty_available_store': qty_available, + 'suggest': suggest, } new_line = self.env['purchase.order.line'].create([param_line]) product.current_po_id = new_po.id diff --git a/indoteknik_custom/views/requisition.xml b/indoteknik_custom/views/requisition.xml index 6e61ce1e..29b3a852 100644 --- a/indoteknik_custom/views/requisition.xml +++ b/indoteknik_custom/views/requisition.xml @@ -96,6 +96,6 @@ \ No newline at end of file -- cgit v1.2.3 From 3e1b0f5e05edebcdc6b78befc3c13cec2490799f Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 19 Jun 2023 16:04:04 +0700 Subject: change id of produk sementara --- 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 52b959db..5293b0fb 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -358,7 +358,7 @@ class SaleOrder(models.Model): # must add product can sell validation if not line.product_id.product_tmpl_id.sale_ok: raise UserError('Product %s belum bisa dijual, harap hubungi finance' % line.product_id.display_name) - if line.product_id.id == 232383: + if line.product_id.id == 224484: raise UserError(_('Tidak bisa Confirm menggunakan Produk Sementara')) if not line.vendor_id or not line.purchase_price or not line.purchase_tax_id: raise UserError(_('Isi Vendor, Harga Beli, dan Tax sebelum Request Approval')) -- cgit v1.2.3 From 9187e2c22d9a537196c05c092762814fe362f8c0 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Mon, 19 Jun 2023 16:08:47 +0700 Subject: Bug fix synchronize order line on purchase --- indoteknik_custom/models/purchase_order.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 5aedb07b..df1ecf14 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -152,9 +152,10 @@ class PurchaseOrder(models.Model): for order_line in self.sale_order_id.order_line: if order_line.product_id.id and order_line.product_id.id not in products_exception: for order_line in self.sale_order_id.order_line: - + if not order_line.product_id: + continue qty_available = order_line.product_id.qty_onhand_bandengan + order_line.product_id.qty_incoming_bandengan - order_line.product_id.outgoing_qty - + suggest = 'harus beli' if qty_available > order_line.product_qty: suggest = 'masih cukup' @@ -166,7 +167,7 @@ class PurchaseOrder(models.Model): 'qty_available_store': qty_available, 'suggest': suggest, } - self.order_line.create(values) + self.env['purchase.order.line'].create(values) def compute_count_line_product(self): for order in self: -- cgit v1.2.3 From aa59f0f8f3edfc0aa1e257b35d5c6e83b8f6978c Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 19 Jun 2023 16:48:16 +0700 Subject: receipt approval in logistic --- indoteknik_custom/models/stock_picking.py | 32 ++++++++++++++++++++----------- indoteknik_custom/models/users.py | 12 +++++++----- indoteknik_custom/views/stock_picking.xml | 2 +- indoteknik_custom/views/users.xml | 1 + 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index c8424121..74fd0356 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -54,6 +54,11 @@ class StockPicking(models.Model): ('approved', 'Approved'), ], string='Approval Status', readonly=True, copy=False, index=True, tracking=3, help="Approval Status untuk Internal Use") + approval_receipt_status = fields.Selection([ + ('pengajuan1', 'Approval Logistic'), + ('approved', 'Approved'), + ], string='Approval Status', readonly=True, copy=False, index=True, tracking=3, help="Approval Status untuk Receipt") + approval_return_status = fields.Selection([ ('pengajuan1', 'Approval Finance'), ('approved', 'Approved'), @@ -184,17 +189,18 @@ class StockPicking(models.Model): if self.env.user.is_accounting: raise UserError("Bisa langsung Validate") - if self.is_internal_use: - stock_move_lines = self.env['stock.move.line'].search([ - ('picking_id', '!=', False), - ('product_id', '=', 236805), - ('picking_id.partner_id', '=', self.partner_id.id), - ('qty_done', '>', 0), - ]) - list_state = ['confirmed', 'done'] - for stock_move_line in stock_move_lines: - if stock_move_line.picking_id.state not in list_state: - continue + # for calendar distribute only + # if self.is_internal_use: + # stock_move_lines = self.env['stock.move.line'].search([ + # ('picking_id', '!=', False), + # ('product_id', '=', 236805), + # ('picking_id.partner_id', '=', self.partner_id.id), + # ('qty_done', '>', 0), + # ]) + # list_state = ['confirmed', 'done'] + # for stock_move_line in stock_move_lines: + # if stock_move_line.picking_id.state not in list_state: + # continue # raise UserError('Sudah pernah dikirim kalender') for pick in self: @@ -264,6 +270,10 @@ class StockPicking(models.Model): if self.is_internal_use and not self.env.user.is_accounting: raise UserError("Harus di Approve oleh Accounting") + print(self.picking_type_id.id) + if self.picking_type_id.id == 28 and not self.env.user.is_logistic_approver: + raise UserError("Harus di Approve oleh Eplin") + if self.group_id.sale_id: if self.group_id.sale_id.payment_link_midtrans: if self.group_id.sale_id.payment_status != 'settlement': diff --git a/indoteknik_custom/models/users.py b/indoteknik_custom/models/users.py index a2074c46..14fcae98 100644 --- a/indoteknik_custom/models/users.py +++ b/indoteknik_custom/models/users.py @@ -5,11 +5,13 @@ from odoo.exceptions import AccessError, UserError, ValidationError class Users(models.Model): _inherit = 'res.users' - is_purchasing_manager = fields.Boolean(String='Purchasing Manager', help='Berhak melakukan Approval PO') - is_sales_manager = fields.Boolean(String='Sales Manager', help='Berhak melakukan Approval SO dengan margin 15-25') - is_leader = fields.Boolean(String='Leader', help='Berhak Approval SO Margin < 15 dan Approval PO') - is_accounting = fields.Boolean(String='Accounting', help='Berhak Approval Internal Use') + is_purchasing_manager = fields.Boolean(string='Purchasing Manager', help='Berhak melakukan Approval PO') + is_sales_manager = fields.Boolean(string='Sales Manager', help='Berhak melakukan Approval SO dengan margin 15-25') + is_leader = fields.Boolean(string='Leader', help='Berhak Approval SO Margin < 15 dan Approval PO') + is_accounting = fields.Boolean(string='Accounting', help='Berhak Approval Internal Use') + is_logistic_approver = fields.Boolean(string='Logistic Approver', help='Berhak Approval Penerimaan Barang') def notify_internal_users(self, message, title): users = self.search([('share', '=', False)]) - users.notify_info(message=message, title=title) \ No newline at end of file + users.notify_info(message=message, title=title) + \ No newline at end of file diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index 4bbdc7b8..02003e05 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -30,7 +30,7 @@ - @@ -53,8 +52,6 @@ - - + + + + + + -- cgit v1.2.3 From 2b43db2108a45e7694cda2e0be94d30cc6570a9a Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 21 Jun 2023 08:33:50 +0700 Subject: Delete note on sale monitoring detail --- indoteknik_custom/models/sale_monitoring_detail.py | 4 +--- indoteknik_custom/views/sale_monitoring_detail.xml | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/indoteknik_custom/models/sale_monitoring_detail.py b/indoteknik_custom/models/sale_monitoring_detail.py index 43a8aeb0..2bcda50c 100755 --- a/indoteknik_custom/models/sale_monitoring_detail.py +++ b/indoteknik_custom/models/sale_monitoring_detail.py @@ -22,7 +22,6 @@ class SaleMonitoringDetail(models.Model): date_order = fields.Datetime(string="Date Order") status = fields.Char(string="Status") qty_reserved = fields.Integer(string="Qty Reserved") - note = fields.Char(string="Note") def init(self): tools.drop_view_if_exists(self.env.cr, self._table) @@ -53,8 +52,7 @@ class SaleMonitoringDetail(models.Model): so.date_order AS date_order, get_qty_po(so.id, sol.product_id) AS qty_po, get_qty_received(so.id, sol.product_id) AS qty_po_received, - get_qty_reserved(so.id, sol.product_id) as qty_reserved, - sol.note_procurement as note + get_qty_reserved(so.id, sol.product_id) as qty_reserved FROM sale_order so JOIN sale_order_line sol ON sol.order_id = so.id JOIN product_product p ON p.id = sol.product_id diff --git a/indoteknik_custom/views/sale_monitoring_detail.xml b/indoteknik_custom/views/sale_monitoring_detail.xml index ce5b8e9b..824e65e8 100755 --- a/indoteknik_custom/views/sale_monitoring_detail.xml +++ b/indoteknik_custom/views/sale_monitoring_detail.xml @@ -23,7 +23,6 @@ decoration-success="status == 'Siap kirim'" decoration-info="status == 'Delivered' or status == 'Invoiced'" /> - @@ -47,7 +46,6 @@ decoration-success="status == 'Siap kirim'" decoration-info="status == 'Delivered' or status == 'Invoiced'" /> - -- cgit v1.2.3 From 6d82a7a763ceecc59b4fe3510fcb011bf6fec334 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 21 Jun 2023 08:36:46 +0700 Subject: Add note on sale monitoring detail --- indoteknik_custom/models/sale_monitoring_detail.py | 4 +++- indoteknik_custom/views/sale_monitoring_detail.xml | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/sale_monitoring_detail.py b/indoteknik_custom/models/sale_monitoring_detail.py index 2bcda50c..43a8aeb0 100755 --- a/indoteknik_custom/models/sale_monitoring_detail.py +++ b/indoteknik_custom/models/sale_monitoring_detail.py @@ -22,6 +22,7 @@ class SaleMonitoringDetail(models.Model): date_order = fields.Datetime(string="Date Order") status = fields.Char(string="Status") qty_reserved = fields.Integer(string="Qty Reserved") + note = fields.Char(string="Note") def init(self): tools.drop_view_if_exists(self.env.cr, self._table) @@ -52,7 +53,8 @@ class SaleMonitoringDetail(models.Model): so.date_order AS date_order, get_qty_po(so.id, sol.product_id) AS qty_po, get_qty_received(so.id, sol.product_id) AS qty_po_received, - get_qty_reserved(so.id, sol.product_id) as qty_reserved + get_qty_reserved(so.id, sol.product_id) as qty_reserved, + sol.note_procurement as note FROM sale_order so JOIN sale_order_line sol ON sol.order_id = so.id JOIN product_product p ON p.id = sol.product_id diff --git a/indoteknik_custom/views/sale_monitoring_detail.xml b/indoteknik_custom/views/sale_monitoring_detail.xml index 824e65e8..ce5b8e9b 100755 --- a/indoteknik_custom/views/sale_monitoring_detail.xml +++ b/indoteknik_custom/views/sale_monitoring_detail.xml @@ -23,6 +23,7 @@ decoration-success="status == 'Siap kirim'" decoration-info="status == 'Delivered' or status == 'Invoiced'" /> + @@ -46,6 +47,7 @@ decoration-success="status == 'Siap kirim'" decoration-info="status == 'Delivered' or status == 'Invoiced'" /> + -- cgit v1.2.3 From dab37603ea378fb84c2bbc0562b901011629063b Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 21 Jun 2023 08:54:57 +0700 Subject: Update tax id on checkout API --- indoteknik_api/controllers/api_v1/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py index ec33495e..671ff5a8 100644 --- a/indoteknik_api/controllers/api_v1/sale_order.py +++ b/indoteknik_api/controllers/api_v1/sale_order.py @@ -246,7 +246,7 @@ class SaleOrder(controller.Controller): parameters = { 'warehouse_id': 8, 'carrier_id': 1, - 'sales_tax_id': 23, + 'sales_tax_id': 20, 'pricelist_id': product_pricelist_default_discount_id, 'payment_term_id': 26, 'team_id': 2, -- cgit v1.2.3 From c1a0d0e48ef64241c92947a8800f93af4ff109d0 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 21 Jun 2023 10:25:26 +0700 Subject: fix approval receipt and hide uneccesary column --- indoteknik_custom/models/stock_picking.py | 36 ++++++++++++++++++------------ indoteknik_custom/views/purchase_order.xml | 1 + indoteknik_custom/views/sale_order.xml | 1 + indoteknik_custom/views/stock_picking.xml | 4 ++-- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index d8c24e10..a14e71a3 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -284,25 +284,33 @@ class StockPicking(models.Model): if self.group_id.sale_id.payment_status != 'settlement': raise UserError('Uang belum masuk (settlement), mohon konfirmasi ke sales atau finance') - if self.is_internal_use: - stock_move_lines = self.env['stock.move.line'].search([ - ('picking_id', '!=', False), - ('product_id', '=', 236805), - ('picking_id.partner_id', '=', self.partner_id.id), - ('qty_done', '>', 0), - ]) - list_state = ['confirmed', 'done'] - for stock_move_line in stock_move_lines: - if stock_move_line.picking_id.state not in list_state: - continue + # for distribute calendar only + # if self.is_internal_use: + # stock_move_lines = self.env['stock.move.line'].search([ + # ('picking_id', '!=', False), + # ('product_id', '=', 236805), + # ('picking_id.partner_id', '=', self.partner_id.id), + # ('qty_done', '>', 0), + # ]) + # list_state = ['confirmed', 'done'] + # for stock_move_line in stock_move_lines: + # if stock_move_line.picking_id.state not in list_state: + # continue # raise UserError('Sudah pernah dikirim kalender') - for line in self.move_line_ids_without_package: - if line.move_id.sale_line_id and self.picking_type_id.code == 'outgoing': + if self.picking_type_id.code == 'outgoing': + for line in self.move_line_ids_without_package: if line.move_id.sale_line_id.qty_delivered + line.qty_done > line.move_id.sale_line_id.product_uom_qty: raise UserError("Qty Delivered akan lebih dari Qty SO") + elif self.picking_type_id.code == 'incoming': + for line in self.move_ids_without_package: + if line.purchase_line_id.qty_received + line.quantity_done > line.purchase_line_id.product_qty: + raise UserError('Qty Received akan lebih dari Qty PO') - self.approval_status = 'approved' + if self.is_internal_use: + self.approval_status = 'approved' + elif self.picking_type_id.code == 'incoming': + self.approval_receipt_status = 'approved' res = super(StockPicking, self).button_validate() self.calculate_line_no() diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index 7a397ff6..5b0c99ef 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -24,6 +24,7 @@