1
- import { SaleOrderLineProductField } from "@sale/js/sale_product_field" ;
2
1
import { patch } from "@web/core/utils/patch" ;
2
+ import { SaleOrderLineProductField } from "@sale/js/sale_product_field" ;
3
3
4
4
patch ( SaleOrderLineProductField . prototype , {
5
+ setup ( ) {
6
+ super . setup ( ...arguments ) ;
7
+ this . lastContractData = false ;
8
+ } ,
9
+
10
+ get extraLines ( ) {
11
+ var res = super . extraLines ;
12
+ if (
13
+ this . props . record . data . is_contract &&
14
+ this . props . record . data . product_contract_description
15
+ ) {
16
+ for ( var val of this . props . record . data . product_contract_description . split (
17
+ "||"
18
+ ) ) {
19
+ res . push ( val ) ;
20
+ }
21
+ }
22
+ return res ;
23
+ } ,
24
+
5
25
async _onProductUpdate ( ) {
6
26
super . _onProductUpdate ( ...arguments ) ;
7
27
if ( this . props . record . data . is_contract ) {
8
28
this . _openContractConfigurator ( true ) ;
9
29
}
10
30
} ,
11
31
12
- _editLineConfiguration ( ) {
13
- super . _editLineConfiguration ( ...arguments ) ;
32
+ _editProductConfiguration ( ) {
33
+ if (
34
+ this . props . record . data . is_configurable_product &&
35
+ this . props . record . data . is_contract
36
+ ) {
37
+ this . lastContractData = this . contractData ;
38
+ }
39
+ super . _editProductConfiguration ( ...arguments ) ;
40
+ } ,
41
+
42
+ onEditContractConfiguration ( ) {
14
43
if ( this . props . record . data . is_contract ) {
15
44
this . _openContractConfigurator ( ) ;
16
45
}
17
46
} ,
18
47
19
- get isConfigurableLine ( ) {
20
- return super . isConfigurableLine || this . props . record . data . is_contract ;
48
+ get isConfigurableContract ( ) {
49
+ return this . props . record . data . is_contract ;
21
50
} ,
22
51
23
- _getContractConfiguratorContext ( ) {
52
+ get contractContext ( ) {
24
53
return {
25
54
active_model : this . props . record . resModel ,
26
55
active_id : this . props . record . resId ,
27
56
default_product_id : this . props . record . data . product_id [ 0 ] ,
28
57
default_partner_id : this . props . record . model . root . data . partner_id [ 0 ] ,
29
58
default_company_id : this . props . record . model . root . data . company_id [ 0 ] ,
30
59
default_recurrence_number : this . props . record . data . recurrence_number ,
31
- default_recurring_interval : this . props . record . data . recurring_interval ,
32
60
default_recurring_rule_type : this . props . record . data . recurring_rule_type ,
33
- default_recurrence_interval : this . props . record . data . recurrence_interval ,
34
61
default_recurring_invoicing_type :
35
62
this . props . record . data . recurring_invoicing_type ,
36
63
default_product_uom_qty : this . props . record . data . product_uom_qty ,
37
64
default_contract_id : this . props . record . data . contract_id [ 0 ] ,
65
+ default_recurring_interval : this . props . record . data . recurring_interval ,
38
66
default_date_start : this . props . record . data . date_start ,
39
67
default_date_end : this . props . record . data . date_end ,
40
68
default_is_auto_renew : this . props . record . data . is_auto_renew ,
@@ -45,13 +73,36 @@ patch(SaleOrderLineProductField.prototype, {
45
73
} ;
46
74
} ,
47
75
76
+ get contractData ( ) {
77
+ return {
78
+ product_id : this . props . record . data . product_id ,
79
+ product_uom_qty : this . props . record . data . product_uom_qty ,
80
+ contract_id : this . props . record . data . contract_id ,
81
+ recurring_interval : this . props . record . data . recurring_interval ,
82
+ date_start : this . props . record . data . date_start ,
83
+ date_end : this . props . record . data . date_end ,
84
+ is_auto_renew : this . props . record . data . is_auto_renew ,
85
+ auto_renew_interval : this . props . record . data . auto_renew_interval ,
86
+ auto_renew_rule_type : this . props . record . data . auto_renew_rule_type ,
87
+ } ;
88
+ } ,
89
+
48
90
async _openContractConfigurator ( isNew = false ) {
49
- const actionContext = this . _getContractConfiguratorContext ( ) ;
91
+ if ( this . lastContractData ) {
92
+ const changes = Object . assign ( { } , this . lastContractData ) ;
93
+ this . lastContractData = false ;
94
+ return this . props . record . _update ( changes , {
95
+ withoutOnchange : true ,
96
+ } ) ;
97
+ }
98
+ const actionContext = this . contractContext ;
50
99
this . action . doAction ( "product_contract.product_contract_configurator_action" , {
51
100
additionalContext : actionContext ,
52
101
onClose : async ( closeInfo ) => {
53
102
if ( closeInfo && ! closeInfo . special ) {
54
- this . props . record . update ( closeInfo . productContractConfiguration ) ;
103
+ this . props . record . _update ( closeInfo . productContractConfiguration , {
104
+ withoutOnchange : true ,
105
+ } ) ;
55
106
} else if ( isNew ) {
56
107
this . props . record . update ( {
57
108
[ this . props . name ] : undefined ,
0 commit comments