diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py
index a70684df1ad..b4f02b6ed0c 100644
--- a/addons/account_voucher/account_voucher.py
+++ b/addons/account_voucher/account_voucher.py
@@ -943,6 +943,8 @@ class account_voucher(osv.osv):
# refresh to make sure you don't unlink an already removed move
voucher.refresh()
for line in voucher.move_ids:
+ # refresh to make sure you don't unreconcile an already unreconciled entry
+ line.refresh()
if line.reconcile_id:
move_lines = [move_line.id for move_line in line.reconcile_id.line_id]
move_lines.remove(line.id)
diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py
index 3517c1a47a3..00fd00dda58 100644
--- a/addons/mail/mail_message.py
+++ b/addons/mail/mail_message.py
@@ -77,7 +77,8 @@ class mail_message(osv.Model):
def default_get(self, cr, uid, fields, context=None):
# protection for `default_type` values leaking from menu action context (e.g. for invoices)
- if context and context.get('default_type') and context.get('default_type') not in self._columns['type'].selection:
+ if context and context.get('default_type') and context.get('default_type') not in [
+ val[0] for val in self._columns['type'].selection]:
context = dict(context, default_type=None)
return super(mail_message, self).default_get(cr, uid, fields, context=context)
diff --git a/addons/project_long_term/project_long_term.py b/addons/project_long_term/project_long_term.py
index a950907fb69..0a2b6d5a1f7 100644
--- a/addons/project_long_term/project_long_term.py
+++ b/addons/project_long_term/project_long_term.py
@@ -266,6 +266,44 @@ class project(osv.osv):
}, context=context)
return True
+ def map_phase(self, cr, uid, old_project_id, new_project_id, context=None):
+ """ copy and map phases from old to new project while keeping order relations """
+ project_phase = self.pool['project.phase']
+ project_task = self.pool['project.task']
+ # mapping source and copy ids to recreate m2m links
+ phase_ids_mapping = {}
+ project = self.browse(cr, uid, old_project_id, context=context)
+ if project.phase_ids:
+ for phase in project.phase_ids:
+ phase_default = {
+ 'project_id': new_project_id,
+ 'previous_phase_ids': [],
+ 'next_phase_ids': [],
+ 'task_ids': [],
+ }
+ # adding relationships with already copied phases
+ for previous_phase in phase.previous_phase_ids:
+ if previous_phase.id in phase_ids_mapping:
+ phase_default['previous_phase_ids'].append((4, phase_ids_mapping[previous_phase.id]))
+ for next_phase in phase.next_phase_ids:
+ if next_phase.id in phase_ids_mapping:
+ phase_default['previous_phase_ids'].append((4, phase_ids_mapping[next_phase.id]))
+ phase_ids_mapping[phase.id] = project_phase.copy(cr, uid, phase.id, phase_default, context=context)
+ if project.tasks:
+ # if has copied tasks, need to update phase_id
+ for task in self.browse(cr, uid, new_project_id, context=context).tasks:
+ if task.phase_id and task.phase_id.id in phase_ids_mapping:
+ project_task.write(cr, uid, task.id, {'phase_id': phase_ids_mapping[phase.id]}, context=context)
+ return True
+
+ def copy(self, cr, uid, id, default=None, context=None):
+ if default is None:
+ default = {}
+ default.update(phase_ids=[])
+ new_project_id = super(project, self).copy(cr, uid, id, default, context)
+ self.map_phase(cr, uid, id, new_project_id, context=context)
+ return new_project_id
+
class account_analytic_account(osv.osv):
_inherit = 'account.analytic.account'
_description = 'Analytic Account'
diff --git a/addons/sale/res_config.py b/addons/sale/res_config.py
index 88f7b247591..f30407223bf 100644
--- a/addons/sale/res_config.py
+++ b/addons/sale/res_config.py
@@ -123,6 +123,7 @@ Example: 10% for retailers, promotion of 5 EUR on this product, etc."""),
product = ir_model_data.xmlid_to_object(cr, uid, 'product.product_product_consultant')
if product and product.exists():
res['time_unit'] = product.uom_id.id
+ res['timesheet'] = res.get('module_account_analytic_analysis')
return res
def _get_default_time_unit(self, cr, uid, context=None):
diff --git a/addons/sale/sale.py b/addons/sale/sale.py
index 1a26d51a164..f7875eb235d 100644
--- a/addons/sale/sale.py
+++ b/addons/sale/sale.py
@@ -256,7 +256,7 @@ class sale_order(osv.osv):
return osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
def copy_quotation(self, cr, uid, ids, context=None):
- id = self.copy(cr, uid, ids[0], context=None)
+ id = self.copy(cr, uid, ids[0], context=context)
view_ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'sale', 'view_order_form')
view_id = view_ref and view_ref[1] or False,
return {
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index ee8dc4b8348..3e0a7d55e3a 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -1298,6 +1298,7 @@ class stock_picking(osv.osv):
{'name': sequence_obj.get(cr, uid,
'stock.picking.%s'%(pick.type)),
})
+ pick.refresh()
new_picking = self.copy(cr, uid, pick.id,
{
'name': new_picking_name,
@@ -1355,9 +1356,8 @@ class stock_picking(osv.osv):
self.action_move(cr, uid, [new_picking], context=context)
self.signal_button_done(cr, uid, [new_picking])
workflow.trg_write(uid, 'stock.picking', pick.id, cr)
- delivered_pack_id = pick.id
- back_order_name = self.browse(cr, uid, delivered_pack_id, context=context).name
- self.message_post(cr, uid, new_picking, body=_("Back order %s has been created.") % (back_order_name), context=context)
+ delivered_pack_id = new_picking
+ self.message_post(cr, uid, new_picking, body=_("Back order %s has been created.") % (pick.name), context=context)
else:
self.action_move(cr, uid, [pick.id], context=context)
self.signal_button_done(cr, uid, [pick.id])
diff --git a/addons/stock/wizard/stock_partial_picking.py b/addons/stock/wizard/stock_partial_picking.py
index ceedb682ed8..7358855924d 100644
--- a/addons/stock/wizard/stock_partial_picking.py
+++ b/addons/stock/wizard/stock_partial_picking.py
@@ -156,6 +156,8 @@ class stock_partial_picking(osv.osv_memory):
return partial_move
def do_partial(self, cr, uid, ids, context=None):
+ if context is None:
+ context = {}
assert len(ids) == 1, 'Partial picking processing may only be done one at a time.'
stock_picking = self.pool.get('stock.picking')
stock_move = self.pool.get('stock.move')
@@ -211,7 +213,19 @@ class stock_partial_picking(osv.osv_memory):
if (picking_type == 'in') and (wizard_line.product_id.cost_method == 'average'):
partial_data['move%s' % (wizard_line.move_id.id)].update(product_price=wizard_line.cost,
product_currency=wizard_line.currency.id)
- stock_picking.do_partial(cr, uid, [partial.picking_id.id], partial_data, context=context)
- return {'type': 'ir.actions.act_window_close'}
+
+ # Do the partial delivery and open the picking that was delivered
+ # We don't need to find which view is required, stock.picking does it.
+ done = stock_picking.do_partial(
+ cr, uid, [partial.picking_id.id], partial_data, context=context)
+ return {
+ 'type': 'ir.actions.act_window',
+ 'res_model': context.get('active_model', 'stock.picking'),
+ 'name': _('Partial Delivery'),
+ 'res_id': done[partial.picking_id.id]['delivered_picking'],
+ 'view_type': 'form',
+ 'view_mode': 'form,tree,calendar',
+ 'context': context,
+ }
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/openerp/tools/translate.py b/openerp/tools/translate.py
index 58eefc92df4..c3786950c44 100644
--- a/openerp/tools/translate.py
+++ b/openerp/tools/translate.py
@@ -812,7 +812,7 @@ def trans_generate(lang, modules, cr):
for bin_path in ['osv', 'report' ]:
path_list.append(os.path.join(config.config['root_path'], bin_path))
- _logger.debug("Scanning modules at paths: ", path_list)
+ _logger.debug("Scanning modules at paths: %s", path_list)
mod_paths = []