I am using Odoo 12 and I would like to make a report for printing the Inventory Valuation at specific date. When I look at the list the quantities are correct and the value also, but when I try to make it work in a report it shows something else, it doesn't take the same value.
<report id="report_inventory_valuation" model="product.product" string="Inventory Valuation Report" name="mymodule.inventory_valuation_report" file="mymodule.inventory_valuation" report_type="qweb-pdf" /> <template id="inventory_valuation_report"> <t t-call="web.html_container"> <t t-call="web.external_layout"> <div class="page"> <h2>Inventory Valuation Report</h2> <div class="row mt32 mb32"> <div class="col-3"> <!--<t t-esc="datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')"/>--> </div> </div> <table class="table table-sm"> <thead> <th>#</th> <th>SKU</th> <th>Name</th> <th>Quantity</th> <th>Price</th> </thead> <tbody> <t t-set="inventory_cost" t-value="0"/> <t t-set="index" t-value="1"/>
<tr t-foreach="docs.sorted(key=lambda x: x.name)" t-as="product"> <t t-if="product.standard_price > 0 and product.qty_at_date > 0"> <td t-esc="index"/><t t-set="index" t-value="index + 1"/> <td t-if="product.code"> [<span t-esc="product.code"/>] </td> <td t-else=""> </td> <td><span t-esc="product.name"/></td> <td><span t-esc="'{0:,.2f}'.format(product.qty_at_date)"/></td> <td><span t-esc="'{0:,.2f}'.format(product.standard_price * product.qty_at_date)"/></td> <t t-set="inventory_cost" t-value="inventory_cost + (product.standard_price * product.qty_at_date)"/> </t> </tr> </tbody>
<tfoot> <tr> <td>TOTAL</td> <td colspan="3"/> <td t-esc="'{0:,.2f}'.format(inventory_cost)"/> </tr> </tfoot> </table> </div> </t> </t> </template>
product.with_context({'to_date': date_val}).qty_available