From 4c2325d4a983ced3a25a9d53d7613a9186360b17 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Wed, 16 Oct 2024 13:15:11 +0700 Subject: update ready stock picup quantity --- indoteknik_api/controllers/api_v1/product.py | 15 +++++++++++++++ indoteknik_api/controllers/api_v1/sale_order.py | 3 ++- indoteknik_api/models/sale_order.py | 1 + indoteknik_custom/models/sale_order_line.py | 1 + indoteknik_custom/models/website_user_cart.py | 2 ++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/indoteknik_api/controllers/api_v1/product.py b/indoteknik_api/controllers/api_v1/product.py index 9673b3ef..b68eb0f9 100644 --- a/indoteknik_api/controllers/api_v1/product.py +++ b/indoteknik_api/controllers/api_v1/product.py @@ -96,6 +96,21 @@ class Product(controller.Controller): return self.response(data, headers=[('Cache-Control', 'max-age=600, private')]) + @http.route(prefix + 'product_variant//qty_available', auth='public', methods=['GET', 'OPTIONS']) + @controller.Controller.must_authorized() + def get_product_variant_stock_available_by_id(self, **kw): + id = int(kw.get('id')) + product = request.env['product.product'].search( + [('id', '=', id)], limit=1) + + qty_available = product.free_qty + + data = { + 'qty': qty_available, + } + + return self.response(data, headers=[('Cache-Control', 'max-age=600, private')]) + @http.route(prefix + 'product/template/price/', auth='public', methods=['GET', 'OPTIONS']) def get_product_template_price_by_id(self, **kw): if not self.authenticate(): diff --git a/indoteknik_api/controllers/api_v1/sale_order.py b/indoteknik_api/controllers/api_v1/sale_order.py index e7664c79..905795b0 100644 --- a/indoteknik_api/controllers/api_v1/sale_order.py +++ b/indoteknik_api/controllers/api_v1/sale_order.py @@ -446,7 +446,8 @@ class SaleOrder(controller.Controller): 'company_id': 1, 'order_id': sale_order.id, 'product_id': cart['id'], - 'product_uom_qty': cart['quantity'] + 'product_uom_qty': cart['quantity'], + 'product_available_quantity': cart['available_quantity'] }) order_line.product_id_change() order_line.onchange_vendor_id() diff --git a/indoteknik_api/models/sale_order.py b/indoteknik_api/models/sale_order.py index 725dbb4b..8e0371a3 100644 --- a/indoteknik_api/models/sale_order.py +++ b/indoteknik_api/models/sale_order.py @@ -84,6 +84,7 @@ class SaleOrder(models.Model): 'subtotal': line.price_subtotal } product['quantity'] = line.product_uom_qty + product['available_quantity'] = line.product_available_quantity data_with_detail['products'].append(product) for invoice in sale_order.invoice_ids: if invoice.state == 'posted': diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index 5e01067a..964b3ff2 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -31,6 +31,7 @@ class SaleOrderLine(models.Model): vendor_subtotal = fields.Float(string='Vendor Subtotal', compute="_compute_vendor_subtotal") amount_voucher_disc = fields.Float(string='Voucher Discount') qty_reserved = fields.Float(string='Qty Reserved', compute='_compute_qty_reserved') + product_available_quantity = fields.Float(string='Qty pickup by user',) reserved_from = fields.Char(string='Reserved From', copy=False) item_percent_margin_without_deduction = fields.Float('%Margin', compute='_compute_item_margin_without_deduction') weight = fields.Float(string='Weight') diff --git a/indoteknik_custom/models/website_user_cart.py b/indoteknik_custom/models/website_user_cart.py index 26e217cb..9dadc40b 100644 --- a/indoteknik_custom/models/website_user_cart.py +++ b/indoteknik_custom/models/website_user_cart.py @@ -65,9 +65,11 @@ class WebsiteUserCart(models.Model): if stock_quant: res['is_in_bu'] = True res['on_hand_qty'] = sum(stock_quant.mapped('quantity')) + res['available_quantity'] = stock_quant.available_quantity else: res['is_in_bu'] = False res['on_hand_qty'] = 0 + res['available_quantity'] = 0 flashsales = self.product_id._get_active_flash_sale() res['has_flashsale'] = True if len(flashsales) > 0 else False -- cgit v1.2.3 From 9b86d64f64e149d26b5e33254fefd5dfc15ce1c4 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 31 Oct 2024 09:03:21 +0700 Subject: approval retur picking --- indoteknik_custom/__manifest__.py | 1 + indoteknik_custom/models/__init__.py | 1 + indoteknik_custom/models/approval_retur_picking.py | 38 ++++++++++++++++++++++ indoteknik_custom/models/stock_picking.py | 16 ++++++++- indoteknik_custom/security/ir.model.access.csv | 1 + indoteknik_custom/views/approval_retur_picking.xml | 27 +++++++++++++++ 6 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 indoteknik_custom/models/approval_retur_picking.py create mode 100644 indoteknik_custom/views/approval_retur_picking.xml diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index c8a658b5..da44ebf3 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -145,6 +145,7 @@ 'views/approval_unreserve.xml', 'views/vendor_approval.xml', 'views/find_page.xml', + 'views/approval_retur_picking.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..4983cc17 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -131,3 +131,4 @@ from . import approval_unreserve from . import vendor_approval from . import partner from . import find_page +from . import approval_retur_picking diff --git a/indoteknik_custom/models/approval_retur_picking.py b/indoteknik_custom/models/approval_retur_picking.py new file mode 100644 index 00000000..63639782 --- /dev/null +++ b/indoteknik_custom/models/approval_retur_picking.py @@ -0,0 +1,38 @@ +from odoo import models, fields +import logging + +_logger = logging.getLogger(__name__) + + +class ApprovalReturPicking(models.TransientModel): + _name = 'approval.retur.picking' + _description = 'Wizard to add Note Return' + + note_return = fields.Text(string="Note Return", required=True) + + def action_confirm_note_return(self): + picking_ids = self._context.get('picking_ids') + picking = self.env['stock.picking'].browse(picking_ids) + + # Update the note_return field + picking.update({ + 'note_return': self.note_return + }) + + # Post a highlighted message to lognote + picking.message_post( + body=f"
" + f"Note Return (Pinned):
{self.note_return}
", + subtype_id=self.env.ref("mail.mt_note").id + ) + + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'title': 'Notification', + 'message': 'Note berhasil ditambah', + 'next': {'type': 'ir.actions.act_window_close'}, + } + } + diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 4c9d7658..107a6e72 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -104,6 +104,7 @@ class StockPicking(models.Model): ('to invoice', 'To Invoice'), ('no', 'Nothing to Invoice') ], string='Invoice Status', related="sale_id.invoice_status") + note_return = fields.Text(string="Note Return", help="Catatan untuk kirim barang kembali") state_reserve = fields.Selection([ ('waiting', 'Waiting For Fullfilment'), @@ -445,6 +446,11 @@ class StockPicking(models.Model): pick.approval_return_status = 'approved' else: pick.approval_return_status = 'pengajuan1' + action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_stock_return_note_wizard') + action['context'] = { + 'picking_ids': [x.id for x in self] + } + return action def calculate_line_no(self): for picking in self: @@ -503,6 +509,9 @@ class StockPicking(models.Model): def button_validate(self): + if not self.env.user.is_logistic_approver and 'Return of' in self.origin: + raise UserError("Button ini hanya untuk Logistik") + if self._name != 'stock.picking': return super(StockPicking, self).button_validate() @@ -553,6 +562,11 @@ class StockPicking(models.Model): self.date_done = datetime.datetime.utcnow() self.state_reserve = 'done' return res + def action_cancel(self): + if not self.env.user.is_logistic_approver and 'Return of' in self.origin: + raise UserError("Button ini hanya untuk Logistik") + res = super(StockPicking, self).action_cancel() + return res @api.model def create(self, vals): @@ -688,4 +702,4 @@ 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}' + return f'{formatted_fastest_eta} - {formatted_longest_eta}' \ 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 553047e6..06848ad7 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_approval_retur_picking,access.approval.retur.picking,model_approval_retur_picking,,1,1,1,1 diff --git a/indoteknik_custom/views/approval_retur_picking.xml b/indoteknik_custom/views/approval_retur_picking.xml new file mode 100644 index 00000000..ebe038d1 --- /dev/null +++ b/indoteknik_custom/views/approval_retur_picking.xml @@ -0,0 +1,27 @@ + + + + approval.retur.picking.form + approval.retur.picking + +
+ + + +
+
+
+
+
+ + + + Add Return Note + approval.retur.picking + form + + new + +
-- cgit v1.2.3 From 1bb2d9edb764ee3de50b0a005ff40aeef60bf5d6 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 11 Nov 2024 13:38:49 +0700 Subject: add approval sales manager and marketing manager on rpo --- indoteknik_custom/models/requisition.py | 16 ++++++++++++++++ indoteknik_custom/views/requisition.xml | 7 +++++++ 2 files changed, 23 insertions(+) diff --git a/indoteknik_custom/models/requisition.py b/indoteknik_custom/models/requisition.py index c4104ec5..a90a5718 100644 --- a/indoteknik_custom/models/requisition.py +++ b/indoteknik_custom/models/requisition.py @@ -22,15 +22,31 @@ class Requisition(models.Model): requisition_match = fields.One2many('requisition.purchase.match', 'requisition_id', string='Matches', auto_join=True) sale_order_id = fields.Many2one('sale.order', string='SO', help='harus diisi nomor SO yang ingin digenerate', domain="[('state', '=', 'sale')]") + sales_approve = fields.Boolean(string='Sales Approve', tracking=3, copy=False) + merchandise_approve = fields.Boolean(string='Merchandise Approve', tracking=3, copy=False) @api.model def create(self, vals): vals['number'] = self.env['ir.sequence'].next_by_code('requisition') or '0' result = super(Requisition, self).create(vals) return result + + def button_approve(self): + if self.env.user.id not in [377, 19]: + raise UserError('Hanya Vita dan Darren Yang Bisa Approve') + if self.env.user.id == 377: + self.sales_approve = True + elif self.env.user.id == 19: + if not self.sales_approve: + raise UserError('Vita Belum Approve') + self.merchandise_approve = True def create_po_from_requisition(self): + if not self.sales_approve: + raise UserError('Harus Di Approve oleh Vita') + if not self.merchandise_approve: + raise UserError('Harus Di Approve oleh Darren') if not self.requisition_lines: raise UserError('Tidak ada Lines, belum bisa create PO') if self.is_po: diff --git a/indoteknik_custom/views/requisition.xml b/indoteknik_custom/views/requisition.xml index b704baaf..cc537eda 100644 --- a/indoteknik_custom/views/requisition.xml +++ b/indoteknik_custom/views/requisition.xml @@ -50,6 +50,13 @@ requisition
+
+
-- cgit v1.2.3 From 4be403f544f63a5161275f0d600c6f6950f3a30c Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 11 Nov 2024 16:13:27 +0700 Subject: push --- indoteknik_custom/models/approval_retur_picking.py | 16 ++++++------- indoteknik_custom/models/requisition.py | 2 +- indoteknik_custom/models/stock_picking.py | 26 +++++++++++++++++----- indoteknik_custom/views/approval_retur_picking.xml | 2 +- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/indoteknik_custom/models/approval_retur_picking.py b/indoteknik_custom/models/approval_retur_picking.py index 63639782..34c449a8 100644 --- a/indoteknik_custom/models/approval_retur_picking.py +++ b/indoteknik_custom/models/approval_retur_picking.py @@ -8,7 +8,7 @@ class ApprovalReturPicking(models.TransientModel): _name = 'approval.retur.picking' _description = 'Wizard to add Note Return' - note_return = fields.Text(string="Note Return", required=True) + note_return = fields.Text(string="Note Return") def action_confirm_note_return(self): picking_ids = self._context.get('picking_ids') @@ -16,22 +16,22 @@ class ApprovalReturPicking(models.TransientModel): # Update the note_return field picking.update({ - 'note_return': self.note_return + 'approval_return_status': 'pengajuan1' }) # Post a highlighted message to lognote - picking.message_post( - body=f"
" - f"Note Return (Pinned):
{self.note_return}
", - subtype_id=self.env.ref("mail.mt_note").id - ) + # picking.message_post( + # body=f"
" + # f"Note Return (Pinned):
{self.note_return}
", + # subtype_id=self.env.ref("mail.mt_note").id + # ) return { 'type': 'ir.actions.client', 'tag': 'display_notification', 'params': { 'title': 'Notification', - 'message': 'Note berhasil ditambah', + 'message': 'Status pengajuan telah berubah', 'next': {'type': 'ir.actions.act_window_close'}, } } diff --git a/indoteknik_custom/models/requisition.py b/indoteknik_custom/models/requisition.py index a90a5718..89ed4a27 100644 --- a/indoteknik_custom/models/requisition.py +++ b/indoteknik_custom/models/requisition.py @@ -117,7 +117,7 @@ class Requisition(models.Model): 'product_id': product.id, 'product_qty': line.qty_purchase, 'product_uom_qty': line.qty_purchase, - 'name': product.name, + 'name': product.display_name, 'price_unit': line.price_unit, 'taxes_id': tax, } diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 107a6e72..ad31a2ba 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -445,14 +445,28 @@ class StockPicking(models.Model): if self.env.user.is_accounting: pick.approval_return_status = 'approved' else: - pick.approval_return_status = 'pengajuan1' - action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_stock_return_note_wizard') - action['context'] = { - 'picking_ids': [x.id for x in self] - } - return action + if self.picking_type_code == 'outgoing': + if self.env.user.id in [3988, 3401, 20]: + action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_stock_return_note_wizard') + action['context'] = { + 'picking_ids': [x.id for x in self] + } + return action + else: + raise UserError('Harus Sales Admin yang Ask Return') + elif self.picking_type_code == 'incoming': + if self.env.user.has_group('indoteknik_custom.group_role_purchasing'): + action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_stock_return_note_wizard') + action['context'] = { + 'picking_ids': [x.id for x in self] + } + return action + else: + raise UserError('Harus Purchasing yang Ask Return') + def calculate_line_no(self): + for picking in self: name = picking.group_id.name for move in picking.move_ids_without_package: diff --git a/indoteknik_custom/views/approval_retur_picking.xml b/indoteknik_custom/views/approval_retur_picking.xml index ebe038d1..5ce28e20 100644 --- a/indoteknik_custom/views/approval_retur_picking.xml +++ b/indoteknik_custom/views/approval_retur_picking.xml @@ -6,7 +6,7 @@ - + Ask Approval Retur?