7
7
8
8
9
9
class PurchaseOrder (models .Model ):
10
- _inherit = ' purchase.order'
10
+ _inherit = " purchase.order"
11
11
12
12
@api .multi
13
- @api .depends (' order_line' )
13
+ @api .depends (" order_line" )
14
14
def _compute_max_line_sequence (self ):
15
15
"""Allow to know the highest sequence entered in purchase order lines.
16
16
Then we add 1 to this value for the next sequence which is given
@@ -19,25 +19,32 @@ def _compute_max_line_sequence(self):
19
19
"""
20
20
for purchase in self :
21
21
purchase .max_line_sequence = (
22
- max (purchase .mapped ('order_line.sequence' ) or [0 ]) + 1 )
22
+ max (purchase .mapped ("order_line.sequence" ) or [0 ]) + 1
23
+ )
23
24
24
- max_line_sequence = fields .Integer (string = 'Max sequence in lines' ,
25
- compute = '_compute_max_line_sequence' )
25
+ max_line_sequence = fields .Integer (
26
+ string = "Max sequence in lines" , compute = "_compute_max_line_sequence"
27
+ )
26
28
27
29
@api .multi
28
30
def _create_picking (self ):
29
31
res = super (PurchaseOrder , self )._create_picking ()
30
32
for order in self :
31
- if any ([ptype in ['product' , 'consu' ] for ptype in
32
- order .order_line .mapped ('product_id.type' )]):
33
+ if any (
34
+ [
35
+ ptype in ["product" , "consu" ]
36
+ for ptype in order .order_line .mapped ("product_id.type" )
37
+ ]
38
+ ):
33
39
pickings = order .picking_ids .filtered (
34
- lambda x : x .state not in ('done' , 'cancel' ))
40
+ lambda x : x .state not in ("done" , "cancel" )
41
+ )
35
42
if pickings :
36
43
picking = pickings [0 ]
37
44
for move , line in zip (
38
- sorted (picking .move_lines ,
39
- key = lambda m : m . id ), order . order_line ):
40
- move .write ({' sequence' : line .sequence })
45
+ sorted (picking .move_lines , key = lambda m : m . id ), order . order_line
46
+ ):
47
+ move .write ({" sequence" : line .sequence })
41
48
return res
42
49
43
50
@api .multi
@@ -56,23 +63,27 @@ def write(self, line_values):
56
63
57
64
@api .multi
58
65
def copy (self , default = None ):
59
- return super (PurchaseOrder ,
60
- self .with_context (keep_line_sequence = True )).copy (default )
66
+ return super (PurchaseOrder , self .with_context (keep_line_sequence = True )).copy (
67
+ default
68
+ )
61
69
62
70
63
71
class PurchaseOrderLine (models .Model ):
64
- _inherit = ' purchase.order.line'
65
- _order = ' sequence, id'
72
+ _inherit = " purchase.order.line"
73
+ _order = " sequence, id"
66
74
67
- sequence = fields .Integer ('Hidden Sequence' ,
68
- help = "Gives the sequence of the line when "
69
- "displaying the purchase order." ,
70
- default = 9999 )
75
+ sequence = fields .Integer (
76
+ "Hidden Sequence" ,
77
+ help = "Gives the sequence of the line when " "displaying the purchase order." ,
78
+ default = 9999 ,
79
+ )
71
80
72
- sequence2 = fields .Integer ('Sequence' ,
73
- help = "Displays the sequence of the line in "
74
- "the purchase order." ,
75
- related = 'sequence' , readonly = True )
81
+ sequence2 = fields .Integer (
82
+ "Sequence" ,
83
+ help = "Displays the sequence of the line in " "the purchase order." ,
84
+ related = "sequence" ,
85
+ readonly = True ,
86
+ )
76
87
77
88
@api .multi
78
89
def _prepare_stock_moves (self , picking ):
@@ -85,6 +96,6 @@ def _prepare_stock_moves(self, picking):
85
96
def create (self , values ):
86
97
line = super (PurchaseOrderLine , self ).create (values )
87
98
# We do not reset the sequence when copying an entire purchase order
88
- if not self .env .context .get (' keep_line_sequence' ):
99
+ if not self .env .context .get (" keep_line_sequence" ):
89
100
line .order_id ._reset_sequence ()
90
101
return line
0 commit comments