forked from OCA/purchase-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIX] purchase_force_invoiced: Adapt BI report to the check
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
1 parent
0b3af67
commit efc4a71
Showing
3 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |