Files
Odoo-Modules/fusion_plating/fusion_plating_configurator/__init__.py
gsinghpal 70fe10c214 fix(configurator): money fields now show $ everywhere
Root cause: pricing.rule records had currency_id=NULL because the
default=lambda only applies on new records. Monetary fields without a
currency silently render as plain numbers — no $ symbol.

Fixes:

1. currency_id now required=True on fp.pricing.rule, fp.treatment,
   fp.customer.price.list, fp.quote.configurator, fusion.plating.quote.request
   — so it can never be missing going forward.

2. post_init_hook + matching backfill helper in
   fusion_plating_configurator/__init__.py pins the company currency
   on any existing records that were created before the required flag.
   Ran on upgrade → all 4 pricing.rule rows now have CAD/$.

3. Flipped two remaining Float money fields to Monetary:
   - fp.job.consumption.unit_cost and total_cost (were Float digits=4/2)
   - (mrp.workorder.x_fc_workcenter_cost_hour stays Float — it is a
     related field from core mrp.workcenter.costs_hour which is Float)

4. Every Monetary field reference in views now has explicit:
     widget="monetary" options="{'currency_field': 'currency_id'}"
   Previously Odoo's default rendering dropped the $ in some contexts.
   Touched: fp_pricing_rule_views (list + form), fp_treatment_views,
   fp_customer_price_list_views (already done), fp_quote_configurator_views
   (list + form shipping/delivery/calculated/override), fp_quote_request_views
   (list + form), fp_job_consumption_views, mrp_production_views job-costing
   group, direct-order wizard (already done earlier).

5. Unit / % suffix polish as we went: rush_surcharge_percent shows "%",
   default_duration_minutes shows "min" on treatment form, treatment list
   labels duration column.

Verified: all 4 pricing rules now render "$0.45", "$0.85" etc; 62 records
across 6 models all have currency_id populated; zero remaining Float $
fields in the codebase.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-17 18:54:14 -04:00

42 lines
1.1 KiB
Python

# -*- coding: utf-8 -*-
# Copyright 2026 Nexa Systems Inc.
# License OPL-1 (Odoo Proprietary License v1.0)
# Part of the Fusion Plating product family.
from . import controllers
from . import models
from . import wizard
def _backfill_currency(env):
"""Fill missing currency_id on existing money-holding records.
Older demo data and manually-created rows were persisted before the
`required=True` was added, so some records sit with currency_id=NULL
and Monetary fields render without a $ symbol. This runs on module
install/upgrade and pins them to the company's currency.
"""
company_currency = env.company.currency_id.id
if not company_currency:
return
for model_name in (
'fp.pricing.rule',
'fp.treatment',
'fp.customer.price.list',
'fp.quote.configurator',
):
Model = env.get(model_name)
if Model is None:
continue
Model.search([('currency_id', '=', False)]).write(
{'currency_id': company_currency}
)
def post_init_hook(env):
_backfill_currency(env)
def post_upgrade_hook(env):
_backfill_currency(env)