7
7
8
8
from odoo import api , fields , models
9
9
10
- import odoo .addons .decimal_precision as dp
11
-
12
10
13
11
class DepositSlip (models .Model ):
14
12
_name = "deposit.slip"
15
13
_description = "Deposit Slip"
16
14
_order = "id desc"
17
- _inherit = ["mail.thread" ]
18
- _track = {
19
- "state" : {
20
- "delivery_carrier_deposit.deposit_slip_done" : lambda self , cr , uid , obj , ctx = None : obj .state
21
- == "done" ,
22
- }
23
- }
15
+ _inherit = ["mail.thread" , "mail.activity.mixin" ]
24
16
25
- @api .one
26
17
@api .depends ("picking_ids" )
27
- def _compute_deposit_slip (self ):
18
+ def _compute_weight (self ):
28
19
weight = 0.0
29
- number_of_packages = 0
30
20
for picking in self .picking_ids :
31
- number_of_packages += picking .number_of_packages
32
- weight += picking .weight
21
+ weight += picking .shipping_weight
33
22
self .weight = weight
34
- self .number_of_packages = number_of_packages
35
-
36
- @api .model
37
- def _get_carrier_type_selection (self ):
38
- return self .env ["delivery.carrier" ]._get_carrier_type_selection ()
39
23
40
24
name = fields .Char (
41
25
readonly = True , states = {"draft" : [("readonly" , False )]}, default = "/" , copy = False
42
26
)
43
- carrier_type = fields .Selection (
44
- selection = "_get_carrier_type_selection" ,
45
- string = "Type" ,
46
- readonly = True ,
47
- required = True ,
48
- copy = False ,
49
- help = "Carrier type (combines several delivery methods)" ,
27
+ delivery_type = fields .Selection (
28
+ selection = lambda self : self .env ["delivery.carrier" ]
29
+ ._fields ["delivery_type" ]
30
+ .selection
50
31
)
51
32
picking_ids = fields .One2many (
52
33
comodel_name = "stock.picking" ,
@@ -67,18 +48,11 @@ def _get_carrier_type_selection(self):
67
48
company_id = fields .Many2one (
68
49
comodel_name = "res.company" ,
69
50
string = "Company" ,
70
- default = lambda self : self .env ["res.company" ]._company_default_get (
71
- "deposit.slip"
72
- ),
51
+ default = lambda self : self .env .company ,
73
52
)
74
53
weight = fields .Float (
75
54
string = "Total Weight" ,
76
- compute = "_compute_deposit_slip" ,
77
- digits = dp .get_precision ("Stock Weight" ),
78
- readonly = True ,
79
- )
80
- number_of_packages = fields .Integer (
81
- string = "Number of Packages" , compute = "_compute_deposit_slip" , readonly = True
55
+ compute = "_compute_weight" ,
82
56
)
83
57
84
58
_sql_constraints = [
@@ -95,32 +69,15 @@ def create(self, vals=None):
95
69
vals = {}
96
70
if vals .get ("name" , "/" ) == "/" :
97
71
vals ["name" ] = self .env ["ir.sequence" ].next_by_code ("delivery.deposit" )
98
- return super (DepositSlip , self ).create (vals )
72
+ return super ().create (vals )
99
73
100
- @api .multi
101
74
def create_edi_file (self ):
102
75
"""
103
76
Override this method for the proper carrier
104
77
"""
105
78
return True
106
79
107
- @api .multi
108
80
def validate_deposit (self ):
109
81
self .create_edi_file ()
110
82
self .write ({"state" : "done" })
111
83
return True
112
-
113
-
114
- class StockPicking (models .Model ):
115
- _inherit = "stock.picking"
116
-
117
- deposit_slip_id = fields .Many2one ("deposit.slip" , "Deposit Slip" )
118
-
119
-
120
- class DeliveryCarrier (models .Model ):
121
- _inherit = "delivery.carrier"
122
-
123
- deposit_slip = fields .Boolean (
124
- string = "Deposit Slip" ,
125
- help = "Allow to create a 'Deposit Slip' report on delivery orders" ,
126
- )
0 commit comments