Skip to content

Commit

Permalink
[FIX] not used cost
Browse files Browse the repository at this point in the history
  • Loading branch information
Saran440 committed Apr 24, 2024
1 parent 575889c commit e5cf456
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 53 deletions.
25 changes: 0 additions & 25 deletions stock_account_report_xlsx/reports/stock_location_report.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,8 @@
t-set="product_company"
t-value="line.product_id.with_company(line.company_id)"
/>
<t t-if="product_company.quantity_svl">
<t
t-set="cost"
t-value="line.quantity * product_company.value_svl / product_company.quantity_svl"
/>
</t>
<t t-else="">
<t t-set="cost" t-value="0" />
</t>
<t t-if="line.quantity">
<t t-set="avg_cost_unit" t-value="cost / line.quantity" />
</t>
<t t-else="">
<t t-set="avg_cost_unit" t-value="0.0" />
</t>
<t t-set="sale_price_unit" t-value="product_company.list_price" />
<t t-set="sale_price" t-value="sale_price_unit * line.quantity" />

<div class="act_as_cell right">
<span t-out="cost" t-options="{'widget': 'float', 'precision': 2}" />
</div>
<div class="act_as_cell right">
<span
t-out="avg_cost_unit"
t-options="{'widget': 'float', 'precision': 2}"
/>
</div>
<div class="act_as_cell right">
<span
t-out="sale_price"
Expand Down
31 changes: 3 additions & 28 deletions stock_account_report_xlsx/reports/stock_location_report_xlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,16 @@ class ReportStockLocationXlsx(models.TransientModel):

def _get_stock_location_template(self):
stock_location_template = super()._get_stock_location_template()

stock_location_template["6_cost"] = {
"header": {"value": "Cost"},
"data": {
"value": self._render("cost"),
"format": FORMATS["format_tcell_amount_right"],
},
"width": 20,
}
stock_location_template["7_avg_cost_unit"] = {
"header": {"value": "Average Cost / Unit"},
"data": {
"value": self._render("avg_cost_unit"),
"format": FORMATS["format_tcell_amount_right"],
},
"width": 20,
}
stock_location_template["8_sale_price"] = {
# Add sale price
stock_location_template["6_sale_price"] = {
"header": {"value": "Sale Price"},
"data": {
"value": self._render("sale_price"),
"format": FORMATS["format_tcell_amount_right"],
},
"width": 20,
}
stock_location_template["9_sale_price_unit"] = {
stock_location_template["7_sale_price_unit"] = {
"header": {"value": "Sale Price / Unit"},
"data": {
"value": self._render("sale_price_unit"),
Expand All @@ -48,16 +32,7 @@ def _get_stock_location_template(self):

def _get_render_space(self, index, line):
render_space = super()._get_render_space(index, line)

# Add cost in report
product_company = line.product_id.with_company(line.company_id)
value = 0.0
if product_company.quantity_svl:
value = (
line.quantity * product_company.value_svl / product_company.quantity_svl
)
render_space["cost"] = value
render_space["avg_cost_unit"] = line.quantity and (value / line.quantity) or 0.0
render_space["sale_price_unit"] = product_company.list_price
render_space["sale_price"] = product_company.list_price * line.quantity
return render_space

0 comments on commit e5cf456

Please sign in to comment.