Salve a tutti.
Ho creato un nuovo modulo per poter stampare in pdf i timesheet, creando un report QWeb, però non riesco a farlo funzionare. Sicuramente c'è qualcosa che mi manca, ma non capisco cosa.
Questo è l'albero di file del modulo:
module/__init__.py  
module/__openerp__.py  
module/timesheet_print_view.xml
module/report/__init__.py
module/report/timesheet_print.py
module/report/report_timesheet_print.xml
I file sono i seguenti:
module/__init__.py
module/__openerp__.py
{
    'name' : 'Printable Timesheet',
    'version' : '0.1',
    'depends' : ['hr_timesheet_sheet'],
    'data': [
                'report/report_timesheet_print.xml',
                'timesheet_print_view.xml'
            ],
    'installable': True,
    'application': False,
    'active': True,
}module/timesheet_print_view.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="hr_timesheet_sheet_print" model="ir.ui.view">
            <field name="name">hr.timesheet.sheet.print</field>
            <field name="model">hr_timesheet_sheet.sheet</field>
            <field name="inherit_id" ref="hr_timesheet_sheet.hr_timesheet_sheet_form"/>
            <field name="arch" type="xml">
                <header>
                    <button name="print_timesheet" string="Print" type="object"/>
                </header>
            </field>
        </record>
        
    </data>
</openerp>module/report/__init__.py
module/report/timesheet_print.py
from openerp.osv import fields, osv
from openerp.tools.translate import _
class timesheet_print(osv.osv):
    _name = "hr_timesheet_sheet.sheet"
    _inherit = "hr_timesheet_sheet.sheet"
    
    def print_timesheet(self, cr, uid, ids, context=None):
        assert len(ids) == 1, 'This option should only be used for a single id at a time'
        return self.pool['report'].get_action(cr, uid, ids, 'timesheet_print.report_timesheet_print', context=context)module/report/report_timesheet_print.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_timesheet_print">
    <t t-call="report.external_layout">
        <div class="page">
            <div class="row">
                <div>
                    <span>Timesheet</span>
                    <span t-field="o.employee_id"/>
                </div>
            </div>
            
            <table>
                <tr>
                    <th>Type</th>
                    <th t-foreach="o.timesheet_ids" t-as="d">
                        <span t-field="d.date"/>
                    </th>
                    
                </tr>
                <tr t-foreach="account.analytic.account" t-as="type">
                    <th>
                        <span t-field="type.name"/>
                    </th>
                    <td t-foreach="o.timesheet_ids" t-as="entry">
                        <t t-if="entry.name == type.name">
                            <span t-field="entry.unit_amount"/>
                        </t>
                        <t t-if="entry.name != type.name">
                            <span>00:00</span>
                        </t>
                    </td>
                </tr>
            </table>
        </div>
    </t>
</template>
<template id="report_timesheet">
    <t t-call="report.html_container">
        <t t-foreach="doc_ids" t-as="doc_id">
            <t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', 'timesheet.report_timesheet_print')"/>
        </t>
    </t>
</template>
</data>
</openerp>
Nella pagina dei timesheet (relativa ad un dipendente) trovo effettivamente il bottone "Print", ma mi restituisce il seguente errore:
Bad Report Reference
This report is not loaded into the database: timesheet_print.report_timesheet_print.
Ecco le mie domande:
- Come faccio a caricare il report nel database?
 
- Devo configurarlo manualmente dal cliet web, oppure devo aggiungere qualche riga di codice ai file che ho creato?
 
- Come faccio ad avere la stampa client_print_multi per un report? In pratica, vorrei il tasto "Stampa" in alto (di fianco ad "Altro"), invece che nella riga delle azioni ("Submit to manager", Reset to draft", ...).