summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2023-10-23 11:23:42 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2023-10-23 11:23:42 +0700
commit3a8d2713d749ce40d3755d4e0b22898ace4b0d6d (patch)
tree91cbe11ba25529f8d6235a3c90f5d125abf34b2f /indoteknik_custom/models
parent7e734333e198e8405ce49ef96f5cb347b0a892d4 (diff)
parent2016ebabb250d1fe521d9b00668b7fa4313dff81 (diff)
Merge branch 'production' of bitbucket.org:altafixco/indoteknik-addons into production
Diffstat (limited to 'indoteknik_custom/models')
-rwxr-xr-xindoteknik_custom/models/purchase_pricelist.py2
-rw-r--r--indoteknik_custom/models/solr/product_product.py10
-rw-r--r--indoteknik_custom/models/solr/product_template.py5
3 files changed, 12 insertions, 5 deletions
diff --git a/indoteknik_custom/models/purchase_pricelist.py b/indoteknik_custom/models/purchase_pricelist.py
index 3607defe..b7c3785a 100755
--- a/indoteknik_custom/models/purchase_pricelist.py
+++ b/indoteknik_custom/models/purchase_pricelist.py
@@ -14,6 +14,8 @@ class PurchasePricelist(models.Model):
system_price = fields.Float(string='System Price', required=True)
human_last_update = fields.Datetime(string='Human Update')
system_last_update = fields.Datetime(string='System Update')
+ count_trx_po = fields.Integer(string='Count Trx Product')
+ count_trx_po_vendor = fields.Integer(string='Count Trx Vendor')
@api.depends('product_id', 'vendor_id')
def _compute_name(self):
diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py
index e1342fc2..85c94741 100644
--- a/indoteknik_custom/models/solr/product_product.py
+++ b/indoteknik_custom/models/solr/product_product.py
@@ -5,6 +5,7 @@ from datetime import datetime
class ProductProduct(models.Model):
_inherit = 'product.product'
+ unpublished = fields.Boolean(string='Unpublished')
last_update_solr = fields.Datetime(string='Last Update Solr')
desc_update_solr = fields.Char(string='Desc Update Solr')
@@ -63,7 +64,7 @@ class ProductProduct(models.Model):
'search_rank_weekly_i': variant.product_tmpl_id.search_rank_weekly,
'attributes': [x.name for x in variant.product_template_attribute_value_ids],
'has_product_info_b': True,
- 'publish_b': variant.active and variant.type == 'product',
+ 'publish_b': not variant.unpublished,
'qty_sold_f': variant.qty_sold
})
@@ -170,8 +171,11 @@ class ProductProduct(models.Model):
return results
- @api.constrains('active')
- def constrains_active(self):
+ @api.constrains('unpublished')
+ def _constrains_unpublished(self):
for rec in self:
+ if rec.product_variant_count == 1:
+ rec.product_tmpl_id.unpublished = rec.unpublished
+
rec.product_tmpl_id._create_solr_queue_sync_product_template()
\ No newline at end of file
diff --git a/indoteknik_custom/models/solr/product_template.py b/indoteknik_custom/models/solr/product_template.py
index aa1708cc..25d7d4b8 100644
--- a/indoteknik_custom/models/solr/product_template.py
+++ b/indoteknik_custom/models/solr/product_template.py
@@ -5,6 +5,7 @@ from datetime import datetime
class ProductTemplate(models.Model):
_inherit = "product.template"
+ unpublished = fields.Boolean(string='Unpublished')
last_update_solr = fields.Datetime(string='Last Update Solr')
desc_update_solr = fields.Char(string='Desc Update Solr')
@@ -23,7 +24,7 @@ class ProductTemplate(models.Model):
'function_name': function_name
})
- @api.constrains('name', 'default_code', 'weight', 'x_manufacture', 'public_categ_ids', 'search_rank', 'search_rank_weekly', 'image_1920', 'active')
+ @api.constrains('name', 'default_code', 'weight', 'x_manufacture', 'public_categ_ids', 'search_rank', 'search_rank_weekly', 'image_1920', 'unpublished')
def _create_solr_queue_sync_product_template(self):
self._create_solr_queue('_sync_product_template_to_solr')
@@ -80,7 +81,7 @@ class ProductTemplate(models.Model):
"category_name": category_name,
"description_t": template.website_description or '',
'has_product_info_b': True,
- 'publish_b': template.active and template.type == 'product',
+ 'publish_b': not template.unpublished,
"qty_sold_f": template.qty_sold
})