42 lines
1.5 KiB
Python
42 lines
1.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Copyright 2026 Nexa Systems Inc.
|
|
# License OPL-1 (Odoo Proprietary License v1.0)
|
|
"""Backfill plating defaults from fp.invoice.strategy.default → res.partner.
|
|
|
|
v3.3 merges the per-customer invoice strategy onto the partner record
|
|
itself so the new "Plating Defaults" tab is the single source of truth.
|
|
Only plain columns are migrated here (invoice_strategy + deposit %).
|
|
The legacy `fp.invoice.strategy.default` model is left in place; the
|
|
new sale.order onchange falls back to it for any partner whose record
|
|
hasn't been migrated, so downstream code keeps working mid-rollout.
|
|
|
|
property_payment_term_id is intentionally skipped — it lives in
|
|
ir_property rather than as a plain column, and the legacy onchange
|
|
fallback already reads payment_term from the strategy default record
|
|
when the partner doesn't have one set directly.
|
|
"""
|
|
|
|
import logging
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
def migrate(cr, version):
|
|
if not version:
|
|
return
|
|
cr.execute("""
|
|
UPDATE res_partner p
|
|
SET x_fc_default_invoice_strategy = COALESCE(
|
|
p.x_fc_default_invoice_strategy, isd.default_strategy),
|
|
x_fc_default_deposit_percent = COALESCE(
|
|
NULLIF(p.x_fc_default_deposit_percent, 0),
|
|
isd.default_deposit_percent)
|
|
FROM fp_invoice_strategy_default isd
|
|
WHERE isd.partner_id = p.id
|
|
""")
|
|
_logger.info(
|
|
'fusion_plating_invoicing migration 19.0.3.3.0: backfilled %d '
|
|
'partner records from fp.invoice.strategy.default',
|
|
cr.rowcount,
|
|
)
|