Also port stock inventory ODS location-independant

This commit is contained in:
Alexis de Lattre
2018-03-12 00:34:43 +01:00
parent 19ad0eff78
commit f9552e7271
5 changed files with 39 additions and 47 deletions

View 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