77
88
99class PurchaseOrder (models .Model ):
10- _inherit = ' purchase.order'
10+ _inherit = " purchase.order"
1111
1212 @api .multi
13- @api .depends (' order_line' )
13+ @api .depends (" order_line" )
1414 def _compute_max_line_sequence (self ):
1515 """Allow to know the highest sequence entered in purchase order lines.
1616 Then we add 1 to this value for the next sequence which is given
@@ -19,25 +19,32 @@ def _compute_max_line_sequence(self):
1919 """
2020 for purchase in self :
2121 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+ )
2324
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+ )
2628
2729 @api .multi
2830 def _create_picking (self ):
2931 res = super (PurchaseOrder , self )._create_picking ()
3032 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+ ):
3339 pickings = order .picking_ids .filtered (
34- lambda x : x .state not in ('done' , 'cancel' ))
40+ lambda x : x .state not in ("done" , "cancel" )
41+ )
3542 if pickings :
3643 picking = pickings [0 ]
3744 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 })
4148 return res
4249
4350 @api .multi
@@ -56,23 +63,27 @@ def write(self, line_values):
5663
5764 @api .multi
5865 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+ )
6169
6270
6371class PurchaseOrderLine (models .Model ):
64- _inherit = ' purchase.order.line'
65- _order = ' sequence, id'
72+ _inherit = " purchase.order.line"
73+ _order = " sequence, id"
6674
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+ )
7180
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+ )
7687
7788 @api .multi
7889 def _prepare_stock_moves (self , picking ):
@@ -85,6 +96,6 @@ def _prepare_stock_moves(self, picking):
8596 def create (self , values ):
8697 line = super (PurchaseOrderLine , self ).create (values )
8798 # 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" ):
89100 line .order_id ._reset_sequence ()
90101 return line
0 commit comments