[16.0][IMP] purchase_request_advance_payment: apply reimbursement rules for เงินยืม - #1257
Open
PiyaChaiyanit wants to merge 5 commits into
Open
PiyaChaiyanit wants to merge 5 commits into
PiyaChaiyanit wants to merge 5 commits into
Conversation
added 4 commits
September 4, 2026 18:16
… เงินยืมทดรอง Same triple as purchase_request_prepaid but gated on payment_type=advance: vendor restricted to internal personnel (partner_type_id.is_internal), procurement_mode locked to ผู้ขอระบุเอง, and vat_included forced to exclusive. Enforced via extended onchange + a new @api.constrains; the partner_id domain plugs into purchase_request_kmitl's shared extension point via super(). No dep on purchase_request_prepaid.
…epaid pattern) purchase_request_advance_payment now applies the same internal-only vendor rule to payment_type=advance as prepaid does. All demo PRs with payment_type=advance previously pointed partner_id at external vendor companies, tripping the new constraint on install. Repoint each via search on user_ids = requested_by (same pattern already used for prepaid records in these files). Covers 4 records in purchase.request.xml and 9 in purchase.request.dashboard.demo.xml.
Mirror the existing prepaid warning banner for payment_type=advance: "กรณีเลือกประเภทการจ่ายเงินเป็นเงินยืมให้เลือกชื่อผู้ยืมเงิน". The English source matches the pre-existing msgid in i18n/th.po; the Thai msgstr is polished from "ชื่อยืมเงิน" to "ชื่อผู้ยืมเงิน".
purchase_request_advance_payment applies the same internal-only vendor rule to payment_type=advance as prepaid. Widen the existing conditional so E2E cases with advance don't trip the constraint on install.
n3n
requested changes
Sep 11, 2026
Comment on lines
+23
to
+27
| def _compute_partner_id_domain(self): | ||
| super()._compute_partner_id_domain() | ||
| for rec in self: | ||
| if rec.payment_type == "advance": | ||
| rec.partner_id_domain = [("partner_type_id.is_internal", "=", True)] |
…partner_id_domain Match the base compute signature in purchase_request_kmitl so overrides follow the same explicit-depends convention.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Applies the same reimbursement rules already used for
payment_type=prepaid(สำรองจ่าย, PR #1236) topayment_type=advance(เงินยืมทดรอง): the vendor must be an internal person (partner_type_id.is_internal),procurement_modeis locked to ผู้ขอระบุเอง, andvat_includedis forced toexclusive.Locks route through the shared
is_vat_editable/is_procurement_mode_editablecompute extension points (extended viasuper()) — no view-attrs stacking — plus an@api.constrainsshell guard. A helper banner mirroring the prepaid one is added onpurchase.request, andkmitl_demorecords/E2E cases withpayment_type=advanceare repointed to internal partners so the new constraint passes on install.Test plan
payment_type:directunrestricted;prepaidunchanged;advancelocks partner to internal,procurement_modereadonly on ผู้ขอระบุเอง,vat_includedreadonly onexclusiveand shows the bannerwrite({'procurement_mode': 'by_officer'}),write({'vat_included': 'inclusive'}),write({'partner_id': <external>})each raiseValidationErrormentioning เงินยืมทดรองkmitl_demoinstalls cleanly (XML data +hooks.pyE2E cases)