Skip to content

Commit

Permalink
Merge PR #338 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by LoisRForgeFlow
  • Loading branch information
OCA-git-bot committed Nov 29, 2024
2 parents 96f9bf0 + d0c56d2 commit 4f397ed
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
39 changes: 27 additions & 12 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 @@ -48,21 +49,35 @@ 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)]
products = self.with_context(active_test=False).search(
[
("type", "=", "product"),
]
)
dp = self.env["decimal.precision"].precision_get("Product Price")
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)]

@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)]
products = self.with_context(active_test=False).search(
[
("type", "=", "product"),
]
)
dp = self.env.ref("product.decimal_discount").precision_get("Discount")
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)]

def _compute_inventory_value(self):
self.env["account.move.line"].check_access_rights("read")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@
name="valuation_discrepancy_not_null"
domain="[('valuation_discrepancy', '!=', 0.0), ('valuation', '=', 'real_time')]"
/>
<separator />
<filter
string="Valuation Or Qty Discrepancy"
name="valuation_or_qty_discrepancy_not_null"
domain="[('valuation', '=', 'real_time'), '|', ('qty_discrepancy', '!=', 0.0), ('valuation_discrepancy', '!=', 0.0)]"
/>
</filter>
</field>
</record>
Expand Down

0 comments on commit 4f397ed

Please sign in to comment.