Skip to content

[16.0][IMP] agx_approval: mint number at submit, use AR/<be>/#### format - #1217

Merged
PiyaChaiyanit merged 4 commits into
16.0from
16.0-imp-approval_request-sequence
Aug 31, 2026
Merged

PiyaChaiyanit merged 4 commits into
16.0from
16.0-imp-approval_request-sequence

Conversation

@PiyaChaiyanit

Copy link
Copy Markdown
Collaborator

Summary

  • Move approval.request number allocation from create() to action_to_verify() so unsent drafts stay / and no longer burn a running counter.
  • Reformat the official number as AR/<be-year>/#### using per-fiscal-year ir.sequence records created on demand (Buddhist year = account_fiscal_year_id.date_to.year + 543), so the counter resets each ปีงบประมาณ.
  • Lock account_fiscal_year_id once the request is numbered — view attrs go readonly outside draft, and a server-side @api.constrains blocks RPC bypasses. The now-unused flat approval_sequence.xml is removed.

Test plan

  • Save a draft without submitting → name stays /, no ir.sequence tick.
  • Submit a draft → name becomes AR/<be>/0001 for the selected FY.
  • Return a numbered request to draft and resubmit → name unchanged.
  • Attempt to change account_fiscal_year_id after submission → view field is readonly and RPC write raises ValidationError.

@n3n n3n left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

เหตุผลเดียวกับ PR #1208

PiyaChaiyanit pushed a commit that referenced this pull request Aug 28, 2026
Address review feedback on PR #1217:

- Restore data/approval_sequence.xml as a single ir.sequence with
  prefix="AR/%(year_be)s/" and use_date_range=1; Odoo auto-creates the
  per-fiscal-year sub-sequences (drops the hand-coded Sequence.create
  helper in the model).
- Add l10n_th_base_sequence to depends (formalizes the %(year_be)s
  interpolation source, matching procurement_plan/__manifest__.py).
- name field default switches from "/" to _("New"), aligning with the
  procurement_plan / kmitl_project house pattern.
- action_to_verify calls next_by_code with ir_sequence_date +
  sequence_date pinned to account_fiscal_year_id.date_to, mirroring
  procurement_plan.action_send_to_verify. Guard accepts "/" alongside
  _("New") so pre-PR drafts still get numbered on first submit.
- View readonly clause on account_fiscal_year_id switches from
  state != draft to name != "New" per reviewer request.
PiyaChaiyanit pushed a commit that referenced this pull request Aug 28, 2026
Address review feedback on PR #1217:

- Restore data/approval_sequence.xml as a single ir.sequence with
  prefix="AR/%(year_be)s/" and use_date_range=1; Odoo auto-creates the
  per-fiscal-year sub-sequences (drops the hand-coded Sequence.create
  helper in the model).
- Add l10n_th_base_sequence to depends (formalizes the %(year_be)s
  interpolation source, matching procurement_plan/__manifest__.py).
- name field default switches from "/" to _("New"), aligning with the
  procurement_plan / kmitl_project house pattern.
- action_to_verify calls next_by_code with ir_sequence_date +
  sequence_date pinned to account_fiscal_year_id.date_to, mirroring
  procurement_plan.action_send_to_verify. Guard accepts "/" alongside
  _("New") so pre-PR drafts still get numbered on first submit.
- View readonly clause on account_fiscal_year_id switches from
  state != draft to name != "New" per reviewer request.
@PiyaChaiyanit
PiyaChaiyanit force-pushed the 16.0-imp-approval_request-sequence branch from 44f497a to 58c71ab Compare August 28, 2026 07:21
@PiyaChaiyanit PiyaChaiyanit added the status/ready-for-review Status: Issue is up for grabs label Aug 28, 2026
Sunny added 3 commits August 31, 2026 10:16
…format

- Move number allocation from create() to action_to_verify(): drafts stay
  "/" until the user actually submits, so unsent drafts no longer burn a
  running counter.
- Reformat the official number as AR/<be-year>/#### using a per-fiscal-year
  ir.sequence created on demand (Buddhist year derived from
  account_fiscal_year_id.date_to.year + 543).
- Lock account_fiscal_year_id once the request is numbered: view attrs go
  readonly outside draft, and a server-side @api.constrains blocks RPC
  changes when name != "/".
- Drop the now-unused flat approval_sequence.xml data record.
Address review feedback on PR #1217:

- Restore data/approval_sequence.xml as a single ir.sequence with
  prefix="AR/%(year_be)s/" and use_date_range=1; Odoo auto-creates the
  per-fiscal-year sub-sequences (drops the hand-coded Sequence.create
  helper in the model).
- Add l10n_th_base_sequence to depends (formalizes the %(year_be)s
  interpolation source, matching procurement_plan/__manifest__.py).
- name field default switches from "/" to _("New"), aligning with the
  procurement_plan / kmitl_project house pattern.
- action_to_verify calls next_by_code with ir_sequence_date +
  sequence_date pinned to account_fiscal_year_id.date_to, mirroring
  procurement_plan.action_send_to_verify. Guard accepts "/" alongside
  _("New") so pre-PR drafts still get numbered on first submit.
- View readonly clause on account_fiscal_year_id switches from
  state != draft to name != "New" per reviewer request.
- Add computed is_number_assigned = bool(name and name not in ("/",
  _("New"))). The FY view attrs, action_to_verify guard, and constraint
  now all consult this flag instead of comparing name against a hard-
  coded English "New", so records created in Thai locale (name stored as
  "รายการใหม่") are treated as unnumbered until action_to_verify.
- Translate _("New") → "รายการใหม่" in th.po.
@PiyaChaiyanit
PiyaChaiyanit force-pushed the 16.0-imp-approval_request-sequence branch from f095f3e to e8c935b Compare August 31, 2026 03:17
…t number

The number is minted at submit, so the placeholder persists in the DB and is
read back by users in other locales. A translated default (_("New")) would
compare unequal to _() evaluated in the reader's language: a th_TH draft stored
"รายการใหม่" would look already-numbered to an en_US user, skipping the mint and
freezing the fiscal year on an unnumbered request.

Follow account.move: store the untranslated "/" sentinel and render the friendly
label in the form view, where it is translated per reader at render time.
@PiyaChaiyanit
PiyaChaiyanit merged commit 95bf79b into 16.0 Aug 31, 2026
1 check passed
@PiyaChaiyanit
PiyaChaiyanit deleted the 16.0-imp-approval_request-sequence branch August 31, 2026 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/ready-for-review Status: Issue is up for grabs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants