Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][FIX] stock_account_valuation_report: improve searching on discrepancies #338

Open
wants to merge 1 commit into
base: 16.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
@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
Loading