summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-01-10 09:18:26 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-01-10 09:18:26 +0700
commite64e3a04ff6db3802779477398020738017b74b8 (patch)
tree2b0ee4057430d4eb36d3ae4bd49d25ae3dc1ef62
parentdfd4a1617d2c62b99d4bbcb6386b477874a33ebf (diff)
multiple delete on purchase order line
-rwxr-xr-xindoteknik_custom/models/purchase_order.py4
-rwxr-xr-xindoteknik_custom/models/purchase_order_line.py1
-rwxr-xr-xindoteknik_custom/views/purchase_order.xml4
3 files changed, 9 insertions, 0 deletions
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 @@
<button name="indoteknik_custom.action_view_uangmuka_pembelian" string="UangMuka"
type="action" attrs="{'invisible': [('approval_status', '!=', 'approved')]}"/>
</button>
+ <button name="button_unlock" position="after">
+ <button name="delete_line" type="object" string="Delete " states="draft"/>
+ </button>
<field name="date_order" position="before">
<field name="sale_order_id" attrs="{'readonly': [('state', 'not in', ['draft'])]}"/>
<field name="approval_status"/>
@@ -46,6 +49,7 @@
</field>
<field name="product_id" position="before">
<field name="line_no" attrs="{'readonly': 1}" optional="hide"/>
+ <field name="delete"/>
</field>
<field name="product_id" position="attributes">
<attribute name="options">{'no_create': True}</attribute>