Files
public/premium_client/models/premium_service.py

57 lines
2.3 KiB
Python

from odoo import fields, models, _
class PremiumService(models.Model):
_name = "premium.service"
_description = "Премиум: сервис/продукт"
_order = "sequence, name"
name = fields.Char(string="Название", required=True, translate=True)
sequence = fields.Integer(default=10)
category = fields.Selection(
selection=[
("services", "Услуги"),
("bank", "Банки, кассы, ЭДО"),
("wms", "WMS, логистика и ЧЗ"),
("marketplace", "Маркетплейсы"),
("industry", "Отраслевые"),
("other", "Другое"),
],
string="Категория",
required=True,
default="services",
translate=False,
)
short_description = fields.Text(string="Краткое описание", translate=True)
description = fields.Html(string="Описание", sanitize=True, translate=True)
author_url = fields.Char(string="Автор (URL)")
image = fields.Image(string="Изображение", max_width=1024, max_height=768)
# Контроль доступа (создание/изменение/удаление только администратором)
# обеспечивается ACL в security/ir.model.access.csv: base.group_user —
# только чтение, base.group_system — полный доступ. Ручные проверки в
# create/write/unlink были избыточным дублированием ACL (и давали raise
# в unlink), поэтому удалены — Odoo сам выбрасывает AccessError.
def action_open_form(self):
self.ensure_one()
return {
"type": "ir.actions.act_window",
"res_model": self._name,
"res_id": self.id,
"view_mode": "form",
"target": "current",
}
def action_open_order_wizard(self):
self.ensure_one()
return {
"name": _("Заказ сервиса"),
"type": "ir.actions.act_window",
"res_model": "premium.order.wizard",
"view_mode": "form",
"target": "new",
"context": {"default_service_id": self.id},
}