diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2024-02-01 11:41:28 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2024-02-01 11:41:28 +0700 |
| commit | 6f0b80656e318914d56d085f9b9e08ccd9838450 (patch) | |
| tree | 1bdcebad107cba79fb32c85414c8d83717c686b0 | |
| parent | fe086f5052ab5ba66c458ce25d50f7804c705211 (diff) | |
fix bug qty purchase and change request fiture delete line
| -rwxr-xr-x | indoteknik_custom/models/purchase_order.py | 4 | ||||
| -rwxr-xr-x | indoteknik_custom/models/purchase_order_line.py | 28 | ||||
| -rwxr-xr-x | indoteknik_custom/views/purchase_order.xml | 4 |
3 files changed, 32 insertions, 4 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py index ebadff06..67299d2c 100755 --- a/indoteknik_custom/models/purchase_order.py +++ b/indoteknik_custom/models/purchase_order.py @@ -54,9 +54,9 @@ class PurchaseOrder(models.Model): revisi_po = fields.Boolean(string='Revisi', tracking=3) def delete_line(self): - lines_to_delete = self.order_line.filtered(lambda line: line.delete_line) + lines_to_delete = self.order_line.filtered(lambda line: line.suggest == 'masih cukup') if not lines_to_delete: - raise UserError('Tidak ada item yang dipilih') + raise UserError('Tidak ada item yang masih cukup') lines_to_delete.unlink() def open_form_multi_confirm_po(self): diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index 465944d5..f1881942 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -36,6 +36,34 @@ class PurchaseOrderLine(models.Model): note = fields.Char(string='Note') qty_reserved = fields.Float(string='Qty Reserved', compute='_compute_qty_reserved') delete_line = fields.Boolean(string='Delete', default=False, help='centang ini jika anda ingin menghapus line ini') + is_edit_product_qty = fields.Boolean(string='Is Edit Product Qty', compute='_compute_is_edit_product_qty') + + def _compute_is_edit_product_qty(self): + for line in self: + + if line.order_id.state in ['draft']: + is_valid = True + else: + is_valid = False + + line.is_edit_product_qty = is_valid + + # @api.constrains('product_qty') + # def change_qty_po_and_qty_demand(self): + # for line in self: + # if line.order_id.state in ['draft', 'cancel'] and len(line.order_id.picking_ids) == 0: + # continue + + # for stock_picking in line.order_id.picking_ids: + # picking = self.env['stock.move'].search([ + # ('picking_id.purchase_id', '=', line.order_id.id), + # ('product_id', '=', line.product_id.id) + # ]) + + # if picking: + # picking.write({ + # 'product_uom_qty': line.product_qty + # }) 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 48443057..52e98787 100755 --- a/indoteknik_custom/views/purchase_order.xml +++ b/indoteknik_custom/views/purchase_order.xml @@ -52,12 +52,12 @@ </field> <field name="product_id" position="before"> <field name="line_no" attrs="{'readonly': 1}" optional="hide"/> - <field name="delete_line"/> </field> <field name="product_id" position="attributes"> <attribute name="options">{'no_create': True}</attribute> </field> <field name="product_qty" position="before"> + <field name="is_edit_product_qty" readonly="1" optional="hide"/> <field name="qty_onhand" readonly="1" optional="hide"/> <field name="qty_incoming" readonly="1" optional="hide"/> <field name="qty_outgoing" readonly="1" optional="hide"/> @@ -102,7 +102,7 @@ </xpath> <xpath expr="//form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='product_qty']" position="attributes"> - <attribute name="attrs">{'readonly': [], 'required': True}</attribute> + <attribute name="attrs">{'readonly': [('is_edit_product_qty', '=', False)], 'required': True}</attribute> </xpath> <xpath expr="//form/sheet/notebook/page[@name='purchase_delivery_invoice']" position="before"> |
