[IMP] stock: move/inventory analysis review: correct report, add product category + improve views

bzr revid: odo@openerp.com-20100928163649-fueh01zap4ox8j86
This commit is contained in:
Olivier Dony
2010-09-28 18:36:49 +02:00
parent 48a0ca06fc
commit 41d387d913
2 changed files with 37 additions and 46 deletions
+12 -12
View File
@@ -153,7 +153,7 @@ class report_stock_inventory(osv.osv):
'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_uom':fields.many2one('product.uom', 'Product UOM', 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),
@@ -171,7 +171,7 @@ 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, m.product_uom as product_uom,l.usage as location_type,
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(-m.product_qty * u.factor)::decimal, 0.0) as product_qty,
@@ -179,18 +179,18 @@ CREATE OR REPLACE view report_stock_inventory AS (
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_product pp ON (m.product_id=pp.id)
LEFT JOIN product_template pt ON (pp.product_tmpl_id=pt.id)
LEFT JOIN product_uom u ON (m.product_uom=u.id)
LEFT JOIN stock_location l ON (m.location_id=l.id)
LEFT JOIN stock_location l ON (m.location_id=l.id)
GROUP BY
m.id, m.product_id, m.address_id, m.location_id, m.prodlot_id,
m.date, m.state, l.usage, m.company_id,m.product_uom
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
) 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, m.product_uom as product_uom, l.usage as location_type,
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(m.product_qty*u.factor)::decimal, 0.0) as product_qty,
@@ -198,12 +198,12 @@ CREATE OR REPLACE view report_stock_inventory AS (
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_product pp ON (m.product_id=pp.id)
LEFT JOIN product_template pt ON (pp.product_tmpl_id=pt.id)
LEFT JOIN product_uom u ON (m.product_uom=u.id)
LEFT JOIN stock_location l ON (m.location_dest_id=l.id)
LEFT JOIN stock_location l ON (m.location_dest_id=l.id)
GROUP BY
m.id, m.product_id, m.product_uom , m.address_id, m.location_id, m.location_dest_id,
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
)
);
+25 -34
View File
@@ -57,18 +57,18 @@
<field name="arch" type="xml">
<search string="Moves Analysis">
<group>
<filter icon="terp-go-year" string=" Year "
<filter icon="terp-go-year" string="Year"
domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')),('date','&gt;=',time.strftime('%%Y-01-01'))]"
help="Current year"/>
<filter icon="terp-go-month" string=" Month "
<filter icon="terp-go-month"
string="Month-1"
separator="1"
domain="[('date','&lt;=', (datetime.date (int(time.strftime('%%Y')), datetime.date.today().month, 1) - datetime.timedelta (days = 1)).strftime('%%Y-%%m-%%d')),('date','&gt;',(datetime.date (int(time.strftime('%%Y')), datetime.date.today().month-1, 1)).strftime('%%Y-%%m-%%d'))]"
help="Last month"/>
<filter icon="terp-go-month" string="Month"
name="month"
domain="[('date','&lt;=', time.strftime('%%Y-%%m-%%d')),('date','&gt;=',time.strftime('%%Y-%%m-01'))]"
help="Current month"/>
<filter icon="terp-go-month"
string=" Month-1 "
separator="1"
domain="[('date','&lt;=', (datetime.date (int(time.strftime('%%Y')), datetime.date.today().month, 1) - datetime.timedelta (days = 1)).strftime('%%Y-%%m-%%d')),('date','&gt;',(datetime.date (int(time.strftime('%%Y')), datetime.date.today().month-1, 1)).strftime('%%Y-%%m-%%d'))]"
help="Last month"/>
<separator orientation="vertical"/>
<filter string="Done"
name="done"
@@ -81,24 +81,15 @@
help = "Future Stock-Moves"/>
<separator orientation="vertical"/>
<filter icon="terp-go-home" name="in" string="Receptions" domain="[('type','=','in')]"/>
<filter icon="terp-go-home" name="internal" string="Internals" domain="[('type','=','internal')]"/>
<filter icon="terp-go-home" name="out" string="Packings" domain="[('type','=','out')]"/>
<filter icon="terp-go-home" name="in" string="Incoming" domain="[('type','=','in')]"/>
<filter icon="terp-go-home" name="internal" string="Internal" domain="[('type','=','internal')]"/>
<filter icon="terp-go-home" name="out" string="Outgoing" domain="[('type','=','out')]"/>
<filter icon="terp-go-home" name="delivery" string="Deliveries" domain="[('type','=','delivery')]"/>
<separator orientation="vertical"/>
<field name="product_id"/>
<field name="product_id" default_focus="1"/>
<field name="partner_id" context="{'contact_display':'partner'}"/>
</group>
<newline/>
<group expand="0" string="Extended Filters..." groups="base.group_extended">
<field name="location_id" widget = "selection"/>
<field name="location_dest_id" widget = "selection"/>
<separator orientation="vertical"/>
<field name="company_id" groups="base.group_multi_company"/>
<newline/>
<field name="date"/>
</group>
<newline/>
<group expand="1" string="Group By...">
<filter name="group_partner" string="Partner" icon="terp-personal" context="{'group_by':'partner_id'}"/>
<separator orientation="vertical"/>
@@ -157,7 +148,7 @@
<field name="location_type" invisible="1"/>
<field name="location_id" invisible="1"/>
<field name="partner_id" invisible="1" context="{'contact_display':'partner'}"/>
<field name="product_uom" invisible="1"/>
<field name="product_categ_id" invisible="1"/>
<field name="product_id" invisible="1"/>
<field name="prodlot_id" invisible="1"/>
<field name="state" invisible="1"/>
@@ -199,26 +190,16 @@
<separator orientation="vertical"/>
<filter icon="terp-go-home" name="location_type_internal" string="Internal" domain="[('location_type','=','internal')]"/>
<filter icon="terp-go-home" name="location_type_scrap" string="Scrap" domain="[('location_type','=','scrap')]"/>
<separator orientation="vertical"/>
<field name="product_id"/>
<field name="location_id"/>
<field name="product_id" default_focus="1"/>
<field name="location_id" filter_domain="[('location_id', 'child_of', self)]"/>
<field name="company_id" groups="base.group_multi_company"/>
</group>
<newline/>
<group expand="0" string="Extended Filters..." groups="base.group_extended">
<field name="partner_id" context="{'contact_display':'partner'}"/>
<field name="product_uom" />
<field name="prodlot_id"/>
<field name="state"/>
<field name="location_type"/>
<field name="date"/>
</group>
<newline/>
<group expand="1" string="Group By..." >
<filter string="Partner" name="group_partner" icon="terp-personal" domain="[]" context="{'group_by':'partner_id'}"/>
<separator orientation="vertical"/>
<filter name="group_product_uom" string="Product UOM" icon="terp-accessories-archiver" context="{'group_by':'product_uom'}"/>
<filter name="group_product_categ_id" string="Product Category" icon="terp-stock_symbol-selection" context="{'group_by':'product_categ_id'}"/>
<filter name="group_product" string="Product" icon="terp-accessories-archiver" context="{'group_by':'product_id'}"/>
<filter name="group_lot" string="Lot" context="{'group_by':'prodlot_id'}"/>
<separator orientation="vertical"/>
@@ -228,6 +209,16 @@
<filter string="Date" icon="terp-go-month" context="{'group_by':'date'}"/>
<filter string="State" icon="terp-stock_effects-object-colorize" context="{'group_by':'state'}"/>
</group>
<newline/>
<group expand="0" string="Extended Filters..." groups="base.group_extended">
<field name="partner_id" context="{'contact_display':'partner'}"/>
<field name="product_categ_id" />
<field name="prodlot_id"/>
<field name="state"/>
<field name="location_type"/>
<field name="date"/>
<filter icon="terp-go-home" name="location_type_scrap" string="Scrap" domain="[('location_type','=','scrap')]"/>
</group>
</search>
</field>
</record>