feat(configurator): fp.pricing.rule — formula-based pricing engine with complexity surcharges

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-04-12 18:28:43 -04:00
parent 2e80fd3ca1
commit 2fa7f2aa2e
5 changed files with 218 additions and 1 deletions

View File

@@ -6,3 +6,6 @@
from . import fp_treatment
from . import fp_part_catalog
from . import fp_coating_config
from . import fp_pricing_complexity_surcharge
from . import fp_pricing_rule
from . import sale_order

View File

@@ -0,0 +1,25 @@
# -*- 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 FpPricingComplexitySurcharge(models.Model):
"""Complexity-based surcharge line on a pricing rule."""
_name = 'fp.pricing.complexity.surcharge'
_description = 'Fusion Plating — Pricing Complexity Surcharge'
_order = 'complexity'
rule_id = fields.Many2one('fp.pricing.rule', string='Pricing Rule', required=True, ondelete='cascade')
complexity = fields.Selection(
[('simple', 'Simple'), ('moderate', 'Moderate'), ('complex', 'Complex'), ('very_complex', 'Very Complex')],
string='Complexity', required=True,
)
surcharge_percent = fields.Float(string='Surcharge %', help='Additional percentage on top of base price.')
_sql_constraints = [
('fp_pricing_surcharge_rule_complexity_uniq', 'unique(rule_id, complexity)',
'Only one surcharge per complexity level per rule.'),
]

View File

@@ -0,0 +1,54 @@
# -*- 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')