# -*- coding: utf-8 -*-
# © 2016 OpenSynergy Indonesia
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import models, api, _


class HrPayslip(models.Model):
    _inherit = "hr.payslip"

    @api.multi
    def button_import_attendance(self):
        for payslip in self:
            self._import_attendance(payslip)

    @api.model
    def _import_attendance(self, payslip):
        wd_obj = self.env["hr.payslip.worked_days"]
        day_obj = self.env["hr_timesheet_sheet.sheet.day"]
        date_from = payslip.date_from
        date_to = payslip.date_to

        criteria1 = [
            ("payslip_id", "=", payslip.id),
            ("import_from_attendance", "=", True),
        ]
        wd_obj.search(criteria1).unlink()

        res = {
            "name": _("Total Attendance"),
            "code": "ATTN",
            "number_of_days": 0.0,
            "number_of_hours": 0.0,
            "contract_id": payslip.contract_id.id,
            "import_from_attendance": True,
            "payslip_id": payslip.id,
        }

        criteria2 = [
            ("sheet_id.date_from", ">=", date_from),
            ("sheet_id.date_to", "<=", date_to),
            ("sheet_id.employee_id", "=", payslip.employee_id.id),
        ]

        for day in day_obj.search(criteria2):
            if day.total_attendance >= 0.0:
                res["number_of_days"] += 1
                res["number_of_hours"] += day.total_attendance

        wd_obj.create(res)

@@ -311,20 +311,23 @@
         
-self
+payslip
 ._import
@@ -338,23 +338,16 @@
 endance(
-payslip
 )%0A%0A    @
@@ -351,20 +351,20 @@
   @api.m
-odel
+ulti
 %0A    def
@@ -391,19 +391,36 @@
 self
-, payslip):
+):%0A        self.ensure_one()
 %0A   
@@ -547,23 +547,20 @@
 _from = 
-payslip
+self
 .date_fr
@@ -580,23 +580,20 @@
 te_to = 
-payslip
+self
 .date_to
@@ -648,23 +648,20 @@
 %22, %22=%22, 
-payslip
+self
 .id),%0A  
@@ -947,23 +947,20 @@
 ct_id%22: 
-payslip
+self
 .contrac
@@ -1038,23 +1038,20 @@
 ip_id%22: 
-payslip
+self
 .id,%0A   
@@ -1224,23 +1224,20 @@
 %22, %22=%22, 
-payslip
+self
 .employe
@@ -1242,24 +1242,67 @@
 yee_id.id),%0A
+            (%22sheet_id.state%22,%22=%22,%22done%22),%0A
         %5D%0A%0A 

Change api.model into api.multi. Only done timesheet can be imported