summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2023-05-22 14:36:57 +0700
committerstephanchrst <stephanchrst@gmail.com>2023-05-22 14:36:57 +0700
commit752db0759177d9e804e9b57ed87e40676a4bcc5d (patch)
tree9acb5c7f42c0e67f645ac4c5efce14d521f32989 /indoteknik_custom/models
parentd63a3069a30c944b63d784625f046d3e7363eebd (diff)
fix sales order monitoring
Diffstat (limited to 'indoteknik_custom/models')
-rwxr-xr-xindoteknik_custom/models/sale_monitoring_detail.py1
-rwxr-xr-xindoteknik_custom/models/sale_order.py18
2 files changed, 16 insertions, 3 deletions
diff --git a/indoteknik_custom/models/sale_monitoring_detail.py b/indoteknik_custom/models/sale_monitoring_detail.py
index 5fd8e47a..a578f67b 100755
--- a/indoteknik_custom/models/sale_monitoring_detail.py
+++ b/indoteknik_custom/models/sale_monitoring_detail.py
@@ -29,6 +29,7 @@ class SaleMonitoringDetail(models.Model):
SELECT
*,
CASE
+ WHEN qty_so = qty_so_invoiced then 'Done'
WHEN qty_po < qty_so AND qty_po <= 0 THEN 'Belum PO sama sekali'
WHEN qty_po < qty_so THEN 'Belum PO full'
WHEN qty_po_received < qty_so and qty_po_received <= 0 THEN 'Belum Received sama sekali'
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 14c87641..85d7e595 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -421,9 +421,21 @@ class SaleOrderLine(models.Model):
def onchange_vendor_id(self):
if not self.product_id or self.product_id.type == 'service':
return
- purchase_price = self.env['purchase.pricelist'].search(
- [('vendor_id', '=', self.vendor_id.id), ('product_id', '=', self.product_id.id)], limit=1)
- self.purchase_price = purchase_price.product_price
+ elif self.product_id.categ_id.id == 34: # finish good / manufacturing only
+ print('a')
+ bom = self.env['mrp.bom'].search(
+ [('product_tmpl_id', '=', self.product_id.product_tmpl_id.id)]
+ , limit=1)
+ cost = 0
+ for line in bom.bom_line_ids:
+ purchase_price = self.env['purchase.pricelist'].search(
+ [('vendor_id', '=', self.vendor_id.id), ('product_id', '=', line.product_id.id)], limit=1)
+ cost += purchase_price.product_price
+ self.purchase_price = cost
+ else:
+ purchase_price = self.env['purchase.pricelist'].search(
+ [('vendor_id', '=', self.vendor_id.id), ('product_id', '=', self.product_id.id)], limit=1)
+ self.purchase_price = purchase_price.product_price
self.purchase_tax_id = 22
@api.onchange('product_id')