summaryrefslogtreecommitdiff
path: root/indoteknik_custom
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2023-07-27 04:18:27 +0000
committerIT Fixcomart <it@fixcomart.co.id>2023-07-27 04:18:27 +0000
commite64105b97b5da3218e3dfbe5db4456b31f08ca73 (patch)
tree332eadffa49d97696aa53dc9c10bfd1cc0537e74 /indoteknik_custom
parent591617f043789ef66a76b7e97e6886b3412369e4 (diff)
parent421ff67560201e8155d03cbe4ff7029cd6b667a4 (diff)
Merged in production (pull request #74)
Production
Diffstat (limited to 'indoteknik_custom')
-rwxr-xr-xindoteknik_custom/models/product_template.py35
-rwxr-xr-xindoteknik_custom/models/sale_order.py3
-rwxr-xr-xindoteknik_custom/models/user_activity_log.py39
-rw-r--r--indoteknik_custom/views/account_move.xml11
-rwxr-xr-xindoteknik_custom/views/sale_order.xml6
5 files changed, 58 insertions, 36 deletions
diff --git a/indoteknik_custom/models/product_template.py b/indoteknik_custom/models/product_template.py
index 7abdf1c1..933c4676 100755
--- a/indoteknik_custom/models/product_template.py
+++ b/indoteknik_custom/models/product_template.py
@@ -156,32 +156,35 @@ class ProductTemplate(models.Model):
template.have_promotion_program = False
@api.model
- def _calculate_rating_product(self):
- #["&","&",["type","=","product"],["active","=",True],"|",["last_calculate_rating","=",False],["last_calculate_rating","<","2023-01-01 00:00:00"]]
+ def _calculate_rating_product(self, limit=1000, expiry_days=30, ids=False):
current_time = datetime.now()
- delta_time = current_time - timedelta(days=30)
+ current_time_str = current_time.strftime('%Y-%m-%d %H:%M:%S')
- current_time = current_time.strftime('%Y-%m-%d %H:%M:%S')
- delta_time = delta_time.strftime('%Y-%m-%d %H:%M:%S')
+ delta_time = current_time - timedelta(days=expiry_days)
+ delta_time_str = delta_time.strftime('%Y-%m-%d %H:%M:%S')
- products = self.env['product.template'].search([
+ query = [
'&','&',
('type', '=', 'product'),
- ('active', '=', True),
- '|',
- ('last_calculate_rating', '=', False),
- ('last_calculate_rating', '<', delta_time),
- # ('id', '=', 22798),
- ], limit=500)
+ ('active', '=', True)
+ ]
+ if not ids:
+ query += [
+ '|',
+ ('last_calculate_rating', '=', False),
+ ('last_calculate_rating', '<', delta_time_str)
+ ]
+ else:
+ query += [('id', 'in', ids)]
+
+ products = self.env['product.template'].search(query, limit=limit)
for product in products:
- # print("Calculate Rating Product ", product)
_logger.info("Calculate Rating Product %s" % product.id)
- # product_variant = self.env['product.product'].search([('product_tmpl_id', '=', product.id)], limit=1)
rate = 0
if product.web_price:
rate += 1
- if product.have_promotion_program: #have discount from pricelist
+ if product.have_promotion_program:
rate += 1
if product.image_128:
rate += 5
@@ -190,7 +193,7 @@ class ProductTemplate(models.Model):
if product.product_variant_id.qty_stock_vendor > 0:
rate += 1
product.product_rating = rate
- product.last_calculate_rating = current_time
+ product.last_calculate_rating = current_time_str
def _get_stock_website(self):
qty = self._get_stock_altama()
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 552f1b0a..12043996 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -327,7 +327,6 @@ class SaleOrder(models.Model):
order.is_warning = False
def sale_order_approve(self):
- # raise UserError("Bisa langsung Confirm")
self.check_due()
for order in self:
@@ -357,6 +356,8 @@ class SaleOrder(models.Model):
if not order.carrier_id:
raise UserError("Shipping Method harus diisi")
for line in order.order_line:
+ if line.product_id.id == 385544:
+ raise UserError('Produk Sementara Tidak Bisa Di Confirm atau Ask Approval')
if not line.product_id or line.product_id.type == 'service':
continue
# must add product can sell validation
diff --git a/indoteknik_custom/models/user_activity_log.py b/indoteknik_custom/models/user_activity_log.py
index ef801ca5..9630e3ab 100755
--- a/indoteknik_custom/models/user_activity_log.py
+++ b/indoteknik_custom/models/user_activity_log.py
@@ -130,15 +130,15 @@ class UserActivityLog(models.Model):
current_time = datetime.now()
delta_time = current_time - timedelta(days=7)
- # current_time = current_time.strftime('%Y-%m-%d %H:%M:%S')
delta_time = delta_time.strftime('%Y-%m-%d %H:%M:%S')
activity_logs = self.env['user.activity.log'].search([
- ('url', 'ilike', 'https://indoteknik.co%/shop/product/%'),
+ ('url', 'ilike', 'https://indoteknik.com%/shop/product/%'),
('create_date', '>', delta_time),
('url', 'not ilike', 'shopping'),
- ], limit=1000)
- for activity_log in activity_logs:
+ ], limit=2000, order='create_date DESC')
+
+ for activity_log in activity_logs:
_logger.info(activity_log.url)
strip_index = i = 0
for c in activity_log.url:
@@ -152,34 +152,37 @@ class UserActivityLog(models.Model):
if any(ch.isalpha() for ch in product_id):
continue
template = self.env['product.template'].search([
- ('id', '=', product_id)
+ ('id', '=', int(product_id))
], limit=1)
- template.search_rank_weekly = int(template.search_rank_weekly) + int(1)
- template.solr_flag = 2
+ if template:
+ template.search_rank_weekly += 1
+ template.solr_flag = 2
def update_rank_search(self):
activity_logs = self.env['user.activity.log'].search([
- ('url', 'ilike', '%/shop/product/%'),
- ('update_product', '=', False),
- # ('url', 'not ilike', '%/shop/product/%google-ads-shopping'),
- # ('id', '=', 211957)
- ], limit=1000)
+ ('url', 'ilike', '%/shop/product/%'),
+ ('update_product', '!=', True),
+ ], limit=1000, order='create_date DESC')
- for activity_log in activity_logs:
+ for activity_log in activity_logs:
_logger.info(activity_log.url)
strip_index = i = 0
for c in activity_log.url:
if c == '-':
strip_index = i
i += 1
- _logger.info(activity_log.url[strip_index+1:len(activity_log.url)])
- product_id = activity_log.url[strip_index+1:len(activity_log.url)]
+ _logger.info(activity_log.url[strip_index + 1:len(activity_log.url)])
+ product_id = activity_log.url[strip_index + 1:len(activity_log.url)]
if '#' in product_id:
continue
if any(ch.isalpha() for ch in product_id):
continue
template = self.env['product.template'].search([
- ('id', '=', product_id)
+ ('id', '=', int(product_id))
], limit=1)
- template.search_rank = int(template.search_rank) + int(1)
- activity_log.update_product = True
+ if template:
+ template.search_rank += 1
+ activity_log.update_product = True
+
+
+
diff --git a/indoteknik_custom/views/account_move.xml b/indoteknik_custom/views/account_move.xml
index 26168561..11558bf4 100644
--- a/indoteknik_custom/views/account_move.xml
+++ b/indoteknik_custom/views/account_move.xml
@@ -59,6 +59,17 @@
</field>
</record>
+ <record id="account_move_in_invoice_tree_inherit" model="ir.ui.view">
+ <field name="name">Account Move</field>
+ <field name="model">account.move</field>
+ <field name="inherit_id" ref="account.view_in_invoice_tree"/>
+ <field name="arch" type="xml">
+ <field name="payment_state" position="after">
+ <field name="payment_schedule" optional="hide"/>
+ </field>
+ </field>
+ </record>
+
<record id="account_move_inherit_purchase_inherit" model="ir.ui.view">
<field name="name">Account Move</field>
<field name="model">account.move</field>
diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml
index 4570f43b..ae16f649 100755
--- a/indoteknik_custom/views/sale_order.xml
+++ b/indoteknik_custom/views/sale_order.xml
@@ -41,7 +41,7 @@
<field name="carrier_id" required="1"/>
<field name="delivery_service_type" readonly="1"/>
</field>
- <field name="source_id" position="after">
+ <field name="medium_id" position="after">
<field name="date_doc_kirim" readonly="1"/>
<field name="notification" readonly="1"/>
</field>
@@ -56,6 +56,10 @@
}
</attribute>
</xpath>
+ <field name="source_id" position="attributes">
+ <attribute name="domain">[('id', 'in', [32, 59, 60, 61])]</attribute>
+ <attribute name="required">1</attribute>
+ </field>
<xpath expr="//form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='price_total']" position="after">
<field name="vendor_id" attrs="{'readonly': [('parent.approval_status', '=', 'approved')]}"/>
<field name="purchase_price" attrs="