from odoo import models, fields, api class LaundryOrderLineAddon(models.Model): """Optional add-on service attached to one sale.order.line. Examples per item: - Express handling (+10 SAR) - Starch / تقطير (+3 SAR) - Packaging (+2 SAR) - Perfume scent (+5 SAR) The parent line's subtotal does NOT automatically include add-on prices (sale.order.line controls its own subtotal). Add-ons are tracked here for printing and reporting purposes; staff can create a separate order line for the add-on product if billing is required. """ _name = 'laundry.order.line.addon' _description = 'Order Line Add-on' _order = 'line_id, id' line_id = fields.Many2one( 'sale.order.line', string='Order Line', required=True, ondelete='cascade', index=True, ) # Denormal for easy reporting — derived from sale.order.line.order_id order_id = fields.Many2one( 'sale.order', related='line_id.order_id', store=True, index=True, ) name = fields.Char( string='Add-on / الإضافة', required=True, help='Name of the additional service (e.g. Express, Starch, Packaging).', ) price = fields.Float( string='Price / السعر', required=True, digits=(10, 2), default=0.0, ) quantity = fields.Float( string='Qty', default=1.0, digits=(10, 2), ) subtotal = fields.Float( string='Subtotal', compute='_compute_subtotal', store=True, digits=(10, 2), ) @api.depends('price', 'quantity') def _compute_subtotal(self): for addon in self: addon.subtotal = addon.price * addon.quantity