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_custom/models/sale_order_line.py | 1 + indoteknik_custom/models/website_user_cart.py | 2 ++ 2 files changed, 3 insertions(+) (limited to 'indoteknik_custom/models') 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/models/__init__.py | 1 + indoteknik_custom/models/approval_retur_picking.py | 38 ++++++++++++++++++++++ indoteknik_custom/models/stock_picking.py | 16 ++++++++- 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 indoteknik_custom/models/approval_retur_picking.py (limited to 'indoteknik_custom/models') 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 -- 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 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'indoteknik_custom/models') 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: -- 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 +++++++++++++++++----- 3 files changed, 29 insertions(+), 15 deletions(-) (limited to 'indoteknik_custom/models') 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: -- cgit v1.2.3 From 0c6f047cab337f7463ef359bbb744a2be7145267 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 12 Nov 2024 08:34:52 +0700 Subject: change domain sale order in requisition --- indoteknik_custom/models/requisition.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/requisition.py b/indoteknik_custom/models/requisition.py index 8ebdd31b..d53fc796 100644 --- a/indoteknik_custom/models/requisition.py +++ b/indoteknik_custom/models/requisition.py @@ -47,8 +47,7 @@ class Requisition(models.Model): notification = fields.Char(string='Notification') is_po = fields.Boolean(string='Is PO') 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')]") + sale_order_id = fields.Many2one('sale.order', string='SO', help='harus diisi nomor SO yang ingin digenerate') sales_approve = fields.Boolean(string='Sales Approve', tracking=3, copy=False) merchandise_approve = fields.Boolean(string='Merchandise Approve', tracking=3, copy=False) -- cgit v1.2.3 From 200d9ba97ba86f759b3d804c253430230c353fe0 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 12 Nov 2024 09:49:06 +0700 Subject: cr vendor approval --- indoteknik_custom/models/vendor_approval.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/vendor_approval.py b/indoteknik_custom/models/vendor_approval.py index b0d58b85..bcc5d3ea 100644 --- a/indoteknik_custom/models/vendor_approval.py +++ b/indoteknik_custom/models/vendor_approval.py @@ -30,10 +30,10 @@ class VendorApproval(models.Model): self.state = 'done' self.order_id.vendor_approval = True - self.order_id.action_confirm() message = "Vendor Approval approved by %s" % (self.env.user.name) self.order_id.message_post(body=message) - + if not self.order_id.due_id: + self.order_id.action_confirm() def action_reject(self): if not self.env.user.has_group('indoteknik_custom.group_role_merchandiser'): -- cgit v1.2.3 From d9d9159e43aaabcc88661d0f23d362ed2e0128f6 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 12 Nov 2024 11:04:24 +0700 Subject: cr stock picking --- indoteknik_custom/models/stock_picking.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'indoteknik_custom/models') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index ef26e002..50e9304b 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -520,8 +520,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 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._name != 'stock.picking': return super(StockPicking, self).button_validate() @@ -574,11 +575,14 @@ class StockPicking(models.Model): 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") + 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") + res = super(StockPicking, self).action_cancel() return res + @api.model def create(self, vals): self._use_faktur(vals) -- cgit v1.2.3