Add inventory valuation without per stock location analysis
This commit is contained in:
Binary file not shown.
BIN
stock_inventory_valuation_ods/inventory_grouped.ods
Normal file
BIN
stock_inventory_valuation_ods/inventory_grouped.ods
Normal file
Binary file not shown.
38
stock_inventory_valuation_ods/inventory_grouped.py
Normal file
38
stock_inventory_valuation_ods/inventory_grouped.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# © 2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from openerp.report import report_sxw
|
||||||
|
|
||||||
|
|
||||||
|
class Parser(report_sxw.rml_parse):
|
||||||
|
def __init__(self, cr, uid, name, context=None):
|
||||||
|
super(Parser, self).__init__(cr, uid, name, context=context)
|
||||||
|
self.localcontext.update({
|
||||||
|
'group_lines': self._group_lines,
|
||||||
|
})
|
||||||
|
|
||||||
|
def _group_lines(self, inventory, context=None):
|
||||||
|
assert inventory, 'Missing inventory'
|
||||||
|
self.cr.execute("""
|
||||||
|
SELECT
|
||||||
|
min(id) AS min_line_id,
|
||||||
|
product_id,
|
||||||
|
package_id,
|
||||||
|
prod_lot_id,
|
||||||
|
product_uom_id,
|
||||||
|
standard_price,
|
||||||
|
sum(product_qty) AS product_qty,
|
||||||
|
sum(theoretical_qty) AS theoretical_qty
|
||||||
|
FROM stock_inventory_line
|
||||||
|
WHERE inventory_id=%s
|
||||||
|
GROUP BY product_id, package_id, prod_lot_id,
|
||||||
|
product_uom_id, standard_price
|
||||||
|
""", (inventory.id, ))
|
||||||
|
res = []
|
||||||
|
silo = self.pool['stock.inventory.line']
|
||||||
|
for row in self.cr.dictfetchall():
|
||||||
|
row['min_line'] = silo.browse(
|
||||||
|
self.cr, self.uid, row['min_line_id'], context=context)
|
||||||
|
res.append(row)
|
||||||
|
return res
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<record id="stock_inventory_valuation_ods" model="ir.actions.report.xml">
|
<record id="stock_inventory_valuation_ods" model="ir.actions.report.xml">
|
||||||
<field name="name">Inventory Valuation ODS</field>
|
<field name="name">Inventory Valuation per Location (ODS)</field>
|
||||||
<field name="model">stock.inventory</field>
|
<field name="model">stock.inventory</field>
|
||||||
<field name="report_name">stock.inventory.ods</field>
|
<field name="report_name">stock.inventory.ods</field>
|
||||||
<field name="report_type">aeroo</field>
|
<field name="report_type">aeroo</field>
|
||||||
@@ -16,12 +16,32 @@
|
|||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="stock_inventory_valuation_ods_button" model="ir.values">
|
<record id="stock_inventory_valuation_ods_button" model="ir.values">
|
||||||
<field name="name">Inventory Valuation ODS</field>
|
<field name="name">Inventory Valuation per Location ODS</field>
|
||||||
<field name="model">stock.inventory</field>
|
<field name="model">stock.inventory</field>
|
||||||
<field name="key2">client_print_multi</field>
|
<field name="key2">client_print_multi</field>
|
||||||
<field name="value" eval="'ir.actions.report.xml,%d'%stock_inventory_valuation_ods"/>
|
<field name="value" eval="'ir.actions.report.xml,%d'%stock_inventory_valuation_ods"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="stock_inventory_valuation_grouped_ods" model="ir.actions.report.xml">
|
||||||
|
<field name="name">Inventory Valuation (ODS)</field>
|
||||||
|
<field name="model">stock.inventory</field>
|
||||||
|
<field name="report_name">stock.inventory.grouped.ods</field>
|
||||||
|
<field name="report_type">aeroo</field>
|
||||||
|
<field name="in_format">oo-ods</field>
|
||||||
|
<field name="report_rml">stock_inventory_valuation_ods/inventory_grouped.ods</field>
|
||||||
|
<field name="parser_state">loc</field>
|
||||||
|
<field name="parser_loc">stock_inventory_valuation_ods/inventory_grouped.py</field>
|
||||||
|
<field name="tml_source">file</field>
|
||||||
|
<field name="out_format" ref="report_aeroo.report_mimetypes_ods_ods"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="stock_inventory_valuation_grouped_ods_button" model="ir.values">
|
||||||
|
<field name="name">Inventory Valuation ODS</field>
|
||||||
|
<field name="model">stock.inventory</field>
|
||||||
|
<field name="key2">client_print_multi</field>
|
||||||
|
<field name="value" eval="'ir.actions.report.xml,%d'%stock_inventory_valuation_grouped_ods"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</openerp>
|
</openerp>
|
||||||
|
|||||||
Reference in New Issue
Block a user