Files
Odoo-Modules/fusion_plating/fusion_plating/models/fp_tank_section.py
gsinghpal 13e300d90e changes
2026-04-28 19:39:37 -04:00

70 lines
1.9 KiB
Python

# -*- coding: utf-8 -*-
# Copyright 2026 Nexa Systems Inc.
# License OPL-1 (Odoo Proprietary License v1.0)
# Part of the Fusion Plating product family.
from odoo import api, fields, models
class FpTankSection(models.Model):
"""A user-defined grouping of tanks (e.g. "Steel Line", "Aluminum Line",
"Specialty Line").
Sections give the shop a familiar way to slice the tank list: every shop
organises its tanks differently — by metal, by chemistry family, by
physical aisle, or by customer programme — and a fixed taxonomy never
fits. Sections are free-form, renameable, and per-facility.
"""
_name = 'fusion.plating.tank.section'
_description = 'Fusion Plating — Tank Section'
_order = 'sequence, name'
name = fields.Char(
string='Section',
required=True,
translate=True,
)
sequence = fields.Integer(
string='Sequence',
default=10,
)
facility_id = fields.Many2one(
'fusion.plating.facility',
string='Facility',
ondelete='restrict',
)
color = fields.Integer(
string='Color',
default=0,
)
description = fields.Text(
string='Description',
translate=True,
)
active = fields.Boolean(default=True)
tank_ids = fields.One2many(
'fusion.plating.tank',
'section_id',
string='Tanks',
)
tank_count = fields.Integer(
compute='_compute_tank_count',
)
@api.depends('tank_ids')
def _compute_tank_count(self):
for rec in self:
rec.tank_count = len(rec.tank_ids)
def action_view_tanks(self):
self.ensure_one()
return {
'name': self.name,
'type': 'ir.actions.act_window',
'res_model': 'fusion.plating.tank',
'view_mode': 'list,kanban,form',
'domain': [('section_id', '=', self.id)],
'context': {'default_section_id': self.id},
}