diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-10-05 08:30:03 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-10-05 08:30:03 +0700 |
| commit | 3d20a65942b64f252a10bada016042a3e1fc498a (patch) | |
| tree | 84882e12d679259cdec9b17240fd26c1df650f16 | |
| parent | b313cffd7c67da80a460eb693e2cbcc4f0e0455b (diff) | |
Update product_template.py
| -rwxr-xr-x | indoteknik_custom/models/product_template.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 348bda99..b121ffe9 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -20,6 +20,8 @@ class ProductTemplate(models.Model): 'Web Price', compute='_compute_web_price', digits='Product Price', inverse='_set_product_lst_price', help="Web Price with pricelist_id = 1") + have_promotion_program = fields.Boolean('Have Promotion Program', help="Punya promotion program gak?") + product_rating = fields.Float('Product Rating', help="Digunakan untuk sorting product di website") def _compute_web_price(self): for template in self: @@ -27,6 +29,29 @@ class ProductTemplate(models.Model): product_pricelist_item = self.env['product.pricelist.item'].search([('pricelist_id', '=', 1),('product_id', '=', product.id)],limit=1) template.web_price = product_pricelist_item.fixed_price + def _have_promotion_program(self): + for template in self: + domain = [ + ('rule_products_domain', 'ilike', template.x_manufacture.x_name), + ('active', '=', True) + ] + coupon_program = self.env['coupon.program'].search(domain, limit=1) + if coupon_program: + template.have_promotion_program = True + else: + template.have_promotion_program = False + + def _calculate_rating_product(self): + for product in self: + rate = 0 + if product.web_price: + rate += 1 + if product.have_promotion_program: + rate += 1 + if product.image_1024: + rate += 1 + + class ProductProduct(models.Model): _inherit = "product.product" web_price = fields.Float( |
