addons14/project_timesheet_time_control/wizards/hr_timesheet_switch.py
def _closest_suggestion(self):
        """Find most similar account.analytic.line record."""
        try:
            active = self.env[self.env.context["active_model"]].browse(
                self.env.context["active_id"]
            )
        except KeyError:
            # If I don't know where's the user, I don't know what to suggest
            return self.env["account.analytic.line"].browse()
        # If you're browsing another account.analytic.line, that's the match
        if active._name == "account.analytic.line":
            return active
        # If browsing other models, prepare a search
        domain = [("employee_id", "in", self.env.user.employee_ids.ids)]
        if active._name == "project.task":
            domain.append(("task_id", "=", active.id))
        elif active._name == "project.project":
            domain += [
                ("project_id", "=", active.id),
                ("task_id", "=", False),
            ]
        else:
            # No clues for other records, sorry
            return self.env["account.analytic.line"].browse()
        return self.env["account.analytic.line"].search(
            domain,
            order="date_time DESC",
            limit=1,
        )
Find most similar account.analytic.line record.
Find most similar account.analytic.line record.
Find most similar account . analytic . line record .
def _closest_suggestion(self):
        try:
            active = self.env[self.env.context["active_model"]].browse(
                self.env.context["active_id"]
            )
        except KeyError:
            return self.env["account.analytic.line"].browse()
        if active._name == "account.analytic.line":
            return active
        domain = [("employee_id", "in", self.env.user.employee_ids.ids)]
        if active._name == "project.task":
            domain.append(("task_id", "=", active.id))
        elif active._name == "project.project":
            domain += [
                ("project_id", "=", active.id),
                ("task_id", "=", False),
            ]
        else:
            return self.env["account.analytic.line"].browse()
        return self.env["account.analytic.line"].search(
            domain,
            order="date_time DESC",
            limit=1,
        )
def _closest_suggestion ( self ) : try : active = self . env [ self . env . context [ "active_model" ] ] . browse ( self . env . context [ "active_id" ] ) except KeyError : return self . env [ "account.analytic.line" ] . browse ( ) if active . _name == "account.analytic.line" : return active domain = [ ( "employee_id" , "in" , self . env . user . employee_ids . ids ) ] if active . _name == "project.task" : domain . append ( ( "task_id" , "=" , active . id ) ) elif active . _name == "project.project" : domain += [ ( "project_id" , "=" , active . id ) , ( "task_id" , "=" , False ) , ] else : return self . env [ "account.analytic.line" ] . browse ( ) return self . env [ "account.analytic.line" ] . search ( domain , order = "date_time DESC" , limit = 1 , )
Find most similar account.analytic.line record.
Find most similar account . analytic . line record .
"""Find most similar account.analytic.line record.""" # If I don't know where's the user, I don't know what to suggest # If you're browsing another account.analytic.line, that's the match # If browsing other models, prepare a search # No clues for other records, sorry
self