-
Notifications
You must be signed in to change notification settings - Fork 5
Add Submit button and statusbar to all detail forms and use Datetime.now() for membership start_date #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Submit button and statusbar to all detail forms and use Datetime.now() for membership start_date #21
Changes from 3 commits
6130efd
33dbbc7
ed508f8
9e7eb4b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| /** @odoo-module **/ | ||
|
|
||
| import {ListController} from "@web/views/list/list_controller"; | ||
| import {onWillStart} from "@odoo/owl"; | ||
| import {patch} from "@web/core/utils/patch"; | ||
| import {user} from "@web/core/user"; | ||
| import {useService} from "@web/core/utils/hooks"; | ||
|
|
||
| patch(ListController.prototype, { | ||
| setup() { | ||
| super.setup(); | ||
| this.actionService = useService("action"); | ||
| onWillStart(async () => { | ||
| const is_admin = await user.hasGroup("spp_security.group_spp_admin"); | ||
| const is_cr_user = await user.hasGroup( | ||
| "spp_change_request_v2.group_cr_user" | ||
| ); | ||
| this.canCreateChangeRequest = is_admin || is_cr_user; | ||
| }); | ||
| }, | ||
|
|
||
| async loadChangeRequestWizard() { | ||
| if (this.model.root.resModel !== "spp.change.request") { | ||
| return; | ||
| } | ||
| await this.actionService.doAction( | ||
| "spp_change_request_v2.action_cr_create_wizard", | ||
| { | ||
| onClose: async () => { | ||
| await this.model.root.load(); | ||
| }, | ||
| } | ||
| ); | ||
| }, | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <templates xml:space="preserve"> | ||
|
|
||
| <t t-inherit="web.ListView" t-inherit-mode="extension"> | ||
| <xpath expr="//Layout/t[@t-set-slot='control-panel-create-button']" position="replace"> | ||
| <t t-set-slot="control-panel-create-button"> | ||
| <t t-if="model.root.resModel == 'spp.change.request'"> | ||
| <button | ||
| t-if="!editedRecord and activeActions.create and props.showButtons and canCreateChangeRequest" | ||
| type="button" | ||
| class="btn btn-primary o_list_button_add_cr" | ||
| accesskey="c" | ||
| title="Create a New Change Request" | ||
| t-on-click="loadChangeRequestWizard" | ||
| >New Request</button> | ||
| </t> | ||
| <t t-else=""> | ||
| <button | ||
| t-if="!editedRecord and activeActions.create and props.showButtons" | ||
| type="button" | ||
| class="btn btn-primary o_list_button_add" | ||
| data-hotkey="c" | ||
| t-on-click="onClickCreate" | ||
| data-bounce-button="" | ||
| >New</button> | ||
| <t t-if="props.showButtons and !env.inDialog" t-call="web.ListView.EditableButtons" /> | ||
| </t> | ||
| </t> | ||
| </xpath> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Template extensions overwrite existing program create buttonHigh Severity The new Additional Locations (1) |
||
| </t> | ||
|
|
||
| <t t-inherit="web.FormView" t-inherit-mode="extension"> | ||
| <xpath expr="//button[hasclass('o_form_button_create')]" position="attributes"> | ||
| <attribute name="t-if">model.root.resModel != 'spp.change.request'</attribute> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FormView create button loses permission check on t-if overrideMedium Severity The FormView modification uses |
||
| </xpath> | ||
| </t> | ||
|
|
||
| </templates> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,46 +6,66 @@ | |
| <field name="model">spp.cr.detail.add_member</field> | ||
| <field name="arch" type="xml"> | ||
| <form> | ||
| <header> | ||
| <button | ||
| name="action_submit_for_approval" | ||
| string="Submit for Approval" | ||
| type="object" | ||
| class="btn-primary" | ||
| invisible="approval_state != 'draft'" | ||
| /> | ||
| <button | ||
| name="action_submit_for_approval" | ||
| string="Resubmit for Review" | ||
| type="object" | ||
| class="btn-primary" | ||
| invisible="approval_state != 'revision'" | ||
| /> | ||
| <field | ||
| name="approval_state" | ||
| widget="statusbar" | ||
| statusbar_visible="draft,pending,approved,applied" | ||
| /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Statusbar references non-existent "applied" state in approval_stateLow Severity The statusbar uses Additional Locations (2) |
||
| </header> | ||
|
Comment on lines
+9
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To improve maintainability and reduce code duplication, consider extracting this common header into a reusable QWeb template. This same header is added to 11 different form views in this PR. By using a template, any future changes to the submission buttons or status bar will only need to be made in one place. You could define the template in a new or existing XML file (e.g., inside a <templates>
<t t-name="spp_change_request_v2.cr_detail_form_header">
<header>
<button
name="action_submit_for_approval"
string="Submit for Approval"
type="object"
class="btn-primary"
invisible="approval_state != 'draft'"
/>
<button
name="action_submit_for_approval"
string="Resubmit for Review"
type="object"
class="btn-primary"
invisible="approval_state != 'revision'"
/>
<field
name="approval_state"
widget="statusbar"
statusbar_visible="draft,pending,approved,applied"
/>
</header>
</t>
</templates>Then, you can replace the |
||
| <sheet> | ||
| <div class="oe_title"> | ||
| <h1>Add Member to Group</h1> | ||
| </div> | ||
|
|
||
| <!-- Target Group --> | ||
| <group string="Target Group"> | ||
| <field name="registrant_id" readonly="1"/> | ||
| <field name="change_request_id" invisible="1"/> | ||
| <field name="registrant_id" readonly="1" /> | ||
| <field name="change_request_id" invisible="1" /> | ||
| </group> | ||
|
|
||
| <!-- Member Details --> | ||
| <group string="New Member Information"> | ||
| <group> | ||
| <field name="given_name" required="1"/> | ||
| <field name="family_name" required="1"/> | ||
| <field name="member_name" readonly="1" force_save="1"/> | ||
| <field name="given_name" required="1" /> | ||
| <field name="family_name" required="1" /> | ||
| <field name="member_name" readonly="1" force_save="1" /> | ||
| </group> | ||
| <group> | ||
| <field name="birthdate"/> | ||
| <field name="gender_id"/> | ||
| <field name="relationship_id"/> | ||
| <field name="birthdate" /> | ||
| <field name="gender_id" /> | ||
| <field name="relationship_id" /> | ||
| </group> | ||
| </group> | ||
|
|
||
| <group string="Contact Information"> | ||
| <group> | ||
| <field name="phone"/> | ||
| <field name="id_number"/> | ||
| <field name="phone" /> | ||
| <field name="id_number" /> | ||
| </group> | ||
| </group> | ||
|
|
||
| <!-- Result (after apply) --> | ||
| <group string="Result" invisible="not created_individual_id"> | ||
| <field name="created_individual_id"/> | ||
| <field name="created_individual_id" /> | ||
| </group> | ||
| </sheet> | ||
| <chatter/> | ||
| <chatter /> | ||
| </form> | ||
| </field> | ||
| </record> | ||
|
|
||
| </odoo> | ||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent keyboard shortcut attribute usage
Low Severity
The "New Request" button uses
accesskey="c"while the fallback "New" button on line 22 and all other buttons in the codebase usedata-hotkey="c". Theaccesskeyattribute is a native HTML attribute with browser-specific behavior, whereasdata-hotkeyis Odoo's unified hotkey system that integrates with the framework's keyboard shortcuts dialog and provides consistent cross-platform behavior. This inconsistency means the shortcut will behave differently and won't appear in Odoo's keyboard shortcuts helper.