[19.0][IMP] base_tier_validation: smart-button on validated documents#33
Open
bosd wants to merge 2 commits into
Open
[19.0][IMP] base_tier_validation: smart-button on validated documents#33bosd wants to merge 2 commits into
bosd wants to merge 2 commits into
Conversation
Add a "Reviews" smart-button to every validated record (account.move, sale.order, ...) showing the number of tier.review rows attached to the record and opening a filtered list when clicked. How it works: - New `tier_review_count` computed integer on the tier.validation abstract mixin (depends on review_ids; simple len, no query gymnastics). - New `action_view_tier_reviews` method on the mixin returning an ir.actions.act_window scoped to the current record's reviews (domain on model + res_id). Reusable by bridge modules that want to add their own jump links. - New `tier_validation_smart_button` QWeb template emitting the `<button class="oe_stat_button">` markup with the counter widget. - Hooked into the existing `get_view` auto-injection machinery: when a form view already has `<div name="button_box">`, the smart-button is appended (only for models with `_tier_validation_manual_config = False`, which is the typical bridge-module setup, including account.move). Bridge modules without auto-injection can xpath the template in manually. Also ships: - Minimal form view for `tier.review` so clicking through from the smart-button drills into individual reviews instead of falling back to Odoo's autogenerated form. - `action_tier_review` window action referenced by the helper method. Test exercises the helper end-to-end: create a record, request validation, check the counter is non-zero and the returned action's domain points at the expected record.
Contributor
|
Hi @LoisRForgeFlow, |
…is appended, not its fields `get_view` iterates `for new_element in new_node` and appends each child of the rendered template to the matched node. With a bare `<button>` at the template root, that loop iterated the *button's* children (the `<field widget="statinfo">`) and appended the field to `button_box` -- not the button itself. The result on screen was "1Reviews" as raw text, no icon, no styling. Wrap the button in a `<div>` (same pattern as the existing `tier_validation_buttons` template). The div is the discarded wrapper; its single child -- the actual `<button class="oe_stat_button">` -- gets appended into `button_box` with its label/icon/click handler intact.
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
Add a Reviews smart-button to every validated record (account.move, sale.order, ...) showing the number of
tier.reviewrows attached to that document and opening a filtered list when clicked.How it works
tier_review_countcomputed integer on thetier.validationabstract mixin (depends onreview_ids; simplelen).action_view_tier_reviews()helper returning anir.actions.act_windowscoped to the current record's reviews (domain onmodel+res_id). Reusable by bridge modules that want to surface their own jump links.tier_validation_smart_buttonQWeb template with the<button class="oe_stat_button">markup +statinfocounter widget.get_viewauto-injection used for buttons/label/reviews: when a form view already has<div name="button_box">, the smart-button is appended. Only fires for_tier_validation_manual_config = False(which is the standard bridge setup, includingaccount.move). Bridge modules with manual config can xpath the template in themselves.Also ships a minimal form view for
tier.reviewso clicking through drills into individual reviews instead of Odoo's autogenerated form.Why auto-inject rather than per-bridge XML
Symmetric with what already happens for buttons/label/reviews. account.move, sale.order, and other bridges pick it up automatically (zero XML changes in
account_move_tier_validation). For custom validated models that want manual control, the template is still public and xpath-able.Test plan
test_action_view_tier_reviews: create a record, request validation, asserttier_review_count > 0, assertaction_view_tier_reviews()returns an action withres_model='tier.review'and a domain pinned to the record'smodel+res_id.Companion follow-ups
tier.correction.item.resource_refdomain fix (separate PR).