[MERGE] forward port of branch saas-3 up to 310d3fe

This commit is contained in:
Christophe Simonis 2014-07-30 19:09:33 +02:00
commit fa07bc8532
10 changed files with 73 additions and 12 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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'

View File

@ -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):

View File

@ -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 {

View File

@ -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 <em>%s</em> has been <b>created</b>.") % (back_order_name), context=context)
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)
else:
self.action_move(cr, uid, [pick.id], context=context)
self.signal_button_done(cr, uid, [pick.id])

View File

@ -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:

View File

@ -184,14 +184,19 @@ class Website(openerp.addons.web.controllers.main.Home):
modules_to_update = []
for temp_id in templates:
view = request.registry['ir.ui.view'].browse(request.cr, request.uid, int(temp_id), context=request.context)
if view.page:
continue
view.model_data_id.write({
'noupdate': False
})
if view.model_data_id.module not in modules_to_update:
modules_to_update.append(view.model_data_id.module)
module_obj = request.registry['ir.module.module']
module_ids = module_obj.search(request.cr, request.uid, [('name', 'in', modules_to_update)], context=request.context)
module_obj.button_immediate_upgrade(request.cr, request.uid, module_ids, context=request.context)
if modules_to_update:
module_obj = request.registry['ir.module.module']
module_ids = module_obj.search(request.cr, request.uid, [('name', 'in', modules_to_update)], context=request.context)
if module_ids:
module_obj.button_immediate_upgrade(request.cr, request.uid, module_ids, context=request.context)
return request.redirect(redirect)
@http.route('/website/customize_template_toggle', type='json', auth='user', website=True)

View File

@ -171,7 +171,7 @@ class ir_http(orm.AbstractModel):
if 'qweb_exception' in values:
view = request.registry.get("ir.ui.view")
views = view._views_get(request.cr, request.uid, exception.qweb['template'], request.context)
to_reset = [v for v in views if v.model_data_id.noupdate is True]
to_reset = [v for v in views if v.model_data_id.noupdate is True and not v.page]
values['views'] = to_reset
elif code == 403:
logger.warn("403 Forbidden:\n\n%s", values['traceback'])

View File

@ -788,7 +788,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 = list(path_list)