Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
9174 Visualizzazioni

Hello,


I have multiple sale order line and sale order line have one field called order id.

When I print sale order line, qweb create a new page for every line that is i want.


But now, when the order id is same for multiple sale order line, it append in one report.


How to do this ??

Thanks,

Avatar
Abbandona
Autore

It's Done.

Autore Risposta migliore

Hello,


I have taken one field in sale order line which is many2one to sale order line.

Now search the record where reference id are same and in that record written the first sale order line id.


For report,

Create a parser class and take method render_html.


Then search the record in the sale order line that line_id is the sale_order_line.id so i get same reference_id record in list and append in the main list.


Because there are many records which have multiple sale order line.

class PackingListReport(models.AbstractModel):

    _name = 'report.work_order.report_packing_list'

    @api.multi

    def render_html(self, data=None):

        family = []

        report_obj = self.env['report']

        work_order_id = self.env['work.order'].browse(self.id)

        for line in work_order_id.work_order_line:

            search_id = work_order_id.work_order_line.search([('order_work_id', '=', self.id), ('reference_id', '=', line.reference_id), ('line_id', '=', line.id)])

            if search_id:

                family.append(search_id)

        report = report_obj._get_report_from_name('work_order.report_packing_list')

        docargs = {

            'doc_ids': self._ids,

            'doc_model': report.model,

            'docs': work_order_id,

            'family': family,

        }

        return report_obj.render('work_order.report_packing_list', docargs)



and this family list append in the dictionary and pass through render method.

So I can easily fetch it into my report template.


Thanks,


Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
0
dic 19
70
0
feb 18
4916
0
apr 19
4585
0
dic 18
4049
1
apr 25
1381