From 3d20a65942b64f252a10bada016042a3e1fc498a Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Wed, 5 Oct 2022 08:30:03 +0700 Subject: Update product_template.py --- indoteknik_custom/models/product_template.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) 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( -- cgit v1.2.3 From c3d509642ddc1d25b4695362a01cb058b186c1d0 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 6 Oct 2022 11:06:10 +0700 Subject: Update product_template.py --- indoteknik_custom/models/product_template.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index b121ffe9..041fcd61 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -1,4 +1,5 @@ -from odoo import fields, models +from odoo import fields, models, api +from datetime import datetime class ProductTemplate(models.Model): @@ -20,8 +21,9 @@ 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?") + have_promotion_program = fields.Boolean('Have Promotion Program', compute='_have_promotion_program', help="Punya promotion program gak?") product_rating = fields.Float('Product Rating', help="Digunakan untuk sorting product di website") + last_calculate_rating = fields.Datetime("Last Calculate Rating") def _compute_web_price(self): for template in self: @@ -41,15 +43,22 @@ class ProductTemplate(models.Model): else: template.have_promotion_program = False + @api.model def _calculate_rating_product(self): - for product in self: + # TODO add filter last calculation date time + products = self.env['product.template'].search([('type', '=', 'product'),('active', '=', True)], limit=1) + for product in products: rate = 0 + test = product.image_128 if product.web_price: rate += 1 if product.have_promotion_program: rate += 1 - if product.image_1024: + if product.image_128: rate += 1 + product.product_rating = rate + current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') + product.last_calculate_rating = current_time class ProductProduct(models.Model): -- cgit v1.2.3 From 97b5798df4cba856d98715cea095fda414f434a9 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Thu, 6 Oct 2022 14:55:30 +0700 Subject: Update product_template.py and product_template.xml --- indoteknik_custom/models/product_template.py | 22 ++++++++++++++++++---- indoteknik_custom/views/product_template.xml | 11 +++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 041fcd61..d1a5867f 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -1,5 +1,5 @@ from odoo import fields, models, api -from datetime import datetime +from datetime import datetime, timedelta class ProductTemplate(models.Model): @@ -46,10 +46,25 @@ class ProductTemplate(models.Model): @api.model def _calculate_rating_product(self): # TODO add filter last calculation date time - products = self.env['product.template'].search([('type', '=', 'product'),('active', '=', True)], limit=1) + # current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') + current_time = datetime.now() + current_time = current_time - timedelta(days=60) + current_time = current_time.strftime('%Y-%m-%d %H:%M:%S') + + products = self.env['product.template'].search([ + ('type', '=', 'product'), + ('active', '=', True), + "|" + ('last_calculate_rating', '!=', False), + ('last_calculate_rating', '<', current_time), + # ('x_manufacture', '=', 10) + # ('id', '=', 33627) + ], limit=5000) for product in products: + print(product.last_calculate_rating) + print("Calculate Rating Product ", product) + # print(product.image_128) rate = 0 - test = product.image_128 if product.web_price: rate += 1 if product.have_promotion_program: @@ -57,7 +72,6 @@ class ProductTemplate(models.Model): if product.image_128: rate += 1 product.product_rating = rate - current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') product.last_calculate_rating = current_time diff --git a/indoteknik_custom/views/product_template.xml b/indoteknik_custom/views/product_template.xml index 78aac34a..d4fa8d57 100755 --- a/indoteknik_custom/views/product_template.xml +++ b/indoteknik_custom/views/product_template.xml @@ -36,5 +36,16 @@ + + Product Template + product.template + + + + + + + + \ No newline at end of file -- cgit v1.2.3 From d6501fd1c30eab8686e87595327ee2887e587a49 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 7 Oct 2022 10:39:24 +0700 Subject: Update product_template.py --- indoteknik_custom/models/product_template.py | 29 +++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index d1a5867f..49f903e4 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -45,25 +45,36 @@ class ProductTemplate(models.Model): @api.model def _calculate_rating_product(self): - # TODO add filter last calculation date time - # current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') current_time = datetime.now() - current_time = current_time - timedelta(days=60) + delta_time = current_time - timedelta(days=60) + current_time = current_time.strftime('%Y-%m-%d %H:%M:%S') + delta_time = delta_time.strftime('%Y-%m-%d %H:%M:%S') products = self.env['product.template'].search([ ('type', '=', 'product'), ('active', '=', True), - "|" ('last_calculate_rating', '!=', False), - ('last_calculate_rating', '<', current_time), - # ('x_manufacture', '=', 10) - # ('id', '=', 33627) ], limit=5000) for product in products: - print(product.last_calculate_rating) print("Calculate Rating Product ", product) - # print(product.image_128) + rate = 0 + if product.web_price: + rate += 1 + if product.have_promotion_program: + rate += 1 + if product.image_128: + rate += 1 + product.product_rating = rate + product.last_calculate_rating = current_time + + products = self.env['product.template'].search([ + ('type', '=', 'product'), + ('active', '=', True), + ('last_calculate_rating', '<', delta_time), + ], limit=5000) + for product in products: + print("Calculate Rating Product OutOfDate", product) rate = 0 if product.web_price: rate += 1 -- cgit v1.2.3 From 8f1d508cbceecc9ed32ed1d53331fe41289c23ba Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 7 Oct 2022 11:31:40 +0700 Subject: Update product_template.py --- indoteknik_custom/models/product_template.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py index 49f903e4..2293f3b8 100755 --- a/indoteknik_custom/models/product_template.py +++ b/indoteknik_custom/models/product_template.py @@ -24,6 +24,7 @@ class ProductTemplate(models.Model): have_promotion_program = fields.Boolean('Have Promotion Program', compute='_have_promotion_program', help="Punya promotion program gak?") product_rating = fields.Float('Product Rating', help="Digunakan untuk sorting product di website") last_calculate_rating = fields.Datetime("Last Calculate Rating") + web_price_sorting = fields.Float('Web Price Sorting', help='Hanya digunakan untuk sorting di web, harga tidak berlaku') def _compute_web_price(self): for template in self: @@ -46,7 +47,7 @@ class ProductTemplate(models.Model): @api.model def _calculate_rating_product(self): current_time = datetime.now() - delta_time = current_time - timedelta(days=60) + delta_time = current_time - timedelta(days=30) current_time = current_time.strftime('%Y-%m-%d %H:%M:%S') delta_time = delta_time.strftime('%Y-%m-%d %H:%M:%S') @@ -61,6 +62,7 @@ class ProductTemplate(models.Model): rate = 0 if product.web_price: rate += 1 + product.web_price_sorting = product.web_price if product.have_promotion_program: rate += 1 if product.image_128: @@ -78,6 +80,7 @@ class ProductTemplate(models.Model): rate = 0 if product.web_price: rate += 1 + product.web_price_sorting = product.web_price if product.have_promotion_program: rate += 1 if product.image_128: -- cgit v1.2.3 From 6290e0e7a935c5084459843f8ba345ab9528d44c Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 7 Oct 2022 14:10:15 +0700 Subject: add domain in purchase tax menu sale order --- indoteknik_custom/views/sale_order.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index f83b2a6b..47f9b4a4 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -25,7 +25,7 @@ - + -- cgit v1.2.3