[IMP] Add section_id in the invoice analysis report.
bzr revid: vba@tinyerp.com-20121121101909-hez6fxcqcyn3njy8
This commit is contained in:
parent
4cbd5c58fc
commit
d17568d572
|
@ -100,14 +100,13 @@ class account_invoice_report(osv.osv):
|
||||||
'user_currency_residual': fields.function(_compute_amounts_in_user_currency, string="Total Residual", type='float', digits_compute=dp.get_precision('Account'), multi="_compute_amounts"),
|
'user_currency_residual': fields.function(_compute_amounts_in_user_currency, string="Total Residual", type='float', digits_compute=dp.get_precision('Account'), multi="_compute_amounts"),
|
||||||
'delay_to_pay': fields.float('Avg. Delay To Pay', readonly=True, group_operator="avg"),
|
'delay_to_pay': fields.float('Avg. Delay To Pay', readonly=True, group_operator="avg"),
|
||||||
'due_delay': fields.float('Avg. Due Delay', readonly=True, group_operator="avg"),
|
'due_delay': fields.float('Avg. Due Delay', readonly=True, group_operator="avg"),
|
||||||
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
|
|
||||||
}
|
}
|
||||||
_order = 'date desc'
|
_order = 'date desc'
|
||||||
def init(self, cr):
|
|
||||||
tools.drop_view_if_exists(cr, 'account_invoice_report')
|
|
||||||
cr.execute("""
|
def _select(self):
|
||||||
create or replace view account_invoice_report as (
|
select_str = """
|
||||||
select min(ail.id) as id,
|
SELECT min(ail.id) as id,
|
||||||
ai.date_invoice as date,
|
ai.date_invoice as date,
|
||||||
to_char(ai.date_invoice, 'YYYY') as year,
|
to_char(ai.date_invoice, 'YYYY') as year,
|
||||||
to_char(ai.date_invoice, 'MM') as month,
|
to_char(ai.date_invoice, 'MM') as month,
|
||||||
|
@ -125,7 +124,6 @@ class account_invoice_report(osv.osv):
|
||||||
ai.journal_id as journal_id,
|
ai.journal_id as journal_id,
|
||||||
ai.fiscal_position as fiscal_position,
|
ai.fiscal_position as fiscal_position,
|
||||||
ai.user_id as user_id,
|
ai.user_id as user_id,
|
||||||
ai.section_id as section_id,
|
|
||||||
ai.company_id as company_id,
|
ai.company_id as company_id,
|
||||||
count(ail.*) as nbr,
|
count(ail.*) as nbr,
|
||||||
ai.type as type,
|
ai.type as type,
|
||||||
|
@ -185,15 +183,30 @@ class account_invoice_report(osv.osv):
|
||||||
where a.id=ai.id)
|
where a.id=ai.id)
|
||||||
ELSE 1
|
ELSE 1
|
||||||
END) / cr.rate as residual
|
END) / cr.rate as residual
|
||||||
from account_invoice_line as ail
|
"""
|
||||||
|
return select_str
|
||||||
|
|
||||||
|
def _where(self):
|
||||||
|
where_str = """
|
||||||
|
WHERE cr.id in (select id from res_currency_rate cr2 where (cr2.currency_id = ai.currency_id)
|
||||||
|
and ((ai.date_invoice is not null and cr.name <= ai.date_invoice) or (ai.date_invoice is null and cr.name <= NOW())) order by name desc limit 1)
|
||||||
|
"""
|
||||||
|
return where_str
|
||||||
|
|
||||||
|
def _from(self):
|
||||||
|
from_str = """
|
||||||
|
FROM account_invoice_line as ail
|
||||||
left join account_invoice as ai ON (ai.id=ail.invoice_id)
|
left join account_invoice as ai ON (ai.id=ail.invoice_id)
|
||||||
left join product_product pr on (pr.id=ail.product_id)
|
left join product_product pr on (pr.id=ail.product_id)
|
||||||
left join product_template pt on (pt.id=pr.product_tmpl_id)
|
left join product_template pt on (pt.id=pr.product_tmpl_id)
|
||||||
left join product_uom u on (u.id=ail.uos_id),
|
left join product_uom u on (u.id=ail.uos_id),
|
||||||
res_currency_rate cr
|
res_currency_rate cr
|
||||||
where cr.id in (select id from res_currency_rate cr2 where (cr2.currency_id = ai.currency_id)
|
"""
|
||||||
and ((ai.date_invoice is not null and cr.name <= ai.date_invoice) or (ai.date_invoice is null and cr.name <= NOW())) order by name desc limit 1)
|
return from_str
|
||||||
group by ail.product_id,
|
|
||||||
|
def _group_by(self):
|
||||||
|
group_by_str = """
|
||||||
|
GROUP BY ail.product_id,
|
||||||
ai.date_invoice,
|
ai.date_invoice,
|
||||||
ai.id,
|
ai.id,
|
||||||
cr.rate,
|
cr.rate,
|
||||||
|
@ -219,10 +232,16 @@ class account_invoice_report(osv.osv):
|
||||||
ai.residual,
|
ai.residual,
|
||||||
ai.amount_total,
|
ai.amount_total,
|
||||||
u.uom_type,
|
u.uom_type,
|
||||||
u.category_id,
|
u.category_id
|
||||||
ai.section_id
|
"""
|
||||||
)
|
return group_by_str
|
||||||
""")
|
|
||||||
|
def init(self, cr):
|
||||||
|
# self._table = account_invoice_report
|
||||||
|
tools.drop_view_if_exists(cr, self._table)
|
||||||
|
cr.execute("CREATE or REPLACE VIEW %s as (%s %s %s %s)" % (
|
||||||
|
self._table,
|
||||||
|
self._select(), self._from(), self._where(), self._group_by()))
|
||||||
|
|
||||||
account_invoice_report()
|
account_invoice_report()
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
<field name="account_line_id" invisible="1"/>
|
<field name="account_line_id" invisible="1"/>
|
||||||
<field name="nbr" sum="# of Lines"/>
|
<field name="nbr" sum="# of Lines"/>
|
||||||
<field name="product_qty" sum="Qty"/>
|
<field name="product_qty" sum="Qty"/>
|
||||||
<field name="section_id"/>
|
|
||||||
<!-- <field name="reconciled" sum="# Reconciled"/> -->
|
<!-- <field name="reconciled" sum="# Reconciled"/> -->
|
||||||
<field name="user_currency_price_total" sum="Total Without Tax"/>
|
<field name="user_currency_price_total" sum="Total Without Tax"/>
|
||||||
<field name="user_currency_residual" sum="Total Residual" invisible="context.get('residual_invisible',False)"/>
|
<field name="user_currency_residual" sum="Total Residual" invisible="context.get('residual_invisible',False)"/>
|
||||||
|
@ -66,7 +65,6 @@
|
||||||
<filter icon="terp-dolar_ok!" string="Refund" domain="['|', ('type','=','out_refund'),('type','=','in_refund')]" help="Customer And Supplier Refunds"/>
|
<filter icon="terp-dolar_ok!" string="Refund" domain="['|', ('type','=','out_refund'),('type','=','in_refund')]" help="Customer And Supplier Refunds"/>
|
||||||
<field name="partner_id"/>
|
<field name="partner_id"/>
|
||||||
<field name="user_id" />
|
<field name="user_id" />
|
||||||
<field name="section_id" />
|
|
||||||
<field name="categ_id" filter_domain="[('categ_id', 'child_of', self)]"/>
|
<field name="categ_id" filter_domain="[('categ_id', 'child_of', self)]"/>
|
||||||
<group expand="1" string="Group By...">
|
<group expand="1" string="Group By...">
|
||||||
<filter string="Partner" name="partner" icon="terp-partner" context="{'group_by':'partner_id','residual_visible':True}"/>
|
<filter string="Partner" name="partner" icon="terp-partner" context="{'group_by':'partner_id','residual_visible':True}"/>
|
||||||
|
@ -83,7 +81,6 @@
|
||||||
<filter string="Day" name="day" icon="terp-go-today" context="{'group_by':'day'}" help="Group by Invoice Date"/>
|
<filter string="Day" name="day" icon="terp-go-today" context="{'group_by':'day'}" help="Group by Invoice Date"/>
|
||||||
<filter string="Month" name="month" icon="terp-go-month" context="{'group_by':'month'}" help="Group by month of Invoice Date"/>
|
<filter string="Month" name="month" icon="terp-go-month" context="{'group_by':'month'}" help="Group by month of Invoice Date"/>
|
||||||
<filter string="Year" name="group_year" icon="terp-go-year" context="{'group_by':'year'}" help="Group by year of Invoice Date"/>
|
<filter string="Year" name="group_year" icon="terp-go-year" context="{'group_by':'year'}" help="Group by year of Invoice Date"/>
|
||||||
<filter string="Sales Team" name='section_id' icon="terp-personal" context="{'group_by':'section_id'}"/>
|
|
||||||
</group>
|
</group>
|
||||||
</search>
|
</search>
|
||||||
</field>
|
</field>
|
||||||
|
|
|
@ -21,5 +21,6 @@
|
||||||
|
|
||||||
import wizard
|
import wizard
|
||||||
import sale_crm
|
import sale_crm
|
||||||
|
import report
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
|
@ -43,7 +43,8 @@ modules.
|
||||||
'sale_crm_view.xml',
|
'sale_crm_view.xml',
|
||||||
'process/sale_crm_process.xml',
|
'process/sale_crm_process.xml',
|
||||||
'security/sale_crm_security.xml',
|
'security/sale_crm_security.xml',
|
||||||
'security/ir.model.access.csv'
|
'security/ir.model.access.csv',
|
||||||
|
'report/sale_crm_account_invoice_report_view.xml',
|
||||||
],
|
],
|
||||||
'demo': [],
|
'demo': [],
|
||||||
'test': ['test/sale_crm.yml'],
|
'test': ['test/sale_crm.yml'],
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# OpenERP, Open Source Management Solution
|
||||||
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
import sales_crm_account_invoice_report
|
||||||
|
|
||||||
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<openerp>
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<!-- Update account invoice !-->
|
||||||
|
<record model="ir.ui.view" id="account_invoice_report_tree">
|
||||||
|
<field name="name">account.invoice.report.tree</field>
|
||||||
|
<field name="model">account.invoice.report</field>
|
||||||
|
<field name="inherit_id" ref="account.view_account_invoice_report_tree"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<data>
|
||||||
|
<xpath expr="//field[@name='date']" position="after">
|
||||||
|
<field name="section_id"/>
|
||||||
|
</xpath>
|
||||||
|
</data>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</openerp>
|
|
@ -0,0 +1,35 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# OpenERP, Open Source Management Solution
|
||||||
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as
|
||||||
|
# published by the Free Software Foundation, either version 3 of the
|
||||||
|
# License, or (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
from osv import fields,osv
|
||||||
|
|
||||||
|
class account_invoice_report(osv.osv):
|
||||||
|
_inherit = 'account.invoice.report'
|
||||||
|
_columns = {
|
||||||
|
'section_id': fields.many2one('crm.case.section', 'Sales Team'),
|
||||||
|
}
|
||||||
|
|
||||||
|
def _select(self):
|
||||||
|
return super(account_invoice_report, self)._select() + ", ai.section_id as section_id"
|
||||||
|
|
||||||
|
def _group_by(self):
|
||||||
|
return super(account_invoice_report, self)._group_by() + ", ai.section_id"
|
||||||
|
|
||||||
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
Loading…
Reference in New Issue