addons14/project_timesheet_time_control/wizards/hr_timesheet_switch.py
def action_switch(self):
        """Stop old timer, start new one."""
        self.ensure_one()
        # Stop old timer
        self.with_context(
            resuming_lines=self.ids,
            stop_dt=self.date_time,
        ).running_timer_id.button_end_work()
        # Start new timer
        _fields = self.env["account.analytic.line"]._fields.keys()
        self.read(_fields)
        values = self._convert_to_write(self._cache)
        new = self.env["account.analytic.line"].create(
            {field: value for (field, value) in values.items() if field in _fields}
        )
        # Display created timer record if requested
        if self.env.context.get("show_created_timer"):
            form_view = self.env.ref("hr_timesheet.hr_timesheet_line_form")
            return {
                "res_id": new.id,
                "res_model": new._name,
                "type": "ir.actions.act_window",
                "view_mode": "form",
                "view_type": "form",
                "views": [(form_view.id, "form")],
            }
        # Close wizard and reload view
        return {
            "type": "ir.actions.act_multi",
            "actions": [
                {"type": "ir.actions.act_window_close"},
                {"type": "ir.actions.act_view_reload"},
            ],
        }
Stop old timer, start new one.
Stop old timer, start new one.
Stop old timer start new one .
def action_switch(self):
        self.ensure_one()
        self.with_context(
            resuming_lines=self.ids,
            stop_dt=self.date_time,
        ).running_timer_id.button_end_work()
        _fields = self.env["account.analytic.line"]._fields.keys()
        self.read(_fields)
        values = self._convert_to_write(self._cache)
        new = self.env["account.analytic.line"].create(
            {field: value for (field, value) in values.items() if field in _fields}
        )
        if self.env.context.get("show_created_timer"):
            form_view = self.env.ref("hr_timesheet.hr_timesheet_line_form")
            return {
                "res_id": new.id,
                "res_model": new._name,
                "type": "ir.actions.act_window",
                "view_mode": "form",
                "view_type": "form",
                "views": [(form_view.id, "form")],
            }
        return {
            "type": "ir.actions.act_multi",
            "actions": [
                {"type": "ir.actions.act_window_close"},
                {"type": "ir.actions.act_view_reload"},
            ],
        }
def action_switch ( self ) : self . ensure_one ( ) self . with_context ( resuming_lines = self . ids , stop_dt = self . date_time , ) . running_timer_id . button_end_work ( ) _fields = self . env [ "account.analytic.line" ] . _fields . keys ( ) self . read ( _fields ) values = self . _convert_to_write ( self . _cache ) new = self . env [ "account.analytic.line" ] . create ( { field : value for ( field , value ) in values . items ( ) if field in _fields } ) if self . env . context . get ( "show_created_timer" ) : form_view = self . env . ref ( "hr_timesheet.hr_timesheet_line_form" ) return { "res_id" : new . id , "res_model" : new . _name , "type" : "ir.actions.act_window" , "view_mode" : "form" , "view_type" : "form" , "views" : [ ( form_view . id , "form" ) ] , } return { "type" : "ir.actions.act_multi" , "actions" : [ { "type" : "ir.actions.act_window_close" } , { "type" : "ir.actions.act_view_reload" } , ] , }
Stop old timer, start new one.
Stop old timer start new one .
"""Stop old timer, start new one.""" # Stop old timer # Start new timer # Display created timer record if requested # Close wizard and reload view
self