diff options
| author | Mqdd <ahmadmiqdad27@gmail.com> | 2026-01-15 00:12:17 +0700 |
|---|---|---|
| committer | Mqdd <ahmadmiqdad27@gmail.com> | 2026-01-15 00:12:17 +0700 |
| commit | 2e1e5b798cc5b859a0c10cbdb4e48cbbe0687112 (patch) | |
| tree | fca1469dde7698f83e0d3169d7cd0353248fc701 | |
| parent | 4e1e2f93b0788c020bd3f1c1f802cf2f53997de5 (diff) | |
<Miqdad> add cancel reason when trying to cancel and some decoration
| -rw-r--r-- | indoteknik_custom/models/gudang_service.py | 39 | ||||
| -rw-r--r-- | indoteknik_custom/views/gudang_service.xml | 8 |
2 files changed, 28 insertions, 19 deletions
diff --git a/indoteknik_custom/models/gudang_service.py b/indoteknik_custom/models/gudang_service.py index 600febfd..585563ca 100644 --- a/indoteknik_custom/models/gudang_service.py +++ b/indoteknik_custom/models/gudang_service.py @@ -12,29 +12,30 @@ class GudangService(models.Model): name = fields.Char('Name', readonly=True) partner_id = fields.Many2one('res.partner', string='Customer', readonly=True) - origin = fields.Many2one('sale.order', string='Origin SO') - picking_id = fields.Many2one('stock.picking', string = 'Picking ID', domain="[('sale_id', '=', origin)]") + origin = fields.Many2one('sale.order', string='Origin SO', required=True) + # picking_id = fields.Many2one('stock.picking', string = 'Picking ID', domain="[('sale_id', '=', origin)]") date = fields.Datetime('Date', default=fields.Datetime.now, required=True) gudang_service_lines = fields.One2many('gudang.service.line', 'gudang_service_id', string='Gudang Service Lines') remaining_date = fields.Char('Remaining Date', compute='_compute_remaining_date') state = fields.Selection([('draft', 'Draft'), ('onprogress', 'On Progress'),('done', 'Done'), ('cancel', 'Cancel')], default='draft') + cancel_reason = fields.Text('Cancel Reason') - @api.onchange('picking_id') - def _onchange_picking_id(self): - if not self.picking_id: - self.gudang_service_lines = [(5, 0, 0)] - return + # @api.onchange('picking_id') + # def _onchange_picking_id(self): + # if not self.picking_id: + # self.gudang_service_lines = [(5, 0, 0)] + # return - lines = [(5, 0, 0)] - for move in self.picking_id.move_ids_without_package: - if move.product_id: - lines.append((0, 0, { - 'product_id': move.product_id.id, - 'quantity': move.product_uom_qty, - 'origin_so': self.origin.id, - })) + # lines = [(5, 0, 0)] + # for move in self.picking_id.move_ids_without_package: + # if move.product_id: + # lines.append((0, 0, { + # 'product_id': move.product_id.id, + # 'quantity': move.product_uom_qty, + # 'origin_so': self.origin.id, + # })) - self.gudang_service_lines = lines + # self.gudang_service_lines = lines def _send_logistic_notification(self): @@ -94,9 +95,13 @@ class GudangService(models.Model): if record.state == 'cancel': record.write({'state': 'draft'}) else: - raise UserError("Hanya record yang di-cancel yang bisa dikembalikan ke draft") + raise UserError("Only Canceled Record Can Be Reset To Draft") def action_cancel(self): + if self.state == 'done': + raise UserError("You cannot cancel a done record") + if not self.cancel_reason: + raise UserError("Cancel Reason must be filled") self.state = 'cancel' # def write(vals, self): diff --git a/indoteknik_custom/views/gudang_service.xml b/indoteknik_custom/views/gudang_service.xml index 8c681451..4365ba5d 100644 --- a/indoteknik_custom/views/gudang_service.xml +++ b/indoteknik_custom/views/gudang_service.xml @@ -6,11 +6,13 @@ <field name="name">gudang.serivice.tree</field> <field name="model">gudang.service</field> <field name="arch" type="xml"> - <tree string="Monitoring Gudang Service"> + <tree string="Monitoring Gudang Service" decoration-info="state == 'draft'" decoration-warning="state == 'onprogress'" decoration-success="state == 'done'" decoration-muted="state == 'cancel'"> <field name="name"/> <field name="partner_id"/> <field name="origin"/> <field name="remaining_date"/> + <field name="state" widget="badge" decoration-info="state in ('draft')" decoration-warning="state == 'onprogress'" + decoration-success="state == 'done'" decoration-muted="state == 'cancel'" /> <!-- <field name="picking_id"/> --> </tree> </field> @@ -45,10 +47,12 @@ <group> <field name="origin"/> <field name="partner_id"/> - <field name="picking_id"/> + <!-- <field name="picking_id"/> --> <field name="date"/> <field name="remaining_date"/> <field name="create_uid"/> + <field name="cancel_reason" + attrs="{'invisible': [('state', 'in', ['done', 'draft'])]}"/> </group> <notebook> <page string="Product Lines" name="product_lines"> |
