mirror of
https://github.com/bringout/oca-ocb-accounting.git
synced 2026-04-26 22:22:04 +02:00
19.0 vanilla
This commit is contained in:
parent
ba20ce7443
commit
768b70e05e
2357 changed files with 1057103 additions and 712486 deletions
|
|
@ -2,20 +2,18 @@
|
|||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import models
|
||||
from odoo.tools.float_utils import float_is_zero, float_repr
|
||||
from odoo.tools.float_utils import float_repr
|
||||
|
||||
|
||||
class ReplenishmentReport(models.AbstractModel):
|
||||
_inherit = 'report.stock.report_product_product_replenishment'
|
||||
class StockForecasted_Product_Product(models.AbstractModel):
|
||||
_inherit = 'stock.forecasted_product_product'
|
||||
|
||||
def _compute_draft_quantity_count(self, product_template_ids, product_variant_ids, wh_location_ids):
|
||||
def _get_report_header(self, product_template_ids, product_ids, wh_location_ids):
|
||||
""" Overrides to computes the valuations of the stock. """
|
||||
res = super()._compute_draft_quantity_count(product_template_ids, product_variant_ids, wh_location_ids)
|
||||
if not self.user_has_groups('stock.group_stock_manager'):
|
||||
res = super()._get_report_header(product_template_ids, product_ids, wh_location_ids)
|
||||
if not self.env.user.has_group('stock.group_stock_manager') or not wh_location_ids:
|
||||
return res
|
||||
domain = self._product_domain(product_template_ids, product_variant_ids)
|
||||
company = self.env['stock.location'].browse(wh_location_ids[0]).company_id
|
||||
svl = self.env['stock.valuation.layer'].search(domain + [('company_id', '=', company.id)])
|
||||
domain_quants = [
|
||||
('company_id', '=', company.id),
|
||||
('location_id', 'in', wh_location_ids)
|
||||
|
|
@ -23,15 +21,11 @@ class ReplenishmentReport(models.AbstractModel):
|
|||
if product_template_ids:
|
||||
domain_quants += [('product_id.product_tmpl_id', 'in', product_template_ids)]
|
||||
else:
|
||||
domain_quants += [('product_id', 'in', product_variant_ids)]
|
||||
domain_quants += [('product_id', 'in', product_ids)]
|
||||
quants = self.env['stock.quant'].search(domain_quants)
|
||||
currency = svl.currency_id or self.env.company.currency_id
|
||||
total_quantity = sum(svl.mapped('quantity'))
|
||||
# Because we can have negative quantities, `total_quantity` may be equal to zero even if the warehouse's `quantity` is positive.
|
||||
if svl and not float_is_zero(total_quantity, precision_rounding=svl.product_id.uom_id.rounding):
|
||||
value = sum(svl.mapped('value')) * (sum(quants.mapped('quantity')) / total_quantity)
|
||||
else:
|
||||
value = 0
|
||||
|
||||
currency = self.env.company.currency_id
|
||||
value = sum(quants.mapped('value'))
|
||||
value = float_repr(value, precision_digits=currency.decimal_places)
|
||||
if currency.position == 'after':
|
||||
value = '%s %s' % (value, currency.symbol)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue