File tree Expand file tree Collapse file tree 3 files changed +75
-0
lines changed
Expand file tree Collapse file tree 3 files changed +75
-0
lines changed Original file line number Diff line number Diff line change 6262 "assets" : {
6363 "web.assets_backend" : [
6464 "spp_change_request_v2/static/src/components/**/*" ,
65+ "spp_change_request_v2/static/src/js/create_change_request.js" ,
66+ "spp_change_request_v2/static/src/xml/create_change_request_template.xml" ,
6567 ],
6668 },
6769 "installable" : True ,
Original file line number Diff line number Diff line change 1+ /** @odoo -module **/
2+
3+ import { ListController } from "@web/views/list/list_controller" ;
4+ import { onWillStart } from "@odoo/owl" ;
5+ import { patch } from "@web/core/utils/patch" ;
6+ import { user } from "@web/core/user" ;
7+ import { useService } from "@web/core/utils/hooks" ;
8+
9+ patch ( ListController . prototype , {
10+ setup ( ) {
11+ super . setup ( ) ;
12+ this . actionService = useService ( "action" ) ;
13+ onWillStart ( async ( ) => {
14+ const is_admin = await user . hasGroup ( "spp_security.group_spp_admin" ) ;
15+ const is_cr_user = await user . hasGroup (
16+ "spp_change_request_v2.group_cr_user"
17+ ) ;
18+ this . canCreateChangeRequest = is_admin || is_cr_user ;
19+ } ) ;
20+ } ,
21+
22+ async loadChangeRequestWizard ( ) {
23+ if ( this . model . root . resModel !== "spp.change.request" ) {
24+ return ;
25+ }
26+ await this . actionService . doAction (
27+ "spp_change_request_v2.action_cr_create_wizard" ,
28+ {
29+ onClose : async ( ) => {
30+ await this . model . root . load ( ) ;
31+ } ,
32+ }
33+ ) ;
34+ } ,
35+ } ) ;
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <templates xml : space =" preserve" >
3+
4+ <t t-inherit =" web.ListView" t-inherit-mode =" extension" >
5+ <xpath expr =" //Layout/t[@t-set-slot='control-panel-create-button']" position =" replace" >
6+ <t t-set-slot =" control-panel-create-button" >
7+ <t t-if =" model.root.resModel == 'spp.change.request'" >
8+ <button
9+ t-if =" !editedRecord and activeActions.create and props.showButtons and canCreateChangeRequest"
10+ type =" button"
11+ class =" btn btn-primary o_list_button_add_cr"
12+ accesskey =" c"
13+ title =" Create a New Change Request"
14+ t-on-click =" loadChangeRequestWizard"
15+ >New Request</button >
16+ </t >
17+ <t t-else =" " >
18+ <button
19+ t-if =" !editedRecord and activeActions.create and props.showButtons"
20+ type =" button"
21+ class =" btn btn-primary o_list_button_add"
22+ data-hotkey =" c"
23+ t-on-click =" onClickCreate"
24+ data-bounce-button =" "
25+ >New</button >
26+ <t t-if =" props.showButtons and !env.inDialog" t-call =" web.ListView.EditableButtons" />
27+ </t >
28+ </t >
29+ </xpath >
30+ </t >
31+
32+ <t t-inherit =" web.FormView" t-inherit-mode =" extension" >
33+ <xpath expr =" //button[hasclass('o_form_button_create')]" position =" attributes" >
34+ <attribute name =" t-if" >model.root.resModel != 'spp.change.request'</attribute >
35+ </xpath >
36+ </t >
37+
38+ </templates >
You can’t perform that action at this time.
0 commit comments