summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-09-11 13:39:13 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-09-11 13:39:13 +0700
commit1371df38b6818960e6e9520ae783f041694209d8 (patch)
tree01ac51459bf52bbbfd4b3f8605c904f4e3917031
parentb61d191e9d5663acb81338de133789fd0c43bdf0 (diff)
ongkos kirim po
-rwxr-xr-xindoteknik_custom/models/purchase_order.py13
-rwxr-xr-xindoteknik_custom/views/purchase_order.xml6
2 files changed, 18 insertions, 1 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index 83e401b7..edcbbb19 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -31,6 +31,7 @@ class PurchaseOrder(models.Model):
('approved', 'Approved'),
], string='Approval Status', readonly=True, copy=False, index=True, tracking=3)
delivery_amount = fields.Float('Delivery Amount', compute='compute_delivery_amount')
+ delivery_amt = fields.Float('Delivery Amt')
total_margin = fields.Float(
'Margin', compute='compute_total_margin',
help="Total Margin in Sales Order Header")
@@ -67,6 +68,14 @@ class PurchaseOrder(models.Model):
], string='Printed?', copy=False, tracking=True)
date_done_picking = fields.Datetime(string='Date Done Picking', compute='get_date_done')
bills_dp_id = fields.Many2one('account.move', string='Bills DP')
+ grand_total = fields.Monetary(string='Grand Total', help='Amount total + amount delivery', compute='_compute_grand_total')
+
+ def _compute_grand_total(self):
+ for order in self:
+ if order.delivery_amt:
+ order.grand_total = order.delivery_amt + order.amount_total
+ else:
+ order.grand_total = order.amount_total
def create_bill_dp(self):
if not self.env.user.is_accounting:
@@ -671,6 +680,8 @@ class PurchaseOrder(models.Model):
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:
+ purchase_price += line.order_id.delivery_amt
real_item_margin = sales_price - purchase_price
sum_margin += real_item_margin
@@ -713,6 +724,8 @@ class PurchaseOrder(models.Model):
purchase_price = po_line.price_subtotal / 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
diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml
index 9ded8308..6bc97bbf 100755
--- a/indoteknik_custom/views/purchase_order.xml
+++ b/indoteknik_custom/views/purchase_order.xml
@@ -37,7 +37,10 @@
<field name="amount_total_without_service"/>
</field>
<field name="approval_status" position="after">
- <field name="revisi_po" attrs="{'readonly': [('state', 'not in', ['draft'])]}"/>
+ <field name="revisi_po" invisible="1"/>
+ </field>
+ <field name="incoterm_id" position="after">
+ <field name="delivery_amt"/>
</field>
<field name="currency_id" position="after">
<field name="summary_qty_po"/>
@@ -45,6 +48,7 @@
<field name="payment_term_id" readonly="1"/>
</field>
<field name="amount_total" position="after">
+ <field name="grand_total"/>
<field name="total_margin"/>
<field name="total_so_margin"/>
<field name="total_percent_margin"/>