From 0b85c98761260dd93b70fa429340c4edbf5154b1 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 14 Nov 2022 11:45:32 +0700 Subject: add approval if want to return --- indoteknik_custom/models/__init__.py | 1 + indoteknik_custom/models/stock_picking.py | 15 ++++++++++++++- indoteknik_custom/models/stock_picking_return.py | 19 +++++++++++++++++++ indoteknik_custom/views/stock_picking.xml | 9 ++++++++- 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 indoteknik_custom/models/stock_picking_return.py diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 94fe56fe..8645fb00 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -29,3 +29,4 @@ from . import users from . import ir_attachment from . import delivery_carrier from . import dunning_run +from . import stock_picking_return diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index d016e241..2f82c6f6 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -50,7 +50,12 @@ class StockPicking(models.Model): approval_status = fields.Selection([ ('pengajuan1', 'Approval Accounting'), ('approved', 'Approved'), - ], string='Approval Status', readonly=True, copy=False, index=True, tracking=3) + ], string='Approval Status', readonly=True, copy=False, index=True, tracking=3, help="Approval Status untuk Internal Use") + + approval_return_status = fields.Selection([ + ('pengajuan1', 'Approval Accounting'), + ('approved', 'Approved'), + ], string='Approval Return Status', readonly=True, copy=False, index=True, tracking=3, help="Approval Status untuk Return") def action_assign(self): res = super(StockPicking, self).action_assign() @@ -68,6 +73,13 @@ class StockPicking(models.Model): raise UserError("Qty tidak boleh 0") pick.approval_status = 'pengajuan1' + def ask_return_approval(self): + for pick in self: + if self.env.user.is_accounting: + pick.approval_return_status = 'approved' + else: + pick.approval_return_status = 'pengajuan1' + def calculate_line_no(self): line_no = 0 for picking in self: @@ -102,6 +114,7 @@ class StockPicking(models.Model): if self.picking_type_id.code == 'incoming' and self.group_id.id == False and self.is_internal_use == False: raise UserError(_('Tidak bisa Validate jika tidak dari Document SO / PO')) + if self.is_internal_use and not self.env.user.is_accounting: raise UserError("Harus di Approve oleh Accounting") res = super(StockPicking, self).button_validate() diff --git a/indoteknik_custom/models/stock_picking_return.py b/indoteknik_custom/models/stock_picking_return.py new file mode 100644 index 00000000..a4a3a500 --- /dev/null +++ b/indoteknik_custom/models/stock_picking_return.py @@ -0,0 +1,19 @@ +from odoo import _, api, fields, models +from odoo.exceptions import UserError +from odoo.tools.float_utils import float_round + + +class ReturnPicking(models.TransientModel): + _inherit = 'stock.return.picking' + + @api.model + def default_get(self, fields): + res = super(ReturnPicking, self).default_get(fields) + + stock_picking = self.env['stock.picking'].search([ + ('id', '=', res['picking_id']), + ]) + if not stock_picking.approval_return_status == 'approved': + raise UserError('Harus Approval Accounting untuk melakukan Retur') + + return res \ No newline at end of file diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index d53bf5b5..ce70fdd8 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -10,6 +10,12 @@
@@ -34,7 +40,8 @@ - + + Date: Mon, 14 Nov 2022 13:58:59 +0700 Subject: return approval if just have invoice only --- indoteknik_custom/models/stock_picking_return.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/stock_picking_return.py b/indoteknik_custom/models/stock_picking_return.py index a4a3a500..91a3a9fd 100644 --- a/indoteknik_custom/models/stock_picking_return.py +++ b/indoteknik_custom/models/stock_picking_return.py @@ -13,7 +13,15 @@ class ReturnPicking(models.TransientModel): stock_picking = self.env['stock.picking'].search([ ('id', '=', res['picking_id']), ]) - if not stock_picking.approval_return_status == 'approved': - raise UserError('Harus Approval Accounting untuk melakukan Retur') + + sale_id = stock_picking.group_id.sale_id + if not stock_picking.approval_return_status == 'approved' and sale_id.invoice_ids: + raise UserError('Harus Approval Accounting AR untuk melakukan Retur') + + purchase = self.env['purchase.order'].search([ + ('name', '=', stock_picking.group_id.name), + ]) + if not stock_picking.approval_return_status == 'approved' and purchase.invoice_ids: + raise UserError('Harus Approval Accounting AP untuk melakukan Retur') return res \ No newline at end of file -- cgit v1.2.3 From 61ada75c5d0e065d62c2aea0c59c153446bbf56c Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 14 Nov 2022 16:20:43 +0700 Subject: qty delivered cant greater than qty so validation --- indoteknik_custom/models/stock_picking.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 2f82c6f6..2bdfbd9e 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -111,12 +111,18 @@ class StockPicking(models.Model): def button_validate(self): if not self.picking_code: self.picking_code = self.env['ir.sequence'].next_by_code('stock.picking.code') or '0' - + if self.picking_type_id.code == 'incoming' and self.group_id.id == False and self.is_internal_use == False: raise UserError(_('Tidak bisa Validate jika tidak dari Document SO / PO')) if self.is_internal_use and not self.env.user.is_accounting: raise UserError("Harus di Approve oleh Accounting") + + for line in self.move_line_ids_without_package: + if line.move_id.sale_line_id and self.picking_type_id.code == 'outgoing': + 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") + res = super(StockPicking, self).button_validate() return res -- cgit v1.2.3 From d23592de2c631cf1b7bbdc53cfca7a95607c0b36 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 15 Nov 2022 09:39:24 +0700 Subject: Update product_pricelist.py and product_pricelist.xml --- indoteknik_custom/models/product_pricelist.py | 1 + indoteknik_custom/views/product_pricelist.xml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/indoteknik_custom/models/product_pricelist.py b/indoteknik_custom/models/product_pricelist.py index 5573ea55..7b850d57 100644 --- a/indoteknik_custom/models/product_pricelist.py +++ b/indoteknik_custom/models/product_pricelist.py @@ -9,6 +9,7 @@ class ProductPricelist(models.Model): banner = fields.Binary(string='Banner') start_date = fields.Datetime(string='Start Date') end_date = fields.Datetime(string='End Date') + banner_mobile = fields.Binary(string='Banner Mobile') class ProductPricelistItem(models.Model): diff --git a/indoteknik_custom/views/product_pricelist.xml b/indoteknik_custom/views/product_pricelist.xml index 18e9835a..3ff6854f 100644 --- a/indoteknik_custom/views/product_pricelist.xml +++ b/indoteknik_custom/views/product_pricelist.xml @@ -13,6 +13,9 @@ + + -- cgit v1.2.3