Skip to content

Commit

Permalink
[IMP] sale_order_type: add sale order type to sales and invoice analy…
Browse files Browse the repository at this point in the history
…sis reports
  • Loading branch information
skeller1 committed Aug 8, 2021
1 parent d268668 commit f4162eb
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 0 deletions.
1 change: 1 addition & 0 deletions sale_order_type/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
from . import reports
from . import wizards
2 changes: 2 additions & 0 deletions sale_order_type/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"views/account_move_views.xml",
"views/res_partner_view.xml",
"data/default_type.xml",
"reports/account_invoice_report_view.xml",
"reports/sale_report_view.xml",
],
"installable": True,
}
4 changes: 4 additions & 0 deletions sale_order_type/reports/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

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

from odoo import fields, models


class AccountInvoiceReport(models.Model):
_inherit = "account.invoice.report"

sale_type_id = fields.Many2one(
comodel_name='sale.order.type',
string='Sale Order Type',
)

def _select(self):
select_str = super()._select()
select_str += """
, move.sale_type_id as sale_type_id
"""
return select_str

def _sub_select(self):
select_str = super()._sub_select()
select_str += """
, ai.sale_type_id
"""
return select_str

def _group_by(self):
group_by_str = super()._group_by()
group_by_str += ", ai.sale_type_id"
return group_by_str
15 changes: 15 additions & 0 deletions sale_order_type/reports/account_invoice_report_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="view_account_invoice_report_search" model="ir.ui.view">
<field name="inherit_id" ref="account.view_account_invoice_report_search"/>
<field name="model">account.invoice.report</field>
<field name="arch" type="xml">
<filter name="user" position="before">
<filter string="Sale Order Type" name="sale_order_type"
context="{'group_by':'sale_type_id'}"/>
</filter>
</field>
</record>

</odoo>
20 changes: 20 additions & 0 deletions sale_order_type/reports/sale_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class SaleReport(models.Model):
_inherit = "sale.report"

type_id = fields.Many2one(
comodel_name='sale.order.type',
string='Type',
)

# pylint:disable=dangerous-default-value
def _query(self, with_clause='', fields={}, groupby='', from_clause=''):
fields['type_id'] = ", s.type_id as type_id"
groupby += ', s.type_id'
return super(SaleReport, self)._query(
with_clause, fields, groupby, from_clause
)
15 changes: 15 additions & 0 deletions sale_order_type/reports/sale_report_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="view_order_product_search" model="ir.ui.view">
<field name="inherit_id" ref="sale.view_order_product_search"/>
<field name="model">sale.report</field>
<field name="arch" type="xml">
<filter name="User" position="before">
<filter string="Sale Order Type" name="sale_order_type"
context="{'group_by':'type_id'}"/>
</filter>
</field>
</record>

</odoo>

0 comments on commit f4162eb

Please sign in to comment.