Skip to content

[16.0][FIX] budget_appropriation_summary: repeat page label on every PDF page#773

Open
n3n wants to merge 3 commits into
16.0from
n3n/16.0-fix-budget_appropriation_summary-pdf-label
Open

[16.0][FIX] budget_appropriation_summary: repeat page label on every PDF page#773
n3n wants to merge 3 commits into
16.0from
n3n/16.0-fix-budget_appropriation_summary-pdf-label

Conversation

@n3n
Copy link
Copy Markdown
Member

@n3n n3n commented May 22, 2026

Summary

  • เมื่อกดปุ่ม "พิมพ์ PDF" จากหน้า master.summary ลาเบลมุมขวาบน (เช่น F2-W-วง-003) จะแสดงเฉพาะหน้าแรกของแต่ละ sub-report เพราะ wkhtmltopdf ไม่ทำซ้ำ element ที่ position fixed/absolute ในแต่ละหน้า
  • เพิ่ม sibling `<div class="header">` ใน template `report_page_label` เพื่อให้ Odoo's `_prepare_html` ดึงไปใส่ header-html ของ wkhtmltopdf ลาเบลจึงแสดงทุกหน้าใน PDF
  • ซ่อน header div นี้บนหน้าจอด้วย CSS เพื่อคงพฤติกรรมเดิมของ HTML preview และ portal print (browser print)

Test plan

เคสที่ 1 — "พิมพ์ PDF" จาก master.summary (เคสที่ buggy)

  1. ไปที่เมนู งบประมาณ → สรุปงบประมาณ → สรุปภาพรวมสถาบัน
  2. เปิด record สรุปภาพรวมสถาบันที่มีข้อมูลรายงานหลายหน้า (เช่นมี F11-W ที่ทอดหลายหน้า)
  3. ที่แถบปุ่มด้านบนของฟอร์ม กดปุ่ม "พิมพ์ PDF"
  4. รอ PDF เด้งขึ้น เปิดดูทุก sub-report (F2, F4-P, F4-W, F3-W/F6-W, F7-W, F5-P, F5-W, F8-W, F9-W, F11-W, F10-W)
  5. ✅ คาดหวัง: ลาเบลมุมขวาบน (เช่น `F2-W-วง-003`, `F11-W-วง-003`) แสดง ทุกหน้า ของแต่ละ sub-report
  6. ❌ ก่อนแก้: ลาเบลแสดงเฉพาะหน้าแรกของแต่ละ sub-report

เคสที่ 2 — Portal HTML print (ต้องไม่ regress)

  1. จากฟอร์มเดียวกัน กดปุ่ม "ดูรายงาน" (เปิด `/budget_appropriation_summary//html` ในแท็บใหม่)
  2. กดปุ่ม "พิมพ์รายงาน" มุมขวาบนของหน้า preview (เรียก `window.print()`)
  3. ใน print dialog ของ browser ตรวจ preview
  4. ✅ คาดหวัง: ลาเบลมุมขวาบนยังแสดงทุกหน้าเหมือนเดิม (ใช้ `position: fixed` ของ browser print)

เคสที่ 3 — HTML preview บนหน้าจอ (ต้องไม่ regress)

  1. ทำตามข้อ 1 ของเคสที่ 2 (เปิด preview ในเบราว์เซอร์)
  2. เลื่อนดูทุกหน้า (.page) ในหน้า preview
  3. ✅ คาดหวัง: ลาเบลแสดงตำแหน่งมุมขวาบนของแต่ละ `.page` ตามเดิม ไม่มีลาเบลซ้อนกลางหน้า/ค้างบรรทัด

n3n added 2 commits May 26, 2026 11:13
When printing the master summary via "พิมพ์ PDF", the top-right page
label only showed on the first page of each sub-report because the
positioned label is in the body and wkhtmltopdf does not repeat
fixed-positioned elements per page. Emit a sibling `<div class="header">`
that Odoo's `_prepare_html` extracts into `--header-html`, so the label
now repeats on every PDF page. Hidden on screen to preserve the existing
HTML preview / browser print behavior.
@n3n n3n force-pushed the n3n/16.0-fix-budget_appropriation_summary-pdf-label branch from 45cbac7 to 511a9f5 Compare May 26, 2026 04:13
@PiyaChaiyanit
Copy link
Copy Markdown
Collaborator

Test ทั้ง 3 เคสแล้วผ่านหมดครับ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants