Forward port of branch 7.0 up to 1933e92

This commit is contained in:
Martin Trigaux 2014-09-24 17:10:14 +02:00
commit 0c36f8a4ce
6 changed files with 73 additions and 13 deletions

View File

@ -153,6 +153,11 @@ class crm_lead(format_address, osv.osv):
return result, fold
def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
if view_type == 'form' and context and context.get('opportunity_id'):
# TODO: replace by get_formview_action call
lead_type = self.browse(cr, user, context['opportunity_id'], context=context).type
view_lead_xml_id = 'crm_case_form_view_oppor' if lead_type == 'opportunity' else 'crm_case_form_view_leads'
_, view_id = self.pool['ir.model.data'].get_object_reference(cr, user, 'crm', view_lead_xml_id)
res = super(crm_lead, self).fields_view_get(cr, user, view_id, view_type, context, toolbar=toolbar, submenu=submenu)
if view_type == 'form':
res['arch'] = self.fields_view_get_address(cr, user, res['arch'], context=context)

View File

@ -99,7 +99,7 @@
domain="[('object_id.model', '=', 'crm.phonecall')]"/>
<field name="partner_mobile"/>
<field name="priority"/>
<field name="opportunity_id" on_change="on_change_opportunity(opportunity_id)"/>
<field name="opportunity_id" on_change="on_change_opportunity(opportunity_id)" context="{'opportunity_id': opportunity_id}"/>
</group>
<field name="description" placeholder="Description..."/>
</sheet>

View File

@ -64,7 +64,6 @@
<field name="res_model">account.invoice</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('type','in',['out_invoice','out_refund'])]</field>
<field name="context">{'type':['out_invoice','out_refund'], 'journal_type': 'sale'}</field>
<field name="search_view_id" ref="account.view_account_invoice_filter"/>
<field name="help">We haven't sent you any invoice.</field>
</record>

View File

@ -95,6 +95,7 @@ Dashboard / Reports for Warehouse Management will include:
'test/opening_stock.yml',
'test/shipment.yml',
'test/stock_report.yml',
'test/setlast_tracking.yml',
],
'installable': True,
'application': True,

View File

@ -1290,11 +1290,12 @@ class stock_picking(osv.osv):
product_avail[product.id] += qty
# every line of the picking is empty, do not generate anything
empty_picking = not any(q for q in move_product_qty.values() if q > 0)
for move in too_few:
product_qty = move_product_qty[move.id]
if not new_picking:
if not new_picking and not empty_picking:
new_picking_name = pick.name
self.write(cr, uid, [pick.id],
{'name': sequence_obj.get(cr, uid,
@ -1360,6 +1361,8 @@ class stock_picking(osv.osv):
workflow.trg_write(uid, 'stock.picking', pick.id, cr)
delivered_pack_id = new_picking
self.message_post(cr, uid, new_picking, body=_("Back order <em>%s</em> has been <b>created</b>.") % (pick.name), context=context)
elif empty_picking:
delivered_pack_id = pick.id
else:
self.action_move(cr, uid, [pick.id], context=context)
self.signal_button_done(cr, uid, [pick.id])
@ -2198,16 +2201,24 @@ class stock_move(osv.osv):
return count
def setlast_tracking(self, cr, uid, ids, context=None):
tracking_obj = self.pool.get('stock.tracking')
picking = self.browse(cr, uid, ids, context=context)[0].picking_id
if picking:
last_track = [line.tracking_id.id for line in picking.move_lines if line.tracking_id]
if not last_track:
last_track = tracking_obj.create(cr, uid, {}, context=context)
assert len(ids) == 1, "1 ID expected, got %s" % (ids, )
tracking_obj = self.pool['stock.tracking']
move = self.browse(cr, uid, ids[0], context=context)
picking_id = move.picking_id.id
if picking_id:
move_ids = self.search(cr, uid, [
('picking_id', '=', picking_id),
('tracking_id', '!=', False)
], limit=1, order='tracking_id DESC', context=context)
if move_ids:
tracking_move = self.browse(cr, uid, move_ids[0],
context=context)
tracking_id = tracking_move.tracking_id.id
else:
last_track.sort()
last_track = last_track[-1]
self.write(cr, uid, ids, {'tracking_id': last_track})
tracking_id = tracking_obj.create(cr, uid, {}, context=context)
self.write(cr, uid, move.id,
{'tracking_id': tracking_id},
context=context)
return True
#

View File

@ -0,0 +1,44 @@
-
In order to check if the last tracking is set on moves, I create a picking
-
!record {model: stock.picking, id: shipment_tracking}:
type: out
location_dest_id: stock_location_output
-
!record {model: stock.move, id: shipment_tracking_move1}:
picking_id: shipment_tracking
product_id: product_product_6
product_uom: product.product_uom_unit
product_qty: 10.0
location_id: location_monitor
location_dest_id: stock_location_output
-
!record {model: stock.move, id: shipment_tracking_move2}:
picking_id: shipment_tracking
product_id: product_product_6
product_uom: product.product_uom_unit
product_qty: 10.0
location_id: location_monitor
location_dest_id: stock_location_output
-
Then I call setlast_tracking on the moves and check if the tracking is correct
-
!python {model: stock.move}: |
move_id = ref('shipment_tracking_move1')
move = self.browse(cr, uid, move_id)
assert not move.tracking_id, "Move1 must not have a tracking at this point"
tracking_ids = self.pool['stock.tracking'].search(cr, uid, [])
self.setlast_tracking(cr, uid, [move_id])
move.refresh()
tracking_id = move.tracking_id.id
assert tracking_id, "The move must have a tracking_id"
assert tracking_id not in tracking_ids, "The tracking must be a new one"
move2_id = ref('shipment_tracking_move2')
move2 = self.browse(cr, uid, move2_id)
assert not move2.tracking_id, "Move2 must not have a tracking at this point"
self.setlast_tracking(cr, uid, [move2_id])
move2.refresh()
tracking2_id = move2.tracking_id.id
assert tracking2_id, "Move2 must have a tracking_id"
assert tracking2_id == tracking_id, "The second move must have the same tracking than the previous one"