# _*_ coding: utf-8 _*_
from odoo import models, api,fields
import collections

class StudentList(models.AbstractModel):
    _name = 'report.jptip_request.student_list'

    @api.model
    def get_report_values(self, docids, data=None):
        docs = self.env['request.document'].browse(docids)
        i = 0
        res_doc = []
        order_doc = []
        for line in docs:
            temp = {}
            i = 0
            total = 0
            if any(line.request_document_ids):
                for row in line.request_document_ids.sorted(key=lambda r: r.company_id):
                    i += 1
                    total += row.deposit_amount
                    order_temp = {
                        'partner_id': row.partner_id.name,
                        'actual_arrival_date': row.actual_arrival_date,
                        'set_contract_name': row.set_contract_name.set_contract_name,
                        'company': row.company_id.name,
                        'commission_receivable':row.commission_receivable,
                        'selected_materials':row.selected_materials,
                        'deposit_amount': row.deposit_amount,
                        'remarks':row.remarks
                    }
                    order_doc.append(order_temp)
                temp ={
                    'request_object': line.request_object.request_object,
                    'number': i,
                    'total': total,
                    'lines':order_doc
                }
                res_doc.append(temp)
        docargs = {
            'doc_ids': docids,
            'docs': res_doc}
        return docargs