0

I made this report that is called from an action in a tree view of SO. So i can select few reports and print them out.

The thing is that i want to change state in Sale Orders that I selected and printed out the reports. State should change from "draft" to "sent". How can I do this?

<data>

    <report 
        id="report_het_sale_order"
        string="Het Sale Order Pdf"
        model="sale.order"
        name="het.het_sale_order"
        rml="config_het/report/het_sale_order.ods"
        menu="True"
    />

    <record model="ir.actions.report.xml" id="report_hetl_sale_order">
        <field name="report_type">aeroo</field>
        <field name="parser_loc">config_het/report/het_sale_order.pyc</field>
        <field name="tml_Source">file</field>
        <field name="parser_state">loc</field>
        <field name="out_format" ref="report_aeroo.report_mimetypes_pdf_odt"/>
        <field name="in_format">oo-ods</field>
        <field name="auto" eval="True" />
    </record>
Chaban33
  • 1,362
  • 11
  • 38
  • How do you call the print action from your wizard? Have you looked into the "Print" button and the method behind it in the original Odoo code? – CZoellner Aug 30 '18 at 07:38

1 Answers1

2

You can do it by modifying AbstractModel

For example:

<report 
            id="agedpartnerbalance_template"
            string="Aged Partner Template"
            model="account.move" 
            report_type="qweb-pdf"
            file="account.report_agedpartnerbalance" 
            name="account.report_agedpartnerbalance"
        />


    class ReportAgedPartnerBalance(models.AbstractModel):

        _name = 'report.account.report_agedpartnerbalance'


        @api.model
        def render_html(self, docids, data=None):
            *****
            Your Logic
            docs = self.env[model].browse(self.env.context.get('active_id'))
            for doc in docs:
                doc.state = 'sent'
            *****
            docargs = {
                'doc_ids': self.ids,
                'doc_model': model,
                'data': data['form'],
                'docs': docs,
                'time': time,
                'get_partner_lines': movelines,
                'get_direction': total,
            }
            return self.env['report'].render('account.report_agedpartnerbalance', docargs)
PsPranav
  • 973
  • 7
  • 10