summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2023-06-27 16:44:25 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2023-06-27 16:44:25 +0700
commit0c3abd74ac9aa0b3f1b6fe4e2435698922387b0b (patch)
tree31e84b3bf0ebb14a00390a2e3b85946664516dfb
parent45dc1483342d9ec195c53711b5194e7ddf88b343 (diff)
add new field subtotal_vendot to so line
-rwxr-xr-xindoteknik_custom/models/sale_order.py19
-rwxr-xr-xindoteknik_custom/views/sale_order.xml1
2 files changed, 19 insertions, 1 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 0a794f6d..d980e1fe 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -462,7 +462,7 @@ class SaleOrderLine(models.Model):
'res.partner', string='Vendor', readonly=True,
states={'draft': [('readonly', False)], 'sent': [('readonly', False)]},
change_default=True, index=True, tracking=1,
- domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", )
+ domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]",)
purchase_price = fields.Float('Purchase', required=True, digits='Product Price', default=0.0)
purchase_tax_id = fields.Many2one('account.tax', string='Tax',
domain=['|', ('active', '=', False), ('active', '=', True)])
@@ -470,6 +470,23 @@ class SaleOrderLine(models.Model):
fee_third_party_line = fields.Float('FeeThirdPartyLine', compute='compute_fee_third_party_line', default=0)
line_no = fields.Integer('No', default=0, copy=False)
note_procurement = fields.Char(string='Note', help="Harap diisi jika ada keterangan tambahan dari Procurement, agar dapat dimonitoring")
+ vendor_subtotal = fields.Float(
+ string='Vendor Subtotal', compute="compute_vendor_subtotal")
+
+ def compute_vendor_subtotal(self):
+ # self.vendor_subtotal = 1
+ for line in self:
+ if line.vendor_id:
+ product = line.product_id
+
+ if product:
+ vendor_price = line.purchase_price
+ if line.purchase_tax_id.price_include:
+ vendor_price = line.purchase_price
+ else:
+ vendor_price = line.purchase_price + (line.purchase_price*11/100)
+
+ line.vendor_subtotal = vendor_price * line.product_uom_qty
def compute_item_margin(self):
for line in self:
diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml
index 85f687c1..ef72c10f 100755
--- a/indoteknik_custom/views/sale_order.xml
+++ b/indoteknik_custom/views/sale_order.xml
@@ -63,6 +63,7 @@
<field name="purchase_tax_id" attrs="{'readonly': [('parent.approval_status', '!=', False)]}" domain="[('type_tax_use','=','purchase')]"/>
<field name="item_percent_margin"/>
<field name="note_procurement" optional="hide"/>
+ <field name="vendor_subtotal" optional="hide"/>
</xpath>
<xpath expr="//form/sheet/notebook/page/field[@name='order_line']/tree/field[@name='product_id']" position="before">
<field name="line_no" readonly="1" optional="hide"/>