@@ -202,5 +202,80 @@ class report_invoice_created(osv.osv):
|
||||
)""")
|
||||
report_invoice_created()
|
||||
|
||||
class report_account_type_sales(osv.osv):
|
||||
_name = "report.account_type.sales"
|
||||
_description = "Report of the Sales by Account Type"
|
||||
_auto = False
|
||||
_columns = {
|
||||
'name': fields.char('Month', size=64, readonly=True),
|
||||
'period_id': fields.many2one('account.period', 'Force Period',readonly=True),
|
||||
'product_id': fields.many2one('product.product', 'Product',readonly=True),
|
||||
'quantity': fields.float('Quantity', readonly=True),
|
||||
'user_type': fields.many2one('account.account.type', 'Account Type', readonly=True),
|
||||
'amount_total': fields.float('Total', readonly=True),
|
||||
'currency_id': fields.many2one('res.currency', 'Currency', readonly=True),
|
||||
}
|
||||
_order = 'name desc,amount_total desc'
|
||||
|
||||
def init(self, cr):
|
||||
cr.execute("""create or replace view report_account_type_sales as (
|
||||
select
|
||||
min(inv_line.id) as id,
|
||||
to_char(inv.date_invoice, 'YYYY-MM-01') as name,
|
||||
sum(inv_line.price_subtotal) as amount_total,
|
||||
inv.currency_id as currency_id,
|
||||
inv.period_id,
|
||||
inv_line.product_id,
|
||||
sum(inv_line.quantity) as quantity,
|
||||
account.user_type
|
||||
from
|
||||
account_invoice_line inv_line
|
||||
inner join account_invoice inv on inv.id = inv_line.invoice_id
|
||||
inner join account_account account on account.id = inv_line.account_id
|
||||
where
|
||||
inv.state in ('open','paid')
|
||||
group by
|
||||
to_char(inv.date_invoice, 'YYYY-MM-01'),inv.currency_id, inv.period_id, inv_line.product_id, account.user_type
|
||||
)""")
|
||||
report_account_type_sales()
|
||||
|
||||
|
||||
class report_account_sales(osv.osv):
|
||||
_name = "report.account.sales"
|
||||
_description = "Report of the Sales by Account"
|
||||
_auto = False
|
||||
_columns = {
|
||||
'name': fields.char('Month', size=64, readonly=True),
|
||||
'period_id': fields.many2one('account.period', 'Force Period',readonly=True),
|
||||
'product_id': fields.many2one('product.product', 'Product',readonly=True),
|
||||
'quantity': fields.float('Quantity', readonly=True),
|
||||
'account_id': fields.many2one('account.account', 'Account', readonly=True),
|
||||
'amount_total': fields.float('Total', readonly=True),
|
||||
'currency_id': fields.many2one('res.currency', 'Currency', readonly=True),
|
||||
}
|
||||
_order = 'name desc,amount_total desc'
|
||||
|
||||
def init(self, cr):
|
||||
cr.execute("""create or replace view report_account_sales as (
|
||||
select
|
||||
min(inv_line.id) as id,
|
||||
to_char(inv.date_invoice, 'YYYY-MM-01') as name,
|
||||
sum(inv_line.price_subtotal) as amount_total,
|
||||
inv.currency_id as currency_id,
|
||||
inv.period_id,
|
||||
inv_line.product_id,
|
||||
sum(inv_line.quantity) as quantity,
|
||||
account.id as account_id
|
||||
from
|
||||
account_invoice_line inv_line
|
||||
inner join account_invoice inv on inv.id = inv_line.invoice_id
|
||||
inner join account_account account on account.id = inv_line.account_id
|
||||
where
|
||||
inv.state in ('open','paid')
|
||||
group by
|
||||
to_char(inv.date_invoice, 'YYYY-MM-01'),inv.currency_id, inv.period_id, inv_line.product_id, account.id
|
||||
)""")
|
||||
report_account_sales()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
@@ -114,5 +114,107 @@
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="board_view_created_invoice"/>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_report_this_month" name="This Month" parent="account.menu_finance_reporting"/>
|
||||
<menuitem id="menu_report_all_months" name="All Months" parent="account.menu_finance_reporting"/>
|
||||
<!-- Report of the sales by product and account -->
|
||||
<record id="view_report_account_sales_tree" model="ir.ui.view">
|
||||
<field name="name">report.account.sales.tree</field>
|
||||
<field name="model">report.account.sales</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Sales by Account">
|
||||
<field name="name"/>
|
||||
<field name="period_id"/>
|
||||
<field name="product_id"/>
|
||||
<field name="account_id"/>
|
||||
<field name="quantity"/>
|
||||
<field name="amount_total"/>
|
||||
<field name="currency_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_report_account_sales_graph" model="ir.ui.view">
|
||||
<field name="name">report.account.sales.graph</field>
|
||||
<field name="model">report.account.sales</field>
|
||||
<field name="type">graph</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Sales by Account" type="pie">
|
||||
<field name="account_id"/>
|
||||
<field name="amount_total"/>
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_report_account_sales_tree" model="ir.actions.act_window">
|
||||
<field name="name">Sales by Account (this month)</field>
|
||||
<field name="res_model">report.account.sales</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">graph,tree</field>
|
||||
<field name="domain">[('name','=',time.strftime('%Y-%m-01'))]</field>
|
||||
</record>
|
||||
|
||||
<menuitem action="action_report_account_sales_tree" id="menu_report_account_sales" parent="menu_report_this_month"/>
|
||||
|
||||
<record id="action_report_account_sales_tree_all" model="ir.actions.act_window">
|
||||
<field name="name">Sales by Account</field>
|
||||
<field name="res_model">report.account.sales</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">graph,tree</field>
|
||||
</record>
|
||||
<menuitem action="action_report_account_sales_tree_all" id="menu_report_account_sales_all" parent="menu_report_all_months"/>
|
||||
|
||||
|
||||
|
||||
<!-- Report of the sales by product and account type -->
|
||||
<record id="view_report_account_type_sales_tree" model="ir.ui.view">
|
||||
<field name="name">report.account_type.sales.tree</field>
|
||||
<field name="model">report.account_type.sales</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Sales by Account type">
|
||||
<field name="name"/>
|
||||
<field name="period_id"/>
|
||||
<field name="product_id"/>
|
||||
<field name="user_type"/>
|
||||
<field name="quantity"/>
|
||||
<field name="amount_total"/>
|
||||
<field name="currency_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="view_report_account_type_sales_graph" model="ir.ui.view">
|
||||
<field name="name">report.account_type.sales.graph</field>
|
||||
<field name="model">report.account_type.sales</field>
|
||||
<field name="type">graph</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Sales by Account" type="pie">
|
||||
<field name="user_type"/>
|
||||
<field name="amount_total"/>
|
||||
</graph>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_report_account_type_sales_tree" model="ir.actions.act_window">
|
||||
<field name="name">Sales by Account Type (this month)</field>
|
||||
<field name="res_model">report.account_type.sales</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">graph,tree</field>
|
||||
<field name="domain">[('name','=',time.strftime('%Y-%m-01'))]</field>
|
||||
</record>
|
||||
|
||||
<menuitem action="action_report_account_type_sales_tree" id="menu_report_account_type_sales" parent="menu_report_this_month"/>
|
||||
|
||||
<record id="action_report_account_type_sales_tree_all" model="ir.actions.act_window">
|
||||
<field name="name">Sales by Account Type</field>
|
||||
<field name="res_model">report.account_type.sales</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">graph,tree</field>
|
||||
</record>
|
||||
<menuitem action="action_report_account_type_sales_tree_all" id="menu_report_account_type_sales_all" parent="menu_report_all_months"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
Reference in New Issue
Block a user