fix(promote-customer-spec): leftover has_cost_data ref in _compute_margin

Phase E removed the coating-rollup loop but left a stale `has_cost_data`
reference in the percent computation. NameError on every SO list /
form load.

Margin is "not available" until recipe-level cost data exists
(backlog item). Set all three margin fields to 0 / False explicitly
so no stale references remain.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-05-15 07:11:41 -04:00
parent d891002c84
commit 7d27db69c6

View File

@@ -563,11 +563,8 @@ class SaleOrder(models.Model):
""" """
for rec in self: for rec in self:
rec.x_fc_margin_available = False rec.x_fc_margin_available = False
rec.x_fc_margin_amount = (rec.amount_untaxed or 0) rec.x_fc_margin_amount = 0.0
rec.x_fc_margin_percent = ( rec.x_fc_margin_percent = 0.0
(rec.x_fc_margin_amount / rec.amount_untaxed)
if (rec.amount_untaxed and has_cost_data) else 0.0
)
@api.onchange('upload_rfq_file') @api.onchange('upload_rfq_file')
def _onchange_upload_rfq_file(self): def _onchange_upload_rfq_file(self):