summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-02-06 16:16:13 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-02-06 16:16:13 +0700
commitf38eba228ef0e95ce3a0d1079f4d81153fc1b2ab (patch)
treef1211d3f66176f7663a6c9dadce529d9bfdd35fb
parent4de40c41c5f1c7d1221cd177667e6935ea993b71 (diff)
fix error taxes
-rw-r--r--indoteknik_custom/models/automatic_purchase.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/indoteknik_custom/models/automatic_purchase.py b/indoteknik_custom/models/automatic_purchase.py
index bf6901d3..ff566aa9 100644
--- a/indoteknik_custom/models/automatic_purchase.py
+++ b/indoteknik_custom/models/automatic_purchase.py
@@ -24,6 +24,7 @@ class AutomaticPurchase(models.Model):
raise UserError('Tidak ada Lines, belum bisa create PO')
if self.is_po:
raise UserError('Sudah pernah di create PO')
+
current_time = datetime.now()
vendor_ids = self.env['automatic.purchase.line'].read_group([('automatic_purchase_id', '=', self.id), ('partner_id', '!=', False)], fields=['partner_id'], groupby=['partner_id'])
@@ -47,6 +48,8 @@ class AutomaticPurchase(models.Model):
], order='brand_id')
count = brand_id = 0
for product in products_vendors:
+ if not product.taxes_id:
+ raise UserError('Tidak ada Taxes')
if count == 200 or brand_id != product.brand_id.id:
count = 0
counter_po_number += 1
@@ -74,6 +77,7 @@ class AutomaticPurchase(models.Model):
'qty_available_store': qty_available,
'suggest': suggest,
'product_uom_qty': product.qty_purchase,
+ 'taxes_id': [product.taxes_id.id],
'price_unit': product.last_price,
}
new_line = self.env['purchase.order.line'].create([param_line])
@@ -145,12 +149,12 @@ class AutomaticPurchase(models.Model):
human_last_update = purchase_price.human_last_update or datetime.min
system_last_update = purchase_price.system_last_update or datetime.min
+ price = purchase_price.product_price
+ taxes = purchase_price.taxes_product_id.id
+
if system_last_update > human_last_update:
price = purchase_price.system_price
taxes = purchase_price.taxes_system_id.id
- else:
- price = purchase_price.product_price
- taxes = purchase_price.taxes_product_id.id
return price, taxes