[FIX] mrp: fixed report.mrp.inout to get figures company wise, to take into account only the 'done' move, and to reuse the unit_price set on the move instead of making a fuzzy computation that doesn't consider the cost method of products (in average, fifo... it makes a difference)
bzr revid: qdp-launchpad@openerp.com-20130527085547-kd3fyfssuqm0rwfg
This commit is contained in:
@@ -63,6 +63,7 @@ class report_mrp_inout(osv.osv):
|
||||
_columns = {
|
||||
'date': fields.char('Week', size=64, required=True),
|
||||
'value': fields.float('Stock value', required=True, digits=(16,2)),
|
||||
'company_id': fields.many2one('res.company', 'Company', required=True),
|
||||
}
|
||||
|
||||
def init(self, cr):
|
||||
@@ -72,14 +73,15 @@ class report_mrp_inout(osv.osv):
|
||||
min(sm.id) as id,
|
||||
to_char(sm.date,'YYYY:IW') as date,
|
||||
sum(case when (sl.usage='internal') then
|
||||
ip.value_float * sm.product_qty
|
||||
sm.price_unit * sm.product_qty
|
||||
else
|
||||
0.0
|
||||
end - case when (sl2.usage='internal') then
|
||||
ip.value_float * sm.product_qty
|
||||
sm.price_unit * sm.product_qty
|
||||
else
|
||||
0.0
|
||||
end) as value
|
||||
end) as value,
|
||||
sm.company_id
|
||||
from
|
||||
stock_move sm
|
||||
left join product_product pp
|
||||
@@ -89,15 +91,11 @@ class report_mrp_inout(osv.osv):
|
||||
left join stock_location sl
|
||||
on ( sl.id = sm.location_id)
|
||||
left join stock_location sl2
|
||||
on ( sl2.id = sm.location_dest_id),
|
||||
ir_property ip
|
||||
on ( sl2.id = sm.location_dest_id)
|
||||
where
|
||||
sm.state in ('waiting','confirmed','assigned')
|
||||
and
|
||||
ip.name='standard_price' AND ip.res_id=CONCAT('product.template,',pt.id) AND (ip.company_id=sm.company_id OR ip.company_id IS NULL)
|
||||
sm.state = 'done'
|
||||
group by
|
||||
to_char(sm.date,'YYYY:IW'), ip.company_id
|
||||
order by ip.company_id ASC LIMIT 1
|
||||
to_char(sm.date,'YYYY:IW'), sm.company_id
|
||||
)""")
|
||||
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
<field name="model">report.mrp.inout</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Stock value variation">
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
<field name="date"/>
|
||||
<field name="value"/>
|
||||
</tree>
|
||||
@@ -62,6 +63,7 @@
|
||||
<group col="4">
|
||||
<field name="date"/>
|
||||
<field name="value"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
@@ -73,6 +75,7 @@
|
||||
<field name="model">report.mrp.inout</field>
|
||||
<field name="arch" type="xml">
|
||||
<graph string="Stock value variation" type="bar">
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
<field name="date"/>
|
||||
<field name="value" operator="+"/>
|
||||
</graph>
|
||||
|
||||
Reference in New Issue
Block a user