@@ -39,23 +39,29 @@ def new_action_invoice_create(self, grouped=False, final=False):
39
39
new_lines = False
40
40
# END HOOK
41
41
for order in self :
42
- # START HOOK
43
- # Add more flexibility in grouping key fields
44
- # WAS: group_key = order.id if grouped
45
- # else (order.partner_invoice_id.id, order.currency_id.id)
46
- group_key = order .id if grouped else \
47
- self ._get_invoice_group_key (order )
48
- # 'invoice' must be always instantiated respecting the old logic
49
- if group_key in invoices :
50
- invoice = invoices [group_key ]
51
- # END HOOK
52
42
for line in order .order_line .sorted (
53
43
key = lambda l : l .qty_to_invoice < 0 ):
54
44
if float_is_zero (line .qty_to_invoice ,
55
45
precision_digits = precision ):
56
46
continue
47
+ # START HOOK
48
+ # Allow to check if a line should not be invoiced
49
+ if line ._do_not_invoice ():
50
+ continue
51
+ # END HOOK
52
+ # START HOOK
53
+ # Add more flexibility in grouping key fields
54
+ # WAS: group_key = order.id if grouped
55
+ # else (order.partner_invoice_id.id, order.currency_id.id)
56
+ group_key = order .id if grouped else \
57
+ self ._get_invoice_group_line_key (line )
58
+ # 'invoice' must be always instantiated
59
+ # respecting the old logic
60
+ if group_key in invoices :
61
+ invoice = invoices [group_key ]
62
+ # END HOOK
57
63
if group_key not in invoices :
58
- inv_data = order ._prepare_invoice ()
64
+ inv_data = line ._prepare_invoice ()
59
65
invoice = inv_obj .create (inv_data )
60
66
references [invoice ] = order
61
67
invoices [group_key ] = invoice
0 commit comments