Files
repair/odoo/addons/dsrpt_repair_materials/models/material.py
2026-02-13 16:44:40 +07:00

37 lines
1.2 KiB
Python

from odoo import fields, models
class RepairMaterial(models.Model):
_name = "repair.material"
_description = "Repair Material"
_order = "name"
_inherit = ["mail.thread", "mail.activity.mixin"]
name = fields.Char(required=True, tracking=True)
default_code = fields.Char(string="Code", tracking=True)
uom_name = fields.Char(string="UoM", default="pcs", tracking=True)
standard_cost = fields.Float(string="Cost", tracking=True)
state = fields.Selection(
selection=[
("draft", "Draft"),
("active", "Active"),
("archived", "Archived"),
],
default="draft",
tracking=True,
group_expand="_group_expand_states",
)
active = fields.Boolean(default=True, tracking=True)
def _group_expand_states(self, states, domain, order):
return [key for key, _label in self._fields["state"].selection]
def action_set_active(self):
self.write({"state": "active", "active": True})
def action_archive(self):
self.write({"state": "archived", "active": False})
def action_reset_draft(self):
self.write({"state": "draft", "active": True})