52 lines
2.0 KiB
Python
52 lines
2.0 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 FpReceivingDamage(models.Model):
|
|
"""Damage log entry on a receiving record.
|
|
|
|
Documents condition issues found during parts inspection:
|
|
severity, photos, required action, and customer follow-up.
|
|
"""
|
|
_name = 'fp.receiving.damage'
|
|
_description = 'Fusion Plating — Receiving Damage'
|
|
_order = 'id'
|
|
|
|
receiving_id = fields.Many2one(
|
|
'fp.receiving', string='Receiving', required=True, ondelete='cascade',
|
|
)
|
|
description = fields.Text(string='Description', required=True, help='What is damaged.')
|
|
severity = fields.Selection(
|
|
[('cosmetic', 'Cosmetic'), ('functional', 'Functional'), ('rejected', 'Rejected')],
|
|
string='Severity', required=True, default='cosmetic',
|
|
)
|
|
photo_ids = fields.Many2many(
|
|
'ir.attachment', 'fp_receiving_damage_photo_rel', 'damage_id', 'attachment_id',
|
|
string='Photos',
|
|
)
|
|
action_required = fields.Selection(
|
|
[('none', 'None'), ('notify_customer', 'Notify Customer'),
|
|
('return_parts', 'Return Parts'), ('proceed_as_is', 'Proceed As-Is')],
|
|
string='Action Required', default='none',
|
|
)
|
|
customer_notified = fields.Boolean(string='Customer Notified')
|
|
customer_response = fields.Text(string='Customer Response')
|
|
resolved = fields.Boolean(string='Resolved')
|
|
|
|
@api.depends('severity', 'description', 'receiving_id')
|
|
def _compute_display_name(self):
|
|
labels = dict(self._fields['severity'].selection)
|
|
for rec in self:
|
|
severity = labels.get(rec.severity, rec.severity or '')
|
|
desc = (rec.description or '').strip().split('\n', 1)[0][:40]
|
|
bits = []
|
|
if severity:
|
|
bits.append(severity)
|
|
if desc:
|
|
bits.append(desc)
|
|
rec.display_name = ': '.join(bits) or 'Damage'
|