Skip to content

Commit

Permalink
Add a month fy to invoice report
Browse files Browse the repository at this point in the history
  • Loading branch information
ecino committed Dec 16, 2016
1 parent 7107112 commit 0c4a686
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions account_invoice_unreconcile/models/account_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class AccountInvoiceReport(osv.osv):
_inherit = 'account.invoice.report'
_description = "Invoices Statistics with FISCAL YEAR"
_columns = {
'monthfy': fields.integer('month# in FY', readonly=True),
'fiscalyear_id': fields.related(
'period_id', 'fiscalyear_id', type="many2one",
relation="account.fiscalyear", string="fiscal year",
Expand All @@ -40,7 +41,7 @@ def _select(self):
select_str = """
SELECT sub.id, sub.date, sub.product_id, sub.partner_id,
sub.country_id,sub.fiscalyear_id, sub.payment_term,
sub.period_id, sub.uom_name, sub.currency_id, sub.journal_id,
sub.period_id, sub.uom_name,sub.monthfy, sub.currency_id, sub.journal_id,
sub.fiscal_position, sub.user_id, sub.company_id, sub.nbr,
sub.type, sub.state, sub.categ_id, sub.date_due,
sub.account_id, sub.account_line_id, sub.partner_bank_id,
Expand All @@ -58,7 +59,14 @@ def _sub_select(self):
ail.product_id, ai.partner_id, ai.payment_term, ai.period_id,
ap.fiscalyear_id,u2.name AS uom_name, ai.currency_id,
ai.journal_id, ai.fiscal_position, ai.user_id, ai.company_id,
count(ail.*) AS nbr,
count(ail.*) AS nbr,case
when left(ap.code,2)<>'00'
then case
when left(ap.code,2)::int>6
then left(ap.code,2)::int-5
else left(ap.code,2)::int+5
end
end as monthfy,
ai.type, ai.state, pt.categ_id, ai.date_due, ai.account_id,
ail.account_id AS account_line_id, ai.partner_bank_id,
SUM(CASE
Expand Down Expand Up @@ -128,7 +136,7 @@ def _group_by(self):
ai.journal_id, ai.fiscal_position, ai.user_id,
ai.company_id, ai.type, ai.state, pt.categ_id,
ai.date_due, ai.account_id, ail.account_id,
ai.partner_bank_id, ai.residual,
ai.partner_bank_id, ai.residual,monthfy,
ai.amount_total, ai.commercial_partner_id,
partner.country_id
"""
Expand Down

0 comments on commit 0c4a686

Please sign in to comment.