summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/purchase_order.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-09-27 14:42:59 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-09-27 14:42:59 +0700
commit3a8710d164ced77e532b0b96988d84bb08515602 (patch)
tree976ebb25089d80d938ca5bc9132aacb669e041cf /indoteknik_custom/models/purchase_order.py
parent90ee21e0c1b2179b53d1dbadd6232bf22a3eea5a (diff)
Update purchase_order.py, sale_order.py, and sale_order.xml
Diffstat (limited to 'indoteknik_custom/models/purchase_order.py')
-rwxr-xr-xindoteknik_custom/models/purchase_order.py45
1 files changed, 29 insertions, 16 deletions
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index 406b17fc..cffeff69 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -75,6 +75,10 @@ class PurchaseOrder(models.Model):
res = super(PurchaseOrder, self).button_confirm()
for line in self.order_line:
+ if not line.product_id:
+ continue
+ if line.product_id.type == 'service' and self.env.user.id != 6:
+ raise UserError("Ada tambahan Ongkos kirim, harus Approval Manager")
sale_order_line = self.env['sale.order.line'].search(
[('product_id', '=', line.product_id.id),
('order_id', '=', line.order_id.sale_order_id.id)], limit=1, order='price_reduce_taxexcl')
@@ -89,8 +93,10 @@ class PurchaseOrder(models.Model):
if (sale_order_line.purchase_tax_id.amount != real_tax_amount or count_real_tax > 1 \
or real_tax.price_include != sale_order_line.purchase_tax_id.price_include) and (self.env.user.id != 6):
raise UserError("Beda tax amount dengan Sales, harus Approval Manager")
- elif est_purchase_price != real_purchase_price and self.env.user.id != 6:
+ elif est_purchase_price < real_purchase_price and self.env.user.id != 6:
raise UserError("Beda Price dengan Sales, harus Approval Manager")
+ # elif line.product_id.type == 'service' and self.env.user_id != 6:
+ # raise UserError("Ada tambahan Ongkos kirim, harus Approval Manager")
self.approval_status = 'approved'
return res
@@ -98,22 +104,29 @@ class PurchaseOrder(models.Model):
def po_approve(self):
approval = 0
for line in self.order_line:
- sale_order_line = self.env['sale.order.line'].search(
- [('product_id', '=', line.product_id.id),
- ('order_id', '=', line.order_id.sale_order_id.id)], limit=1, order='price_reduce_taxexcl')
-
- est_purchase_price = sale_order_line.purchase_price
- real_purchase_price = line.price_unit
- real_tax = real_tax_amount = count_real_tax = 0
- for tax in line.taxes_id:
- count_real_tax += 1
- real_tax = tax
- real_tax_amount += tax.amount
- if (sale_order_line.purchase_tax_id.amount != real_tax_amount or count_real_tax > 1 \
- or real_tax.price_include != sale_order_line.purchase_tax_id.price_include) and self.env.user.id != 6:
- approval += 1
- elif est_purchase_price != real_purchase_price and self.env.user.id != 6:
+ if not line.product_id:
+ continue
+ elif line.product_id.type == 'service' and self.env.user.id != 6:
approval += 1
+ else:
+ sale_order_line = self.env['sale.order.line'].search(
+ [('product_id', '=', line.product_id.id),
+ ('order_id', '=', line.order_id.sale_order_id.id)], limit=1, order='price_reduce_taxexcl')
+
+ est_purchase_price = sale_order_line.purchase_price
+ real_purchase_price = line.price_unit
+ real_tax = real_tax_amount = count_real_tax = 0
+ for tax in line.taxes_id:
+ count_real_tax += 1
+ real_tax = tax
+ real_tax_amount += tax.amount
+ if (sale_order_line.purchase_tax_id.amount != real_tax_amount or count_real_tax > 1 \
+ or real_tax.price_include != sale_order_line.purchase_tax_id.price_include) and self.env.user.id != 6:
+ approval += 1
+ elif est_purchase_price != real_purchase_price and self.env.user.id != 6:
+ approval += 1
+ elif line.product_id.type == 'service' and self.env.user.id != 6:
+ approval += 1
if approval > 0:
self.approval_status = "pengajuan1"
else: