From e64e3a04ff6db3802779477398020738017b74b8 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 10 Jan 2024 09:18:26 +0700 Subject: multiple delete on purchase order line --- indoteknik_custom/models/purchase_order.py | 4 ++++ indoteknik_custom/models/purchase_order_line.py | 1 + indoteknik_custom/views/purchase_order.xml | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index 6a641aff..6d156cb6 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -52,6 +52,10 @@ class PurchaseOrder(models.Model): responsible_ids = fields.Many2many('res.users', string='Responsibles', compute='_compute_responsibles') status_paid_cbd = fields.Boolean(string='Paid Status', tracking=3, help='Field ini diisi secara manual oleh Finance AP dan hanya untuk status PO CBD') + def delete_line(self): + lines_to_delete = self.order_line.filtered(lambda line: line.delete) + lines_to_delete.unlink() + def open_form_multi_confirm_po(self): action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_purchase_order_multi_confirm') action['context'] = { diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index 9406f85f..9240c504 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -34,6 +34,7 @@ class PurchaseOrderLine(models.Model): is_ltc = fields.Boolean(string='Sudah di LTC', default=False, help='centang ini jika barang sudah di LTC') note = fields.Char(string='Note') qty_reserved = fields.Float(string='Qty Reserved', compute='_compute_qty_reserved') + delete = fields.Boolean(string='Delete', default=False, help='centang ini jika anda ingin menghapus line ini') def _compute_qty_reserved(self): for line in self: diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml index fff582b1..c7989eeb 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -23,6 +23,9 @@ + @@ -46,6 +49,7 @@ + {'no_create': True} -- cgit v1.2.3