Skip to content

Commit

Permalink
[FIX] stock_account_valuation_report: search discrepancies should tak…
Browse files Browse the repository at this point in the history
…e into account decimal precision
  • Loading branch information
AaronHForgeFlow committed Sep 13, 2024
1 parent d4d84fa commit 3e0bcbb
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions stock_account_valuation_report/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


from odoo import _, api, fields, models
from odoo.tools import float_compare


class ProductProduct(models.Model):
Expand Down Expand Up @@ -49,20 +50,26 @@ def _search_valuation(self, operator, value):
@api.model
def _search_qty_discrepancy(self, operator, value):
products = self.env["product.product"].search([("type", "=", "product")])
pp_list = []
for pp in products:
if pp.qty_at_date != pp.account_qty_at_date:
pp_list.append(pp.id)
return [("id", "in", pp_list)]
dp = self.env["decimal.precision"].precision_get("Product Price")

Check warning on line 53 in stock_account_valuation_report/models/product_product.py

View check run for this annotation

Codecov / codecov/patch

stock_account_valuation_report/models/product_product.py#L53

Added line #L53 was not covered by tests
products_with_discrepancy = products.filtered(
lambda pp: float_compare(
pp.qty_at_date, pp.account_qty_at_date, precision_digits=dp
)
!= 0
)
return [("id", "in", products_with_discrepancy.ids)]

Check warning on line 60 in stock_account_valuation_report/models/product_product.py

View check run for this annotation

Codecov / codecov/patch

stock_account_valuation_report/models/product_product.py#L60

Added line #L60 was not covered by tests

@api.model
def _search_valuation_discrepancy(self, operator, value):
products = self.env["product.product"].search([("type", "=", "product")])
pp_list = []
for pp in products:
if pp.stock_value != pp.account_value:
pp_list.append(pp.id)
return [("id", "in", pp_list)]
dp = self.env.ref("product.decimal_discount").precision_get("Discount")

Check warning on line 65 in stock_account_valuation_report/models/product_product.py

View check run for this annotation

Codecov / codecov/patch

stock_account_valuation_report/models/product_product.py#L65

Added line #L65 was not covered by tests
products_with_discrepancy = products.filtered(
lambda pp: float_compare(
pp.stock_value, pp.account_value, precision_digits=dp
)
!= 0
)
return [("id", "in", products_with_discrepancy.ids)]

Check warning on line 72 in stock_account_valuation_report/models/product_product.py

View check run for this annotation

Codecov / codecov/patch

stock_account_valuation_report/models/product_product.py#L72

Added line #L72 was not covered by tests

def _compute_inventory_value(self):
self.env["account.move.line"].check_access_rights("read")
Expand Down

0 comments on commit 3e0bcbb

Please sign in to comment.