12.1.4
by openerp
[IMP] Sale Report - Adding Field Sequence to view in Sale Order Line - Add Diff to be applied in all Servers to use without errors |
1 |
=== modified file 'hr_timesheet_invoice/report/report_analytic.py'
|
2 |
--- hr_timesheet_invoice/report/report_analytic.py 2011-01-14 00:11:01 +0000
|
|
3 |
+++ hr_timesheet_invoice/report/report_analytic.py 2011-07-24 15:57:23 +0000
|
|
4 |
@@ -66,45 +66,45 @@
|
|
5 |
_name = "report.account.analytic.line.to.invoice" |
|
6 |
_description = "Analytic lines to invoice report" |
|
7 |
_auto = False |
|
8 |
- _columns = {
|
|
9 |
- 'name': fields.char('Year',size=64,required=False, readonly=True),
|
|
10 |
- 'product_id':fields.many2one('product.product', 'Product', readonly=True),
|
|
11 |
- 'account_id':fields.many2one('account.analytic.account', 'Analytic account', readonly=True),
|
|
12 |
- 'product_uom_id':fields.many2one('product.uom', 'UoM', readonly=True),
|
|
13 |
- 'unit_amount': fields.float('Units', readonly=True),
|
|
14 |
- 'sale_price': fields.float('Sale price', readonly=True, digits_compute=dp.get_precision('Sale Price')),
|
|
15 |
- 'amount': fields.float('Amount', readonly=True, digits_compute=dp.get_precision('Account')),
|
|
16 |
- 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), ('05','May'), ('06','June'),
|
|
17 |
- ('07','July'), ('08','August'), ('09','September'), ('10','October'), ('11','November'), ('12','December')],'Month',readonly=True),
|
|
18 |
- }
|
|
19 |
- _order = 'name desc, product_id asc, account_id asc'
|
|
20 |
+# _columns = {
|
|
21 |
+# 'name': fields.char('Year',size=64,required=False, readonly=True),
|
|
22 |
+# 'product_id':fields.many2one('product.product', 'Product', readonly=True),
|
|
23 |
+# 'account_id':fields.many2one('account.analytic.account', 'Analytic account', readonly=True),
|
|
24 |
+# 'product_uom_id':fields.many2one('product.uom', 'UoM', readonly=True),
|
|
25 |
+# 'unit_amount': fields.float('Units', readonly=True),
|
|
26 |
+# 'sale_price': fields.float('Sale price', readonly=True, digits_compute=dp.get_precision('Sale Price')),
|
|
27 |
+# 'amount': fields.float('Amount', readonly=True, digits_compute=dp.get_precision('Account')),
|
|
28 |
+# 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), ('05','May'), ('06','June'),
|
|
29 |
+# ('07','July'), ('08','August'), ('09','September'), ('10','October'), ('11','November'), ('12','December')],'Month',readonly=True),
|
|
30 |
+# }
|
|
31 |
+# _order = 'name desc, product_id asc, account_id asc'
|
|
32 |
||
33 |
- def init(self, cr):
|
|
34 |
- tools.drop_view_if_exists(cr, 'report_account_analytic_line_to_invoice')
|
|
35 |
- cr.execute("""
|
|
36 |
- CREATE OR REPLACE VIEW report_account_analytic_line_to_invoice AS (
|
|
37 |
- SELECT
|
|
38 |
- DISTINCT(to_char(l.date,'MM')) as month,
|
|
39 |
- to_char(l.date, 'YYYY') as name,
|
|
40 |
- MIN(l.id) AS id,
|
|
41 |
- l.product_id,
|
|
42 |
- l.account_id,
|
|
43 |
- SUM(l.amount) AS amount,
|
|
44 |
- SUM(l.unit_amount*t.list_price) AS sale_price,
|
|
45 |
- SUM(l.unit_amount) AS unit_amount,
|
|
46 |
- l.product_uom_id
|
|
47 |
- FROM
|
|
48 |
- account_analytic_line l
|
|
49 |
- left join
|
|
50 |
- product_product p on (l.product_id=p.id)
|
|
51 |
- left join
|
|
52 |
- product_template t on (p.product_tmpl_id=t.id)
|
|
53 |
- WHERE
|
|
54 |
- (invoice_id IS NULL) and (to_invoice IS NOT NULL)
|
|
55 |
- GROUP BY
|
|
56 |
- to_char(l.date, 'YYYY'), to_char(l.date,'MM'), product_id, product_uom_id, account_id
|
|
57 |
- )
|
|
58 |
- """)
|
|
59 |
+# def init(self, cr):
|
|
60 |
+# tools.drop_view_if_exists(cr, 'report_account_analytic_line_to_invoice')
|
|
61 |
+# cr.execute("""
|
|
62 |
+# CREATE OR REPLACE VIEW report_account_analytic_line_to_invoice AS (
|
|
63 |
+# SELECT
|
|
64 |
+# DISTINCT(to_char(l.date,'MM')) as month,
|
|
65 |
+# to_char(l.date, 'YYYY') as name,
|
|
66 |
+# MIN(l.id) AS id,
|
|
67 |
+# l.product_id,
|
|
68 |
+# l.account_id,
|
|
69 |
+# SUM(l.amount) AS amount,
|
|
70 |
+# SUM(l.unit_amount*t.list_price) AS sale_price,
|
|
71 |
+# SUM(l.unit_amount) AS unit_amount,
|
|
72 |
+# l.product_uom_id
|
|
73 |
+# FROM
|
|
74 |
+# account_analytic_line l
|
|
75 |
+# left join
|
|
76 |
+# product_product p on (l.product_id=p.id)
|
|
77 |
+# left join
|
|
78 |
+# product_template t on (p.product_tmpl_id=t.id)
|
|
79 |
+# WHERE
|
|
80 |
+# (invoice_id IS NULL) and (to_invoice IS NOT NULL)
|
|
81 |
+# GROUP BY
|
|
82 |
+# to_char(l.date, 'YYYY'), to_char(l.date,'MM'), product_id, product_uom_id, account_id
|
|
83 |
+# )
|
|
84 |
+# """)
|
|
85 |
report_account_analytic_line_to_invoice() |
|
86 |
||
87 |
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
|
88 |
||
89 |
=== modified file 'stock/report/report_stock_move.py'
|
|
90 |
--- stock/report/report_stock_move.py 2011-05-03 09:57:42 +0000
|
|
91 |
+++ stock/report/report_stock_move.py 2011-07-24 15:39:14 +0000
|
|
92 |
@@ -1,23 +1,23 @@
|
|
93 |
-# -*- coding: utf-8 -*-
|
|
94 |
-##############################################################################
|
|
95 |
-#
|
|
96 |
-# OpenERP, Open Source Management Solution
|
|
97 |
-# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
|
98 |
-#
|
|
99 |
-# This program is free software: you can redistribute it and/or modify
|
|
100 |
-# it under the terms of the GNU Affero General Public License as
|
|
101 |
-# published by the Free Software Foundation, either version 3 of the
|
|
102 |
-# License, or (at your option) any later version.
|
|
103 |
-#
|
|
104 |
-# This program is distributed in the hope that it will be useful,
|
|
105 |
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
106 |
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
107 |
-# GNU Affero General Public License for more details.
|
|
108 |
-#
|
|
109 |
-# You should have received a copy of the GNU Affero General Public License
|
|
110 |
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
111 |
-#
|
|
112 |
-##############################################################################
|
|
113 |
+## -*- coding: utf-8 -*-
|
|
114 |
+###############################################################################
|
|
115 |
+##
|
|
116 |
+## OpenERP, Open Source Management Solution
|
|
117 |
+## Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
|
118 |
+##
|
|
119 |
+## This program is free software: you can redistribute it and/or modify
|
|
120 |
+## it under the terms of the GNU Affero General Public License as
|
|
121 |
+## published by the Free Software Foundation, either version 3 of the
|
|
122 |
+## License, or (at your option) any later version.
|
|
123 |
+##
|
|
124 |
+## This program is distributed in the hope that it will be useful,
|
|
125 |
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
126 |
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
127 |
+## GNU Affero General Public License for more details.
|
|
128 |
+##
|
|
129 |
+## You should have received a copy of the GNU Affero General Public License
|
|
130 |
+## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
131 |
+##
|
|
132 |
+###############################################################################
|
|
133 |
||
134 |
import tools |
|
135 |
from osv import fields,osv |
|
136 |
@@ -28,121 +28,121 @@
|
|
137 |
_name = "report.stock.move" |
|
138 |
_description = "Moves Statistics" |
|
139 |
_auto = False |
|
140 |
- _columns = {
|
|
141 |
- 'date': fields.date('Date', readonly=True),
|
|
142 |
- 'year': fields.char('Year', size=4, readonly=True),
|
|
143 |
- 'day': fields.char('Day', size=128, readonly=True),
|
|
144 |
- 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'),
|
|
145 |
- ('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'),
|
|
146 |
- ('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True),
|
|
147 |
- 'partner_id':fields.many2one('res.partner.address', 'Partner', readonly=True),
|
|
148 |
- 'product_id':fields.many2one('product.product', 'Product', readonly=True),
|
|
149 |
- 'company_id':fields.many2one('res.company', 'Company', readonly=True),
|
|
150 |
- 'picking_id':fields.many2one('stock.picking', 'Packing', readonly=True),
|
|
151 |
- 'type': fields.selection([('out', 'Sending Goods'), ('in', 'Getting Goods'), ('internal', 'Internal'), ('other', 'Others')], 'Shipping Type', required=True, select=True, help="Shipping type specify, goods coming in or going out."),
|
|
152 |
- 'location_id': fields.many2one('stock.location', 'Source Location', readonly=True, select=True, help="Sets a location if you produce at a fixed location. This can be a partner location if you subcontract the manufacturing operations."),
|
|
153 |
- 'location_dest_id': fields.many2one('stock.location', 'Dest. Location', readonly=True, select=True, help="Location where the system will stock the finished products."),
|
|
154 |
- 'state': fields.selection([('draft', 'Draft'), ('waiting', 'Waiting'), ('confirmed', 'Confirmed'), ('assigned', 'Available'), ('done', 'Done'), ('cancel', 'Cancelled')], 'State', readonly=True, select=True),
|
|
155 |
- 'product_qty':fields.integer('Quantity',readonly=True),
|
|
156 |
- 'categ_id': fields.many2one('product.category', 'Product Category', ),
|
|
157 |
- 'product_qty_in':fields.integer('In Qty',readonly=True),
|
|
158 |
- 'product_qty_out':fields.integer('Out Qty',readonly=True),
|
|
159 |
- 'value' : fields.float('Total Value', required=True),
|
|
160 |
- 'day_diff2':fields.float('Lag (Days)',readonly=True, digits_compute=dp.get_precision('Shipping Delay'), group_operator="avg"),
|
|
161 |
- 'day_diff1':fields.float('Planned Lead Time (Days)',readonly=True, digits_compute=dp.get_precision('Shipping Delay'), group_operator="avg"),
|
|
162 |
- 'day_diff':fields.float('Execution Lead Time (Days)',readonly=True, digits_compute=dp.get_precision('Shipping Delay'), group_operator="avg"),
|
|
163 |
- 'stock_journal': fields.many2one('stock.journal','Stock Journal', select=True),
|
|
164 |
-
|
|
165 |
-
|
|
166 |
- }
|
|
167 |
-
|
|
168 |
- def init(self, cr):
|
|
169 |
- tools.drop_view_if_exists(cr, 'report_stock_move')
|
|
170 |
- cr.execute("""
|
|
171 |
- CREATE OR REPLACE view report_stock_move AS (
|
|
172 |
- SELECT
|
|
173 |
- min(sm_id) as id,
|
|
174 |
- date_trunc('day',al.dp) as date,
|
|
175 |
- al.curr_year as year,
|
|
176 |
- al.curr_month as month,
|
|
177 |
- al.curr_day as day,
|
|
178 |
- al.curr_day_diff as day_diff,
|
|
179 |
- al.curr_day_diff1 as day_diff1,
|
|
180 |
- al.curr_day_diff2 as day_diff2,
|
|
181 |
- al.location_id as location_id,
|
|
182 |
- al.picking_id as picking_id,
|
|
183 |
- al.company_id as company_id,
|
|
184 |
- al.location_dest_id as location_dest_id,
|
|
185 |
- al.product_qty,
|
|
186 |
- al.out_qty as product_qty_out,
|
|
187 |
- al.in_qty as product_qty_in,
|
|
188 |
- al.address_id as partner_id,
|
|
189 |
- al.product_id as product_id,
|
|
190 |
- al.state as state ,
|
|
191 |
- al.product_uom as product_uom,
|
|
192 |
- al.categ_id as categ_id,
|
|
193 |
- coalesce(al.type, 'other') as type,
|
|
194 |
- al.stock_journal as stock_journal,
|
|
195 |
- sum(al.in_value - al.out_value) as value
|
|
196 |
- FROM (SELECT
|
|
197 |
- CASE WHEN sp.type in ('out') THEN
|
|
198 |
- sum(sm.product_qty * pu.factor)
|
|
199 |
- ELSE 0.0
|
|
200 |
- END AS out_qty,
|
|
201 |
- CASE WHEN sp.type in ('in') THEN
|
|
202 |
- sum(sm.product_qty * pu.factor)
|
|
203 |
- ELSE 0.0
|
|
204 |
- END AS in_qty,
|
|
205 |
- CASE WHEN sp.type in ('out') THEN
|
|
206 |
- sum(sm.product_qty * pu.factor) * pt.standard_price
|
|
207 |
- ELSE 0.0
|
|
208 |
- END AS out_value,
|
|
209 |
- CASE WHEN sp.type in ('in') THEN
|
|
210 |
- sum(sm.product_qty * pu.factor) * pt.standard_price
|
|
211 |
- ELSE 0.0
|
|
212 |
- END AS in_value,
|
|
213 |
- min(sm.id) as sm_id,
|
|
214 |
- sm.date as dp,
|
|
215 |
- to_char(date_trunc('day',sm.date), 'YYYY') as curr_year,
|
|
216 |
- to_char(date_trunc('day',sm.date), 'MM') as curr_month,
|
|
217 |
- to_char(date_trunc('day',sm.date), 'YYYY-MM-DD') as curr_day,
|
|
218 |
- avg(date(sm.date)-date(sm.create_date)) as curr_day_diff,
|
|
219 |
- avg(date(sm.date_expected)-date(sm.create_date)) as curr_day_diff1,
|
|
220 |
- avg(date(sm.date)-date(sm.date_expected)) as curr_day_diff2,
|
|
221 |
- sm.location_id as location_id,
|
|
222 |
- sm.location_dest_id as location_dest_id,
|
|
223 |
- sum(sm.product_qty) as product_qty,
|
|
224 |
- pt.categ_id as categ_id ,
|
|
225 |
- sm.address_id as address_id,
|
|
226 |
- sm.product_id as product_id,
|
|
227 |
- sm.picking_id as picking_id,
|
|
228 |
- sm.company_id as company_id,
|
|
229 |
- sm.state as state,
|
|
230 |
- sm.product_uom as product_uom,
|
|
231 |
- sp.type as type,
|
|
232 |
- sp.stock_journal_id AS stock_journal
|
|
233 |
- FROM
|
|
234 |
- stock_move sm
|
|
235 |
- LEFT JOIN stock_picking sp ON (sm.picking_id=sp.id)
|
|
236 |
- LEFT JOIN product_product pp ON (sm.product_id=pp.id)
|
|
237 |
- LEFT JOIN product_uom pu ON (sm.product_uom=pu.id)
|
|
238 |
- LEFT JOIN product_template pt ON (pp.product_tmpl_id=pt.id)
|
|
239 |
- LEFT JOIN stock_location sl ON (sm.location_id = sl.id)
|
|
240 |
-
|
|
241 |
- GROUP BY
|
|
242 |
- sm.id,sp.type, sm.date,sm.address_id,
|
|
243 |
- sm.product_id,sm.state,sm.product_uom,sm.date_expected,
|
|
244 |
- sm.product_id,pt.standard_price, sm.picking_id, sm.product_qty,
|
|
245 |
- sm.company_id,sm.product_qty, sm.location_id,sm.location_dest_id,pu.factor,pt.categ_id, sp.stock_journal_id)
|
|
246 |
- AS al
|
|
247 |
-
|
|
248 |
- GROUP BY
|
|
249 |
- al.out_qty,al.in_qty,al.curr_year,al.curr_month,
|
|
250 |
- al.curr_day,al.curr_day_diff,al.curr_day_diff1,al.curr_day_diff2,al.dp,al.location_id,al.location_dest_id,
|
|
251 |
- al.address_id,al.product_id,al.state,al.product_uom,
|
|
252 |
- al.picking_id,al.company_id,al.type,al.product_qty, al.categ_id, al.stock_journal
|
|
253 |
- )
|
|
254 |
- """)
|
|
255 |
+# _columns = {
|
|
256 |
+# 'date': fields.date('Date', readonly=True),
|
|
257 |
+# 'year': fields.char('Year', size=4, readonly=True),
|
|
258 |
+# 'day': fields.char('Day', size=128, readonly=True),
|
|
259 |
+# 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'),
|
|
260 |
+# ('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'),
|
|
261 |
+# ('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True),
|
|
262 |
+# 'partner_id':fields.many2one('res.partner.address', 'Partner', readonly=True),
|
|
263 |
+# 'product_id':fields.many2one('product.product', 'Product', readonly=True),
|
|
264 |
+# 'company_id':fields.many2one('res.company', 'Company', readonly=True),
|
|
265 |
+# 'picking_id':fields.many2one('stock.picking', 'Packing', readonly=True),
|
|
266 |
+# 'type': fields.selection([('out', 'Sending Goods'), ('in', 'Getting Goods'), ('internal', 'Internal'), ('other', 'Others')], 'Shipping Type', required=True, select=True, help="Shipping type specify, goods coming in or going out."),
|
|
267 |
+# 'location_id': fields.many2one('stock.location', 'Source Location', readonly=True, select=True, help="Sets a location if you produce at a fixed location. This can be a partner location if you subcontract the manufacturing operations."),
|
|
268 |
+# 'location_dest_id': fields.many2one('stock.location', 'Dest. Location', readonly=True, select=True, help="Location where the system will stock the finished products."),
|
|
269 |
+# 'state': fields.selection([('draft', 'Draft'), ('waiting', 'Waiting'), ('confirmed', 'Confirmed'), ('assigned', 'Available'), ('done', 'Done'), ('cancel', 'Cancelled')], 'State', readonly=True, select=True),
|
|
270 |
+# 'product_qty':fields.integer('Quantity',readonly=True),
|
|
271 |
+# 'categ_id': fields.many2one('product.category', 'Product Category', ),
|
|
272 |
+# 'product_qty_in':fields.integer('In Qty',readonly=True),
|
|
273 |
+# 'product_qty_out':fields.integer('Out Qty',readonly=True),
|
|
274 |
+# 'value' : fields.float('Total Value', required=True),
|
|
275 |
+# 'day_diff2':fields.float('Lag (Days)',readonly=True, digits_compute=dp.get_precision('Shipping Delay'), group_operator="avg"),
|
|
276 |
+# 'day_diff1':fields.float('Planned Lead Time (Days)',readonly=True, digits_compute=dp.get_precision('Shipping Delay'), group_operator="avg"),
|
|
277 |
+# 'day_diff':fields.float('Execution Lead Time (Days)',readonly=True, digits_compute=dp.get_precision('Shipping Delay'), group_operator="avg"),
|
|
278 |
+# 'stock_journal': fields.many2one('stock.journal','Stock Journal', select=True),
|
|
279 |
+
|
|
280 |
+
|
|
281 |
+# }
|
|
282 |
+
|
|
283 |
+# def init(self, cr):
|
|
284 |
+# tools.drop_view_if_exists(cr, 'report_stock_move')
|
|
285 |
+# cr.execute("""
|
|
286 |
+# CREATE OR REPLACE view report_stock_move AS (
|
|
287 |
+# SELECT
|
|
288 |
+# min(sm_id) as id,
|
|
289 |
+# date_trunc('day',al.dp) as date,
|
|
290 |
+# al.curr_year as year,
|
|
291 |
+# al.curr_month as month,
|
|
292 |
+# al.curr_day as day,
|
|
293 |
+# al.curr_day_diff as day_diff,
|
|
294 |
+# al.curr_day_diff1 as day_diff1,
|
|
295 |
+# al.curr_day_diff2 as day_diff2,
|
|
296 |
+# al.location_id as location_id,
|
|
297 |
+# al.picking_id as picking_id,
|
|
298 |
+# al.company_id as company_id,
|
|
299 |
+# al.location_dest_id as location_dest_id,
|
|
300 |
+# al.product_qty,
|
|
301 |
+# al.out_qty as product_qty_out,
|
|
302 |
+# al.in_qty as product_qty_in,
|
|
303 |
+# al.address_id as partner_id,
|
|
304 |
+# al.product_id as product_id,
|
|
305 |
+# al.state as state ,
|
|
306 |
+# al.product_uom as product_uom,
|
|
307 |
+# al.categ_id as categ_id,
|
|
308 |
+# coalesce(al.type, 'other') as type,
|
|
309 |
+# al.stock_journal as stock_journal,
|
|
310 |
+# sum(al.in_value - al.out_value) as value
|
|
311 |
+# FROM (SELECT
|
|
312 |
+# CASE WHEN sp.type in ('out') THEN
|
|
313 |
+# sum(sm.product_qty * pu.factor)
|
|
314 |
+# ELSE 0.0
|
|
315 |
+# END AS out_qty,
|
|
316 |
+# CASE WHEN sp.type in ('in') THEN
|
|
317 |
+# sum(sm.product_qty * pu.factor)
|
|
318 |
+# ELSE 0.0
|
|
319 |
+# END AS in_qty,
|
|
320 |
+# CASE WHEN sp.type in ('out') THEN
|
|
321 |
+# sum(sm.product_qty * pu.factor) * pt.standard_price
|
|
322 |
+# ELSE 0.0
|
|
323 |
+# END AS out_value,
|
|
324 |
+# CASE WHEN sp.type in ('in') THEN
|
|
325 |
+# sum(sm.product_qty * pu.factor) * pt.standard_price
|
|
326 |
+# ELSE 0.0
|
|
327 |
+# END AS in_value,
|
|
328 |
+# min(sm.id) as sm_id,
|
|
329 |
+# sm.date as dp,
|
|
330 |
+# to_char(date_trunc('day',sm.date), 'YYYY') as curr_year,
|
|
331 |
+# to_char(date_trunc('day',sm.date), 'MM') as curr_month,
|
|
332 |
+# to_char(date_trunc('day',sm.date), 'YYYY-MM-DD') as curr_day,
|
|
333 |
+# avg(date(sm.date)-date(sm.create_date)) as curr_day_diff,
|
|
334 |
+# avg(date(sm.date_expected)-date(sm.create_date)) as curr_day_diff1,
|
|
335 |
+# avg(date(sm.date)-date(sm.date_expected)) as curr_day_diff2,
|
|
336 |
+# sm.location_id as location_id,
|
|
337 |
+# sm.location_dest_id as location_dest_id,
|
|
338 |
+# sum(sm.product_qty) as product_qty,
|
|
339 |
+# pt.categ_id as categ_id ,
|
|
340 |
+# sm.address_id as address_id,
|
|
341 |
+# sm.product_id as product_id,
|
|
342 |
+# sm.picking_id as picking_id,
|
|
343 |
+# sm.company_id as company_id,
|
|
344 |
+# sm.state as state,
|
|
345 |
+# sm.product_uom as product_uom,
|
|
346 |
+# sp.type as type,
|
|
347 |
+# sp.stock_journal_id AS stock_journal
|
|
348 |
+# FROM
|
|
349 |
+# stock_move sm
|
|
350 |
+# LEFT JOIN stock_picking sp ON (sm.picking_id=sp.id)
|
|
351 |
+# LEFT JOIN product_product pp ON (sm.product_id=pp.id)
|
|
352 |
+# LEFT JOIN product_uom pu ON (sm.product_uom=pu.id)
|
|
353 |
+# LEFT JOIN product_template pt ON (pp.product_tmpl_id=pt.id)
|
|
354 |
+# LEFT JOIN stock_location sl ON (sm.location_id = sl.id)
|
|
355 |
+
|
|
356 |
+# GROUP BY
|
|
357 |
+# sm.id,sp.type, sm.date,sm.address_id,
|
|
358 |
+# sm.product_id,sm.state,sm.product_uom,sm.date_expected,
|
|
359 |
+# sm.product_id,pt.standard_price, sm.picking_id, sm.product_qty,
|
|
360 |
+# sm.company_id,sm.product_qty, sm.location_id,sm.location_dest_id,pu.factor,pt.categ_id, sp.stock_journal_id)
|
|
361 |
+# AS al
|
|
362 |
+
|
|
363 |
+# GROUP BY
|
|
364 |
+# al.out_qty,al.in_qty,al.curr_year,al.curr_month,
|
|
365 |
+# al.curr_day,al.curr_day_diff,al.curr_day_diff1,al.curr_day_diff2,al.dp,al.location_id,al.location_dest_id,
|
|
366 |
+# al.address_id,al.product_id,al.state,al.product_uom,
|
|
367 |
+# al.picking_id,al.company_id,al.type,al.product_qty, al.categ_id, al.stock_journal
|
|
368 |
+# )
|
|
369 |
+# """)
|
|
370 |
||
371 |
report_stock_move() |
|
372 |
||
373 |
@@ -151,75 +151,75 @@
|
|
374 |
_name = "report.stock.inventory" |
|
375 |
_description = "Stock Statistics" |
|
376 |
_auto = False |
|
377 |
- _columns = {
|
|
378 |
- 'date': fields.datetime('Date', readonly=True),
|
|
379 |
- 'partner_id':fields.many2one('res.partner.address', 'Partner', readonly=True),
|
|
380 |
- 'product_id':fields.many2one('product.product', 'Product', readonly=True),
|
|
381 |
- 'product_categ_id':fields.many2one('product.category', 'Product Category', readonly=True),
|
|
382 |
- 'location_id': fields.many2one('stock.location', 'Location', readonly=True),
|
|
383 |
- 'prodlot_id': fields.many2one('stock.production.lot', 'Lot', readonly=True),
|
|
384 |
- 'company_id': fields.many2one('res.company', 'Company', readonly=True),
|
|
385 |
- 'product_qty':fields.float('Quantity', digits_compute=dp.get_precision('Product UoM'), readonly=True),
|
|
386 |
- 'value' : fields.float('Total Value', digits_compute=dp.get_precision('Account'), required=True),
|
|
387 |
- 'state': fields.selection([('draft', 'Draft'), ('waiting', 'Waiting'), ('confirmed', 'Confirmed'), ('assigned', 'Available'), ('done', 'Done'), ('cancel', 'Cancelled')], 'State', readonly=True, select=True,
|
|
388 |
- help='When the stock move is created it is in the \'Draft\' state.\n After that it is set to \'Confirmed\' state.\n If stock is available state is set to \'Avaiable\'.\n When the picking it done the state is \'Done\'.\
|
|
389 |
- \nThe state is \'Waiting\' if the move is waiting for another one.'),
|
|
390 |
- 'location_type': fields.selection([('supplier', 'Supplier Location'), ('view', 'View'), ('internal', 'Internal Location'), ('customer', 'Customer Location'), ('inventory', 'Inventory'), ('procurement', 'Procurement'), ('production', 'Production'), ('transit', 'Transit Location for Inter-Companies Transfers')], 'Location Type', required=True),
|
|
391 |
- }
|
|
392 |
- def init(self, cr):
|
|
393 |
- tools.drop_view_if_exists(cr, 'report_stock_inventory')
|
|
394 |
- cr.execute("""
|
|
395 |
-CREATE OR REPLACE view report_stock_inventory AS (
|
|
396 |
- (SELECT
|
|
397 |
- min(m.id) as id, m.date as date,
|
|
398 |
- m.address_id as partner_id, m.location_id as location_id,
|
|
399 |
- m.product_id as product_id, pt.categ_id as product_categ_id, l.usage as location_type,
|
|
400 |
- m.company_id,
|
|
401 |
- m.state as state, m.prodlot_id as prodlot_id,
|
|
402 |
- coalesce(sum(-pt.standard_price * m.product_qty)::decimal, 0.0) as value,
|
|
403 |
- CASE when pt.uom_id = m.product_uom
|
|
404 |
- THEN
|
|
405 |
- coalesce(sum(-m.product_qty)::decimal, 0.0)
|
|
406 |
- ELSE
|
|
407 |
- coalesce(sum(-m.product_qty * pu.factor)::decimal, 0.0) END as product_qty
|
|
408 |
- FROM
|
|
409 |
- stock_move m
|
|
410 |
- LEFT JOIN stock_picking p ON (m.picking_id=p.id)
|
|
411 |
- LEFT JOIN product_product pp ON (m.product_id=pp.id)
|
|
412 |
- LEFT JOIN product_template pt ON (pp.product_tmpl_id=pt.id)
|
|
413 |
- LEFT JOIN product_uom pu ON (pt.uom_id=pu.id)
|
|
414 |
- LEFT JOIN product_uom u ON (m.product_uom=u.id)
|
|
415 |
- LEFT JOIN stock_location l ON (m.location_id=l.id)
|
|
416 |
- GROUP BY
|
|
417 |
- m.id, m.product_id, m.product_uom, pt.categ_id, m.address_id, m.location_id, m.location_dest_id,
|
|
418 |
- m.prodlot_id, m.date, m.state, l.usage, m.company_id,pt.uom_id
|
|
419 |
-) UNION ALL (
|
|
420 |
- SELECT
|
|
421 |
- -m.id as id, m.date as date,
|
|
422 |
- m.address_id as partner_id, m.location_dest_id as location_id,
|
|
423 |
- m.product_id as product_id, pt.categ_id as product_categ_id, l.usage as location_type,
|
|
424 |
- m.company_id,
|
|
425 |
- m.state as state, m.prodlot_id as prodlot_id,
|
|
426 |
- coalesce(sum(pt.standard_price * m.product_qty )::decimal, 0.0) as value,
|
|
427 |
- CASE when pt.uom_id = m.product_uom
|
|
428 |
- THEN
|
|
429 |
- coalesce(sum(m.product_qty)::decimal, 0.0)
|
|
430 |
- ELSE
|
|
431 |
- coalesce(sum(m.product_qty * pu.factor)::decimal, 0.0) END as product_qty
|
|
432 |
- FROM
|
|
433 |
- stock_move m
|
|
434 |
- LEFT JOIN stock_picking p ON (m.picking_id=p.id)
|
|
435 |
- LEFT JOIN product_product pp ON (m.product_id=pp.id)
|
|
436 |
- LEFT JOIN product_template pt ON (pp.product_tmpl_id=pt.id)
|
|
437 |
- LEFT JOIN product_uom pu ON (pt.uom_id=pu.id)
|
|
438 |
- LEFT JOIN product_uom u ON (m.product_uom=u.id)
|
|
439 |
- LEFT JOIN stock_location l ON (m.location_dest_id=l.id)
|
|
440 |
- GROUP BY
|
|
441 |
- m.id, m.product_id, m.product_uom, pt.categ_id, m.address_id, m.location_id, m.location_dest_id,
|
|
442 |
- m.prodlot_id, m.date, m.state, l.usage, m.company_id,pt.uom_id
|
|
443 |
- )
|
|
444 |
-);
|
|
445 |
- """)
|
|
446 |
+# _columns = {
|
|
447 |
+# 'date': fields.datetime('Date', readonly=True),
|
|
448 |
+# 'partner_id':fields.many2one('res.partner.address', 'Partner', readonly=True),
|
|
449 |
+# 'product_id':fields.many2one('product.product', 'Product', readonly=True),
|
|
450 |
+# 'product_categ_id':fields.many2one('product.category', 'Product Category', readonly=True),
|
|
451 |
+# 'location_id': fields.many2one('stock.location', 'Location', readonly=True),
|
|
452 |
+# 'prodlot_id': fields.many2one('stock.production.lot', 'Lot', readonly=True),
|
|
453 |
+# 'company_id': fields.many2one('res.company', 'Company', readonly=True),
|
|
454 |
+# 'product_qty':fields.float('Quantity', digits_compute=dp.get_precision('Product UoM'), readonly=True),
|
|
455 |
+# 'value' : fields.float('Total Value', digits_compute=dp.get_precision('Account'), required=True),
|
|
456 |
+# 'state': fields.selection([('draft', 'Draft'), ('waiting', 'Waiting'), ('confirmed', 'Confirmed'), ('assigned', 'Available'), ('done', 'Done'), ('cancel', 'Cancelled')], 'State', readonly=True, select=True,
|
|
457 |
+# help='When the stock move is created it is in the \'Draft\' state.\n After that it is set to \'Confirmed\' state.\n If stock is available state is set to \'Avaiable\'.\n When the picking it done the state is \'Done\'.\
|
|
458 |
+# \nThe state is \'Waiting\' if the move is waiting for another one.'),
|
|
459 |
+# 'location_type': fields.selection([('supplier', 'Supplier Location'), ('view', 'View'), ('internal', 'Internal Location'), ('customer', 'Customer Location'), ('inventory', 'Inventory'), ('procurement', 'Procurement'), ('production', 'Production'), ('transit', 'Transit Location for Inter-Companies Transfers')], 'Location Type', required=True),
|
|
460 |
+# }
|
|
461 |
+# def init(self, cr):
|
|
462 |
+# tools.drop_view_if_exists(cr, 'report_stock_inventory')
|
|
463 |
+# cr.execute("""
|
|
464 |
+#CREATE OR REPLACE view report_stock_inventory AS (
|
|
465 |
+# (SELECT
|
|
466 |
+# min(m.id) as id, m.date as date,
|
|
467 |
+# m.address_id as partner_id, m.location_id as location_id,
|
|
468 |
+# m.product_id as product_id, pt.categ_id as product_categ_id, l.usage as location_type,
|
|
469 |
+# m.company_id,
|
|
470 |
+# m.state as state, m.prodlot_id as prodlot_id,
|
|
471 |
+# coalesce(sum(-pt.standard_price * m.product_qty)::decimal, 0.0) as value,
|
|
472 |
+# CASE when pt.uom_id = m.product_uom
|
|
473 |
+# THEN
|
|
474 |
+# coalesce(sum(-m.product_qty)::decimal, 0.0)
|
|
475 |
+# ELSE
|
|
476 |
+# coalesce(sum(-m.product_qty * pu.factor)::decimal, 0.0) END as product_qty
|
|
477 |
+# FROM
|
|
478 |
+# stock_move m
|
|
479 |
+# LEFT JOIN stock_picking p ON (m.picking_id=p.id)
|
|
480 |
+# LEFT JOIN product_product pp ON (m.product_id=pp.id)
|
|
481 |
+# LEFT JOIN product_template pt ON (pp.product_tmpl_id=pt.id)
|
|
482 |
+# LEFT JOIN product_uom pu ON (pt.uom_id=pu.id)
|
|
483 |
+# LEFT JOIN product_uom u ON (m.product_uom=u.id)
|
|
484 |
+# LEFT JOIN stock_location l ON (m.location_id=l.id)
|
|
485 |
+# GROUP BY
|
|
486 |
+# m.id, m.product_id, m.product_uom, pt.categ_id, m.address_id, m.location_id, m.location_dest_id,
|
|
487 |
+# m.prodlot_id, m.date, m.state, l.usage, m.company_id,pt.uom_id
|
|
488 |
+#) UNION ALL (
|
|
489 |
+# SELECT
|
|
490 |
+# -m.id as id, m.date as date,
|
|
491 |
+# m.address_id as partner_id, m.location_dest_id as location_id,
|
|
492 |
+# m.product_id as product_id, pt.categ_id as product_categ_id, l.usage as location_type,
|
|
493 |
+# m.company_id,
|
|
494 |
+# m.state as state, m.prodlot_id as prodlot_id,
|
|
495 |
+# coalesce(sum(pt.standard_price * m.product_qty )::decimal, 0.0) as value,
|
|
496 |
+# CASE when pt.uom_id = m.product_uom
|
|
497 |
+# THEN
|
|
498 |
+# coalesce(sum(m.product_qty)::decimal, 0.0)
|
|
499 |
+# ELSE
|
|
500 |
+# coalesce(sum(m.product_qty * pu.factor)::decimal, 0.0) END as product_qty
|
|
501 |
+# FROM
|
|
502 |
+# stock_move m
|
|
503 |
+# LEFT JOIN stock_picking p ON (m.picking_id=p.id)
|
|
504 |
+# LEFT JOIN product_product pp ON (m.product_id=pp.id)
|
|
505 |
+# LEFT JOIN product_template pt ON (pp.product_tmpl_id=pt.id)
|
|
506 |
+# LEFT JOIN product_uom pu ON (pt.uom_id=pu.id)
|
|
507 |
+# LEFT JOIN product_uom u ON (m.product_uom=u.id)
|
|
508 |
+# LEFT JOIN stock_location l ON (m.location_dest_id=l.id)
|
|
509 |
+# GROUP BY
|
|
510 |
+# m.id, m.product_id, m.product_uom, pt.categ_id, m.address_id, m.location_id, m.location_dest_id,
|
|
511 |
+# m.prodlot_id, m.date, m.state, l.usage, m.company_id,pt.uom_id
|
|
512 |
+# )
|
|
513 |
+#);
|
|
514 |
+# """)
|
|
515 |
report_stock_inventory() |
|
516 |
||
517 |
||
518 |