From 4a200ee4e0caf44e78273215b12c3655655f4273 Mon Sep 17 00:00:00 2001 From: HafidBuroiroh Date: Wed, 11 Mar 2026 20:08:23 +0700 Subject: naekin sorcing job --- indoteknik_custom/models/sourcing_job_order.py | 31 +++-------------- indoteknik_custom/security/ir.model.access.csv | 1 + indoteknik_custom/views/sourcing.xml | 46 +++++++++++++++++--------- 3 files changed, 35 insertions(+), 43 deletions(-) diff --git a/indoteknik_custom/models/sourcing_job_order.py b/indoteknik_custom/models/sourcing_job_order.py index 0e5334a8..ce0bc4ec 100644 --- a/indoteknik_custom/models/sourcing_job_order.py +++ b/indoteknik_custom/models/sourcing_job_order.py @@ -269,7 +269,7 @@ class SourcingJobOrderLine(models.Model): product_id = fields.Many2one('product.product', string='Product', ondelete='cascade') md_person_ids = fields.Many2one('res.users', string='MD Person', ondelete='cascade') brand_id = fields.Many2one('x_manufactures', string='Manufactures', ondelete='cascade') - so_id = fields.Many2one('sale.order', string='SO Number', tracking=True, readonly=True) + so_id = fields.Many2one('sale.order', string='SO Number', tracking=True) product_name_md = fields.Char(string='Nama Barang') descriptions_md = fields.Text(string='Deskripsi Barang') @@ -325,11 +325,11 @@ class SourcingJobOrderLine(models.Model): so_state = fields.Selection( [ - ('draft', 'Draft'), + ('draft', 'Quotation'), ('cancel', 'Cancel'), - ('sale', 'Sale') + ('sale', 'Sale Order') ], - string="SO State", + string="Status SO", compute="_compute_so_data" ) @@ -408,7 +408,6 @@ class SourcingJobOrderLine(models.Model): vals['show_salesperson'] = order.so_id.user_id.id rec = super().create(vals) - rec._check_line_limit() return rec def write(self, vals): @@ -423,30 +422,8 @@ class SourcingJobOrderLine(models.Model): res = super().write(vals) if 'state' in vals: self._update_parent_state() - self._check_line_limit() return res - def _check_line_limit(self): - for rec in self: - if not rec.order_id or not rec.order_id.so_id: - continue - - so = rec.order_id.so_id - - so_line_count = len(so.order_line) - - sourcing_lines = self.search([ - ('order_id', '=', rec.order_id.id), - ('state', '!=', 'cancel') - ]) - - if len(sourcing_lines) > so_line_count: - raise UserError( - f"Jumlah Sourcing Line tidak boleh melebihi Sales Order Line.\n\n" - f"Sales Order Line : {so_line_count}\n" - f"Sourcing Line : {len(sourcing_lines)}" - ) - def _update_parent_state(self): for rec in self: order = rec.order_id diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index b8a1fd6f..4776b9e8 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -232,4 +232,5 @@ access_sjo_give_wizard_user,sjo.give.wizard user,model_sjo_give_wizard,base.grou access_sjo_reject_give_wizard_user,sjo.reject.give.wizard user,model_sjo_reject_give_wizard,base.group_user,1,1,1,1 access_token_log,access.token.log,model_token_log,,1,1,1,1 +access_reopen_cancel_line_wizard,reopen.cancel.line.wizard,model_reopen_cancel_line_wizard,base.group_user,1,1,1,1 access_account_move_change_date_wizard,access.account.move.change.date.wizard,model_account_move_change_date_wizard,,1,1,1,1 diff --git a/indoteknik_custom/views/sourcing.xml b/indoteknik_custom/views/sourcing.xml index 006817cf..cd1de5a4 100644 --- a/indoteknik_custom/views/sourcing.xml +++ b/indoteknik_custom/views/sourcing.xml @@ -102,12 +102,6 @@ groups="indoteknik_custom.group_role_merchandiser" attrs="{'invisible': [('state', 'in', ['cancel', 'done'])]}"/> -