Also port stock inventory ODS location-independant
This commit is contained in:
@@ -1 +1,3 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from . import stock_inventory
|
||||||
|
|||||||
Binary file not shown.
@@ -1,38 +0,0 @@
|
|||||||
# -*- 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
|
|
||||||
@@ -19,18 +19,14 @@
|
|||||||
<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">
|
<record id="stock_inventory_valuation_grouped_ods" model="ir.actions.report.xml">
|
||||||
<field name="name">Inventory Valuation (ODS)</field>
|
<field name="name">Inventory Valuation (ODS)</field>
|
||||||
<field name="model">stock.inventory</field>
|
<field name="model">stock.inventory</field>
|
||||||
<field name="report_name">stock.inventory.grouped.ods</field>
|
<field name="report_name">stock.inventory.grouped.ods</field>
|
||||||
<field name="report_type">aeroo</field>
|
<field name="report_type">py3o</field>
|
||||||
<field name="in_format">oo-ods</field>
|
<field name="py3o_filetype">ods</field>
|
||||||
<field name="report_rml">stock_inventory_valuation_ods/inventory_grouped.ods</field>
|
<field name="module">stock_inventory_valuation_ods</field>
|
||||||
<field name="parser_state">loc</field>
|
<field name="py3o_template_fallback">inventory_grouped.ods</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>
|
||||||
|
|
||||||
<record id="stock_inventory_valuation_grouped_ods_button" model="ir.values">
|
<record id="stock_inventory_valuation_grouped_ods_button" model="ir.values">
|
||||||
@@ -39,6 +35,5 @@
|
|||||||
<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_grouped_ods"/>
|
<field name="value" eval="'ir.actions.report.xml,%d'%stock_inventory_valuation_grouped_ods"/>
|
||||||
</record>
|
</record>
|
||||||
-->
|
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
33
stock_inventory_valuation_ods/stock_inventory.py
Normal file
33
stock_inventory_valuation_ods/stock_inventory.py
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright 2016-2018 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from odoo import models
|
||||||
|
|
||||||
|
|
||||||
|
class StockInventory(models.Model):
|
||||||
|
_inherit = 'stock.inventory'
|
||||||
|
|
||||||
|
def report_group_lines(self):
|
||||||
|
self.ensure_one()
|
||||||
|
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
|
||||||
|
""", (self.id, ))
|
||||||
|
res = []
|
||||||
|
silo = self.env['stock.inventory.line']
|
||||||
|
for row in self._cr.dictfetchall():
|
||||||
|
row['min_line'] = silo.browse(row['min_line_id'])
|
||||||
|
res.append(row)
|
||||||
|
return res
|
||||||
Reference in New Issue
Block a user