[FIX] account, sale, purchase: Improved analysis report
lp bug: https://launchpad.net/bugs/673835 fixed bzr revid: pso@tinyerp.com-20101220122422-kqao990cf3q582df
This commit is contained in:
parent
c4af077809
commit
a0c6493743
|
@ -36,7 +36,7 @@ class account_invoice_report(osv.osv):
|
|||
('10','October'), ('11','November'), ('12','December')], 'Month', readonly=True),
|
||||
'product_id': fields.many2one('product.product', 'Product', readonly=True),
|
||||
'product_qty':fields.float('Qty', readonly=True),
|
||||
'uom_name': fields.char('Default UoM', size=128, readonly=True),
|
||||
'uom_name': fields.char('Reference UoM', size=128, readonly=True),
|
||||
'payment_term': fields.many2one('account.payment.term', 'Payment Term', readonly=True),
|
||||
'period_id': fields.many2one('account.period', 'Force Period', domain=[('state','<>','done')], readonly=True),
|
||||
'fiscal_position': fields.many2one('account.fiscal.position', 'Fiscal Position', readonly=True),
|
||||
|
@ -88,7 +88,11 @@ class account_invoice_report(osv.osv):
|
|||
ai.partner_id as partner_id,
|
||||
ai.payment_term as payment_term,
|
||||
ai.period_id as period_id,
|
||||
u.name as uom_name,
|
||||
(case when u.uom_type not in ('reference') then
|
||||
(select name from product_uom where uom_type='reference' and category_id=u.category_id)
|
||||
else
|
||||
u.name
|
||||
end) as uom_name,
|
||||
ai.currency_id as currency_id,
|
||||
ai.journal_id as journal_id,
|
||||
ai.fiscal_position as fiscal_position,
|
||||
|
@ -104,9 +108,9 @@ class account_invoice_report(osv.osv):
|
|||
ai.account_id as account_id,
|
||||
ai.partner_bank_id as partner_bank_id,
|
||||
sum(case when ai.type in ('out_refund','in_invoice') then
|
||||
ail.quantity * u.factor * -1
|
||||
ail.quantity / u.factor * -1
|
||||
else
|
||||
ail.quantity * u.factor
|
||||
ail.quantity / u.factor
|
||||
end) as product_qty,
|
||||
sum(case when ai.type in ('out_refund','in_invoice') then
|
||||
ail.quantity*ail.price_unit * -1
|
||||
|
@ -125,9 +129,9 @@ class account_invoice_report(osv.osv):
|
|||
else
|
||||
sum(ail.quantity*ail.price_unit)
|
||||
end)/(case when ai.type in ('out_refund','in_invoice') then
|
||||
sum(ail.quantity*u.factor*-1)
|
||||
sum(ail.quantity/u.factor*-1)
|
||||
else
|
||||
sum(ail.quantity*u.factor)
|
||||
sum(ail.quantity/u.factor)
|
||||
end) / cr.rate as price_average,
|
||||
cr.rate as currency_rate,
|
||||
sum((select extract(epoch from avg(date_trunc('day',aml.date_created)-date_trunc('day',l.create_date)))/(24*60*60)::decimal(16,2)
|
||||
|
@ -179,7 +183,9 @@ class account_invoice_report(osv.osv):
|
|||
ai.account_id,
|
||||
ai.partner_bank_id,
|
||||
ai.residual,
|
||||
ai.amount_total
|
||||
ai.amount_total,
|
||||
u.uom_type,
|
||||
u.category_id
|
||||
)
|
||||
""")
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ class purchase_report(osv.osv):
|
|||
'date_approve':fields.date('Date Approved', readonly=True),
|
||||
'expected_date':fields.date('Expected Date', readonly=True),
|
||||
'validator' : fields.many2one('res.users', 'Validated By', readonly=True),
|
||||
'product_uom' : fields.many2one('product.uom', 'Product UoM', required=True),
|
||||
'product_uom' : fields.many2one('product.uom', 'Reference UoM', required=True),
|
||||
'company_id':fields.many2one('res.company', 'Company', readonly=True),
|
||||
'user_id':fields.many2one('res.users', 'Responsible', readonly=True),
|
||||
'delay':fields.float('Days to Validate', digits=(16,2), readonly=True),
|
||||
|
@ -92,16 +92,20 @@ class purchase_report(osv.osv):
|
|||
s.company_id as company_id,
|
||||
l.product_id,
|
||||
t.categ_id as category_id,
|
||||
l.product_uom as product_uom,
|
||||
(case when u.uom_type not in ('reference') then
|
||||
(select id from product_uom where uom_type='reference' and category_id = 1)
|
||||
else
|
||||
u.id
|
||||
end) as product_uom,
|
||||
s.location_id as location_id,
|
||||
sum(l.product_qty*u.factor) as quantity,
|
||||
sum(l.product_qty/u.factor) as quantity,
|
||||
extract(epoch from age(s.date_approve,s.date_order))/(24*60*60)::decimal(16,2) as delay,
|
||||
extract(epoch from age(l.date_planned,s.date_order))/(24*60*60)::decimal(16,2) as delay_pass,
|
||||
count(*) as nbr,
|
||||
(l.price_unit*l.product_qty*u.factor)::decimal(16,2) as price_total,
|
||||
avg(100.0 * (l.price_unit*l.product_qty*u.factor) / (t.standard_price*l.product_qty*u.factor))::decimal(16,2) as negociation,
|
||||
sum(t.standard_price*l.product_qty*u.factor)::decimal(16,2) as price_standard,
|
||||
(sum(l.product_qty*l.price_unit)/sum(l.product_qty*u.factor))::decimal(16,2) as price_average
|
||||
(sum(l.product_qty*l.price_unit)/sum(l.product_qty/u.factor))::decimal(16,2) as price_average
|
||||
from purchase_order s
|
||||
left join purchase_order_line l on (s.id=l.order_id)
|
||||
left join product_product p on (l.product_id=p.id)
|
||||
|
@ -131,7 +135,10 @@ class purchase_report(osv.osv):
|
|||
to_char(s.date_order, 'MM'),
|
||||
to_char(s.date_order, 'YYYY-MM-DD'),
|
||||
s.state,
|
||||
s.warehouse_id
|
||||
s.warehouse_id,
|
||||
u.uom_type,
|
||||
u.category_id,
|
||||
u.id
|
||||
)
|
||||
""")
|
||||
purchase_report()
|
||||
|
|
|
@ -101,7 +101,7 @@
|
|||
<separator orientation="vertical"/>
|
||||
<filter string="Product" name="group_product_id" icon="terp-accessories-archiver" context="{'group_by':'product_id'}"/>
|
||||
<filter string="Category" name="group_category_id" icon="terp-accessories-archiver" context="{'group_by':'category_id'}"/>
|
||||
<filter string="Product UOM" name="group_product_uom" icon="terp-accessories-archiver" context="{'group_by':'product_uom'}"/>
|
||||
<filter string="Reference UOM" name="group_product_uom" icon="terp-accessories-archiver" context="{'group_by':'product_uom'}"/>
|
||||
<filter string="Warehouse" icon="terp-go-home" context="{'group_by':'warehouse_id'}" groups="base.group_extended"/>
|
||||
<filter string="Destination" icon="terp-gtk-jump-to-ltr" context="{'group_by':'location_id'}"/>
|
||||
<separator orientation="vertical"/>
|
||||
|
|
|
@ -38,7 +38,7 @@ class sale_report(osv.osv):
|
|||
('10', 'October'), ('11', 'November'), ('12', 'December')], 'Month', readonly=True),
|
||||
'day': fields.char('Day', size=128, readonly=True),
|
||||
'product_id': fields.many2one('product.product', 'Product', readonly=True),
|
||||
'uom_name': fields.char('Default UoM', size=128, readonly=True),
|
||||
'uom_name': fields.char('Reference UoM', size=128, readonly=True),
|
||||
'product_uom_qty': fields.float('# of Qty', readonly=True),
|
||||
|
||||
'partner_id': fields.many2one('res.partner', 'Partner', readonly=True),
|
||||
|
@ -90,17 +90,21 @@ class sale_report(osv.osv):
|
|||
sale_order s,
|
||||
(
|
||||
select l.id as id,
|
||||
l.product_id as product_id,
|
||||
u.name as uom_name,
|
||||
sum(l.product_uom_qty * u.factor) as product_uom_qty,
|
||||
sum(l.product_uom_qty*l.price_unit) as price_total,
|
||||
(sum(l.product_uom_qty*l.price_unit)/sum(l.product_uom_qty * u.factor)*count(l.product_id))::decimal(16,2) as price_average,
|
||||
pt.categ_id, l.order_id
|
||||
l.product_id as product_id,
|
||||
(case when u.uom_type not in ('reference') then
|
||||
(select name from product_uom where uom_type='reference' and category_id=u.category_id)
|
||||
else
|
||||
u.name
|
||||
end) as uom_name,
|
||||
sum(l.product_uom_qty/u.factor) as product_uom_qty,
|
||||
sum(l.product_uom_qty*l.price_unit) as price_total,
|
||||
(sum(l.product_uom_qty*l.price_unit)/sum(l.product_uom_qty/u.factor)*count(l.product_id))::decimal(16,2) as price_average,
|
||||
pt.categ_id, l.order_id
|
||||
from
|
||||
sale_order_line l
|
||||
left join product_uom u on (u.id=l.product_uom)
|
||||
left join product_template pt on (pt.id=l.product_id)
|
||||
group by l.id, l.order_id, l.product_id, u.name, pt.categ_id) el
|
||||
group by l.id, l.order_id, l.product_id, u.name, pt.categ_id, u.uom_type, u.category_id) el
|
||||
where s.id = el.order_id
|
||||
group by el.id,
|
||||
el.product_id,
|
||||
|
|
|
@ -100,7 +100,7 @@
|
|||
<filter string="Partner" icon="terp-partner" name="Customer" context="{'group_by':'partner_id'}"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter string="Product" icon="terp-accessories-archiver" context="{'group_by':'product_id','set_visible':True}"/>
|
||||
<filter string="Default UoM" icon="terp-mrp" context="{'group_by':'uom_name'}"/>
|
||||
<filter string="Reference UoM" icon="terp-mrp" context="{'group_by':'uom_name'}"/>
|
||||
<filter string="Category of Product" icon="terp-stock_symbol-selection" name="Category" context="{'group_by':'categ_id'}"/>
|
||||
<separator orientation="vertical" groups="analytic.group_analytic_accounting"/>
|
||||
<filter string="Analytic Account" icon="terp-folder-green" context="{'group_by':'analytic_account_id'}" groups="analytic.group_analytic_accounting"/>
|
||||
|
|
Loading…
Reference in New Issue