summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2023-08-14 09:41:18 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2023-08-14 09:41:18 +0700
commitb603e5eca682c7d42d259d3432316ed28b41737f (patch)
tree7764521755db971132584da63155d84130529f70 /indoteknik_custom/models
parented310664434620cbcdb536fad3762199d154af9b (diff)
product pricelist solr
Diffstat (limited to 'indoteknik_custom/models')
-rw-r--r--indoteknik_custom/models/product_pricelist.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/indoteknik_custom/models/product_pricelist.py b/indoteknik_custom/models/product_pricelist.py
index 95e63cf0..2053accc 100644
--- a/indoteknik_custom/models/product_pricelist.py
+++ b/indoteknik_custom/models/product_pricelist.py
@@ -24,16 +24,22 @@ class ProductPricelist(models.Model):
remaining_time = (self.end_date - datetime.now()).total_seconds()
remaining_time = round(remaining_time)
return max(remaining_time, 0)
-
+
+ def update_product_solr_flag(self):
+ for item in self.item_ids:
+ item.product_id.product_tmpl_id.solr_flag = 2
+ return {
+ 'type': 'ir.actions.client',
+ 'tag': 'display_notification',
+ 'params': { 'title': 'Notification', 'message': f'{len(self.item_ids)} produk akan diupdate ke SOLR' }
+ }
class ProductPricelistItem(models.Model):
_inherit = 'product.pricelist.item'
manufacture_id = fields.Many2one('x_manufactures', string='Manufacture')
- @api.onchange('fixed_price','price_discount')
- def update_solr_flag(self):
+ @api.constrains('fixed_price','price_discount')
+ def update_product_solr_flag(self):
for item in self:
- if item.product_id.product_tmpl_id.solr_flag == 1:
- item.product_id.product_tmpl_id.solr_flag = 2
- \ No newline at end of file
+ item.product_id.product_tmpl_id.solr_flag = 2 \ No newline at end of file