Skip to content
Snippets Groups Projects
Commit 8eab549c authored by Matheus Leal Viana (malv)'s avatar Matheus Leal Viana (malv)
Browse files

[FIX] purchase: Do not display notes/sections in purchase reporting


The issue is when we create a new PO with notes/sections and these notes/sections are showed on purchase reporting and only the products were supposed to appear there.

This issue happens because the SQL query wasn't applying any filter to the lines. The solution is apply a filter by display_type.

Steps to reproduce:
1) Go to Purchase App -> Purchase Orders -> Create a new PO with notes/sections
2) Go to Reporting -> View as pivot
3) You'll be able to see the section/notes you just created

closes odoo/odoo#118020

Opw: 3245933
Signed-off-by: default avatarAdrien Widart <awt@odoo.com>
parent fcf0fe54
No related branches found
No related tags found
No related merge requests found
......@@ -62,7 +62,7 @@ class PurchaseReport(models.Model):
@property
def _table_query(self):
''' Report needs to be dynamic to take into account multi-company selected + multi-currency rates '''
return '%s %s %s' % (self._select(), self._from(), self._group_by())
return '%s %s %s %s' % (self._select(), self._from(), self._where(), self._group_by())
def _select(self):
select_str = """
......@@ -120,6 +120,12 @@ class PurchaseReport(models.Model):
)
return from_str
def _where(self):
return """
WHERE
l.display_type IS NULL
"""
def _group_by(self):
group_by_str = """
GROUP BY
......
......@@ -89,6 +89,36 @@ class TestPurchaseOrderReport(AccountTestInvoicingCommon):
self.assertEqual(round(report[0]['delay']), -10, msg="The PO has been confirmed 10 days in advance")
self.assertEqual(round(report[0]['delay_pass']), 5, msg="There are 5 days between the order date and the planned date")
def test_02_po_report_note_section_filter(self):
po = self.env['purchase.order'].create({
'partner_id': self.partner_a.id,
'currency_id': self.currency_data['currency'].id,
'order_line': [
(0, 0, {
'name': 'This is a note',
'display_type': 'line_note',
'product_id': False,
'product_qty': 0.0,
'product_uom': False,
'price_unit': 0.0,
'taxes_id': False,
}),
(0, 0, {
'name': 'This is a section',
'display_type': 'line_section',
'product_id': False,
'product_qty': 0.0,
'product_uom': False,
'price_unit': 0.0,
'taxes_id': False,
}),
],
})
po.button_confirm()
result_po = self.env['purchase.report'].search([('order_id', '=', po.id)])
self.assertFalse(result_po, "The report should ignore the notes and sections")
def test_avg_price_calculation(self):
"""
Check that the average price is calculated based on the quantity ordered in each line
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment