diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2023-12-22 09:04:41 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2023-12-22 09:04:41 +0700 |
| commit | fbb11ab07e66b28459375af175459c3a23148597 (patch) | |
| tree | 53483794d588dd3467c1fbc625280b005799602b /indoteknik_custom/models/product_template.py | |
| parent | 9abad8c8ee173626b05d13a5db9e81352dce0bb6 (diff) | |
| parent | 80afbdeecd286c990ddc80c277287df6c95f5ee8 (diff) | |
Merge branch 'production' into purchasing-job
Diffstat (limited to 'indoteknik_custom/models/product_template.py')
| -rwxr-xr-x | indoteknik_custom/models/product_template.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 90e8a144..34aff4fa 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -339,8 +339,10 @@ 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_onhand_bandengan = fields.Float(string='Qty Onhand Bandengan', compute='_get_qty_onhand_bandengan') qty_incoming_bandengan = fields.Float(string='Qty Incoming Bandengan', compute='_get_qty_incoming_bandengan') + qty_outgoing_bandengan = fields.Float(string='Qty Outgoing Bandengan', compute='_get_qty_outgoing_bandengan') + qty_available_bandengan = fields.Float(string='Qty Available Bandengan', compute='_get_qty_available_bandengan') qty_upcoming = fields.Float(string='Qty Upcoming', compute='_get_qty_upcoming') sla_version = fields.Integer(string="SLA Version", default=0) is_edited = fields.Boolean(string='Is Edited') @@ -408,6 +410,17 @@ class ProductProduct(models.Model): qty = sum(qty_incoming.mapped('product_uom_qty')) product.qty_incoming_bandengan = qty + def _get_qty_outgoing_bandengan(self): + for product in self: + qty_incoming = self.env['stock.move'].search([ + ('product_id', '=', product.id), + ('location_dest_id', '=', 5), + ('location_id', '=', 57), + ('state', 'not in', ['done', 'cancel']) + ]) + qty = sum(qty_incoming.mapped('product_uom_qty')) + product.qty_outgoing_bandengan = qty + def _get_qty_onhand_bandengan(self): for product in self: qty_onhand = self.env['stock.quant'].search([ @@ -417,6 +430,11 @@ class ProductProduct(models.Model): qty = sum(qty_onhand.mapped('quantity')) product.qty_onhand_bandengan = qty + def _get_qty_available_bandengan(self): + for product in self: + qty_available = product.qty_incoming_bandengan + product.qty_onhand_bandengan - product.qty_outgoing_bandengan + product.qty_available_bandengan = qty_available + # def write(self, vals): # if 'solr_flag' not in vals: # for variant in self: |
