def _write_lines(self, cr, uid, ids, category_names, context=None) :
     i = self.current_line
     sheet = self.sheet
     today = self.today
     year = today.year
     month = today.month
     day = today.day
     sheet.row(i).height_mismatch = True
     sheet.row(i).height = 256/2*3
     for j in (13,14):
         sheet.write(i-1,j,"",xl_module.black_line)
     for j in range(15,28):
         sheet.write(i-1,j,"",xl_module.blue_line)
     assets = self._get_assets(cr, uid, ids, category_names=category_names, context=context)
     if not assets:
         self.current_line += 1
         return
     for asset in assets :
         purchase_date = datetime.strptime(asset.purchase_date_2,'%Y-%m-%d')
         if purchase_date > today:
             continue
         purchase_value = float(asset.x_purchase_value) if purchase_date < datetime(2014,1,1) else asset.purchase_value
         an_dot = 0.0
         m_deprec = [0.0]*12
         last_date = datetime(year=year-1, month=1, day=1)
         remaining_value = asset.purchase_value
         last_year_last_date = datetime(year=year-1, month=1, day=1)
         pre_value = asset.purchase_value
         if asset.depreciation_line_ids:
             an_dot = asset.depreciation_line_ids[0].amount * 12.0
             for line in asset.depreciation_line_ids:
                 deprec_date = datetime.strptime(line.depreciation_date,'%Y-%m-%d')
                 if deprec_date.year > 2013 and deprec_date.year < year and deprec_date > last_year_last_date:
                     last_year_last_date = deprec_date
                     pre_value = line.remaining_value
                 elif deprec_date.year == year and deprec_date < today:
                     m_deprec[deprec_date.month-1] = line.amount
                     if deprec_date > last_date:
                         last_date = deprec_date
                         remaining_value = line.remaining_value
         sheet.write(i,1,asset.name,xl_module.line_left)
         sheet.write(i,2,asset.code or "")
         sheet.write(i,3,asset.allocation or "")
         sheet.write(i,4,purchase_date.strftime('%d/%m/%Y'),xl_module.line)
         sheet.write(i,5,purchase_value,xl_module.line)
         sheet.write(i,6,pre_value if purchase_date.year < year else 0)
         sheet.write(i,7,purchase_value if purchase_date.year == year else '')
         sheet.write(i,10,xl_module.list_sum([[i,5,+1],[i,8,-1]]),xl_module.line)
         sheet.write(i,11,str(int(100.0/(asset.category_id.method_number/12.0))) + "%",xl_module.line)
         sheet.write(i,12,xl_module.list_sum([[i,5,+1],[i,6,-1]]) if purchase_date.year < year else 0,xl_module.line)
         sheet.write(i,13,an_dot,xl_module.black_line)
         sheet.write(i,14,sum(m_deprec),xl_module.black_red_line)
         for j in range(0,11):
             sheet.write(i,15+j,m_deprec[j],xl_module.blue_line)
         sheet.write(i,26,m_deprec[11],xl_module.blue_red_line)
         sheet.write(i,27,xl_module.range_sum(i,15,i,26),xl_module.blue_red_line)
         sheet.write(i,28,remaining_value,xl_module.line_right)
         i += 1
     self.current_line = i
    def _write_total(self, title, i1, i2):
        self.current_line += 1
        i = self.current_line
        sheet = self.sheet
        sheet.write(self.current_line-1,1,"",xl_module.line_left)
        sheet.write(self.current_line-1,28,"",xl_module.line_right)
        for j in (13,14):
            sheet.write(i-1,j,"",xl_module.black_line)
        for j in range(15,28):
            sheet.write(i-1,j,"",xl_module.blue_line)
        self.total_lines.append(self.current_line)
        sheet.row(self.current_line).height_mismatch = True
        sheet.row(self.current_line).height = 256*3
        sheet.write(self.current_line,1,title,xl_module.total_left)
        for j in (2,3,4,9,11) :
            sheet.write(self.current_line,j,"",xl_module.total_center)
        if i1<=i2 :
            for j in (5,6,7,8,10,12) :
                sheet.write(self.current_line,j,xl_module.range_sum(i1,j,i2,j),xl_module.total_center)
            sheet.write(self.current_line,13,xl_module.range_sum(i1,13,i2,13),xl_module.total_black)
            sheet.write(self.current_line,14,xl_module.range_sum(i1,14,i2,14),xl_module.total_black_red)

            for j in range(15,26) :
                sheet.write(self.current_line,j,xl_module.range_sum(i1,j,i2,j),xl_module.total_blue)

            sheet.write(self.current_line,26,xl_module.range_sum(i1,26,i2,26),xl_module.total_blue_red)
            sheet.write(self.current_line,27,xl_module.range_sum(i1,27,i2,27),xl_module.total_blue_red)
            sheet.write(self.current_line,28,xl_module.range_sum(i1,28,i2,28),xl_module.total_right)
        self.current_line += 1
 def _write_lines(self, cr, uid, ids, category_names, context=None) :
     i = self.current_line
     sheet = self.sheet
     today = self.today
     year = today.year
     month = today.month
     day = today.day
     sheet.row(i).height_mismatch = True
     sheet.row(i).height = 256/2*3
     for j in (13,14):
         sheet.write(i-1,j,"",xl_module.black_line)
     for j in range(15,28):
         sheet.write(i-1,j,"",xl_module.blue_line)
     assets = self._get_assets(cr, uid, ids, category_names=category_names, context=context)
     if not assets or len(assets)<=0:
         self.current_line += 1
         return
     for asset in assets :
         sheet.write(i,1,asset.name,xl_module.line_left)
         sheet.write(i,2,asset.code or "")
         sheet.write(i,3,asset.allocation or "")
         purchase_date = datetime.strptime(asset.purchase_date_2,'%Y-%m-%d')
         sheet.write(i,4,purchase_date.strftime('%d/%m/%Y'),xl_module.line)
         if purchase_date < datetime(2014,1,1):
             sheet.write(i,5,float(asset.x_purchase_value),xl_module.line)
         else:
             sheet.write(i,5,asset.purchase_value,xl_module.line)
         sheet.write(i,6,xl_module.list_sum([[i,5,+1],[i,12,-1]] if datetime.strptime(asset.purchase_date,'%Y-%m-%d') > datetime(year,1,1) else 0))
         sheet.write(i,10,xl_module.list_sum([[i,6,+1],[i,7,+1],[i,8,-1]]),xl_module.line)
         sheet.write(i,11,str(int(100.0/(asset.category_id.method_number/12.0))) + "%",xl_module.line)
         totcurr = an_dot = 0.0
         totpre = asset.dep_2013 or 0.0
         m_deprec = [0.0]*12
         if len(asset.depreciation_line_ids)>0:
             an_dot = asset.depreciation_line_ids[0].amount *12.0
             for line in asset.depreciation_line_ids :
                 deprec_date = datetime.strptime(line.depreciation_date,'%Y-%m-%d')
                 if deprec_date.year > 2013 and deprec_date.year < year:
                     totpre += line.amount
                 elif deprec_date.year == year :
                     m_deprec[deprec_date.month-1] = line.amount
                     if deprec_date < today:
                         totcurr += line.amount
         sheet.write(i,12,totpre,xl_module.line)
         sheet.write(i,13,an_dot,xl_module.black_line)
         sheet.write(i,14,totcurr,xl_module.black_red_line)
         for j in range(0,11) :
             sheet.write(i,15+j,m_deprec[j],xl_module.blue_line)
         sheet.write(i,26,m_deprec[11],xl_module.blue_red_line)
         sheet.write(i,27,xl_module.range_sum(i,15,i,26),xl_module.blue_red_line)
         sheet.write(i,28,asset.value_residual,xl_module.line_right)
         i += 1
     self.current_line = i