Merge lp:~unifield-team/unifield-server/us-2041 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 4310
Proposed branch: lp:~unifield-team/unifield-server/us-2041
Merge into: lp:unifield-server
Diff against target: 100 lines (+34/-5)
2 files modified
bin/addons/purchase_override/purchase.py (+13/-0)
bin/addons/stock/stock.py (+21/-5)
To merge this branch: bzr merge lp:~unifield-team/unifield-server/us-2041
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+320318@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/addons/purchase_override/purchase.py'
2--- bin/addons/purchase_override/purchase.py 2017-02-16 13:27:33 +0000
3+++ bin/addons/purchase_override/purchase.py 2017-03-22 09:52:36 +0000
4@@ -2035,6 +2035,9 @@
5 if isinstance(ids, (int, long)):
6 ids = [ids]
7
8+ if context is None:
9+ context = {}
10+
11 # duplicated code with wkf_confirm_wait_order because of backward compatibility issue with yml tests for dates,
12 # which doesnt execute wkf_confirm_wait_order (null value in column "date_expected" violates not-null constraint for stock.move otherwise)
13 # msf_order_date checks
14@@ -2063,6 +2066,7 @@
15 todo2 = []
16 todo3 = []
17 todo4 = {}
18+ to_invoice = set()
19 if order.partner_id.partner_type in ('internal', 'esc') and order.order_type == 'regular' or \
20 order.order_type in ['donation_exp', 'donation_st', 'loan']:
21 self.write(cr, uid, [order.id], {'invoice_method': 'manual'})
22@@ -2107,6 +2111,10 @@
23 'date': strftime('%Y-%m-%d %H:%M:%S')}, context=context)
24 wf_service.trg_trigger(uid, 'stock.move', move.id, cr)
25 if move.picking_id:
26+ if move.picking_id.sale_id:
27+ sale = move.picking_id.sale_id
28+ if sale.partner_id.partner_type in ('section', 'intermission') and sale.invoice_quantity == 'procurement':
29+ to_invoice.add(move.picking_id.id)
30 all_move_closed = True
31 # Check if the picking should be updated
32 if move.picking_id.subtype == 'picking':
33@@ -2123,6 +2131,11 @@
34 wf_service.trg_validate(uid, 'stock.picking', pick_id, 'button_confirm', cr)
35 wf_service.trg_write(uid, 'stock.picking', pick_id, cr)
36
37+ if to_invoice:
38+ conf_context = context.copy()
39+ conf_context['invoice_dpo_confirmation'] = order.id
40+ self.pool.get('stock.picking').action_invoice_create(cr, uid, list(to_invoice), type='out_invoice', context=conf_context)
41+
42 # @@@override@purchase.purchase.order.wkf_approve_order
43 self.write(cr, uid, ids, {'state': 'approved', 'date_approve': strftime('%Y-%m-%d')})
44 return True
45
46=== modified file 'bin/addons/stock/stock.py'
47--- bin/addons/stock/stock.py 2017-03-06 08:27:43 +0000
48+++ bin/addons/stock/stock.py 2017-03-22 09:52:36 +0000
49@@ -1081,6 +1081,7 @@
50 invoices_group = {}
51 res = {}
52 inv_type = type
53+ all_pick_lines_invoiced = True
54 for picking in self.browse(cr, uid, ids, context=context):
55 if picking.invoice_state != '2binvoiced':
56 continue
57@@ -1180,9 +1181,22 @@
58 invoice_id = invoice_obj.create(cr, uid, invoice_vals, context=context)
59 invoices_group[partner.id] = invoice_id
60 res[picking.id] = invoice_id
61+ all_pick_lines_invoiced = True
62 for move_line in picking.move_lines:
63 if move_line.state == 'cancel':
64 continue
65+
66+ # US-2041 - Do not invoice Picking Ticket / Delivery Order lines that are not linked to a DPO when
67+ # invoice creation was requested at DPO confirmation
68+ if picking.type == 'out' and context.get('invoice_dpo_confirmation') and move_line.dpo_id.id != context.get('invoice_dpo_confirmation'):
69+ all_pick_lines_invoiced = False
70+ continue
71+
72+ # US-2041 - Do not invoice Picking Ticket / Delivery Order lines that are linked to a DPO
73+ # when the invoice creation was requested at Picking Ticket / Delivery Order processing
74+ if picking.type == 'out' and not context.get('invoice_dpo_confirmation') and move_line.dpo_line_id:
75+ continue
76+
77 origin = move_line.picking_id.name or ''
78 if move_line.picking_id.origin:
79 origin += ':' + move_line.picking_id.origin
80@@ -1232,13 +1246,15 @@
81
82 invoice_obj.button_compute(cr, uid, [invoice_id], context=context,
83 set_total=(inv_type in ('in_invoice', 'in_refund')))
84- self.write(cr, uid, [picking.id], {
85+ if all_pick_lines_invoiced:
86+ self.write(cr, uid, [picking.id], {
87+ 'invoice_state': 'invoiced',
88+ }, context=context)
89+ self._invoice_hook(cr, uid, picking, invoice_id)
90+ if all_pick_lines_invoiced:
91+ self.write(cr, uid, res.keys(), {
92 'invoice_state': 'invoiced',
93 }, context=context)
94- self._invoice_hook(cr, uid, picking, invoice_id)
95- self.write(cr, uid, res.keys(), {
96- 'invoice_state': 'invoiced',
97- }, context=context)
98 return res
99
100 def test_done(self, cr, uid, ids, context=None):

Subscribers

People subscribed via source and target branches

to all changes: