summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/product_template.py
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_custom/models/product_template.py')
-rwxr-xr-xindoteknik_custom/models/product_template.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index b1930ada..da1a111f 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -52,7 +52,11 @@ class ProductTemplate(models.Model):
help='Centang jika ingin ditammpilkan di website sebagai segment Produk Baru')
seq_new_product = fields.Integer(string='Seq New Product', help='Urutan Sequence New Product')
is_edited = fields.Boolean(string='Is Edited')
-
+ qty_sold = fields.Float(string='Sold Quantity', compute='_get_qty_sold')
+
+ def _get_qty_sold(self):
+ for rec in self:
+ rec.qty_sold = sum(x.qty_sold for x in rec.product_variant_ids)
def day_product_to_edit(self):
day_products = []
@@ -331,6 +335,15 @@ class ProductProduct(models.Model):
qty_incoming_bandengan = fields.Float(string='Qty Incoming Bandengan', compute='_get_qty_incoming_bandengan')
sla_version = fields.Integer(string="SLA Version", default=0)
is_edited = fields.Boolean(string='Is Edited')
+ qty_sold = fields.Float(string='Sold Quantity', compute='_get_qty_sold')
+
+ def _get_qty_sold(self):
+ for product in self:
+ order_line = self.env['sale.order.line'].search([
+ ('order_id.state', 'in', ['done', 'sale']),
+ ('product_id', '=', product.id)
+ ])
+ product.qty_sold = sum(x.product_uom_qty for x in order_line)
def day_product_to_edit(self):
day_products = []