summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/purchase_order_line.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2023-12-14 11:32:25 +0700
committerstephanchrst <stephanchrst@gmail.com>2023-12-14 11:32:25 +0700
commitbb2a3647ac1f5885bc6481ce10bfcd91813bfe81 (patch)
tree8a4c56c0141611e08e2ad42df00b1106c9569644 /indoteknik_custom/models/purchase_order_line.py
parente6770e132602c094197fbd6d9becc2bbc9c2d8e0 (diff)
change suggest to virtual column
Diffstat (limited to 'indoteknik_custom/models/purchase_order_line.py')
-rwxr-xr-xindoteknik_custom/models/purchase_order_line.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py
index eced5d43..5e1c7b5f 100755
--- a/indoteknik_custom/models/purchase_order_line.py
+++ b/indoteknik_custom/models/purchase_order_line.py
@@ -22,18 +22,26 @@ class PurchaseOrderLine(models.Model):
help="Total % Margin in Sales Order Header")
delivery_amt_line = fields.Float('DeliveryAmtLine', compute='compute_delivery_amt_line')
line_no = fields.Integer('No', default=0)
- qty_available = fields.Float('Qty Available', compute='compute_qty_stock')
- qty_onhand = fields.Float('Qty On Hand', compute='compute_qty_stock')
- qty_incoming = fields.Float('Qty Incoming', compute='compute_qty_stock')
- qty_outgoing = fields.Float('Qty Outgoing', compute='compute_qty_stock')
+ qty_available = fields.Float('Qty Available', compute='_compute_qty_stock')
+ qty_onhand = fields.Float('Qty On Hand', compute='_compute_qty_stock')
+ qty_incoming = fields.Float('Qty Incoming', compute='_compute_qty_stock')
+ qty_outgoing = fields.Float('Qty Outgoing', compute='_compute_qty_stock')
qty_available_store = fields.Float(string='Available')
- suggest = fields.Char(string='Suggest')
+ suggest = fields.Char(string='Suggest', compute='_compute_suggest_purchasing')
price_vendor = fields.Float(string='Price Vendor', compute='compute_price_vendor')
so_line_id = fields.Many2one('sale.order.line', string='ID SO Line')
indent = fields.Boolean(string='Indent', help='centang ini jika barang indent')
is_ltc = fields.Boolean(string='Sudah di LTC', default=False, help='centang ini jika barang sudah di LTC')
note = fields.Char(string='Note')
+ def _compute_suggest_purchasing(self):
+ print(1)
+ for line in self:
+ if line.qty_available < 0:
+ line.suggest = 'harus beli'
+ else:
+ line.suggest = 'masih cukup'
+
def compute_price_vendor(self):
for line in self:
purchase_pricelist = self.env['purchase.pricelist'].search([
@@ -48,7 +56,7 @@ class PurchaseOrderLine(models.Model):
else:
line.price_vendor = 0
- def compute_qty_stock(self):
+ def _compute_qty_stock(self):
for line in self:
line.qty_available = line.product_id.virtual_available
line.qty_onhand = line.product_id.qty_available
@@ -57,7 +65,7 @@ class PurchaseOrderLine(models.Model):
@api.onchange('product_id')
def _onchange_product_custom(self):
- self.compute_qty_stock()
+ self._compute_qty_stock()
# Override method from addons/purchase/models/purchase.py
@api.onchange('product_qty', 'product_uom')