[IMP] stock: Task id 596 reporting stock move

bzr revid: mso@mso-20100514132705-9du8yhfm1zjh7qgh
This commit is contained in:
mso
2010-05-14 18:57:05 +05:30
parent 431559c80a
commit 1399bb0b2b
2 changed files with 44 additions and 22 deletions
+22 -14
View File
@@ -28,16 +28,18 @@ class report_stock_move(osv.osv):
_description = "Stock Statistics"
_auto = False
_columns = {
'date': fields.date('Date', readonly=True),
'date_planned': 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', 'Partner', readonly=True),
'product_id':fields.many2one('product.product', 'Product', readonly=True),
'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."),
'product_qty':fields.integer('Qty',readonly=True),
'value' : fields.float('Total Value', required=True),
'product_uom': fields.many2one('product.uom', 'Product UOM', readonly=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\'.\
@@ -49,18 +51,24 @@ class report_stock_move(osv.osv):
tools.drop_view_if_exists(cr, 'report_stock_move')
cr.execute("""
create or replace view report_stock_move as (
select min(m.id) as id,
m.date as date,
to_char(date_trunc('day',m.date), 'YYYY') as year,
to_char(date_trunc('day',m.date), 'MM') as month,
to_char(date_trunc('day',m.date), 'YYYY-MM-DD') as day,
m.location_id as location_id,
m.location_dest_id as location_dest_id,
m.product_id as product_id,
m.state as state,
m.product_uom as product_uom,
sum(m.product_qty) as product_qty
from stock_move as m group by m.id, m.product_id, m.location_id, m.location_dest_id, m.date, m.state, m.product_uom
)
select min(m.id) as id,
m.date_planned as date_planned,
to_char(date_trunc('day',m.date_planned), 'YYYY') as year,
to_char(date_trunc('day',m.date_planned), 'MM') as month,
to_char(date_trunc('day',m.date_planned), 'YYYY-MM-DD') as day,
m.address_id as partner_id,
m.location_id as location_id,
m.location_dest_id as location_dest_id,
m.product_id as product_id,
m.state as state,
m.product_uom as product_uom,
sum(m.product_qty) as product_qty,
pt.standard_price * sum(m.product_qty) as value
from stock_move m ,product_product pp,product_template pt
where
m.product_id=pp.id and pp.product_tmpl_id=pt.id
group by
m.id, m.product_id,m.address_id, m.location_id, m.location_dest_id,
m.date_planned, m.state, m.product_uom,pt.standard_price )
""")
report_stock_move()
+22 -8
View File
@@ -7,16 +7,18 @@
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Stock Orders Statistics">
<field name="date"/>
<field name="date_planned"/>
<field name="year" invisible="1" />
<field name="month" invisible="1"/>
<field name="day" invisible="1"/>
<field name="location_id" invisible="1"/>
<field name="location_dest_id" invisible="1"/>
<field name="product_id"/>
<field name="partner_id"/>
<field name="product_qty"/>
<field name="product_uom"/>
<field name="state"/>
<field name="value"/>
</tree>
</field>
@@ -46,13 +48,14 @@
domain="[('year','=',time.strftime('%%Y'))]"
help="Stock Moves of the year"/>
<filter icon="terp-stock"
name="month"
string="This Month"
domain="[('month','=',time.strftime('%%m'))]"
help="Stock Moves of this month"/>
<filter icon="terp-stock"
string="Today"
separator="1"
domain="[('date', '=', time.strftime('%%Y-%%m-%%d')]"
domain="[('date_planned','&gt;=', time.strftime('%%Y-%%m-%%d')), ('date_planned','&lt;',(datetime.date.today()-datetime.timedelta(days=1)).strftime('%%Y-%%m-%%d'))]"
help="Stock Moves of today"/>
<separator orientation="vertical"/>
@@ -67,24 +70,35 @@
help = "Available Stock-Moves"/>
<filter string="Done"
name="done"
icon="terp-stock"
domain="[('state','=','done')]"
help = "Completed Stock-Moves"/>
<separator orientation="vertical"/>
<separator orientation="vertical"/>
<filter icon="terp-stock" string="Internal Locations" domain="[('location_id.usage','=','internal')]"/>
<filter icon="terp-stock" string="Scrap Locations" domain="[('location_id.scrap_location','=',1)]"/>
<separator orientation="vertical"/>
<field name="product_id"/>
</group>
<newline/>
<group expand="0" string="Extended options..." colspan="10" col="12">
<field name="location_id" widget = "selection"/>
<field name="location_dest_id" widget = "selection"/>
<field name="date_planned"/>
</group>
<newline/>
<group expand="1" string="Group By..." >
<filter string="Product" icon="terp-stock" context="{'group_by':'product_id'}"/>
<filter string="Source Location" icon="terp-stock" context="{'group_by':'location_id'}"/>
<filter string="Partner" name="Partner" icon="terp-stock" domain="[]" context="{'group_by':'partner_id'}"/>
<filter name="product" string="Product" icon="terp-stock" context="{'group_by':'product_id'}"/>
<separator orientation="vertical"/>
<filter name="src_location" string="Source Location" icon="terp-stock" context="{'group_by':'location_id'}"/>
<filter string="Dest. Location" icon="terp-stock" context="{'group_by':'location_dest_id'}"/>
<filter string="State" icon="terp-stock" context="{'group_by':'state'}"/>
<separator orientation="vertical"/>
<filter string="Day" icon="terp-stock" context="{'group_by':'day'}"/>
<filter string="Month" icon="terp-stock" context="{'group_by':'date'}"/>
<filter string="Month" icon="terp-stock" context="{'group_by':'date_planned'}"/>
<filter string="Year" icon="terp-stock" context="{'group_by':'year'}"/>
</group>
</search>
@@ -97,7 +111,7 @@
<field name="view_type">form</field>
<field name="view_mode">tree,graph</field>
<field name="search_view_id" ref="view_stock_search"/>
<field name="context">{'search_default_product':1, 'search_default_src_location':1,'search_default_done':1,'group_by':[]}</field>
</record>
<menuitem