diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-06-27 14:22:09 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-06-27 14:22:09 +0700 |
| commit | 57c571c40de1acfdcf23132782ec8c7fcbb8c6bd (patch) | |
| tree | 58eccafc69927796ea93c13f70dc0bbf3f47eca3 | |
| parent | feb55333e94aaec783bce85d36667912b3e90f86 (diff) | |
| parent | 45dc1483342d9ec195c53711b5194e7ddf88b343 (diff) | |
Merge branch 'release' into real-stock
| -rwxr-xr-x | indoteknik_custom/models/__init__.py | 2 | ||||
| -rwxr-xr-x | indoteknik_custom/models/sale_order.py | 10 | ||||
| -rw-r--r-- | indoteknik_custom/models/stock_picking.py | 73 | ||||
| -rw-r--r-- | indoteknik_custom/models/users.py | 12 | ||||
| -rwxr-xr-x | indoteknik_custom/views/purchase_order.xml | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/views/sale_order.xml | 1 | ||||
| -rw-r--r-- | indoteknik_custom/views/stock_picking.xml | 28 | ||||
| -rw-r--r-- | indoteknik_custom/views/users.xml | 1 |
8 files changed, 87 insertions, 41 deletions
diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 9764e0c0..3c6ce46c 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -22,9 +22,9 @@ from . import purchase_pricelist from . import res_partner_company_type from . import res_partner from . import res_users +from . import sale_order from . import sale_monitoring_detail from . import sale_monitoring -from . import sale_order from . import sales_outstanding from . import sales_target from . import stock_move diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 0c631761..0a794f6d 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -122,6 +122,16 @@ class SaleOrder(models.Model): line_no += 1 line.line_no = line_no # _logger.info('Calculate PO Line No %s' % line.id) + + def write(self, vals): + res = super(SaleOrder, self).write(vals) + + if 'carrier_id' in vals: + for picking in self.picking_ids: + if picking.state == 'assigned': + picking.carrier_id = self.carrier_id + + return res def calculate_so_status_beginning(self): so_state = ['sale'] diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index c8424121..a14e71a3 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 Receipt 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: @@ -205,6 +211,12 @@ class StockPicking(models.Model): raise UserError("Qty tidak boleh 0") pick.approval_status = 'pengajuan1' + def ask_receipt_approval(self): + if self.env.user.is_logistic_approver: + raise UserError('Bisa langsung validate tanpa Ask Receipt') + else: + self.approval_receipt_status = 'pengajuan1' + def ask_return_approval(self): for pick in self: if self.env.user.is_accounting: @@ -264,30 +276,41 @@ class StockPicking(models.Model): if self.is_internal_use and not self.env.user.is_accounting: raise UserError("Harus di Approve oleh Accounting") + if self.picking_type_id.id == 28 and not self.env.user.is_logistic_approver: + raise UserError("Harus di Approve oleh Logistik") + if self.group_id.sale_id: if self.group_id.sale_id.payment_link_midtrans: 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/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/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 @@ <button name="po_approve" string="Ask Approval" type="object" + attrs="{'invisible': [('approval_status', '=', 'approved')]}" /> <button name="indoteknik_custom.action_view_uangmuka_pembelian" string="UangMuka" type="action" attrs="{'invisible': [('approval_status', '!=', 'approved')]}"/> diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index ea84eb00..85f687c1 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -14,6 +14,7 @@ <button name="sale_order_approve" string="Ask Approval" type="object" + attrs="{'invisible': [('approval_status', 'in', ['pengajuan1', 'pengajuan2', 'approved'])]}" /> <button name="indoteknik_custom.action_view_uangmuka_penjualan" string="UangMuka" type="action" attrs="{'invisible': [('approval_status', '!=', 'approved')]}"/> diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index 4bbdc7b8..99f0d7c0 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -27,10 +27,15 @@ type="object" attrs="{'invisible': [('is_internal_use', '=', False)]}" /> + <button name="ask_receipt_approval" + string="Received" + type="object" + attrs="{'invisible': ['|', ('state', 'in', ['done']), ('approval_receipt_status', '=', 'pengajuan1')]}" + /> <button name="ask_return_approval" string="Ask Return/Acc" type="object" - attrs="{'invisible': ['|', ('state', '=', 'draft'), ('state', '=', 'cancel'), ('approval_return_status', '=', 'pengajuan1')]}" + attrs="{'invisible': ['|', ('state', 'in', ['draft', 'cancel', 'assigned']), ('approval_return_status', '=', 'pengajuan1')]}" /> <button name="action_create_invoice_from_mr" string="Create Bill" @@ -39,12 +44,6 @@ /> </button> <field name="backorder_id" position="after"> - <field name="is_internal_use" - string="Internal Use" - type="object" - attrs="{'readonly': True}" - force_save="1" - /> <field name="summary_qty_detail"/> <field name="count_line_detail"/> </field> @@ -53,8 +52,6 @@ </field> <field name="origin" position="after"> <field name="date_doc_kirim"/> - <field name="approval_status" attrs="{'invisible': [('is_internal_use', '=', False)]}"/> - <field name="approval_return_status" attrs="{'invisible': [('approval_return_status', '=', False)]}"/> <field name="summary_qty_operation"/> <field name="count_line_operation"/> <field name="account_id" @@ -65,8 +62,19 @@ }" /> </field> + <field name="group_id" position="before"> + <field name="is_internal_use" + string="Internal Use" + type="object" + attrs="{'readonly': True}" + force_save="1" + /> + <field name="approval_status"/> + <field name="approval_receipt_status"/> + <field name="approval_return_status"/> + </field> <field name="product_id" position="before"> - <field name="line_no" attrs="{'readonly': 1}"/> + <field name="line_no" attrs="{'readonly': 1}" optional="hide"/> </field> <page name="note" position="after"> <page string="E-Faktur" name="efaktur" attrs="{'invisible': [['is_internal_use', '=', False]]}"> diff --git a/indoteknik_custom/views/users.xml b/indoteknik_custom/views/users.xml index 29d455d4..25e7f90c 100644 --- a/indoteknik_custom/views/users.xml +++ b/indoteknik_custom/views/users.xml @@ -11,6 +11,7 @@ <field name="is_purchasing_manager"/> <field name="is_sales_manager"/> <field name="is_leader"/> + <field name="is_logistic_approver"/> </field> </field> </record> |
