summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-01-15 13:15:17 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-01-15 13:15:17 +0700
commit6da1814f7baaa1973bdde9932d629d33ed436e93 (patch)
treeec661abcd3eebed60834c7cad7836208d59cb7e8 /indoteknik_custom/models
parenta5522dfd19488f2b76ad40d3ba9750852f92da73 (diff)
delivery amt po
Diffstat (limited to 'indoteknik_custom/models')
-rwxr-xr-xindoteknik_custom/models/purchase_order.py65
1 files changed, 44 insertions, 21 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index f497dc9b..57e848bc 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -81,29 +81,38 @@ class PurchaseOrder(models.Model):
help='Centang jika tidak mau masuk perhitungan Incoming Qty')
not_update_purchasepricelist = fields.Boolean(string='Not Update Purchase Pricelist?')
reason_unlock = fields.Char(string='Alasan unlock', tracking=3)
- # total_cost_service = fields.Float(string='Total Cost Service')
+ # total_cost_service = fields.Float(string='Total Cost Service' )
# total_delivery_amt = fields.Float(string='Total Delivery Amt')
+ total_cost_service = fields.Float(string='Total Cost Service')
+ total_delivery_amt = fields.Float(string='Total Delivery Amt')
- # @api.onchange('total_cost_service')
- # def _onchange_total_cost_service(self):
- # for order in self:
- # lines = order.order_line
- # if lines:
- # # Hitung nilai rata-rata cost_service
- # per_line_cost_service = order.total_cost_service / len(lines)
- # for line in lines:
- # line.cost_service = per_line_cost_service
-
- # @api.onchange('total_delivery_amt')
- # def _onchange_total_delivery_amt(self):
- # for order in self:
- # lines = order.order_line
- # if lines:
- # # Hitung nilai rata-rata delivery_amt
- # per_line_delivery_amt = order.total_delivery_amt / len(lines)
- # for line in lines:
- # line.delivery_amt = per_line_delivery_amt
+ @api.onchange('total_cost_service')
+ def _onchange_total_cost_service(self):
+ for order in self:
+ lines = order.order_line
+ if order.total_cost_service > 0:
+ if lines:
+ # Hitung nilai rata-rata cost_service
+ per_line_cost_service = order.total_cost_service / len(lines)
+ for line in lines:
+ line.cost_service = per_line_cost_service
+ else:
+ for line in lines:
+ line.cost_service = 0
+ @api.onchange('total_delivery_amt')
+ def _onchange_total_delivery_amt(self):
+ for order in self:
+ lines = order.order_line
+ if order.total_delivery_amt > 0:
+ if lines:
+ # Hitung nilai rata-rata delivery_amt
+ per_line_delivery_amt = order.total_delivery_amt / len(lines)
+ for line in lines:
+ line.delivery_amt = per_line_delivery_amt
+ else:
+ for line in lines:
+ line.delivery_amt = 0
def _compute_total_margin_match(self):
for purchase in self:
match = self.env['purchase.order.sales.match']
@@ -244,6 +253,7 @@ class PurchaseOrder(models.Model):
move_line.name = '[IT.121456] Down Payment'
move_line.partner_id = self.partner_id.id
+ # Tambahkan lognote
lognote_message = (
f"Vendor bill created from: {self.name} ({self.partner_ref})"
)
@@ -258,6 +268,7 @@ class PurchaseOrder(models.Model):
'domain': [('id', '=', bills.id)]
}
+
def get_date_done(self):
picking = self.env['stock.picking'].search([
('purchase_id', '=', self.id),
@@ -903,6 +914,13 @@ class PurchaseOrder(models.Model):
sales_price -= sale_order_line.fee_third_party_line
sum_sales_price += sales_price
purchase_price = line.price_subtotal
+ if line.ending_price > 0:
+ if line.taxes_id.id == 22:
+ ending_price = line.ending_price / 1.11
+ purchase_price = ending_price
+ else:
+ purchase_price = line.ending_price
+ # purchase_price = line.price_subtotal
if line.order_id.delivery_amount > 0:
purchase_price += line.delivery_amt_line
if line.order_id.delivery_amt > 0:
@@ -946,13 +964,18 @@ class PurchaseOrder(models.Model):
sales_price -= (sale_order_line.fee_third_party_line / sale_order_line.product_uom_qty) * line.qty_po
sum_sales_price += sales_price
- purchase_price = po_line.price_subtotal / po_line.product_qty * line.qty_po
+ if po_line.ending_price > 0:
+ price = po_line.ending_price
+ else:
+ price = po_line.price_subtotal
+ purchase_price = price / po_line.product_qty * line.qty_po
if line.purchase_order_id.delivery_amount > 0:
purchase_price += (po_line.delivery_amt_line / po_line.product_qty) * line.qty_po
if line.purchase_order_id.delivery_amt > 0:
purchase_price += line.purchase_order_id.delivery_amt
real_item_margin = sales_price - purchase_price
sum_margin += real_item_margin
+
if sum_so_margin != 0 and sum_sales_price != 0 and sum_margin != 0:
self.total_so_margin = sum_so_margin