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

49 lines
2.4 KiB
Python

# -*- coding: utf-8 -*-
# Copyright 2026 Nexa Systems Inc.
# License OPL-1 (Odoo Proprietary License v1.0)
from odoo import api, fields, models
from odoo.addons.fusion_plating.models._fp_uom_selection import FP_UOM_SELECTION
class FpWasteManifest(models.Model):
_name = 'fusion.plating.waste.manifest'
_description = 'Fusion Plating - Waste Manifest'
_inherit = ['mail.thread', 'mail.activity.mixin']
_order = 'ship_date desc, id desc'
name = fields.Char(string='Reference', required=True, copy=False, default=lambda s: s._default_name(), tracking=True)
waste_stream_id = fields.Many2one('fusion.plating.waste.stream', string='Waste Stream', required=True, ondelete='restrict', tracking=True)
facility_id = fields.Many2one('fusion.plating.facility', related='waste_stream_id.facility_id', store=True, readonly=True)
company_id = fields.Many2one('res.company', related='facility_id.company_id', store=True, readonly=True)
ship_date = fields.Date(string='Ship Date', default=fields.Date.context_today, tracking=True)
quantity = fields.Float(string='Quantity', digits=(16, 3),
help='Quantity shipped, expressed in the unit selected below.')
uom = fields.Selection(FP_UOM_SELECTION, string='UoM', default='kg',
help='Unit of the shipped quantity (kg, L, m³, etc.).')
carrier_id = fields.Many2one('res.partner', string='Carrier', domain=[('is_company', '=', True)], tracking=True)
receiver_id = fields.Many2one('res.partner', string='Receiver', domain=[('is_company', '=', True)], tracking=True)
manifest_number = fields.Char(string='Manifest #', tracking=True)
state = fields.Selection(
[('draft', 'Draft'), ('shipped', 'Shipped'), ('received', 'Received'), ('closed', 'Closed')],
string='Status', default='draft', required=True, tracking=True,
)
attachment_ids = fields.Many2many(
'ir.attachment', 'fp_waste_manifest_attachment_rel', 'manifest_id', 'attachment_id', string='Attachments',
)
notes = fields.Html(string='Notes')
@api.model
def _default_name(self):
seq = self.env['ir.sequence'].next_by_code('fusion.plating.waste.manifest')
return seq or '/'
def action_ship(self):
self.write({'state': 'shipped'})
def action_receive(self):
self.write({'state': 'received'})
def action_close(self):
self.write({'state': 'closed'})