summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/product_template.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2023-06-16 16:54:14 +0700
committerstephanchrst <stephanchrst@gmail.com>2023-06-16 16:54:14 +0700
commit3246d242a3044c2fb010aa6bf219bf3ca5ae3d5a (patch)
tree1c01f99b601857aec20d80383c886be9d08051cd /indoteknik_custom/models/product_template.py
parent2b55220a09fa15c22fb0a4e405c6495153604f54 (diff)
refactor code qty incoming and onhand for bandengan only and fix suggestion in purchase order line
Diffstat (limited to 'indoteknik_custom/models/product_template.py')
-rwxr-xr-xindoteknik_custom/models/product_template.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index 9c480f4c..a4f8f031 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -211,7 +211,28 @@ class ProductProduct(models.Model):
usage = fields.Char(string='Usage')
specification = fields.Char(string='Specification')
material = fields.Char(string='Material')
+ qty_onhand_bandengan = fields.Float(string='Qty Incoming Bandengan', compute='_get_qty_onhand_bandengan')
+ qty_incoming_bandengan = fields.Float(string='Qty Incoming Bandengan', compute='_get_qty_incoming_bandengan')
+ def _get_qty_incoming_bandengan(self):
+ for product in self:
+ qty_incoming = self.env['stock.move'].search([
+ ('product_id', '=', product.id),
+ ('location_dest_id', '=', 57),
+ ('state', 'not in', ['done', 'cancel'])
+ ])
+ qty = sum(qty_incoming.mapped('product_uom_qty'))
+ product.qty_incoming_bandengan = qty
+
+ def _get_qty_onhand_bandengan(self):
+ for product in self:
+ qty_onhand = self.env['stock.quant'].search([
+ ('product_id', '=', product.id),
+ ('location_id', '=', 57)
+ ])
+ qty = sum(qty_onhand.mapped('quantity'))
+ product.qty_onhand_bandengan = qty
+
# def write(self, vals):
# if 'solr_flag' not in vals:
# for variant in self: