diff options
| author | HafidBuroiroh <hafidburoiroh09@gmail.com> | 2026-01-23 13:39:30 +0700 |
|---|---|---|
| committer | HafidBuroiroh <hafidburoiroh09@gmail.com> | 2026-01-23 13:39:30 +0700 |
| commit | abe9e16dff1d7b65530b258a306a6376b71c655b (patch) | |
| tree | 39cc5ecb3451820b4e030189fc55b78dd69f9be1 | |
| parent | 9e64a74e4576a150d172359999c9eb3cef8505a8 (diff) | |
<hafid> cashback brand
| -rw-r--r-- | indoteknik_custom/models/sale_order_line.py | 17 | ||||
| -rwxr-xr-x | indoteknik_custom/models/x_manufactures.py | 2 | ||||
| -rwxr-xr-x | indoteknik_custom/views/sale_order.xml | 1 | ||||
| -rwxr-xr-x | indoteknik_custom/views/x_manufactures.xml | 2 |
4 files changed, 20 insertions, 2 deletions
diff --git a/indoteknik_custom/models/sale_order_line.py b/indoteknik_custom/models/sale_order_line.py index 1df1a058..7b97bd85 100644 --- a/indoteknik_custom/models/sale_order_line.py +++ b/indoteknik_custom/models/sale_order_line.py @@ -17,6 +17,7 @@ class SaleOrderLine(models.Model): help="Total % Margin in Sales Order Header") item_percent_margin_before = fields.Float('%Margin Before', compute='_compute_item_percent_margin_before', help="Total % Margin excluding third party in Sales Order Header") + amount_cashback = fields.Float('Cashback Brand', compute='_compute_cashback_brand', help='Cashback from product who has cashback percent in manufacture') initial_discount = fields.Float('Initial Discount') vendor_id = fields.Many2one( 'res.partner', string='Vendor', readonly=True, @@ -212,6 +213,8 @@ class SaleOrderLine(models.Model): sales_price -= line.delivery_amt_line # if line.order_id.fee_third_party > 0: # sales_price -= line.fee_third_party_line + if line.amount_cashback > 0: + sales_price += line.amount_cashback purchase_price = line.purchase_price if line.purchase_tax_id.price_include: @@ -247,6 +250,20 @@ class SaleOrderLine(models.Model): margin_per_item = sales_price - purchase_price line.item_before_margin = margin_per_item + def _compute_cashback_brand(self): + for line in self: + line.amount_cashback = 0 + + if not line.product_id: + continue + + cashback_percent = line.product_id.x_manufacture.cashback_percent or 0 + if cashback_percent <= 0: + continue + + price, taxes, vendor_id = self._get_purchase_price(line.product_id) + line.amount_cashback = price * cashback_percent + # @api.onchange('vendor_id') # def onchange_vendor_id(self): # # TODO : need to change this logic @stephan diff --git a/indoteknik_custom/models/x_manufactures.py b/indoteknik_custom/models/x_manufactures.py index 9e214d92..0c3bfa3b 100755 --- a/indoteknik_custom/models/x_manufactures.py +++ b/indoteknik_custom/models/x_manufactures.py @@ -50,7 +50,7 @@ class XManufactures(models.Model): # user_id = fields.Many2one('res.users', string='Responsible', domain="['|'('id', '=', 19), ('id', '=', 6)]", help="Siapa yang bertanggung jawab") user_id = fields.Many2one('res.users', string='Responsible', help="Siapa yang bertanggung jawab") override_vendor_id = fields.Many2one('res.partner', string='Override Vendor') - # cashback_percent = fields.Float(string='Cashback Percent') + cashback_percent = fields.Float(string='Cashback Percent', default=0) def _compute_vendor_ids(self): for manufacture in self: diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index 23fbe155..c3df92ec 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -302,6 +302,7 @@ ] } "/> + <field name="amount_cashback"/> <field name="purchase_price_md" optional="hide"/> <field name="purchase_tax_id" attrs="{'readonly': [('parent.approval_status', '!=', False)]}" diff --git a/indoteknik_custom/views/x_manufactures.xml b/indoteknik_custom/views/x_manufactures.xml index d5cec350..b52fe795 100755 --- a/indoteknik_custom/views/x_manufactures.xml +++ b/indoteknik_custom/views/x_manufactures.xml @@ -82,7 +82,7 @@ <field name="x_negara_asal"/> <field name="x_short_desc"/> <field name="x_manufacture_level"/> - <!-- <field name="cashback_percent" widget="percentage"/> --> + <field name="cashback_percent" widget="percentage"/> <field name="x_produk_aksesoris_sparepart"/> <field name="cache_reset_status"/> <field name="parent_id"/> |
