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

Print report from wizard based on other model [Closed]

By
patrick
on 6/25/13, 6:23 AM 5,584 views

The Question has been closed

by
patrick
on 06/28/2013 08:23:28

I have the following situation:

Multiple stock.picking are selected, than under the button 'More', an option appears, called 'Print Combined Picking'. This will show me a popup (without information, just a button to print and a button to cancel'. Behind the screens, a new record is made in stock.picking.combined.

When clicking on the button 'Print', the relevant information is added to stock.picking.combined, but there appears no report.

When checking under Settings -> Actions -> Reports, I do see the newly defined report.

In the logfiles, I can see that the wizard has enough information to generate the report (I think), but nothing happens.

I checked my code with the following forum entry, and it looks like it is the same.

Below is the relevant information:

The file __openerp__.py:

{
  'name': 'HB Merge Picking',
  'version': '0.1',
  'category': 'Others',
  'complexity': "normal",
  'description': """
  Handedby BV,  MERGE_PICKING
  ===========================
  The module to enable the merging of pickings.
  """,
  'author': ['Patrick van den Eijk, Handed By'],
  'website': 'http://www.handedby.com',
  'depends': ["stock", "sale"],
  'init_xml': [
      "data/merge_picking_data.xml",
  ],
  'update_xml': [
      "wizard/stock_picking_combined_view.xml",
      "report/stock_picking_combined_view.xml",
  ],
  'demo_xml': [],
  'test': [],
  'installable': True,
  'auto_install': False,
  'application': False,
  'images': [],
  'js': [],
}

report/__init__.py:

import stock_picking_combined

report/stock_picking_combined_view.xml:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
<!-- Definition of the report-->
      <report auto="True"
          id="report_combined_picking"
          model="picking.combined"
          name="combined.stock.picking"
          rml="handedby_merge_picking/report/picking.rml"
          string="Combined Delivery Slip"
          menu="False"
      />
    </data>
</openerp>

report/stock_picking_combined.py:

class picking_combined(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context):
        logging.warning("report_picking_combined: %s" %(context))
        super(picking_combined, self).__init__(cr, uid, name, context=context)

        self.localcontext.update({
            'time': time,
    })

# register the new report service :
report_sxw.report_sxw(
    'report.combined.stock.picking', #name of report
    'stock.picking.combined', #which class
    'addons/handedby_merge_picking/report/picking.rml', #the rml location
    parser=picking_combined #the class/parser creating th report
)

wizard/stock_picking_combined_view.xml:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
  <data>
      <record id="view_stock_picking_combined" model="ir.ui.view">
          <field name="name">Stock Picking Combining</field>
          <field name="model">stock.picking.combined</field>
          <field name="arch" type="xml">
            <form string="Form string" version="7.0">
                <footer>
                    <button name="print_combined_pickings" string="Print" type="object" class="oe_highlight"/>
                    or
                    <button string="Cancel" class="oe_link" special="cancel"/>
                </footer>
           </form>
          </field>
      </record>

      <act_window name="Print combined picking"
          res_model="stock.picking.combined"
          src_model="stock.picking.out"
          key2="client_action_multi"
          multi="True"
          view_mode="form"
          view_type="form"
          target="new"
          id="action_stock_picking_combine_wizard"/>
  </data>
</openerp>

wizard/stock_picking_combined.py:

def print_combined_pickings(self, cr, uid, ids, context=None):
    #do the checking and adding of the data
    datas = {
        'ids': ids,
        'model': 'stock.picking.combined',
        'form': self.read(cr, uid, ids)[0]
    }

    x= {
        'type': 'ir.action.report.xml',
        'report_name': 'combined.stock.picking',
        'datas': datas,
    }
    logging.warning('%s' %(x))
    return x

In the log file:

2013-06-25 07:36:15,052 5297 WARNING test root: {'type': 'ir.action.report.xml', 'datas': {'model': 'stock.picking.combined', 'ids': [22], 'form': {'name': u'COUT/1300012', 'type': u'out', 'sale_id': (3, u'SO003'), 'picking_ids': [3, 1], 'note': u'wdfghjmasc\n\ns\nx\nTerms & Conditions 1', 'partner_id': (5, u'A'), 'id': 22, 'move_lines': [1, 3]}}, 'report_name': 'report.combined.picking'}

There is no entry in the logfile for the logging of the report/parser, so somehow I missed a step to activate the parser.

Hi! It should work. Can you please paste here report.combined.picking report tag? Make sure you have initialized stock_picking_combined.py file and your report file in __openerp__.py file.

Keyur
on 6/25/13, 8:37 AM

Hope this is all what you need. It is probably something small, I just don't see it.

patrick
on 6/26/13, 6:11 AM

This much is enough to print a simple report but I am still little worried about stock_picking_combined.py initialization in report __init__.py file.

Keyur
on 6/26/13, 6:23 AM

I am trying on creating report you have pasted here. We also need to import report in main __init__.py file.

Keyur
on 6/26/13, 10:20 AM

Try the following dropbox-link. Should contain everything. https://www.dropbox.com/sh/3iseqlc60mpbom5/thQyjBkD-D

patrick
on 6/26/13, 11:53 AM
0

patrick

--patrick--
1958
| 5 4 7
Baarn, Netherlands
--patrick--
patrick
On 6/28/13, 8:23 AM

Issue solved, I had defined a method in the wizard, and in the new class/object.

Also the wizard and the new class shared the same table, giving me issue.

The following link allows you to take a look at the code and download it.

About This Community

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

Question tools

1 follower(s)

Stats

Asked: 6/25/13, 6:23 AM
Seen: 5584 times
Last updated: 3/16/15, 8:10 AM