mirror of
https://gitlab.com/flectra-hq/flectra.git
synced 2025-02-25 18:55:21 -06:00
[MOD]Account Discount Function for Sale Order
This commit is contained in:
committed by
Parthiv Patel
parent
4e4593b880
commit
caa805b6aa
@@ -1,3 +1,3 @@
|
||||
from . import res_company
|
||||
from . import res_config_settings
|
||||
from . import account_move
|
||||
# from . import res_company
|
||||
# from . import res_config_settings
|
||||
|
||||
@@ -32,26 +32,6 @@ class AccountMove(models.Model):
|
||||
compute_sudo=True,
|
||||
)
|
||||
|
||||
amount_gross = fields.Monetary(
|
||||
string='Gross Amount',
|
||||
store=True,
|
||||
readonly=True,
|
||||
compute='_compute_amount',
|
||||
)
|
||||
|
||||
document_discount = fields.Monetary(
|
||||
string='Document Discount',
|
||||
store=True,
|
||||
readonly=True,
|
||||
compute='_compute_document_discount',
|
||||
)
|
||||
|
||||
document_discount_tax_amount = fields.Monetary(
|
||||
string='Document Discount Tax',
|
||||
store=True,
|
||||
readonly=True,
|
||||
compute='_compute_document_discount',
|
||||
)
|
||||
|
||||
has_document_discount = fields.Boolean(
|
||||
string='Has Document Discount',
|
||||
@@ -124,12 +104,6 @@ class AccountMove(models.Model):
|
||||
'discount': discount_ratio
|
||||
})
|
||||
move._move_autocomplete_invoice_lines_values()
|
||||
else:
|
||||
for line in move.invoice_line_ids:
|
||||
line.update({
|
||||
'discount': 0.0
|
||||
})
|
||||
move._move_autocomplete_invoice_lines_values()
|
||||
|
||||
@api.depends(
|
||||
'line_ids.matched_debit_ids.debit_move_id.move_id.line_ids.amount_residual',
|
||||
@@ -145,7 +119,6 @@ class AccountMove(models.Model):
|
||||
'line_ids.payment_id.state',
|
||||
'line_ids.full_reconcile_id',
|
||||
'line_ids.price_total',
|
||||
'document_discount',
|
||||
)
|
||||
def _compute_amount(self):
|
||||
super(AccountMove, self)._compute_amount()
|
||||
@@ -154,10 +127,18 @@ class AccountMove(models.Model):
|
||||
amount_gross = sum(
|
||||
move.line_ids.filtered(lambda f: not f.exclude_from_invoice_tab).mapped('price_subtotal'))
|
||||
move.update({
|
||||
'amount_gross': amount_gross,
|
||||
'amount_untaxed': amount_gross
|
||||
})
|
||||
# move._generate_document_discount_move_line()
|
||||
move.update({
|
||||
'amount_total': move.amount_untaxed + move.amount_tax,
|
||||
})
|
||||
|
||||
|
||||
def clear_discount(self):
|
||||
for move in self.with_context(check_move_validity=False):
|
||||
for inv in move.invoice_line_ids:
|
||||
if inv.product_id:
|
||||
inv.write({'discount': 0.0})
|
||||
move.discount_value = 0.0
|
||||
self.with_context(check_move_validity=False)._recompute_dynamic_lines(recompute_all_taxes=True)
|
||||
|
||||
|
||||
@@ -2,24 +2,16 @@
|
||||
<flectra>
|
||||
<template id="report_invoice_document" inherit_id="account.report_invoice_document">
|
||||
<xpath expr="//div[@id='total']/div/table/tr[1]" position="before">
|
||||
<t t-if="o.has_document_discount">
|
||||
<tr class="border-black o_subtotal" style="">
|
||||
<td>
|
||||
<strong>Gross Amount</strong>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<span t-field="o.amount_gross"/>
|
||||
</td>
|
||||
</tr>
|
||||
<t t-if="o.discount_type">
|
||||
<tr style="">
|
||||
<td t-if="o.discount_type == 'fixed'">
|
||||
Fixed Discount
|
||||
</td>
|
||||
<td t-if="o.discount_type == 'percent'">
|
||||
<span t-field="o.discount_value_percent"/>% Discount
|
||||
% Discount
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<span t-field="o.document_discount"/>
|
||||
<span t-field="o.discount_value"/>
|
||||
</td>
|
||||
</tr>
|
||||
</t>
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
<field name="arch" type="xml">
|
||||
<field name="amount_untaxed" position="before">
|
||||
<field name="has_document_discount" invisible="1"/>
|
||||
<field name="amount_gross"/>
|
||||
</field>
|
||||
<field name="narration" position="after">
|
||||
<group>
|
||||
@@ -18,6 +17,12 @@
|
||||
<field name="discount_value"
|
||||
attrs="{'invisible': [('discount_type', '=', False)], 'readonly': [('state','=','posted')]}"/>
|
||||
</div>
|
||||
<div>
|
||||
<button type="object" name="clear_discount"
|
||||
class="btn-primary" string="Clear Discount"
|
||||
attrs="{'invisible': [('state','=','posted')]}">
|
||||
</button>
|
||||
</div>
|
||||
</group>
|
||||
</group>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user