跳至内容
菜单
此问题已终结
2 回复
12244 查看

I want to create menu like Reporting/Point of sale/Sale Details and print my report while clicking Print Report button. I have created a report which comes under Settings/Technical/Actions/Reports.How can i integrate my report to button click and how to create pop up? Any one please help?

形象
丢弃
最佳答案

hello, you can use wizard to achieve this, the wizard is as normal model but it will inherit 'osv.osv_memory'

class print_report_wiz(osv.osv_memory):
    _name = "print.report.wiz"

    _columns = {
        'name': fields.many2one('name.name', 'Name',required = True),
    }

the xml view is also as normal but add:

<field name = "target">new</field>

to the action,

the print button will return a dictionary like:

return {
            'type': 'ir.actions.report.xml',
            'report_name': 'your.report.name',
            'datas': datas,
            'context': context,
        }

also you can see these questions:

print report from wizard

create a wizard

Updated

on the print function of the wizard,

first you can fetch the wizard data e.g date_from , date_to, name ....

by using this:

wiz_data = self.read(cr, uid, ids[0], context = context)

now you can access them by using dictionary key e.g : wiz_date[date_from]

after that you can use these values to formulate sql query to fetch the ids you want...

cr.execute('SELECT id '\
                        'FROM table_name ' \
                        "WHERE date BETWEEN %s AND %s", (wiz_data['from_date'], wiz_data['to_date']))

then you have to fetch these ids you can use for e.g:

res_ids = [id for id, in cr.fetchall()]

at this time , you have your desired ids ...

the datas dict will be passed to your report , with three keys: model, ids of this model, and form which contains the wiz_data could be like this:

datas = {
            'ids': res_ids,
            'model': 'model.name',
            'form': wiz_data,
        }

now your report has all information needed,

the "objects" contains a browse record of the given ids on datas dict... also you can use the wizard information in your report like this:

if you want to print e.g this report from date ... to date ...

you can use:

[[ data['form']['from_date'] ]] and [[ data['form']['to_date'] ]]

remember, the form contains your fetched wizard's data ...

also you can filter your data using the report python file by declaring a function to do some filtering...

it depends on your requirements , and it will be a performance issue to filter your data on the wizard function's or in a report's python file [for e.g you'll use the returns values in another function on the python file]....

I hope it'll helps you ....

Regards..

形象
丢弃
编写者

I changed code but still it didnt create any menu under "Reporting" what is the issue?

编写者 最佳答案
i created the wizard and my code is (calldetails/wizard/calldata_view.xml)
<?xml version="1.0" encoding="utf-8"?>
<openerp>
  <data>

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

 <field name="model">calldata.print.report.wiz</field>
    <field name="type">form</field>
    <field name="arch" type="xml">
      <form string="Wizard with step" version="7.0">
    <field name="one" />
 </form>
    </field>
   </record>
 <record model="ir.actions.act_window" id="action_calldata_form1">
   <field name="name">Calldetails</field>
   <field name="res_model">calldata.print.report.wiz</field>
</record>
<act_window name="Create Combined Picking" res_model="calldata.print.report.wiz" src_model="calldata.print.report.wiz" key2="client_action_multi" multi="True" view_mode="form" view_type="form" target="new" id="action_stock_picking_combined_wizard" />
</data>
</openerp>

Object file is(calldetails/wizard/calldata_print.py)
from openerp.osv import fields, osv


class calldata_print_report_wiz(osv.osv_memory):
    _name = "calldata.print.report.wiz"

    _columns = {
        'one':  fields.char('Name 1',),}

calldata_print_report_wiz()

i added calldata_print in wizard/__init__.py  ,wizard in calldetails/__init__.py and calldata_view.xml in __openerp__.py stil it didnt create any menu under "Reporting"
 What is the issue. Please help
形象
丢弃

you didn't add a menuitem to your view, just try to add a menuitem and specify the the action and parent menu,...

also i think you missing: field name = "name" on the form view,..

编写者

It worked :). Thanks alot Ahmed

编写者

While clicking print it shoes error "RML is not available at specified location or not enough data to print! (None, None, None)". please help

编写者

Corrected. i was given invalid path for rml

编写者

helo i have created report and while clicking print it prints all data.but filtering not works .can you please help?what is the value i should pass with datas dictionary and with datas['form']?

Hello, I have updated my answer...Regards..

编写者

@Ahmed M.Elmubarak , It worked thanks alot for your help !!

编写者

i want remove repetition from my select box .my code is def _sel_func(self, cr, uid,context=None): cr.execute("select distinct on(caller) id,caller FROM calldata1 order by caller") result = cr.fetchall() lst = [] for r in result: dct = {} dct['id'] = r[o] dct['name'] = r[1] lst.append(dct) res_ids = [(r['id'], r['name']) for r in lst] return res_ids How to achive this?

hello @Anuradha, I cannot get what is the problem actually, but if your list has a repetition you can simply convert it to a set and then make it list again,

but note it seems it is another question than the title, I suggest to make a new question, or you can send to me a msg via my LinkedIn profile, it is already in my profile!.

Thanks

编写者

I have posted another question http://help.openerp.com/question/29526/how-to-show-distict-data-in-many-to-one-filed/ please check or please send me your email id

Where do I find the setting for the RML issue? "Corrected. i was given invalid path for rml" I get this trying to print an invoice, and I haven't done any coding in the system??

相关帖文 回复 查看 活动
1
11月 16
4450
1
3月 15
4448
2
2月 24
14112
1
10月 22
5710
1
8月 21
4146