Files
gsinghpal 091f98e1f9 changes
2026-05-18 22:33:23 -04:00

45 lines
1.6 KiB
Python

# -*- coding: utf-8 -*-
# Copyright 2026 Nexa Systems Inc.
# License OPL-1 (Odoo Proprietary License v1.0)
"""Per-package row for outbound multi-piece shipments.
Each fp.receiving has zero-or-more fp.outbound.package rows. When the
operator clicks Generate Outbound Label, one stock.package + one
carrier label is generated per row.
Single-box scenario: the form auto-fills one row when the receiving's
top-level weight/dim are set, so existing UX still works.
Multi-box scenario: operator adds more rows. Each row gets its own
tracking number + label PDF/ZPL stored back on the row after the API
call returns.
"""
from odoo import fields, models
class FpOutboundPackage(models.Model):
_name = 'fp.outbound.package'
_description = 'Fusion Plating — Outbound Package (per-box detail)'
_order = 'sequence, id'
receiving_id = fields.Many2one(
'fp.receiving', required=True, ondelete='cascade', index=True,
)
sequence = fields.Integer(default=10)
weight = fields.Float(string='Weight', digits=(10, 3))
length = fields.Float(string='Length', digits=(10, 2))
width = fields.Float(string='Width', digits=(10, 2))
height = fields.Float(string='Height', digits=(10, 2))
# Populated by the carrier API once Generate Label fires.
tracking_number = fields.Char(readonly=True, copy=False)
label_attachment_id = fields.Many2one(
'ir.attachment',
string='Label',
ondelete='set null',
readonly=True,
copy=False,
)
# Computed convenience: filename of the label (for download UX).
label_filename = fields.Char(
related='label_attachment_id.name', readonly=True,
)