Skip to content

[7030][ADD] product_weighing: append-only weighing lines with product Weighing tab - #172

Merged
yostashiro merged 6 commits into
15.0from
7030-add-product_weighing
Aug 6, 2026
Merged

[7030][ADD] product_weighing: append-only weighing lines with product Weighing tab#172
yostashiro merged 6 commits into
15.0from
7030-add-product_weighing

Conversation

@nobuQuartile

@nobuQuartile nobuQuartile commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

QT7030

What

Add a new module product_weighing that stores weighing results sent from the external odoo-upload-system against a product.

Why

The weighing data is used to back a "no tampering of weighing data" claim, so the detail model must be append-only.

How

  • New model product.weighing.line (gross/dust/net weight, weighing id, measured at, image hash), weighing_id SQL unique.
  • Append-only, no escape: creation is limited to a dedicated group_weighing_integration via ACL (no write/unlink granted to anyone), and the model overrides write/unlink to always raise AccessError. So a line can never be modified or deleted after creation through any ORM path — UI, RPC, sudo or the developer-mode superuser included; there is no context flag to bypass it. Direct SQL is out of scope by design.
  • Trail preserved: product_tmpl_id is ondelete="restrict", so a product with weighing lines cannot be deleted (no cascade erasure of the evidence).
  • product.template gets three computed+stored aggregate fields (weighing count, total net weight, weighing confirmed at) plus the one2many. The integration only creates lines — it never writes to product.template.
  • No mail.thread / no field tracking on the line: there is no chatter view for the line and, being append-only, it never changes, so tracking would add cost with no auditable effect. A searchable audit trail (create/write/unlink of the line, plus permission changes) is intended to be provided by the OCA auditlog module as a follow-up (module to be vendored into rmm-oca).
  • Read-only Weighing tab on the product form (matches the requested mockup: no add/delete, row click opens a read-only detail with the image hash).
  • Japanese translation (i18n/ja.po) and tests.

Test

-u product_weighing --test-enable → 3/3 pass. Covered: integration user create OK; create denied for regular/admin; write and unlink raise for everyone incl. sudo; product with lines cannot be deleted (restrict); duplicate weighing_id rejected; aggregates computed.

@nobuQuartile
nobuQuartile force-pushed the 7030-add-product_weighing branch 2 times, most recently from 4a86afd to b7cb6a1 Compare July 31, 2026 08:19
@nobuQuartile
nobuQuartile marked this pull request as ready for review July 31, 2026 08:19
@nobuQuartile
nobuQuartile force-pushed the 7030-add-product_weighing branch from b7cb6a1 to 2c33380 Compare July 31, 2026 08:34
@nobuQuartile nobuQuartile changed the title [7030][ADD] product_weighing: append-only weighing lines with product Weighing tab [7030][ADD] product_weighing: audit-logged weighing lines with product Weighing tab Jul 31, 2026
@nobuQuartile
nobuQuartile force-pushed the 7030-add-product_weighing branch from 2c33380 to b7ecf36 Compare July 31, 2026 08:39
@nobuQuartile
nobuQuartile marked this pull request as draft July 31, 2026 08:41
@nobuQuartile
nobuQuartile force-pushed the 7030-add-product_weighing branch from b7ecf36 to 8aa0a3c Compare July 31, 2026 08:46
@nobuQuartile nobuQuartile changed the title [7030][ADD] product_weighing: audit-logged weighing lines with product Weighing tab [7030][ADD] product_weighing: append-only weighing lines with product Weighing tab Jul 31, 2026
@nobuQuartile
nobuQuartile force-pushed the 7030-add-product_weighing branch 7 times, most recently from 13eb33f to 3755f9e Compare August 3, 2026 05:04
… Weighing tab

Store weighing results (gross/dust/net weight) sent from the external
odoo-upload-system against a product, as an append-only model to back the
"no tampering of weighing data" claim. Creation is limited to a dedicated
integration group via ACL, and the model overrides write/unlink to always
raise AccessError, so a line can never be modified or deleted after creation
through any ORM path - UI, RPC, sudo or the developer-mode superuser
included; there is no context flag to bypass it. Direct SQL is out of
scope by design. The parent product cannot be deleted while lines exist
(product_tmpl_id ondelete="restrict"), so the trail is preserved.

product.template gets three computed+stored aggregate fields (weighing
count, total net weight, weighing confirmed at) plus the one2many; the
integration only creates lines and never writes to product.template.

The line model does not inherit mail.thread and uses no field tracking:
there is no chatter view for the line and, being append-only, it never
changes, so tracking would add cost with no auditable effect. A searchable
audit trail (create/write/unlink of the line, plus permission changes) is
intended to be provided by the OCA auditlog module as a follow-up.

The product form gets a read-only Weighing tab matching the requested
mockup (no add/delete, row click opens a read-only detail with the image
hash).

task-7030
@nobuQuartile
nobuQuartile force-pushed the 7030-add-product_weighing branch from 3755f9e to 564b4b6 Compare August 3, 2026 05:28
@nobuQuartile
nobuQuartile marked this pull request as ready for review August 3, 2026 05:28

@AungKoKoLin1997 AungKoKoLin1997 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review: LG

Comment thread product_weighing/i18n/ja.po
@nobuQuartile

Copy link
Copy Markdown
Contributor Author

Add ja.po

Translation notes

Translations are referenced from existing Odoo translations where available (odoo/product).

The following terms have no reference and are translated independently:

msgid msgstr
<strong>A weighing line has been added.</strong> <strong>計量明細が追加されました。</strong>
A weighing line with this Weighing ID already exists. この計量IDの計量明細は既に存在します。
Breakdown of deducted items (e.g. 'cage cart x2, cart x1'). 控除品目の内訳(例:「かご台車×2, 台車×1」)。
Dust Deduction Detail ダスト控除内訳
Dust Deduction Weight (kg) ダスト控除重量(kg)
External weighing identifier (e.g. WEIGH-KNG-20260513-0001). 外部計量ID(例: WEIGH-KNG-20260513-0001)。
Gross Weight (kg) 総重量(kg)
Image Hash 画像ハッシュ
Measured At 計測日時
Measured At: 計測日時:
Measurer 計測者
Net Weight (kg) 正味重量(kg)
Net Weight (kg): 正味重量(kg):
Receipt No. レシート番号
SHA-256 of the evidence image(s), comma-separated, for tamper verification. 証跡画像のSHA-256(複数の場合はカンマ区切り)。改ざん検証用。
Total Net Weight 合計正味重量
Users allowed to create weighing lines via the external integration (odoo-upload-system). 外部連携(odoo-upload-system)経由で計量明細を作成できるユーザ。
Weighing 計量
Weighing Confirmed At 計量確定日時
Weighing Count 計量数
Weighing ID 計量ID
Weighing ID: 計量ID:
Weighing Integration 計量連携
Weighing Line 計量明細
Weighing Lines 計量明細
Weighing line 計量明細
Weighing lines are append-only and cannot be deleted. 計量明細は追記専用のため削除できません。
Weighing lines are append-only and cannot be modified. 計量明細は追記専用のため変更できません。
has been updated. が更新されました。

@smorita7749 smorita7749 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code and functional review: LGTM

@yostashiro
yostashiro merged commit 7235d1b into 15.0 Aug 6, 2026
2 checks passed
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.

4 participants