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_id = fields.Many2one(
|
||||||
'uom.uom', string='UoM',
|
'uom.uom', string='UoM',
|
||||||
)
|
)
|
||||||
unit_cost = fields.Float(
|
currency_id = fields.Many2one(
|
||||||
string='Unit Cost (snapshot)', digits=(12, 4),
|
'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.',
|
help='Taken from product.standard_price at log time.',
|
||||||
)
|
)
|
||||||
total_cost = fields.Float(
|
total_cost = fields.Monetary(
|
||||||
string='Total Cost', compute='_compute_total_cost', store=True, digits=(12, 2),
|
string='Total Cost', currency_field='currency_id',
|
||||||
)
|
compute='_compute_total_cost', store=True,
|
||||||
currency_id = fields.Many2one(
|
|
||||||
'res.currency', default=lambda self: self.env.company.currency_id,
|
|
||||||
)
|
)
|
||||||
logged_date = fields.Datetime(
|
logged_date = fields.Datetime(
|
||||||
string='Logged', default=fields.Datetime.now,
|
string='Logged', default=fields.Datetime.now,
|
||||||
|
|||||||
@@ -12,10 +12,12 @@
|
|||||||
<field name="product_id"/>
|
<field name="product_id"/>
|
||||||
<field name="quantity"/>
|
<field name="quantity"/>
|
||||||
<field name="uom_id"/>
|
<field name="uom_id"/>
|
||||||
<field name="unit_cost"/>
|
<field name="currency_id" column_invisible="1"/>
|
||||||
<field name="total_cost" sum="Total"/>
|
<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="source"/>
|
||||||
<field name="currency_id" invisible="1"/>
|
|
||||||
<field name="logged_by_id" optional="hide"/>
|
<field name="logged_by_id" optional="hide"/>
|
||||||
</list>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
@@ -38,9 +40,11 @@
|
|||||||
<group>
|
<group>
|
||||||
<field name="quantity"/>
|
<field name="quantity"/>
|
||||||
<field name="uom_id"/>
|
<field name="uom_id"/>
|
||||||
<field name="unit_cost"/>
|
<field name="currency_id"/>
|
||||||
<field name="total_cost" readonly="1"/>
|
<field name="unit_cost" widget="monetary"
|
||||||
<field name="currency_id" invisible="1"/>
|
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_date"/>
|
||||||
<field name="logged_by_id"/>
|
<field name="logged_by_id"/>
|
||||||
</group>
|
</group>
|
||||||
|
|||||||
@@ -29,17 +29,22 @@
|
|||||||
<field name="x_fc_currency_id" invisible="1"/>
|
<field name="x_fc_currency_id" invisible="1"/>
|
||||||
<group>
|
<group>
|
||||||
<field name="x_fc_quoted_revenue" readonly="1"
|
<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"
|
<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"
|
<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"
|
<field name="x_fc_actual_cost" readonly="1"
|
||||||
widget="monetary"/>
|
widget="monetary"
|
||||||
|
options="{'currency_field': 'x_fc_currency_id'}"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="x_fc_margin_actual" readonly="1"
|
<field name="x_fc_margin_actual" readonly="1"
|
||||||
widget="monetary"
|
widget="monetary"
|
||||||
|
options="{'currency_field': 'x_fc_currency_id'}"
|
||||||
decoration-success="x_fc_margin_actual > 0"
|
decoration-success="x_fc_margin_actual > 0"
|
||||||
decoration-danger="x_fc_margin_actual < 0"/>
|
decoration-danger="x_fc_margin_actual < 0"/>
|
||||||
<field name="x_fc_margin_pct" readonly="1"
|
<field name="x_fc_margin_pct" readonly="1"
|
||||||
|
|||||||
@@ -6,3 +6,36 @@
|
|||||||
from . import controllers
|
from . import controllers
|
||||||
from . import models
|
from . import models
|
||||||
from . import wizard
|
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)
|
||||||
|
|||||||
@@ -67,4 +67,6 @@ Provides:
|
|||||||
'installable': True,
|
'installable': True,
|
||||||
'application': False,
|
'application': False,
|
||||||
'auto_install': False,
|
'auto_install': False,
|
||||||
|
'post_init_hook': 'post_init_hook',
|
||||||
|
'post_load': None,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class FpCustomerPriceList(models.Model):
|
|||||||
)
|
)
|
||||||
currency_id = fields.Many2one(
|
currency_id = fields.Many2one(
|
||||||
'res.currency', string='Currency',
|
'res.currency', string='Currency',
|
||||||
default=lambda self: self.env.company.currency_id,
|
required=True, default=lambda self: self.env.company.currency_id,
|
||||||
)
|
)
|
||||||
effective_from = fields.Date(
|
effective_from = fields.Date(
|
||||||
string='Effective From', default=fields.Date.today, required=True, tracking=True,
|
string='Effective From', default=fields.Date.today, required=True, tracking=True,
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class FpPricingRule(models.Model):
|
|||||||
string='Pricing Method', required=True, default='per_sqin',
|
string='Pricing Method', required=True, default='per_sqin',
|
||||||
)
|
)
|
||||||
currency_id = fields.Many2one('res.currency', string='Currency',
|
currency_id = fields.Many2one('res.currency', string='Currency',
|
||||||
default=lambda self: self.env.company.currency_id)
|
required=True, default=lambda self: self.env.company.currency_id)
|
||||||
base_rate = fields.Monetary(string='Base Rate', currency_field='currency_id',
|
base_rate = fields.Monetary(string='Base Rate', currency_field='currency_id',
|
||||||
help='Price per unit (sq in, sq ft, piece, or flat).')
|
help='Price per unit (sq in, sq ft, piece, or flat).')
|
||||||
thickness_factor = fields.Float(string='Thickness Factor', default=1.0,
|
thickness_factor = fields.Float(string='Thickness Factor', default=1.0,
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ class FpQuoteConfigurator(models.Model):
|
|||||||
# ----- Pricing ----------------------------------------------------------
|
# ----- Pricing ----------------------------------------------------------
|
||||||
currency_id = fields.Many2one(
|
currency_id = fields.Many2one(
|
||||||
'res.currency', string='Currency',
|
'res.currency', string='Currency',
|
||||||
default=lambda self: self.env.company.currency_id,
|
required=True, default=lambda self: self.env.company.currency_id,
|
||||||
)
|
)
|
||||||
shipping_fee = fields.Monetary(string='Shipping Fee', currency_field='currency_id')
|
shipping_fee = fields.Monetary(string='Shipping Fee', currency_field='currency_id')
|
||||||
delivery_fee = fields.Monetary(string='Delivery Fee', currency_field='currency_id')
|
delivery_fee = fields.Monetary(string='Delivery Fee', currency_field='currency_id')
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ class FpTreatment(models.Model):
|
|||||||
currency_id = fields.Many2one(
|
currency_id = fields.Many2one(
|
||||||
'res.currency',
|
'res.currency',
|
||||||
string='Currency',
|
string='Currency',
|
||||||
|
required=True,
|
||||||
default=lambda self: self.env.company.currency_id,
|
default=lambda self: self.env.company.currency_id,
|
||||||
)
|
)
|
||||||
default_cost = fields.Monetary(
|
default_cost = fields.Monetary(
|
||||||
|
|||||||
@@ -19,8 +19,10 @@
|
|||||||
<field name="certification_level"/>
|
<field name="certification_level"/>
|
||||||
<field name="pricing_method"/>
|
<field name="pricing_method"/>
|
||||||
<field name="currency_id" column_invisible="1"/>
|
<field name="currency_id" column_invisible="1"/>
|
||||||
<field name="base_rate"/>
|
<field name="base_rate" widget="monetary"
|
||||||
<field name="minimum_charge"/>
|
options="{'currency_field': 'currency_id'}" sum="Total"/>
|
||||||
|
<field name="minimum_charge" widget="monetary"
|
||||||
|
options="{'currency_field': 'currency_id'}"/>
|
||||||
<field name="active" widget="boolean_toggle"/>
|
<field name="active" widget="boolean_toggle"/>
|
||||||
</list>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
@@ -54,15 +56,23 @@
|
|||||||
<group string="Pricing">
|
<group string="Pricing">
|
||||||
<group>
|
<group>
|
||||||
<field name="pricing_method"/>
|
<field name="pricing_method"/>
|
||||||
<field name="currency_id" invisible="1"/>
|
<field name="currency_id"/>
|
||||||
<field name="base_rate"/>
|
<field name="base_rate" widget="monetary"
|
||||||
|
options="{'currency_field': 'currency_id'}"/>
|
||||||
<field name="thickness_factor"/>
|
<field name="thickness_factor"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="masking_rate_per_zone"/>
|
<field name="masking_rate_per_zone" widget="monetary"
|
||||||
<field name="setup_fee"/>
|
options="{'currency_field': 'currency_id'}"/>
|
||||||
<field name="minimum_charge"/>
|
<field name="setup_fee" widget="monetary"
|
||||||
<field name="rush_surcharge_percent"/>
|
options="{'currency_field': 'currency_id'}"/>
|
||||||
|
<field name="minimum_charge" widget="monetary"
|
||||||
|
options="{'currency_field': 'currency_id'}"/>
|
||||||
|
<label for="rush_surcharge_percent"/>
|
||||||
|
<div class="o_row">
|
||||||
|
<field name="rush_surcharge_percent" nolabel="1" class="oe_inline"/>
|
||||||
|
<span class="ms-1">%</span>
|
||||||
|
</div>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<notebook>
|
<notebook>
|
||||||
@@ -70,7 +80,7 @@
|
|||||||
<field name="complexity_surcharge_ids">
|
<field name="complexity_surcharge_ids">
|
||||||
<list editable="bottom">
|
<list editable="bottom">
|
||||||
<field name="complexity"/>
|
<field name="complexity"/>
|
||||||
<field name="surcharge_percent"/>
|
<field name="surcharge_percent" string="Surcharge %"/>
|
||||||
</list>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
</page>
|
</page>
|
||||||
|
|||||||
@@ -198,19 +198,23 @@
|
|||||||
<group>
|
<group>
|
||||||
<group string="Delivery & Fees">
|
<group string="Delivery & Fees">
|
||||||
<field name="delivery_method"/>
|
<field name="delivery_method"/>
|
||||||
<field name="shipping_fee"/>
|
|
||||||
<field name="delivery_fee"/>
|
|
||||||
<field name="currency_id" invisible="1"/>
|
<field name="currency_id" invisible="1"/>
|
||||||
|
<field name="shipping_fee" widget="monetary"
|
||||||
|
options="{'currency_field': 'currency_id'}"/>
|
||||||
|
<field name="delivery_fee" widget="monetary"
|
||||||
|
options="{'currency_field': 'currency_id'}"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<separator string="Pricing"/>
|
<separator string="Pricing"/>
|
||||||
<group>
|
<group>
|
||||||
<group>
|
<group>
|
||||||
<field name="calculated_price" widget="monetary" readonly="1"
|
<field name="calculated_price" widget="monetary" readonly="1"
|
||||||
|
options="{'currency_field': 'currency_id'}"
|
||||||
class="fw-bold fs-4"/>
|
class="fw-bold fs-4"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="estimator_override_price" widget="monetary"/>
|
<field name="estimator_override_price" widget="monetary"
|
||||||
|
options="{'currency_field': 'currency_id'}"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
@@ -298,8 +302,11 @@
|
|||||||
<field name="surface_area"/>
|
<field name="surface_area"/>
|
||||||
<field name="quantity"/>
|
<field name="quantity"/>
|
||||||
<field name="currency_id" column_invisible="1"/>
|
<field name="currency_id" column_invisible="1"/>
|
||||||
<field name="calculated_price"/>
|
<field name="calculated_price" widget="monetary"
|
||||||
<field name="estimator_override_price" string="Final Price"/>
|
options="{'currency_field': 'currency_id'}" sum="Total"/>
|
||||||
|
<field name="estimator_override_price" string="Final Price"
|
||||||
|
widget="monetary"
|
||||||
|
options="{'currency_field': 'currency_id'}" sum="Total"/>
|
||||||
<field name="state" widget="badge"
|
<field name="state" widget="badge"
|
||||||
decoration-success="state == 'confirmed'"
|
decoration-success="state == 'confirmed'"
|
||||||
decoration-info="state == 'draft'"
|
decoration-info="state == 'draft'"
|
||||||
|
|||||||
@@ -15,9 +15,10 @@
|
|||||||
<field name="sequence" widget="handle"/>
|
<field name="sequence" widget="handle"/>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="treatment_type"/>
|
<field name="treatment_type"/>
|
||||||
<field name="default_duration_minutes"/>
|
<field name="default_duration_minutes" string="Duration (min)"/>
|
||||||
<field name="currency_id" column_invisible="1"/>
|
<field name="currency_id" column_invisible="1"/>
|
||||||
<field name="default_cost"/>
|
<field name="default_cost" widget="monetary"
|
||||||
|
options="{'currency_field': 'currency_id'}" sum="Total"/>
|
||||||
<field name="active" widget="boolean_toggle"/>
|
<field name="active" widget="boolean_toggle"/>
|
||||||
</list>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
@@ -41,9 +42,14 @@
|
|||||||
<field name="sequence"/>
|
<field name="sequence"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="default_duration_minutes"/>
|
<label for="default_duration_minutes"/>
|
||||||
<field name="currency_id" invisible="1"/>
|
<div class="o_row">
|
||||||
<field name="default_cost"/>
|
<field name="default_duration_minutes" nolabel="1" class="oe_inline"/>
|
||||||
|
<span class="ms-1">min</span>
|
||||||
|
</div>
|
||||||
|
<field name="currency_id"/>
|
||||||
|
<field name="default_cost" widget="monetary"
|
||||||
|
options="{'currency_field': 'currency_id'}"/>
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ class FpQuoteRequest(models.Model):
|
|||||||
currency_id = fields.Many2one(
|
currency_id = fields.Many2one(
|
||||||
'res.currency',
|
'res.currency',
|
||||||
string='Currency',
|
string='Currency',
|
||||||
|
required=True,
|
||||||
default=lambda self: self.env.company.currency_id,
|
default=lambda self: self.env.company.currency_id,
|
||||||
)
|
)
|
||||||
quoted_by_id = fields.Many2one(
|
quoted_by_id = fields.Many2one(
|
||||||
|
|||||||
@@ -23,8 +23,9 @@
|
|||||||
<field name="contact_name" optional="show"/>
|
<field name="contact_name" optional="show"/>
|
||||||
<field name="quantity"/>
|
<field name="quantity"/>
|
||||||
<field name="target_delivery"/>
|
<field name="target_delivery"/>
|
||||||
<field name="quoted_price" widget="monetary" optional="show"/>
|
<field name="currency_id" column_invisible="1"/>
|
||||||
<field name="currency_id" invisible="1"/>
|
<field name="quoted_price" widget="monetary"
|
||||||
|
options="{'currency_field': 'currency_id'}" optional="show" sum="Total"/>
|
||||||
<field name="state" widget="badge"
|
<field name="state" widget="badge"
|
||||||
decoration-info="state == 'new'"
|
decoration-info="state == 'new'"
|
||||||
decoration-warning="state == 'under_review'"
|
decoration-warning="state == 'under_review'"
|
||||||
@@ -80,9 +81,10 @@
|
|||||||
<field name="quantity"/>
|
<field name="quantity"/>
|
||||||
<field name="target_delivery"/>
|
<field name="target_delivery"/>
|
||||||
<field name="process_type_ids" widget="many2many_tags"/>
|
<field name="process_type_ids" widget="many2many_tags"/>
|
||||||
<field name="quoted_price" widget="monetary"
|
|
||||||
readonly="state in ('new','under_review')"/>
|
|
||||||
<field name="currency_id" groups="base.group_multi_currency"/>
|
<field name="currency_id" groups="base.group_multi_currency"/>
|
||||||
|
<field name="quoted_price" widget="monetary"
|
||||||
|
options="{'currency_field': 'currency_id'}"
|
||||||
|
readonly="state in ('new','under_review')"/>
|
||||||
<field name="quoted_by_id" readonly="1"/>
|
<field name="quoted_by_id" readonly="1"/>
|
||||||
<field name="quote_sent_date" readonly="1"/>
|
<field name="quote_sent_date" readonly="1"/>
|
||||||
<field name="customer_response_date" readonly="1"/>
|
<field name="customer_response_date" readonly="1"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user