Files
Odoo-Modules/fusion_plating/scripts/fp_bol_pageverify.py
gsinghpal b16486f66b fix(reports): keep BoL signature row intact across page breaks
Landscape BoL was splitting the signature row down the middle —
boxes half on page 1, half on page 2. Two complementary fixes:

1. **Per-element rule**: added `page-break-inside: avoid` +
   `break-inside: avoid` to `.sig-box` (both portrait + landscape
   styles) so an individual signature box can never split across
   pages.

2. **Wrapper rule**: introduced `.fp-keep-together` utility +
   wrapped the BoL's certification statement + signature row in
   it, so the whole "sign here" block moves to the next page as
   one unit if it doesn't fit. Also applied
   `page-break-inside: avoid` to `table tr` so cargo lines don't
   split mid-row either.

Lives in shared `report_base_styles.xml` so any FP template that
opts into `.fp-keep-together` benefits automatically.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-19 07:35:55 -04:00

32 lines
1.2 KiB
Python

env = env # noqa
import subprocess, os
rep = env.ref('fusion_plating_reports.action_report_fp_bol_landscape')
dlv = env['fusion.plating.delivery'].search([], order='id desc', limit=1)
pdf, _ = rep.with_context(force_report_rendering=True
)._render_qweb_pdf(rep.report_name, [dlv.id])
path = '/tmp/bol_landscape.pdf'
with open(path, 'wb') as f:
f.write(pdf)
print(f'wrote {len(pdf)/1024:.1f} KB to {path}')
# Extract text per page using pdftotext (poppler-utils)
try:
for p in (1, 2, 3):
out = subprocess.run(
['pdftotext', '-layout', '-f', str(p), '-l', str(p), path, '-'],
capture_output=True, text=True, timeout=10
)
if out.returncode != 0 or not out.stdout.strip():
continue
text = out.stdout
sig_labels = [
'Shipper (Signature' in text,
'Carrier / Driver' in text,
'Consignee (Signature' in text,
]
cert_present = 'is to certify' in text
print(f'PAGE {p}: cert={cert_present} sigs={sig_labels} '
f'(all-3-sigs-together={all(sig_labels)})')
except FileNotFoundError:
print('pdftotext not installed — skipping per-page text check')