Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to create a qweb reports for my custom Module [Closed]

By
Odoo
on 3/30/15, 7:12 PM 1,315 views

The Question has been closed for reason: duplicate question

by
Odoo
on 03/31/2015 01:47:22

Hi All,

Need a help... 

Now I am creating a Journal voucher Report form  based on 'frm' date and to 'date'  entering from the user a one2many line is updated with corresponding date matches .Here How can I create a Print for this report.

I want to create a  reports  via qweb. This is a custom module, In this Report want to show these fields

                 'voucher'

                  'name'

                  'number'   These fields are from my 'inherit.voucher.line ' model  and

other fields are from 'inherit.voucher'  model 

                 'to'

                 'frm'

                 'partner_id These fields are coming in the report from two different classes .So how to create a custom report ? I have no idea  


This is my xml file-------------



<record id="inherit_voucher_form" model="ir.ui.view">

<field name="name">inherit.voucher.form</field>

<field name="model">inherit.voucher</field>

<field name="arch" type="xml">

<form string="Journal Voucher Report" version="8.0" create="false" edit="false">

<!--<button name="test" string="more" type="action" icon="gtk-print"/> -->

<sheet>

<group colspan="2" col="3" >

<group>

<field name="partner_id" on_change="get_value(partner_id,journal_id,frm,to)" />

<field name="frm" />

</group>

<group>

<field name="journal_id" on_change="get_value(partner_id,journal_id,frm,to)"/>

<field name="to" on_change="get_value(partner_id,journal_id,frm,to)"/>

</group>

<group>

<field name="today" />

</group>

</group>

<group string="Report">

<field name="voucher_id" nolabel="1" colspan="4" >

<tree editable="bottom">

<field name="number"/>

<field name="name"/>

<field name="dat"/>

<field name="debit"/>

<field name="credit"/>

<field name="state"/>

<!--<field name="location_id"/> -->

</tree>

</field>

</group>

</sheet>

</form>

</field>

</record>

<record id="inherit_voucher_action" model="ir.actions.act_window">

<field name="name">Journal Voucher Report</field>

<field name="res_model">inherit.voucher</field>

<field name="view_type">form</field>

<field name="view_mode">form</field>

</record>

<menuitem id="menu_journal_inherit" name="Journal Voucher Report" parent="account.menu_finance_entries" action="inherit_voucher_action"/>



.py file-------------------------------------------


class inherit_voucher(osv.osv):

_name = 'inherit.voucher'

def get_value(self,cr,uid,ids,partner_id,journal_id,frm,to,context=None):

if (partner_id !=False or journal_id != False or (frm != False and to != False)) :

if partner_id != False and (journal_id == False and (frm == False and to == False)) :

cr.execute('Select account_voucher.number,account_voucher.state,account_voucher.date,account_voucher_line.name,account_voucher_line.type,account_voucher_line.amount from account_voucher join account_voucher_line on account_voucher.id = account_voucher_line.voucher_id and account_voucher.partner_id =%s',(partner_id,))

elif partner_id != False and journal_id != False and (frm == False and to == False) :

cr.execute('Select account_voucher.number,account_voucher.state,account_voucher.date,account_voucher_line.name,account_voucher_line.type,account_voucher_line.amount from account_voucher join account_voucher_line on account_voucher.id = account_voucher_line.voucher_id and account_voucher.partner_id =%s and account_voucher.journal_id =%s',(partner_id,journal_id,))

elif partner_id != False and (frm != False and to != False) and journal_id == False:

cr.execute('Select account_voucher.number,account_voucher.state,account_voucher.date,account_voucher_line.name,account_voucher_line.type,account_voucher_line.amount from account_voucher join account_voucher_line on account_voucher.id = account_voucher_line.voucher_id and account_voucher.partner_id =%s and date between %s and %s',(partner_id,frm,to,))

elif partner_id == False and (frm == False and to == False) and journal_id != False:

cr.execute('Select account_voucher.number,account_voucher.state,account_voucher.date,account_voucher_line.name,account_voucher_line.type,account_voucher_line.amount from account_voucher join account_voucher_line on account_voucher.id = account_voucher_line.voucher_id and account_voucher.journal_id =%s',(journal_id))

elif partner_id == False and (frm != False and to != False) and journal_id != False:

cr.execute('Select account_voucher.number,account_voucher.state,account_voucher.date,account_voucher_line.name,account_voucher_line.type,account_voucher_line.amount from account_voucher join account_voucher_line on account_voucher.id = account_voucher_line.voucher_id and account_voucher.journal_id =%s and date between %s and %s',(journal_id,frm,to,))

elif partner_id == False and (frm != False and to != False) and journal_id == False:

cr.execute('Select account_voucher.number,account_voucher.state,account_voucher.date,account_voucher_line.name,account_voucher_line.type,account_voucher_line.amount from account_voucher join account_voucher_line on account_voucher.id = account_voucher_line.voucher_id and and date between %s and %s',(frm,to,))

else:

cr.execute('Select account_voucher.number,account_voucher.state,account_voucher.date,account_voucher_line.name,account_voucher_line.type,account_voucher_line.amount from account_voucher join account_voucher_line on account_voucher.id = account_voucher_line.voucher_id and account_voucher.partner_id =%s and account_voucher.journal_id =%s and date between %s and %s',(partner_id,journal_id,frm,to,))

#fm= datetime.datetime.strptime(frm, '%d-%M-%Y').strftime('%Y-%M-%d')

#t = datetime.datetime.strptime(to, '%d-%M-%Y').strftime('%Y-%M-%d')

#print '##############'+str(fm)

#print '##############'+str(t)

#cr.execute('Select account_voucher.number,account_voucher.state,account_voucher.date,account_voucher_line.name,account_voucher_line.type,account_voucher_line.amount from account_voucher join account_voucher_line on account_voucher.id = account_voucher_line.voucher_id and date between %s and %s',fm,t,)

i= cr.fetchall()

sub_lines = []

if i:

for x in i:

debit=0.0

credit = 0.0

if x[4] == 'cr':

credit = float(x[5])

else :

debit = float(x[5])

#dt = datetime.datetime.strptime(str(x[2]), '%Y-%M-%d').strftime('%d-%M-%y')

sub_lines.append({'number':str(x[0]),'name':str(x[3]),'debit':debit,'credit':credit,'state':str(x[1]),'dat':str(x[2])} )

return {'value': {'voucher_id': sub_lines}}

else :

return True

_columns={

'to': fields.date('To'),

'frm': fields.date('From'),

'partner_id':fields.many2one('res.partner','Receive From'),

'journal_id':fields.many2one('account.journal','Journal ID'),

'today':fields.date('Date'),

'voucher_id':fields.one2many('inherit.voucher.line','voucher','Voucher Report')

}

_defaults={

'today':date.today().strftime('%Y-%m-%d'),

}

inherit_voucher()

class inherit_voucher_line(osv.osv):

_name = 'inherit.voucher.line'

_columns={

'voucher': fields.many2one('account.voucher','Voucher'),

'name':fields.char('Description'),

'number': fields.char('Number'),

'state':fields.char('Status'),

'debit': fields.float('Debit'),

'credit': fields.float('Credit'),

'dat':fields.char('Date'),

}

2

Anil R. Kesariya

--Anil R. Kesariya--
4321
| 6 5 8
Gandhinagar, India
--Anil R. Kesariya--
ERP Consultant

Key Skill
-
Technical & Functional Expert
Anil R. Kesariya
On 3/30/15, 11:32 PM

Hello Dep,

Here you Go! click on below link already given answer for this.


Click Here

Regards,

Anil.

Thanks Anil..Its very useful video....

Odoo
on 3/31/15, 12:43 AM

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 3/30/15, 7:12 PM
Seen: 1315 times
Last updated: 4/1/15, 2:29 AM