Add inventory valuation without per stock location analysis

This commit is contained in:
Alexis de Lattre
2016-05-30 15:55:57 +02:00
parent 30089555c5
commit 34a763d894
4 changed files with 60 additions and 2 deletions

Binary file not shown.

View 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

View File

@@ -4,7 +4,7 @@
<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="report_name">stock.inventory.ods</field>
<field name="report_type">aeroo</field>
@@ -16,12 +16,32 @@
</record>
<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="key2">client_print_multi</field>
<field name="value" eval="'ir.actions.report.xml,%d'%stock_inventory_valuation_ods"/>
</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>
</openerp>