from odoo import models, fields


class FusionOrderPackage(models.Model):
    """Stores per-package dimensions and service info on a sale order.

    Created when the user confirms the "Add Shipping" wizard after
    defining one or more packages with dimensions.
    Used by ``send_shipping`` to apply the correct dimensions
    to each physical package on the delivery order.
    """

    _name = 'fusion.order.package'
    _description = 'Order Package'
    _order = 'sequence, id'

    sale_order_id = fields.Many2one(
        'sale.order',
        string='Sale Order',
        ondelete='cascade',
        required=True,
        index=True,
    )
    sequence = fields.Integer(default=10)
    package_type_id = fields.Many2one(
        'stock.package.type',
        string='Box Type',
    )
    package_length = fields.Float(string='Length')
    package_width = fields.Float(string='Width')
    package_height = fields.Float(string='Height')
    weight = fields.Float(string='Weight')
    service_code = fields.Char(string='Service Code')
    service_name = fields.Char(string='Service')
    price = fields.Float(string='Shipping Cost', digits='Product Price')
    expected_delivery = fields.Char(string='Expected Delivery')
    currency_id = fields.Many2one(
        'res.currency',
        related='sale_order_id.currency_id',
    )
