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