summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/product_template.py
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2023-01-23 09:20:18 +0000
committerIT Fixcomart <it@fixcomart.co.id>2023-01-23 09:20:18 +0000
commitda5f5134f56b2ccf1c1de16c3f7616ab3719f3ea (patch)
treebc1bcb4fb00f2659be81810d528a9cf2cc6ce20d /indoteknik_custom/models/product_template.py
parente52cf84fd2284330412162b44066f29bd382f590 (diff)
parent8af5ee591aabc2d5d946c0eece93a5caab989975 (diff)
Merged in release (pull request #27)
Release
Diffstat (limited to 'indoteknik_custom/models/product_template.py')
-rwxr-xr-xindoteknik_custom/models/product_template.py51
1 files changed, 30 insertions, 21 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index 9f0410f4..74b4edb1 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -46,12 +46,33 @@ class ProductTemplate(models.Model):
material = fields.Char(string='Material')
is_new_product = fields.Boolean(string='Produk Baru',
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')
# def write(self, vals):
# if 'solr_flag' not in vals and self.solr_flag == 1:
# vals['solr_flag'] = 2
# return super().write(vals)
+ def update_new_product(self):
+ current_time = datetime.now()
+ delta_time = current_time - timedelta(days=30)
+
+ delta_time = delta_time.strftime('%Y-%m-%d %H:%M:%S')
+
+ products = self.env['product.template'].search([
+ ('type', '=', 'product'),
+ ('active', '=', True),
+ ('product_rating', '>', 3),
+ ('create_date', '>=', delta_time),
+ ], limit=100)
+
+ seq = 0
+ for product in products:
+ seq += 1
+ product.is_new_product = True
+ product.seq_new_product = seq
+ _logger.info('Updated New Product %s' % product.name)
+
def update_internal_reference(self):
templates_without_variant = self.env['product.template'].search([
('default_code', '=', False),
@@ -92,33 +113,21 @@ class ProductTemplate(models.Model):
for template in self:
product = self.env['product.product'].search([('product_tmpl_id', '=', template.id)], limit=1)
- # product_pricelist_default = self.env['ir.config_parameter'].sudo().get_param('product.pricelist.default')
- # product_pricelist_disc = self.env['product.pricelist.item'].search([
- # ('pricelist_id', '=', product_pricelist_default.int()),
- # ('product_id', '=', product.id)], limit=1)
- # disc = product_pricelist_disc.price_discount
-
product_pricelist_item = self.env['product.pricelist.item'].search([
('pricelist_id', '=', 1),
('product_id', '=', product.id)], limit=1)
price = product_pricelist_item.fixed_price
- #
- # if not disc and not price:
- # template.web_price = 0
- # elif not disc:
template.web_price = price
- # else:
- # price_disc = price - (price * disc / 100)
- # template.web_price = price_disc
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:
+ product = self.env['product.product'].search([('product_tmpl_id', '=', template.id)], limit=1)
+
+ product_pricelist_item = self.env['product.pricelist.item'].search([
+ ('pricelist_id', '=', 4),
+ ('product_id', '=', product.id)], limit=1)
+ discount = product_pricelist_item.price_discount
+ if discount:
template.have_promotion_program = True
else:
template.have_promotion_program = False
@@ -136,7 +145,7 @@ class ProductTemplate(models.Model):
('active', '=', True),
('last_calculate_rating', '=', False),
# ('id', '=', 22798),
- ], limit=10000)
+ ], limit=100)
for product in products:
# print("Calculate Rating Product ", product)
@@ -161,7 +170,7 @@ class ProductTemplate(models.Model):
('type', '=', 'product'),
('active', '=', True),
('last_calculate_rating', '<', delta_time),
- ], limit=10000)
+ ], limit=100)
for product in products:
print("Calculate Rating Product OutOfDate", product)