diff --git a/addons/sale_journal/__init__.py b/addons/sale_journal/__init__.py
index 4cb6588ed18..f846067a3b4 100644
--- a/addons/sale_journal/__init__.py
+++ b/addons/sale_journal/__init__.py
@@ -18,10 +18,8 @@
# along with this program. If not, see .
#
##############################################################################
-
import sale_journal
-import sale_journal_inherit
-import sale_journal_report
-import sale_journal_picking_report
+import report
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/sale_journal/__openerp__.py b/addons/sale_journal/__openerp__.py
index d204d4a3ee5..94d343debb9 100644
--- a/addons/sale_journal/__openerp__.py
+++ b/addons/sale_journal/__openerp__.py
@@ -28,7 +28,7 @@
The sale journal modules allows you to categorise your
sales and deliveries (picking lists) between different journals.
This module is very helpful for bigger companies that
- work by departments.
+ works by departments.
You can use journal for different purposes, some examples:
* isolate sales of different departments
@@ -54,8 +54,7 @@
'update_xml': [
'security/ir.model.access.csv',
'sale_journal_view.xml',
- 'picking_journal_view.xml',
- 'picking_journal_view_report.xml'
+ 'report/sale_journal_report_view.xml',
],
'demo_xml': ['sale_journal_demo.xml'],
'installable': True,
diff --git a/addons/sale_journal/report/__init__.py b/addons/sale_journal/report/__init__.py
new file mode 100644
index 00000000000..0f9b6da35da
--- /dev/null
+++ b/addons/sale_journal/report/__init__.py
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+import sale_journal_report
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
diff --git a/addons/sale_journal/report/sale_journal_report.py b/addons/sale_journal/report/sale_journal_report.py
new file mode 100644
index 00000000000..0607f3be607
--- /dev/null
+++ b/addons/sale_journal/report/sale_journal_report.py
@@ -0,0 +1,141 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2004-2010 Tiny SPRL ().
+#
+# 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 .
+#
+##############################################################################
+
+from osv import fields, osv
+import tools
+
+class sale_journal_report(osv.osv):
+ _name = "sale.journal.report"
+ _description = "Sales Orders by Journal"
+ _auto = False
+ _columns = {
+ 'name': fields.char('Year', size=64, required=False, readonly=True),
+ 'month':fields.selection([('01', 'January'), ('02', 'February'), ('03', 'March'), ('04', 'April'),
+ ('05', 'May'), ('06', 'June'), ('07', 'July'), ('08', 'August'), ('09', 'September'),
+ ('10', 'October'), ('11', 'November'), ('12', 'December')], 'Month', readonly=True),
+ 'state': fields.selection([
+ ('draft', 'Quotation'),
+ ('waiting_date', 'Waiting Schedule'),
+ ('manual', 'Manual in progress'),
+ ('progress', 'In progress'),
+ ('shipping_except', 'Shipping Exception'),
+ ('invoice_except', 'Invoice Exception'),
+ ('done', 'Done'),
+ ('cancel', 'Cancel')
+ ], 'Order State', readonly=True),
+ 'journal_id':fields.many2one('sale_journal.sale.journal', 'Journal', readonly=True),
+ 'quantity': fields.float('Quantities', readonly=True),
+ 'price_total': fields.float('Total Price', readonly=True),
+ 'price_average': fields.float('Average Price', readonly=True),
+ 'count': fields.integer('# of Lines', readonly=True),
+ }
+
+ _order = 'journal_id, name desc,price_total desc'
+
+ def init(self, cr):
+ tools.drop_view_if_exists(cr, 'sale_journal_report')
+ cr.execute("""
+ create or replace view sale_journal_report as (
+ select
+ min(l.id) as id,
+ to_char(s.date_order, 'YYYY') as name,
+ to_char(s.date_order,'MM') as month,
+ s.state,
+ s.journal_id,
+ sum(l.product_uom_qty) as quantity,
+ count(*),
+ sum(l.product_uom_qty*l.price_unit) as price_total,
+ (sum(l.product_uom_qty*l.price_unit)/sum(l.product_uom_qty))::decimal(16,2) as price_average
+ from sale_order s
+ right join sale_order_line l on (s.id=l.order_id)
+ group by s.journal_id , to_char(s.date_order, 'YYYY'),to_char(s.date_order, 'MM'), s.state
+ )
+ """)
+
+sale_journal_report()
+
+#==========================================
+#picking report
+#==========================================
+
+
+class sale_journal_picking_report(osv.osv):
+ """
+ Picking list by journal and by invoice
+ """
+ _name = "sale.journal.picking.report"
+ _description = "Picking lists"
+ _auto = False
+ _columns = {
+ 'name': fields.char('Year', size=64, required=False, readonly=True),
+ 'month':fields.selection([('01', 'January'), ('02', 'February'), ('03', 'March'), ('04', 'April'), ('05', 'May'), ('06', 'June'),
+ ('07', 'July'), ('08', 'August'), ('09', 'September'), ('10', 'October'), ('11', 'November'), ('12', 'December')], 'Month', readonly=True),
+
+ 'invoice_state':fields.selection([
+ ("invoiced", "invoiced"),
+ ("2binvoiced", "to be invoiced"),
+ ("none", "None")
+ ], "Invoice state", readonly=True),
+ 'state': fields.selection([
+ ('draft', 'draft'),
+ ('auto', 'waiting'),
+ ('confirmed', 'confirmed'),
+ ('assigned', 'assigned'),
+ ('done', 'done'),
+ ('cancel', 'cancel'),
+ ], 'State', readonly=True),
+ 'invoice_type_id': fields.many2one('sale_journal.invoice.type', 'Invoicing method', readonly=True),
+ 'journal_id':fields.many2one('sale_journal.picking.journal', 'Journal', readonly=True),
+ 'quantity': fields.float('Quantities', readonly=True),
+ 'price_total': fields.float('Total Price', readonly=True),
+ 'price_average': fields.float('Average Price', readonly=True),
+ 'count': fields.integer('# of Lines', readonly=True),
+ }
+ _order = 'journal_id, name desc, price_total desc'
+
+ def init(self, cr):
+ tools.drop_view_if_exists(cr, 'sale_journal_picking_report')
+
+ cr.execute("""
+ create or replace view sale_journal_picking_report as (
+ select
+ min(l.id) as id,
+ to_char(s.date, 'YYYY') as name,
+ to_char(s.date, 'MM') as month,
+ s.state,
+ s.invoice_state,
+ s.invoice_type_id,
+ s.journal_id,
+ sum(l.product_qty) as quantity,
+ count(*) as count,
+ sum(l.product_qty*ol.price_unit*(1.0-ol.discount/100.0)) as price_total,
+ (sum(l.product_qty*ol.price_unit*(1.0-ol.discount/100.0))/sum(l.product_qty))::decimal(16,2) as price_average
+ from stock_picking s
+ right join stock_move l on (s.id=l.picking_id)
+ left join sale_order_line ol on (l.sale_line_id=ol.id)
+ group by s.journal_id, s.invoice_type_id, to_char(s.date, 'YYYY'),to_char(s.date, 'MM'),s.state, s.invoice_state
+ order by s.invoice_type_id, s.invoice_state, s.state
+ )
+ """)
+
+sale_journal_picking_report()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/sale_journal/report/sale_journal_report_view.xml b/addons/sale_journal/report/sale_journal_report_view.xml
new file mode 100644
index 00000000000..9d4cdf3e368
--- /dev/null
+++ b/addons/sale_journal/report/sale_journal_report_view.xml
@@ -0,0 +1,187 @@
+
+
+
+
+
+
+ sale.journal.report.tree
+ sale.journal.report
+ tree
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ sale.journal.report.graph
+ sale.journal.report
+ graph
+
+
+
+
+
+
+
+
+
+
+
+ sale.journal.report.search
+ sale.journal.report
+ search
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ sale.journal.picking.report.tree
+ sale.journal.picking.report
+ tree
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ sale.journal.picking.report.graph
+ sale.journal.picking.report
+ graph
+
+
+
+
+
+
+
+
+
+
+
+
+ sale.journal.picking.report.search
+ sale.journal.picking.report
+ search
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Statistics on picking to invoice
+ sale.journal.picking.report
+ ir.actions.act_window
+ form
+ tree,form
+ [('invoice_state','=','2binvoiced'),('invoice_type_id','=',active_id)]
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/sale_journal/sale_journal.py b/addons/sale_journal/sale_journal.py
index 4115e969264..ad9b0e656c4 100644
--- a/addons/sale_journal/sale_journal.py
+++ b/addons/sale_journal/sale_journal.py
@@ -25,7 +25,7 @@ import time
class sale_journal_invoice_type(osv.osv):
_name = 'sale_journal.invoice.type'
- _description = 'Invoice Type'
+ _description = 'Invoice Types'
_columns = {
'name': fields.char('Invoice Type', size=64, required=True),
'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the invoice type without removing it."),
diff --git a/addons/sale_journal/sale_journal_view.xml b/addons/sale_journal/sale_journal_view.xml
index c1e415b8833..eba25a2d5aa 100644
--- a/addons/sale_journal/sale_journal_view.xml
+++ b/addons/sale_journal/sale_journal_view.xml
@@ -1,385 +1,472 @@
-
-
- sale_journal.invoice.type.form
- sale_journal.invoice.type
- form
-
-
-
-
-
- sale_journal.invoice.type.tree
- sale_journal.invoice.type
- tree
-
-
-
-
-
-
-
-
- sale_journal.invoice.type
- form
- tree,form
-
-
-
-
-
- sale_journal.sale.journal.form
- sale_journal.sale.journal
- form
-
-
-
-
-
- sale_journal.sale.journal.tree
- sale_journal.sale.journal
- tree
-
-
-
-
-
-
-
-
-
-
-
-
- sale_journal.sale.journal.search
- sale_journal.sale.journal
- search
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- sale_journal.sale.journal
- form
- tree,form
- {"search_default_user_id":uid}
-
-
-
-
-
-
-
-
- sale.order.journal.view.form
- form
- sale.order
-
-
-
-
-
-
-
-
-
- sale.order.journal.view.tree
- tree
- sale.order
-
-
-
-
-
-
-
-
-
-
- stock.picking.journal.view.form
- form
- stock.picking
-
-
-
-
-
-
-
-
-
-
-
- stock.picking.journal.view.tree
- tree
- stock.picking
-
-
-
-
-
-
-
-
-
-
-
- stock.picking.journal.view.form
- form
- stock.picking
-
-
-
-
-
-
-
-
-
-
-
- stock.picking.journal.view.tree
- tree
- stock.picking
-
-
-
-
-
-
-
-
-
-
-
-
- stock.picking.journal.view.form
- form
- stock.picking
-
-
-
-
-
-
-
-
-
-
-
- stock.picking.journal.view.tree
- tree
- stock.picking
-
-
-
-
-
-
-
-
-
-
-
-
- stock.picking.journal.view.form
- form
- stock.picking
-
-
-
-
-
-
-
-
-
-
-
- stock.picking.journal.view.tree
- tree
- stock.picking
-
-
-
-
-
-
-
-
-
-
-
-
-
- sale_journal.sale.stats.tree
- sale_journal.sale.stats
- tree
-
-
-
-
-
-
-
-
-
-
-
-
-
- sale_journal.sale.stats.form
- sale_journal.sale.stats
- form
-
-
-
-
-
-
- sale_journal.sale.stats.search
- sale_journal.sale.stats
- search
-
-
-
-
-
-
+
+
+
+
+
+ sale_journal.invoice.type.form
+ sale_journal.invoice.type
+ form
+
+
+
+
+
+
+
+
+ sale_journal.invoice.type.tree
+ sale_journal.invoice.type
+ tree
+
+
+
+
+
+
+
+
+
+
+ sale_journal.invoice.type
+ form
+ tree,form
+
+
+
+
+
+
+
+ sale_journal.sale.journal.form
+ sale_journal.sale.journal
+ form
+
+
+
+
+
+
+
+
+ sale_journal.sale.journal.tree
+ sale_journal.sale.journal
+ tree
+
+
+
+
+
+
+
+
+
+
+
+
+
+ sale_journal.sale.journal.search
+ sale_journal.sale.journal
+ search
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ sale_journal.sale.journal
+ form
+ tree,form
+
+
+
+
+
+
+
+
+ sale.order.journal.view.form
+ form
+ sale.order
+
+
+
+
+
+
+
+
+
+
+
+
+
+ sale.order.journal.view.tree
+ tree
+ sale.order
+
+
+
+
-
-
-
-
+
+
+
-
+
+
+
+ stock.picking.journal.view.form
+ form
+ stock.picking
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+ stock.picking.journal.view.tree
+ tree
+ stock.picking
+
+
+
+
+
+
+
+
+
+
+
+
+
+ stock.picking.journal.view.form
+ form
+ stock.picking
+
+
+
+
+
+
+
+
+
+
+
+
+
+ stock.picking.journal.view.tree
+ tree
+ stock.picking
+
+
+
+
+
+
+
+
+
+
+
+ stock.picking.journal.view.form
+ form
+ stock.picking
+
+
+
+
+
+
+
+
+
+
+
+ stock.picking.journal.view.tree
+ tree
+ stock.picking
+
+
+
+
+
+
+
+
+
+
+
+ stock.picking.journal.view.form
+ form
+ stock.picking
+
+
+
+
+
+
+
+
+
+
+
+ stock.picking.journal.view.tree
+ tree
+ stock.picking
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+ res.partner.journal.property.form.inherit
+ res.partner
+ form
+
+
+
+
+
+
+
+
+
+
+
+
+
+ sale_journal.picking.journal.form
+ sale_journal.picking.journal
+ form
+
+
+
+
+
+
+ sale_journal.picking.journal.tree
+ sale_journal.picking.journal
+ tree
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+ sale_journal.picking.journal.search
+ sale_journal.picking.journal
+ search
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Picking Journals
+ sale_journal.picking.journal
+ form
+ tree,form
+
+
+
+
+
+
+ Picking by invoice_method
+ sale_journal.invoice.type
+ ir.actions.act_window
+ tree
+
+
+
+ Picking to invoice
+ stock.picking
+ ir.actions.act_window
+ form
+ tree,form
+ [('state','=','done'),('invoice_state','=','2binvoiced'),('invoice_type_id','=',active_id)]
+
+
+
+ tree_but_open
+ sale_journal.invoice.type
+ Picking to invoice
+
+
+
-
-
-
-
-
-
-
- res.partner.journal.property.form.inherit
- res.partner
- form
-
-
-
-
-
-
-
-
-
-
+