summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/product_template.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2024-11-06 17:00:48 +0700
committerstephanchrst <stephanchrst@gmail.com>2024-11-06 17:00:48 +0700
commit8b54606ef925ff2e6feb2794aabaafa4864e6961 (patch)
tree9515824181438653d34d9fc346d060f5c3d6beb0 /indoteknik_custom/models/product_template.py
parent295088070b43c409c2114a0a98d898ff3ff4ae7b (diff)
initial commit max plafon qty order
Diffstat (limited to 'indoteknik_custom/models/product_template.py')
-rwxr-xr-xindoteknik_custom/models/product_template.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index 2ca4925b..35844c22 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -374,6 +374,8 @@ class ProductProduct(models.Model):
is_edited = fields.Boolean(string='Is Edited')
qty_sold = fields.Float(string='Sold Quantity', compute='_get_qty_sold')
short_spesification = fields.Char(string='Short Spesification')
+ max_qty_reorder = fields.Float(string='Max Qty Reorder', compute='_get_max_qty_reordering_rule')
+ plafon_qty = fields.Float(string='Max Plafon', compute='_get_plafon_qty_product')
def _get_clean_website_description(self):
for rec in self:
@@ -487,13 +489,32 @@ class ProductProduct(models.Model):
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
+ product.qty_available_bandengan = qty_available or 0
def _get_qty_free_bandengan(self):
for product in self:
qty_free = product.qty_onhand_bandengan - product.qty_outgoing_bandengan
product.qty_free_bandengan = qty_free
-
+
+ def _get_max_qty_reordering_rule(self):
+ for product in self:
+ reordering = self.env['stock.warehouse.orderpoint'].search([
+ ('product_id', '=', product.id)
+ ], limit=1)
+ if not reordering:
+ product.max_qty_reorder = 0
+ else:
+ product.max_qty_reorder = reordering.product_max_qty
+ test = reordering.product_max_qty
+ print(test)
+
+ def _get_plafon_qty_product(self):
+ for product in self:
+ qty_available = product.qty_available_bandengan
+ max_qty = product.max_qty_reorder
+ product.plafon_qty = max_qty - qty_available
+
+
# def write(self, vals):
# if 'solr_flag' not in vals:
# for variant in self: