Skip to content

[16.0][ADD] purchase_contract_revision_kmitl: replace PO change wizard - #1272

Open
PiyaChaiyanit wants to merge 3 commits into
16.0from
po-contract-revision-redesign
Open

[16.0][ADD] purchase_contract_revision_kmitl: replace PO change wizard#1272
PiyaChaiyanit wants to merge 3 commits into
16.0from
po-contract-revision-redesign

Conversation

@PiyaChaiyanit

Copy link
Copy Markdown
Collaborator

Summary

Replaces the purchase_order_change / purchase_order_change_committee wizard flow with a first-class purchase.contract revision model (N per PO). Rev 0 is snapshotted at button_confirm and applies immediately; Rev N is user-initiated from "แก้ไขข้อมูลสัญญา", edited in a 2-tab form (lines → งวด, case-3 locked gate), and applied only after ≥ 1 external-approval file is attached — there is deliberately no in-system approval flow (approval happens on paper, ADR-0003). Apply syncs back to purchase.order.line / purchase.invoice.plan while leaving the budget.commitment untouched; งวด with a disbursement.request are frozen (ADR-0002). The legacy modules are deleted outright — target DBs must uninstall them from the Apps UI before deploy or Odoo will fail to boot.

Test plan

  • Uninstall purchase_order_change + purchase_order_change_committee from the dev DB via Apps UI
  • Install purchase_contract_revision_kmitl and confirm migration backfills a rev 0 for every existing confirmed PO
  • Create new PO → confirm → smart button "สัญญา" reads 1, PO fields carry through from rev 0
  • Click แก้ไขข้อมูลสัญญา without an attachment → apply fails with "กรุณาแนบเอกสารอนุมัติ"; attach any file and retry → PO reflects the new values, budget commitment unchanged
  • Repeat on a PO with disbursement on งวด 1 → tab งวด shows งวด 1 readonly, งวด 2+ editable with balance re-check
  • Run `odoo-bin -d -i purchase_contract_revision_kmitl --test-enable` (14 tests in `tests/test_purchase_contract.py`)
  • Print the amendment report from a Rev N and verify the diff view (header, lines, งวด, committees)

Redesign the PO amendment flow as first-class purchase.contract revision
records: rev 0 auto-created at button_confirm, rev N user-initiated from
"แก้ไขข้อมูลสัญญา". Each revision is a full snapshot (header + lines + งวด +
committees) that syncs back to purchase.order.line / purchase.invoice.plan on
apply while leaving the budget commitment untouched. Approval is gated on an
attached external approval document (no in-system approval flow, ADR-0003);
งวด with a disbursement.request are frozen (ADR-0002). Deletes the legacy
purchase_order_change and purchase_order_change_committee modules — target
DBs must uninstall them via Apps UI before deploy.
@PiyaChaiyanit
PiyaChaiyanit force-pushed the po-contract-revision-redesign branch from 6927b02 to a4fe02f Compare September 10, 2026 11:01
Sunny added 2 commits September 11, 2026 12:44
… xmlid

base.module_category_operations_purchase does not exist in Odoo 16 —
the purchase security groups use base.module_category_inventory_purchase
(defined in odoo/addons/purchase/security/purchase_security.xml).
…tton

The smart button had name='object' which isn't a real method — it was a
scaffold leftover. Removed the whole block; the purchase_id M2O in the
main group already exposes the parent PO clearly.
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.

1 participant