summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/product_template.py
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2023-10-17 11:22:54 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2023-10-17 11:22:54 +0700
commitee9255e9e404938fa7a49d8219b14101df84f8b9 (patch)
tree7019e8428c6531e61f32d0d09cf60b96f8c254c3 /indoteknik_custom/models/product_template.py
parent464e80d0cb180335dada9878272c62f5db9b9e73 (diff)
parent2c65cca19a67b66ac7d96eef0d6d74d3cee1740e (diff)
Merge branch 'production' of bitbucket.org:altafixco/indoteknik-addons into production
# Conflicts: # indoteknik_custom/models/product_template.py
Diffstat (limited to 'indoteknik_custom/models/product_template.py')
-rwxr-xr-xindoteknik_custom/models/product_template.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index e69d6044..19bcc780 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 = []
@@ -184,12 +188,7 @@ class ProductTemplate(models.Model):
def _compute_web_price(self):
for template in self:
- products = self.env['product.product'].search([
- ('product_tmpl_id', '=', template.id),
- ('active', 'in', [True, False])
- ])
- for variants in products:
- template.web_price = variants[0].web_price
+ template.web_price = template.product_variant_id.web_price
def _have_promotion_program(self):
for template in self:
@@ -332,9 +331,19 @@ class ProductProduct(models.Model):
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')
+ qty_sold = fields.Float(string='Sold Quantity', compute='_get_qty_sold')
+
def _get_qty_upcoming(self):
for product in self:
product.qty_upcoming = product.incoming_qty + product.qty_available
+
+ 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 = []
@@ -407,7 +416,7 @@ class ProductProduct(models.Model):
for product in self:
pricelist_id = self.env['ir.config_parameter'].sudo().get_param('product.pricelist.default_price_id_v2')
- domain = [('pricelist_id', '=', pricelist_id or 17022), ('product_id', '=', product.id)]
+ domain = [('pricelist_id.id', '=', pricelist_id or 17022), ('product_id.id', '=', product.id)]
product_pricelist_item = self.env['product.pricelist.item'].search(domain, limit=1)
if product_pricelist_item.base_pricelist_id: