mirror of
https://github.com/bringout/oca-project.git
synced 2026-04-19 12:22:00 +02:00
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
# Copyright 2017 - 2018 Modoolar <info@modoolar.com>
|
|
# License LGPLv3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.en.html).
|
|
|
|
import werkzeug
|
|
|
|
from odoo import http
|
|
|
|
# from odoo.http import request
|
|
|
|
|
|
class ProjectBrowser(http.Controller):
|
|
def get_record_url(self, model, domain, action_xml_id):
|
|
env = http.request.env()
|
|
|
|
records = env[model].search(domain)
|
|
record_id = records and records.id or -1
|
|
action_id = env.ref(action_xml_id).id
|
|
|
|
return "/web#id={}&view_type=form&model={}&action={}".format(
|
|
record_id, model, action_id
|
|
)
|
|
|
|
def get_task_url(self, key):
|
|
return self.get_record_url(
|
|
"project.task", [("key", "=ilike", key)], "project.action_view_task"
|
|
)
|
|
|
|
def get_project_url(self, key):
|
|
return self.get_record_url(
|
|
"project.project",
|
|
[("key", "=ilike", key)],
|
|
"project.open_view_project_all_config",
|
|
)
|
|
|
|
@http.route(["/projects/<string:key>"], type="http", auth="user")
|
|
def open_project(self, key, **kwargs):
|
|
return werkzeug.utils.redirect(self.get_project_url(key), 301)
|
|
|
|
@http.route(["/tasks/<string:key>"], type="http", auth="user")
|
|
def open_task(self, key, **kwargs):
|
|
return werkzeug.utils.redirect(self.get_task_url(key), 301)
|