[FIX] stock_account: stock_history report
* shadowing of "fields" import in the read_group function as it receives a "fields" arg. As we have to use fields.Datetime in this method, whe choosed to reimport it as "fieldsDatetime" to use it. * cast not_real_cost_method_products.ids list to tuple, because psycopg2 only accept tuple for "IN" condition.
This commit is contained in:
committed by
Simon Lejeune
parent
07a63ca22d
commit
0633bde576
@@ -2,6 +2,7 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models, tools
|
||||
from odoo.fields import Datetime as fieldsDatetime
|
||||
|
||||
|
||||
class StockHistory(models.Model):
|
||||
@@ -26,7 +27,7 @@ class StockHistory(models.Model):
|
||||
def read_group(self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True):
|
||||
res = super(StockHistory, self).read_group(domain, fields, groupby, offset=offset, limit=limit, orderby=orderby, lazy=lazy)
|
||||
if 'inventory_value' in fields:
|
||||
date = self._context.get('history_date', fields.Datetime.now())
|
||||
date = self._context.get('history_date', fieldsDatetime.now())
|
||||
stock_history = self.env['stock.history']
|
||||
group_lines = {}
|
||||
for line in res:
|
||||
@@ -40,7 +41,7 @@ class StockHistory(models.Model):
|
||||
self._cr.execute("""SELECT DISTINCT ON (product_id, company_id) product_id, company_id, cost
|
||||
FROM product_price_history
|
||||
WHERE product_id in %s AND datetime <= %s
|
||||
ORDER BY product_id, company_id, datetime DESC""", (not_real_cost_method_products.ids, date))
|
||||
ORDER BY product_id, company_id, datetime DESC""", (tuple(not_real_cost_method_products.ids), date))
|
||||
for history in self._cr.dictfetchall():
|
||||
histories_dict[(history['product_id'], history['company_id'])] = history['cost']
|
||||
|
||||
|
||||
Reference in New Issue
Block a user