summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2023-09-25 15:17:15 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2023-09-25 15:17:15 +0700
commite7ff231d611df44b71cbd497424b6077b1c88a87 (patch)
treeb0577072e8f74570b7acc64159f5c50cc903e993
parent447b8587ff5203e7ee0b27967bf27d2e4bf9ab48 (diff)
fix miss compute margin po
-rwxr-xr-xindoteknik_custom/models/purchase_order.py5
-rwxr-xr-xindoteknik_custom/models/purchase_order_line.py1
-rwxr-xr-xindoteknik_custom/views/purchase_order.xml3
3 files changed, 6 insertions, 3 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index 3fb61955..daf8d269 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -195,6 +195,7 @@ class PurchaseOrder(models.Model):
'product_qty': order_line.product_qty,
'qty_available_store': qty_available,
'suggest': suggest,
+ 'so_line_id': order_line.id,
}
self.order_line.create(values)
@@ -258,8 +259,6 @@ class PurchaseOrder(models.Model):
self.env['po.sync.price'].create([{
'order_line_id': line.id,
}])
-
-
def _send_mail(self):
output = io.BytesIO()
@@ -341,7 +340,7 @@ class PurchaseOrder(models.Model):
sum_so_margin = sum_sales_price = sum_margin = 0
for line in self.order_line:
sale_order_line = self.env['sale.order.line'].search(
- [('product_id', '=', line.product_id.id),
+ [('id', '=', line.so_line_id.id),
('order_id', '=', line.order_id.sale_order_id.id)], limit=1, order='price_reduce_taxexcl')
sum_so_margin += sale_order_line.item_margin
sales_price = sale_order_line.price_reduce_taxexcl * sale_order_line.product_uom_qty
diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py
index 39aeba0f..95e85122 100755
--- a/indoteknik_custom/models/purchase_order_line.py
+++ b/indoteknik_custom/models/purchase_order_line.py
@@ -29,6 +29,7 @@ class PurchaseOrderLine(models.Model):
qty_available_store = fields.Float(string='Available')
suggest = fields.Char(string='Suggest')
price_vendor = fields.Float(string='Price Vendor', compute='compute_price_vendor')
+ so_line_id = fields.Many2one('sale.order.line', string='ID SO Line')
def compute_price_vendor(self):
for line in self:
diff --git a/indoteknik_custom/views/purchase_order.xml b/indoteknik_custom/views/purchase_order.xml
index 85e08f79..ac423bc5 100755
--- a/indoteknik_custom/views/purchase_order.xml
+++ b/indoteknik_custom/views/purchase_order.xml
@@ -63,6 +63,9 @@
<field name="price_unit" position="after">
<field name="price_vendor" attrs="{'readonly': 1}" optional="hide"/>
</field>
+ <field name="price_subtotal" position="after">
+ <field name="so_line_id" attrs="{'readonly': 1}" optional="hide"/>
+ </field>
<page name="purchase_delivery_invoice" position="after">
<page name="purchase_vendor_bills" string="Vendor Bills" groups="indoteknik_custom.technical_administrator">
<group>