summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indoteknik_api/controllers/api_v1/product.py87
-rw-r--r--indoteknik_custom/models/refund_sale_order.py5
-rwxr-xr-xindoteknik_custom/models/sale_order.py29
-rw-r--r--indoteknik_custom/models/solr/apache_solr_queue.py19
-rw-r--r--indoteknik_custom/models/solr/product_product.py4
-rw-r--r--indoteknik_custom/views/apache_solr_queue.xml3
6 files changed, 81 insertions, 66 deletions
diff --git a/indoteknik_api/controllers/api_v1/product.py b/indoteknik_api/controllers/api_v1/product.py
index e97a7ff8..2f546078 100644
--- a/indoteknik_api/controllers/api_v1/product.py
+++ b/indoteknik_api/controllers/api_v1/product.py
@@ -103,17 +103,21 @@ class Product(controller.Controller):
@controller.Controller.must_authorized()
def get_product_template_stock_by_id(self, **kw):
id = int(kw.get('id'))
- date_7_days_ago = datetime.now() - timedelta(days=7)
+ # date_7_days_ago = datetime.now() - timedelta(days=7)
+ product = request.env['product.product'].search([('id', '=', id)], limit=1)
+ if not product:
+ return self.response({'qty': 0, 'sla_date': 'N/A'}, headers=[('Cache-Control', 'max-age=600, private')])
+
product_pruchase = request.env['purchase.pricelist'].search([
('product_id', '=', id),
('is_winner', '=', True)
- ])
- stock_vendor = request.env['stock.vendor'].search([
- ('product_variant_id', '=', id),
- ('write_date', '>=', date_7_days_ago.strftime("%Y-%m-%d %H:%M:%S"))
], limit=1)
+ # stock_vendor = request.env['stock.vendor'].search([
+ # ('product_variant_id', '=', id),
+ # ('write_date', '>=', date_7_days_ago.strftime("%Y-%m-%d %H:%M:%S"))
+ # ], limit=1)
- product = product_pruchase.product_id
+ # product = product_pruchase.product_id
vendor_sla = request.env['vendor.sla'].search([('id_vendor', '=', product_pruchase.vendor_id.id)], limit=1)
slatime = 15
@@ -132,42 +136,45 @@ class Product(controller.Controller):
if qty_available < 1 :
qty_available = 0
- qty = 0
+ # qty = 0
+ qty = qty_available
sla_date = f'{slatime} Hari'
+ if qty_available > 0:
+ sla_date = '1 Hari'
# Qty Stock Vendor
- qty_vendor = stock_vendor.quantity
- qty_vendor -= int(qty_vendor * 0.1)
- qty_vendor = math.ceil(float(qty_vendor))
- total_excell = qty_vendor
-
- is_altama_product = product.x_manufacture.id in [10, 122, 89]
- if is_altama_product:
- try:
- # Qty Altama
- qty_altama = request.env['product.template'].get_stock_altama(
- product.default_code)
- qty_altama -= int(qty_altama * 0.1)
- qty_altama = math.ceil(float(qty_altama))
- total_adem = qty_altama
-
- if qty_available > 0:
- qty = qty_available + total_adem + total_excell
- sla_date = '1 Hari'
- elif qty_altama > 0 or qty_vendor > 0:
- qty = total_adem if qty_altama > 0 else total_excell
- sla_date = f'{slatime} Hari'
- else:
- sla_date = f'{slatime} Hari'
- except:
- print('error')
- else:
- if qty_available > 0:
- qty = qty_available
- sla_date = f'1 Hari'
- elif qty_vendor > 0:
- qty = total_excell
- sla_date = f'{slatime} Hari'
+ # qty_vendor = stock_vendor.quantity
+ # qty_vendor -= int(qty_vendor * 0.1)
+ # qty_vendor = math.ceil(float(qty_vendor))
+ # total_excell = qty_vendor
+
+ # is_altama_product = product.x_manufacture.id in [10, 122, 89]
+ # if is_altama_product:
+ # try:
+ # # Qty Altama
+ # qty_altama = request.env['product.template'].get_stock_altama(
+ # product.default_code)
+ # qty_altama -= int(qty_altama * 0.1)
+ # qty_altama = math.ceil(float(qty_altama))
+ # total_adem = qty_altama
+
+ # if qty_available > 0:
+ # qty = qty_available + total_adem + total_excell
+ # sla_date = '1 Hari'
+ # elif qty_altama > 0 or qty_vendor > 0:
+ # qty = total_adem if qty_altama > 0 else total_excell
+ # sla_date = f'{slatime} Hari'
+ # else:
+ # sla_date = f'{slatime} Hari'
+ # except:
+ # print('error')
+ # else:
+ # if qty_available > 0:
+ # qty = qty_available
+ # sla_date = f'1 Hari'
+ # elif qty_vendor > 0:
+ # qty = total_excell
+ # sla_date = f'{slatime} Hari'
data = {
'qty': qty,
@@ -245,6 +252,8 @@ class Product(controller.Controller):
[('id', '=', id)], limit=1)
qty_available = product.qty_free_bandengan
+ if qty_available < 1:
+ qty_available = 0
data = {
'qty': qty_available,
diff --git a/indoteknik_custom/models/refund_sale_order.py b/indoteknik_custom/models/refund_sale_order.py
index 47565dfc..e6547a88 100644
--- a/indoteknik_custom/models/refund_sale_order.py
+++ b/indoteknik_custom/models/refund_sale_order.py
@@ -753,10 +753,11 @@ class RefundSaleOrder(models.Model):
line_vals = []
for so in self.sale_order_ids:
for line in so.order_line:
- if line.qty_delivered == 0:
+ barang_kurang = line.product_uom_qty - line.qty_delivered
+ if line.qty_delivered == 0 or barang_kurang > 0:
line_vals.append((0, 0, {
'product_id': line.product_id.id,
- 'quantity': line.product_uom_qty,
+ 'quantity': barang_kurang,
'from_name': so.name,
'prod_id': so.id,
'reason': '',
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index a5e2f7c4..5c8f34c6 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -399,20 +399,21 @@ class SaleOrder(models.Model):
)
def action_open_partial_delivery_wizard(self):
- self.ensure_one()
- pickings = self.picking_ids.filtered(lambda p: p.state not in ['done', 'cancel'] and p.name and 'BU/PICK/' in p.name)
- return {
- 'type': 'ir.actions.act_window',
- 'name': 'Partial Delivery',
- 'res_model': 'partial.delivery.wizard',
- 'view_mode': 'form',
- 'target': 'new',
- 'context': {
- 'default_sale_id': self.id,
- # kasih langsung list of int biar ga ribet di wizard
- 'default_picking_ids': pickings.ids,
- }
- }
+ raise UserError("Fitur ini sedang dalam pengembangan")
+ # self.ensure_one()
+ # pickings = self.picking_ids.filtered(lambda p: p.state not in ['done', 'cancel'] and p.name and 'BU/PICK/' in p.name)
+ # return {
+ # 'type': 'ir.actions.act_window',
+ # 'name': 'Partial Delivery',
+ # 'res_model': 'partial.delivery.wizard',
+ # 'view_mode': 'form',
+ # 'target': 'new',
+ # 'context': {
+ # 'default_sale_id': self.id,
+ # # kasih langsung list of int biar ga ribet di wizard
+ # 'default_picking_ids': pickings.ids,
+ # }
+ # }
@api.depends('partner_id.is_cbd_locked')
diff --git a/indoteknik_custom/models/solr/apache_solr_queue.py b/indoteknik_custom/models/solr/apache_solr_queue.py
index 1b51538f..3d6bd733 100644
--- a/indoteknik_custom/models/solr/apache_solr_queue.py
+++ b/indoteknik_custom/models/solr/apache_solr_queue.py
@@ -1,10 +1,10 @@
from odoo import models, fields
from datetime import datetime, timedelta
-import logging, time
-
+import logging, time, traceback # <-- tambah traceback
_logger = logging.getLogger(__name__)
+
class ApacheSolrQueue(models.Model):
_name = 'apache.solr.queue'
@@ -19,6 +19,7 @@ class ApacheSolrQueue(models.Model):
], 'Execute Status')
execute_date = fields.Datetime('Execute Date')
description = fields.Text('Description')
+ log = fields.Text('Log')
def _compute_display_name(self):
for rec in self:
@@ -39,7 +40,7 @@ class ApacheSolrQueue(models.Model):
if elapsed_time > max_exec_time:
break
rec.execute_queue()
-
+
def open_target_record(self):
return {
'name': '',
@@ -67,17 +68,21 @@ class ApacheSolrQueue(models.Model):
if model_instance:
getattr(model_instance, function_name)()
rec.execute_status = 'success'
+ rec.log = traceback.format_exc()
else:
rec.execute_status = 'not_found'
except Exception as e:
- rec.description = e
+ # simpan error ringkas + traceback lengkap
+ rec.description = str(e)
+ rec.log = traceback.format_exc()
rec.execute_status = 'failed'
+
rec.execute_date = datetime.utcnow()
self.env.cr.commit()
def create_unique(self, payload={}):
count = self.search_count([
- ('res_model', '=', payload['res_model']),
+ ('res_model', '=', payload['res_model']),
('res_id', '=', payload['res_id']),
('function_name', '=', payload['function_name']),
('execute_status', '=', False)
@@ -90,8 +95,6 @@ class ApacheSolrQueue(models.Model):
('execute_status', '=', 'success'),
('execute_date', '>=', (datetime.utcnow() - timedelta(days=days_after))),
], limit=limit)
-
+
for rec in solr:
rec.unlink()
-
-
diff --git a/indoteknik_custom/models/solr/product_product.py b/indoteknik_custom/models/solr/product_product.py
index d8bc3973..7260c3ca 100644
--- a/indoteknik_custom/models/solr/product_product.py
+++ b/indoteknik_custom/models/solr/product_product.py
@@ -69,9 +69,9 @@ class ProductProduct(models.Model):
'product_id_i': variant.id,
'template_id_i': variant.product_tmpl_id.id,
'image_s': ir_attachment.api_image('product.template', 'image_512', variant.product_tmpl_id.id),
- 'image_carousel_s': [ir_attachment.api_image('image.carousel', 'image', carousel.id) for carousel in variant.product_tmpl_id.image_carousel_lines],
+ 'image_carousel_ss': [ir_attachment.api_image('image.carousel', 'image', carousel.id) for carousel in variant.product_tmpl_id.image_carousel_lines],
'image_mobile_s': ir_attachment.api_image('product.template', 'image_256', variant.product_tmpl_id.id),
- 'stock_total_f': variant.qty_stock_vendor,
+ 'stock_total_f': variant.qty_free_bandengan,
'weight_f': variant.weight,
'manufacture_id_i': variant.product_tmpl_id.x_manufacture.id or 0,
'manufacture_name_s': variant.product_tmpl_id.x_manufacture.x_name or '',
diff --git a/indoteknik_custom/views/apache_solr_queue.xml b/indoteknik_custom/views/apache_solr_queue.xml
index 4c145b9f..a87d49f6 100644
--- a/indoteknik_custom/views/apache_solr_queue.xml
+++ b/indoteknik_custom/views/apache_solr_queue.xml
@@ -9,7 +9,7 @@
<field name="display_name" readonly="1" />
<field name="res_model" readonly="1" />
<field name="res_id" readonly="1" />
- <field name="function_name" readonly="1" />
+ <field name="function_name" readonly="1" optional="hide"/>
<field
name="execute_status"
widget="badge"
@@ -18,6 +18,7 @@
decoration-success="execute_status == 'success'"
decoration-primary="execute_status == 'not_found'"
/>
+ <field name = "log" readonly="1"/>
<field name="execute_date" readonly="1" />
<field name="create_date" readonly="1" />
</tree>