From 464c85d149b6425d1679753ca9216e96d1da8302 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 22 Aug 2024 14:10:53 +0700 Subject: add cancel to approval date doc --- indoteknik_custom/models/approval_date_doc.py | 6 +++++- indoteknik_custom/views/approval_date_doc.xml | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/approval_date_doc.py b/indoteknik_custom/models/approval_date_doc.py index efd4ffed..441ada3d 100644 --- a/indoteknik_custom/models/approval_date_doc.py +++ b/indoteknik_custom/models/approval_date_doc.py @@ -16,11 +16,12 @@ class ApprovalDateDoc(models.Model): string='Driver Departure Date', copy=False ) - state = fields.Selection([('draft', 'Draft'), ('done', 'Done')], string='State', default='draft', tracking=True) + state = fields.Selection([('draft', 'Draft'), ('done', 'Done'), ('cancel', 'Cancel')], string='State', default='draft', tracking=True) approve_date = fields.Datetime(string='Approve Date', copy=False) approve_by = fields.Many2one('res.users', string='Approve By', copy=False) sale_id = fields.Many2one('sale.order', string='Sale Order') partner_id = fields.Many2one('res.partner', string='Partner', related='picking_id.partner_id') + note = fields.Char(string='Note') @api.onchange('picking_id') def onchange_picking_id(self): @@ -43,6 +44,9 @@ class ApprovalDateDoc(models.Model): self.approve_date = datetime.utcnow() self.approve_by = self.env.user.id + def button_cancel(self): + self.state = 'cancel' + @api.model def create(self, vals): vals['number'] = self.env['ir.sequence'].next_by_code('approval.date.doc') or '0' diff --git a/indoteknik_custom/views/approval_date_doc.xml b/indoteknik_custom/views/approval_date_doc.xml index 58bf38d8..3d597aa8 100644 --- a/indoteknik_custom/views/approval_date_doc.xml +++ b/indoteknik_custom/views/approval_date_doc.xml @@ -28,6 +28,11 @@ string="Approve" type="object" attrs="{'invisible': [('state', '=', 'done')]}" + /> +