# -*- 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 fields, models class FpPricingRule(models.Model): """Formula-based pricing rule. Rules are matched by coating config, substrate material, and certification level. The first matching rule (by sequence) wins. Global rules (no filters set) act as fallbacks. """ _name = 'fp.pricing.rule' _description = 'Fusion Plating — Pricing Rule' _order = 'sequence, id' name = fields.Char(string='Rule Name', required=True) coating_config_id = fields.Many2one('fp.coating.config', string='Coating Config', help='Leave blank for a global rule.') substrate_material = fields.Selection( [('aluminium', 'Aluminium'), ('steel', 'Steel'), ('stainless', 'Stainless Steel'), ('copper', 'Copper'), ('titanium', 'Titanium'), ('other', 'Other')], string='Substrate Material', help='Leave blank to match all materials.', ) certification_level = fields.Selection( [('commercial', 'Commercial'), ('mil_spec', 'Mil-Spec'), ('nadcap', 'Nadcap'), ('nuclear', 'Nuclear (CSA N299)')], string='Certification Level', help='Leave blank to match all levels.', ) pricing_method = fields.Selection( [('per_sqin', 'Per Square Inch'), ('per_sqft', 'Per Square Foot'), ('per_piece', 'Per Piece'), ('flat_rate', 'Flat Rate')], string='Pricing Method', required=True, default='per_sqin', ) currency_id = fields.Many2one('res.currency', string='Currency', default=lambda self: self.env.company.currency_id) base_rate = fields.Monetary(string='Base Rate', currency_field='currency_id', help='Price per unit (sq in, sq ft, piece, or flat).') thickness_factor = fields.Float(string='Thickness Factor', default=1.0, help='Multiplier per mil of coating thickness. 1.0 = no adjustment.') complexity_surcharge_ids = fields.One2many('fp.pricing.complexity.surcharge', 'rule_id', string='Complexity Surcharges') masking_rate_per_zone = fields.Monetary(string='Masking Rate / Zone', currency_field='currency_id') setup_fee = fields.Monetary(string='Setup Fee', currency_field='currency_id', help='One-time setup fee per batch.') minimum_charge = fields.Monetary(string='Minimum Charge', currency_field='currency_id', help='Floor price.') rush_surcharge_percent = fields.Float(string='Rush Surcharge %') sequence = fields.Integer(string='Sequence', default=10) active = fields.Boolean(string='Active', default=True) notes = fields.Text(string='Notes')