server-ux/document_quick_access/models/base.py

18 lines
455 B
Python
Raw Normal View History

2021-03-23 19:15:27 +00:00
# Copyright 2019 Creu Blanca
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from flectra import models
class Base(models.AbstractModel):
_inherit = "base"
def get_quick_access_code(self):
self.ensure_one()
rule = self.env["document.quick.access.rule"].search(
[("model_id.model", "=", self._name)], limit=1
)
if not rule:
return False
return rule.get_code(self)