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>
This commit is contained in:
@@ -40,15 +40,17 @@ class FpJobConsumption(models.Model):
|
||||
uom_id = fields.Many2one(
|
||||
'uom.uom', string='UoM',
|
||||
)
|
||||
unit_cost = fields.Float(
|
||||
string='Unit Cost (snapshot)', digits=(12, 4),
|
||||
currency_id = fields.Many2one(
|
||||
'res.currency', required=True,
|
||||
default=lambda self: self.env.company.currency_id,
|
||||
)
|
||||
unit_cost = fields.Monetary(
|
||||
string='Unit Cost (snapshot)', currency_field='currency_id',
|
||||
help='Taken from product.standard_price at log time.',
|
||||
)
|
||||
total_cost = fields.Float(
|
||||
string='Total Cost', compute='_compute_total_cost', store=True, digits=(12, 2),
|
||||
)
|
||||
currency_id = fields.Many2one(
|
||||
'res.currency', default=lambda self: self.env.company.currency_id,
|
||||
total_cost = fields.Monetary(
|
||||
string='Total Cost', currency_field='currency_id',
|
||||
compute='_compute_total_cost', store=True,
|
||||
)
|
||||
logged_date = fields.Datetime(
|
||||
string='Logged', default=fields.Datetime.now,
|
||||
|
||||
@@ -12,10 +12,12 @@
|
||||
<field name="product_id"/>
|
||||
<field name="quantity"/>
|
||||
<field name="uom_id"/>
|
||||
<field name="unit_cost"/>
|
||||
<field name="total_cost" sum="Total"/>
|
||||
<field name="currency_id" column_invisible="1"/>
|
||||
<field name="unit_cost" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"/>
|
||||
<field name="total_cost" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}" sum="Total"/>
|
||||
<field name="source"/>
|
||||
<field name="currency_id" invisible="1"/>
|
||||
<field name="logged_by_id" optional="hide"/>
|
||||
</list>
|
||||
</field>
|
||||
@@ -38,9 +40,11 @@
|
||||
<group>
|
||||
<field name="quantity"/>
|
||||
<field name="uom_id"/>
|
||||
<field name="unit_cost"/>
|
||||
<field name="total_cost" readonly="1"/>
|
||||
<field name="currency_id" invisible="1"/>
|
||||
<field name="currency_id"/>
|
||||
<field name="unit_cost" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"/>
|
||||
<field name="total_cost" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}" readonly="1"/>
|
||||
<field name="logged_date"/>
|
||||
<field name="logged_by_id"/>
|
||||
</group>
|
||||
|
||||
@@ -29,17 +29,22 @@
|
||||
<field name="x_fc_currency_id" invisible="1"/>
|
||||
<group>
|
||||
<field name="x_fc_quoted_revenue" readonly="1"
|
||||
widget="monetary"/>
|
||||
widget="monetary"
|
||||
options="{'currency_field': 'x_fc_currency_id'}"/>
|
||||
<field name="x_fc_labour_cost" readonly="1"
|
||||
widget="monetary"/>
|
||||
widget="monetary"
|
||||
options="{'currency_field': 'x_fc_currency_id'}"/>
|
||||
<field name="x_fc_consumables_cost" readonly="1"
|
||||
widget="monetary"/>
|
||||
widget="monetary"
|
||||
options="{'currency_field': 'x_fc_currency_id'}"/>
|
||||
<field name="x_fc_actual_cost" readonly="1"
|
||||
widget="monetary"/>
|
||||
widget="monetary"
|
||||
options="{'currency_field': 'x_fc_currency_id'}"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="x_fc_margin_actual" readonly="1"
|
||||
widget="monetary"
|
||||
options="{'currency_field': 'x_fc_currency_id'}"
|
||||
decoration-success="x_fc_margin_actual > 0"
|
||||
decoration-danger="x_fc_margin_actual < 0"/>
|
||||
<field name="x_fc_margin_pct" readonly="1"
|
||||
|
||||
Reference in New Issue
Block a user