Skip to content

[16.0][IMP] disbursement: รวม smart button ของ DR เป็นปุ่มเดียว - #1262

Merged
PiyaChaiyanit merged 5 commits into
16.0from
16.0-imp-disbursement-merge-smartbuttons
Sep 8, 2026
Merged

PiyaChaiyanit merged 5 commits into
16.0from
16.0-imp-disbursement-merge-smartbuttons

Conversation

@PiyaChaiyanit

Copy link
Copy Markdown
Collaborator

Summary

  • รวม smart button 3 ปุ่มบนฟอร์ม disbursement.request (ใบตั้งหนี้, รายการล้างหนี้, Cash & Revenue Handover) ที่ล้วนเปิด account.move ให้เป็นปุ่ม "ใบสำคัญบัญชี" ปุ่มเดียวใน disbursement_finance_kmitl — กดแล้วเห็น bill + payment moves + handover ในหน้า tree เดียว
  • เพิ่ม compute related_move_ids / related_move_count และ action_view_related_moves ใน finance bridge, และเพิ่ม dep บน disbursement_cash_revenue_handover เพื่อให้ compute เห็น field ครบ
  • ลบ smart button + action method ต้นทางทั้ง 3 ออก (action_view_bill, action_view_payment_moves, action_view_cash_revenue_handover) และลบไฟล์ view ของ handover ที่กลายเป็นว่างเปล่า

Test plan

  • เปิด DR ที่มีทั้ง bill / payment (posted) / handover — เห็นปุ่ม "ใบสำคัญบัญชี" ปุ่มเดียว count = ผลรวม move ทั้ง 3 (ไม่นับ cancel)
  • กดปุ่ม → เปิด tree ของ account.move มี record ครบ 3 ประเภท
  • DR ที่มี move เดียว → กดแล้วเปิด form โดยตรง
  • DR ที่ยังไม่มี move → ปุ่มถูกซ่อน

Sunny and others added 5 commits September 7, 2026 15:03
รวม smart button 3 ปุ่มบนฟอร์ม disbursement.request ที่เปิด account.move
เหมือนกัน (action_view_bill / action_view_payment_moves /
action_view_cash_revenue_handover) เป็นปุ่ม "ใบสำคัญบัญชี" ปุ่มเดียวที่
รวม vendor bill + payment journal entries + cash & revenue handover ให้
เปิด tree ของ account.move ทั้งหมดในหน้าเดียว

- disbursement_finance_kmitl: เพิ่ม related_move_ids/count compute และ
  action_view_related_moves; เพิ่ม dep บน disbursement_cash_revenue_handover
- disbursement_accounting_kmitl: ลบปุ่ม action_view_bill และ method
- disbursement_cash_revenue_handover: ลบวิว/ปุ่ม action_view_cash_revenue_handover
  และ method (ลบไฟล์ views/disbursement_request_views.xml)
The removed ใบตั้งหนี้ smart button was the only place rendering
bill_count in this view, but the Create Bill / Return to Verification
buttons above still reference bill_count in their attrs. Odoo's view
validator requires the field to be present — re-add it as an invisible
marker inside the button_box xpath.
…มาที่นี่ด้วย introspection

รอบก่อน smart button รวมอยู่ที่ disbursement_finance_kmitl และผูก 3 field
รวมกัน (bill_ids | payment_move_ids | cash_revenue_handover_move_ids)
ต้อง depend บน disbursement_cash_revenue_handover เพื่อให้ compute เห็น
field ครบ

ย้ายมาที่ disbursement_accounting_kmitl แทน และหา account.move จากฝั่ง
move ขึ้นมา — introspect Many2one บน account.move._fields ที่ชี้
disbursement.request แล้ว OR ทั้งหมดใน domain เดียว ทำให้:

- ไม่ต้อง depend cross-module (finance → handover ถูกถอนออก)
- โมดูลปลายทางที่เพิ่ม linking field ใหม่บน account.move ถูกเก็บ
  อัตโนมัติโดยไม่ต้องแก้โค้ดตรงนี้

label ปุ่มเปลี่ยนเป็น "รายการบันทึกบัญชี"

Cleanup ต่อเนื่องใน finance: ลบ payment_move_ids/count ที่ไม่มีใครใช้แล้ว
(ปุ่มถูกลบตั้งแต่รอบก่อน) และ trigger payment_ids.move_id บน compute
หลัง unified smart button คุมทุก move แล้ว, ปุ่ม/count เดิมไม่ถูกอ้าง:
- cash_revenue_handover_count (+ compute)
- bill_draft_count, bill_status_display (+ บรรทัดใน _compute_bill_count)

เก็บ dead code ทิ้ง และรวม comment/docstring ที่ซ้ำของ related_move_ids ให้
field อธิบาย *why*, docstring ของ _related_move_domain อธิบาย *how* อย่างละที่
@PiyaChaiyanit
PiyaChaiyanit merged commit 6c811ff into 16.0 Sep 8, 2026
1 check passed
@PiyaChaiyanit
PiyaChaiyanit deleted the 16.0-imp-disbursement-merge-smartbuttons branch September 8, 2026 03:49
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