| 1 |
# -*- coding: utf-8 -*- |
| 2 |
# Part of Odoo. See LICENSE file for full copyright and licensing details. |
| 3 |
|
| 4 |
from odoo import models |
| 5 |
from odoo.tools.float_utils import float_repr |
| 6 |
|
| 7 |
|
| 8 |
class StockForecasted_Product_Product(models.AbstractModel): |
| 9 |
_inherit = 'stock.forecasted_product_product' |
| 10 |
|
| 11 |
def _get_report_header(self, product_template_ids, product_ids, wh_location_ids): |
| 12 |
""" Overrides to computes the valuations of the stock. """ |
| 13 |
res = super()._get_report_header(product_template_ids, product_ids, wh_location_ids) |
| 14 |
if not self.env.user.has_group('stock.group_stock_manager') or not wh_location_ids: |
| 15 |
return res |
| 16 |
company = self.env['stock.location'].browse(wh_location_ids[0]).company_id |
| 17 |
domain_quants = [ |
| 18 |
('company_id', '=', company.id), |
| 19 |
('location_id', 'in', wh_location_ids) |
| 20 |
] |
| 21 |
if product_template_ids: |
| 22 |
domain_quants += [('product_id.product_tmpl_id', 'in', product_template_ids)] |
| 23 |
else: |
| 24 |
domain_quants += [('product_id', 'in', product_ids)] |
| 25 |
quants = self.env['stock.quant'].search(domain_quants) |
| 26 |
|
| 27 |
currency = self.env.company.currency_id |
| 28 |
value = sum(quants.mapped('value')) |
| 29 |
value = float_repr(value, precision_digits=currency.decimal_places) |
| 30 |
if currency.position == 'after': |
| 31 |
value = '%s %s' % (value, currency.symbol) |
| 32 |
else: |
| 33 |
value = '%s %s' % (currency.symbol, value) |
| 34 |
res['value'] = value |
| 35 |
return res |