🎉 Initialize module repository
This commit is contained in:
52
models/mvd_tcg_mtg_card_legality.py
Normal file
52
models/mvd_tcg_mtg_card_legality.py
Normal file
@@ -0,0 +1,52 @@
|
||||
"""Magic: The Gathering legality models."""
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
LEGALITY_SELECTION = [
|
||||
("legal", "Legal"),
|
||||
("not_legal", "Not Legal"),
|
||||
("restricted", "Restricted"),
|
||||
("banned", "Banned"),
|
||||
]
|
||||
|
||||
|
||||
class MvdTcgMtgCardLegality(models.Model):
|
||||
"""Store one legality status per MTG card and constructed format."""
|
||||
|
||||
_name = "mvd.tcg.mtg.card.legality"
|
||||
_description = "MTG Card Legality"
|
||||
_order = "format_sequence, id"
|
||||
|
||||
card_id = fields.Many2one(
|
||||
"mvd.tcg.card",
|
||||
required=True,
|
||||
index=True,
|
||||
ondelete="cascade",
|
||||
)
|
||||
format_id = fields.Many2one(
|
||||
"mvd.tcg.mtg.format",
|
||||
required=True,
|
||||
index=True,
|
||||
ondelete="restrict",
|
||||
)
|
||||
format_code = fields.Char(
|
||||
related="format_id.code",
|
||||
store=True,
|
||||
index=True,
|
||||
)
|
||||
format_sequence = fields.Integer(
|
||||
related="format_id.sequence",
|
||||
store=True,
|
||||
index=True,
|
||||
)
|
||||
status = fields.Selection(
|
||||
selection=LEGALITY_SELECTION,
|
||||
required=True,
|
||||
default="not_legal",
|
||||
index=True,
|
||||
)
|
||||
|
||||
_card_format_unique = models.Constraint(
|
||||
"UNIQUE (card_id, format_id)",
|
||||
"The MTG legality format must be unique per card.",
|
||||
)
|
||||
Reference in New Issue
Block a user