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
=== modified file 'bin/addons/purchase_override/purchase.py'
--- bin/addons/purchase_override/purchase.py 2017-02-16 13:27:33 +0000
+++ bin/addons/purchase_override/purchase.py 2017-03-22 09:52:36 +0000
@@ -2035,6 +2035,9 @@
2035 if isinstance(ids, (int, long)):2035 if isinstance(ids, (int, long)):
2036 ids = [ids]2036 ids = [ids]
20372037
2038 if context is None:
2039 context = {}
2040
2038 # duplicated code with wkf_confirm_wait_order because of backward compatibility issue with yml tests for dates,2041 # duplicated code with wkf_confirm_wait_order because of backward compatibility issue with yml tests for dates,
2039 # which doesnt execute wkf_confirm_wait_order (null value in column "date_expected" violates not-null constraint for stock.move otherwise)2042 # which doesnt execute wkf_confirm_wait_order (null value in column "date_expected" violates not-null constraint for stock.move otherwise)
2040 # msf_order_date checks2043 # msf_order_date checks
@@ -2063,6 +2066,7 @@
2063 todo2 = []2066 todo2 = []
2064 todo3 = []2067 todo3 = []
2065 todo4 = {}2068 todo4 = {}
2069 to_invoice = set()
2066 if order.partner_id.partner_type in ('internal', 'esc') and order.order_type == 'regular' or \2070 if order.partner_id.partner_type in ('internal', 'esc') and order.order_type == 'regular' or \
2067 order.order_type in ['donation_exp', 'donation_st', 'loan']:2071 order.order_type in ['donation_exp', 'donation_st', 'loan']:
2068 self.write(cr, uid, [order.id], {'invoice_method': 'manual'})2072 self.write(cr, uid, [order.id], {'invoice_method': 'manual'})
@@ -2107,6 +2111,10 @@
2107 'date': strftime('%Y-%m-%d %H:%M:%S')}, context=context)2111 'date': strftime('%Y-%m-%d %H:%M:%S')}, context=context)
2108 wf_service.trg_trigger(uid, 'stock.move', move.id, cr)2112 wf_service.trg_trigger(uid, 'stock.move', move.id, cr)
2109 if move.picking_id:2113 if move.picking_id:
2114 if move.picking_id.sale_id:
2115 sale = move.picking_id.sale_id
2116 if sale.partner_id.partner_type in ('section', 'intermission') and sale.invoice_quantity == 'procurement':
2117 to_invoice.add(move.picking_id.id)
2110 all_move_closed = True2118 all_move_closed = True
2111 # Check if the picking should be updated2119 # Check if the picking should be updated
2112 if move.picking_id.subtype == 'picking':2120 if move.picking_id.subtype == 'picking':
@@ -2123,6 +2131,11 @@
2123 wf_service.trg_validate(uid, 'stock.picking', pick_id, 'button_confirm', cr)2131 wf_service.trg_validate(uid, 'stock.picking', pick_id, 'button_confirm', cr)
2124 wf_service.trg_write(uid, 'stock.picking', pick_id, cr)2132 wf_service.trg_write(uid, 'stock.picking', pick_id, cr)
21252133
2134 if to_invoice:
2135 conf_context = context.copy()
2136 conf_context['invoice_dpo_confirmation'] = order.id
2137 self.pool.get('stock.picking').action_invoice_create(cr, uid, list(to_invoice), type='out_invoice', context=conf_context)
2138
2126 # @@@override@purchase.purchase.order.wkf_approve_order2139 # @@@override@purchase.purchase.order.wkf_approve_order
2127 self.write(cr, uid, ids, {'state': 'approved', 'date_approve': strftime('%Y-%m-%d')})2140 self.write(cr, uid, ids, {'state': 'approved', 'date_approve': strftime('%Y-%m-%d')})
2128 return True2141 return True
21292142
=== modified file 'bin/addons/stock/stock.py'
--- bin/addons/stock/stock.py 2017-03-06 08:27:43 +0000
+++ bin/addons/stock/stock.py 2017-03-22 09:52:36 +0000
@@ -1081,6 +1081,7 @@
1081 invoices_group = {}1081 invoices_group = {}
1082 res = {}1082 res = {}
1083 inv_type = type1083 inv_type = type
1084 all_pick_lines_invoiced = True
1084 for picking in self.browse(cr, uid, ids, context=context):1085 for picking in self.browse(cr, uid, ids, context=context):
1085 if picking.invoice_state != '2binvoiced':1086 if picking.invoice_state != '2binvoiced':
1086 continue1087 continue
@@ -1180,9 +1181,22 @@
1180 invoice_id = invoice_obj.create(cr, uid, invoice_vals, context=context)1181 invoice_id = invoice_obj.create(cr, uid, invoice_vals, context=context)
1181 invoices_group[partner.id] = invoice_id1182 invoices_group[partner.id] = invoice_id
1182 res[picking.id] = invoice_id1183 res[picking.id] = invoice_id
1184 all_pick_lines_invoiced = True
1183 for move_line in picking.move_lines:1185 for move_line in picking.move_lines:
1184 if move_line.state == 'cancel':1186 if move_line.state == 'cancel':
1185 continue1187 continue
1188
1189 # US-2041 - Do not invoice Picking Ticket / Delivery Order lines that are not linked to a DPO when
1190 # invoice creation was requested at DPO confirmation
1191 if picking.type == 'out' and context.get('invoice_dpo_confirmation') and move_line.dpo_id.id != context.get('invoice_dpo_confirmation'):
1192 all_pick_lines_invoiced = False
1193 continue
1194
1195 # US-2041 - Do not invoice Picking Ticket / Delivery Order lines that are linked to a DPO
1196 # when the invoice creation was requested at Picking Ticket / Delivery Order processing
1197 if picking.type == 'out' and not context.get('invoice_dpo_confirmation') and move_line.dpo_line_id:
1198 continue
1199
1186 origin = move_line.picking_id.name or ''1200 origin = move_line.picking_id.name or ''
1187 if move_line.picking_id.origin:1201 if move_line.picking_id.origin:
1188 origin += ':' + move_line.picking_id.origin1202 origin += ':' + move_line.picking_id.origin
@@ -1232,13 +1246,15 @@
12321246
1233 invoice_obj.button_compute(cr, uid, [invoice_id], context=context,1247 invoice_obj.button_compute(cr, uid, [invoice_id], context=context,
1234 set_total=(inv_type in ('in_invoice', 'in_refund')))1248 set_total=(inv_type in ('in_invoice', 'in_refund')))
1235 self.write(cr, uid, [picking.id], {1249 if all_pick_lines_invoiced:
1250 self.write(cr, uid, [picking.id], {
1251 'invoice_state': 'invoiced',
1252 }, context=context)
1253 self._invoice_hook(cr, uid, picking, invoice_id)
1254 if all_pick_lines_invoiced:
1255 self.write(cr, uid, res.keys(), {
1236 'invoice_state': 'invoiced',1256 'invoice_state': 'invoiced',
1237 }, context=context)1257 }, context=context)
1238 self._invoice_hook(cr, uid, picking, invoice_id)
1239 self.write(cr, uid, res.keys(), {
1240 'invoice_state': 'invoiced',
1241 }, context=context)
1242 return res1258 return res
12431259
1244 def test_done(self, cr, uid, ids, context=None):1260 def test_done(self, cr, uid, ids, context=None):

Subscribers

People subscribed via source and target branches

to all changes: