Files
Odoo-Modules/fusion_plating/scripts/fp_reset_cert_30045.py
gsinghpal 1314f4581d changes
2026-05-21 03:37:25 -04:00

57 lines
2.1 KiB
Python

# -*- coding: utf-8 -*-
"""One-off: reset CoC-30045 to draft for re-issue testing.
Clears all thickness data + attachments so the operator can re-run
the Issue Certs wizard from a clean slate (upload RTF + PNG image,
verify the full inline-render flow).
Run with:
odoo shell -c /etc/odoo/odoo.conf -d admin --no-http < this_file
"""
cert = env['fp.certificate'].browse(501)
print('before: state=%s, readings=%d, attachment_id=%s, evidence=%s, image=%s' % (
cert.state,
len(cert.thickness_reading_ids),
cert.attachment_id.id if cert.attachment_id else None,
cert.x_fc_local_thickness_evidence_id.id if cert.x_fc_local_thickness_evidence_id else None,
cert.x_fc_thickness_image_id.id if cert.x_fc_thickness_image_id else None,
))
# Drop all readings
n_readings = len(cert.thickness_reading_ids)
cert.thickness_reading_ids.unlink()
# Delete any attachments on the cert (RTF, regenerated PDF, image)
atts = env['ir.attachment'].search([
('res_model', '=', 'fp.certificate'),
('res_id', '=', cert.id),
])
n_atts = len(atts)
atts.unlink()
# Wipe cert-level thickness metadata + state-affecting fields
cert.write({
'state': 'draft',
'attachment_id': False,
'x_fc_local_thickness_pdf': False,
'x_fc_local_thickness_pdf_filename': False,
'x_fc_local_thickness_evidence_id': False,
'x_fc_thickness_image_id': False,
'x_fc_thickness_operator': False,
'x_fc_thickness_product': False,
'x_fc_thickness_application': False,
'x_fc_thickness_directory': False,
'x_fc_thickness_equipment': False,
'x_fc_thickness_datetime': False,
'x_fc_thickness_measuring_time_sec': 0,
'x_fc_thickness_source_filename': False,
})
env.cr.commit()
cert.invalidate_recordset()
print('after: state=%s, readings=%d, attachments_removed=%d, prior_readings=%d' % (
cert.state, len(cert.thickness_reading_ids), n_atts, n_readings,
))
print('CoC-30045 ready for re-issue. Open the Issue Certs wizard '
'from WO-30045, upload the RTF + PNG image, click Confirm & Issue.')