diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2025-01-21 13:53:28 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2025-01-21 13:53:28 +0700 |
| commit | 63433ff471ba98e6fc63bca16abd9a585471498b (patch) | |
| tree | 7fe83758b1c40888bab68f5498e4a1c7da4d7891 /indoteknik_custom/models/purchase_order_line.py | |
| parent | ff20b62d6932c6be4ffb56f63f3c05be3aa72c06 (diff) | |
| parent | e3521c2153c36cee6629cee9146e1b4b0201da9f (diff) | |
Merge branch 'odoo-production' into CR/form-merchant
# Conflicts:
# indoteknik_api/models/res_partner.py
# indoteknik_api/models/res_users.py
# indoteknik_custom/__manifest__.py
# indoteknik_custom/models/__init__.py
# indoteknik_custom/models/res_partner.py
# indoteknik_custom/security/ir.model.access.csv
# indoteknik_custom/views/res_partner.xml
# indoteknik_custom/views/user_company_request.xml
Diffstat (limited to 'indoteknik_custom/models/purchase_order_line.py')
| -rwxr-xr-x | indoteknik_custom/models/purchase_order_line.py | 74 |
1 files changed, 73 insertions, 1 deletions
diff --git a/indoteknik_custom/models/purchase_order_line.py b/indoteknik_custom/models/purchase_order_line.py index 9e7d7e81..587a09a1 100755 --- a/indoteknik_custom/models/purchase_order_line.py +++ b/indoteknik_custom/models/purchase_order_line.py @@ -43,7 +43,79 @@ class PurchaseOrderLine(models.Model): qty_reserved = fields.Float(string='Qty Reserved', compute='_compute_qty_reserved') delete_line = fields.Boolean(string='Delete', default=False, help='centang ini jika anda ingin menghapus line ini') is_edit_product_qty = fields.Boolean(string='Is Edit Product Qty', compute='_compute_is_edit_product_qty') - + delivery_amt = fields.Float(string='Delivery Amt', compute='_compute_doc_delivery_amt') + delivery_amt_per_item = fields.Float(string='Delivery Amt Per Item' , compute='_compute_doc_delivery_amt') + contribution_delivery_amt = fields.Float(string='Contribution Delivery Amt', compute='_compute_doc_delivery_amt') + cost_service = fields.Float(string='Biaya Jasa', compute='_compute_doc_delivery_amt') + cost_service_per_item = fields.Float(string='Biaya Jasa Per Item', compute='_compute_doc_delivery_amt') + contribution_cost_service = fields.Float(string='Contribution Cost Service', compute='_compute_doc_delivery_amt') + ending_price = fields.Float(string='Ending Price', compute='_compute_doc_delivery_amt') + + def _compute_doc_delivery_amt(self): + for line in self: + # Inisialisasi nilai default untuk field computed + line.delivery_amt = 0.0 + line.delivery_amt_per_item = 0.0 + line.contribution_delivery_amt = 0.0 + line.cost_service = 0.0 + line.cost_service_per_item = 0.0 + line.contribution_cost_service = 0.0 + line.ending_price = line.price_unit * line.product_qty + + # Ambil nilai dari order_id + total_delivery_amt = line.order_id.total_delivery_amt + total_cost_service = line.order_id.total_cost_service + + include_price = line.price_unit * line.product_qty + if line.order_id.amount_total > 0: + if total_delivery_amt > 0: + contributions = include_price / line.order_id.amount_total + if line.taxes_id.id == 22: + contributions = line.price_subtotal / line.order_id.amount_untaxed + contribution = contributions * total_delivery_amt + line.delivery_amt = contribution + line.delivery_amt_per_item = contribution / line.product_qty + line.contribution_delivery_amt = contributions + + if total_cost_service > 0: + contributions = include_price / line.order_id.amount_total + if line.taxes_id.id == 22: + contributions = line.price_subtotal / line.order_id.amount_untaxed + contribution = contributions * total_cost_service + line.cost_service = contribution + line.cost_service_per_item = contribution / line.product_qty + line.contribution_cost_service = contributions + + if total_delivery_amt > 0 and total_cost_service > 0: + line.ending_price = (line.price_unit + line.delivery_amt_per_item + line.cost_service_per_item) * line.product_qty + elif total_delivery_amt > 0 and total_cost_service == 0: + line.ending_price = (line.price_unit + line.delivery_amt_per_item) * line.product_qty + elif total_delivery_amt == 0 and total_cost_service > 0: + line.ending_price = (line.price_unit + line.cost_service_per_item) * line.product_qty + + # @api.constrains('delivery_amt') + # def delivery_amt_margin(self): + # for line in self: + # if line.delivery_amt: + # line.delivery_amt_per_item = line.delivery_amt / line.product_qty + # line.ending_price = line.price_unit + line.delivery_amt_per_item + line.cost_service + # elif line.delivery_amt == 0: + # line. delivery_amt_per_item = 0 + # if line.cost_service: + # line.ending_price = line.price_unit + line.cost_service + # else: + # line.ending_price = line.price_unit + + # @api.constrains('cost_service') + # def cost_service_margin(self): + # for line in self: + # if line.cost_service: + # line.ending_price = line.price_unit + line.cost_service + line.delivery_amt_per_item + # elif line.cost_service == 0: + # if line.delivery_amt_per_item: + # line.ending_price = line.price_unit + line.delivery_amt_per_item + # else: + # line.ending_price = line.price_unit def _get_clean_website_description_product(self): for line in self: description = line.product_id.website_description |
