Skip to content

Commit

Permalink
[FIX] purchase_force_invoiced: Adapt BI report to the check
Browse files Browse the repository at this point in the history
The purchase BI analysis is not taking into account the
"Force invoiced" check for showing their quantity to be billed, so it
gives contradictory information from the search filter and the pivot.

This commit adapts the SQL report for taking this into account.
  • Loading branch information
pedrobaeza committed Jul 20, 2022
1 parent 0b3af67 commit efc4a71
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions purchase_force_invoiced/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)

from . import model
from . import reports
3 changes: 3 additions & 0 deletions purchase_force_invoiced/reports/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)

from . import purchase_report
21 changes: 21 additions & 0 deletions purchase_force_invoiced/reports/purchase_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
# Copyright 2022 Tecnativa - Pedro M. Baeza

from odoo import models


class PurchaseReport(models.Model):
_inherit = "purchase.report"

def _select(self):
"""Put quantity to be billed as 0 if it has been forced."""
select_str = super()._select()
select_str = select_str.replace(
"case when t.purchase_method = 'purchase'",
"case when po.force_invoiced then 0.0 "
"else (case when t.purchase_method = 'purchase' ",
)
select_str = select_str.replace(
"end as qty_to_be_billed", "end) end as qty_to_be_billed"
)
return select_str

0 comments on commit efc4a71

Please sign in to comment.