[MERGE] Forward-port of latest saas-1 bugfixes, up to rev. 8800 rev-id: dle@openerp.com-20131031162241-goga1hsvwgyqigzd

bzr revid: chs@openerp.com-20131031142325-vo84hk5co2e2phg0
bzr revid: dle@openerp.com-20131031143133-wfus2hag57e73by2
bzr revid: dle@openerp.com-20131031162928-8gpom1ralccy07uc
This commit is contained in:
Denis Ledoux 2013-10-31 17:29:28 +01:00
commit 0cf57bdee2
6 changed files with 43 additions and 25 deletions

View File

@ -51,7 +51,12 @@ openerp.base_import = function (instance) {
type: 'ir.actions.client',
tag: 'import',
params: {
model: self.dataset.model
model: self.dataset.model,
// self.dataset.get_context() could be a compound?
// not sure. action's context should be evaluated
// so safer bet. Odd that timezone & al in it
// though
context: self.getParent().action.context,
}
}, {
on_reverse_breadcrumb: function () {
@ -127,6 +132,7 @@ openerp.base_import = function (instance) {
var self = this;
this._super.apply(this, arguments);
this.res_model = action.params.model;
this.parent_context = action.params.context || {};
// import object id
this.id = null;
this.Import = new instance.web.Model('base_import.import');
@ -353,11 +359,12 @@ openerp.base_import = function (instance) {
},
//- import itself
call_import: function (options) {
call_import: function (kwargs) {
var fields = this.$('.oe_import_fields input.oe_import_match_field').map(function (index, el) {
return $(el).select2('val') || false;
}).get();
return this.Import.call('do', [this.id, fields, this.import_options()], options)
kwargs.context = this.parent_context;
return this.Import.call('do', [this.id, fields, this.import_options()], kwargs)
.then(undefined, function (error, event) {
// In case of unexpected exception, convert
// "JSON-RPC error" to an import failure, and

View File

@ -3,7 +3,7 @@
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
# Copyright (C) 2010-2012 OpenERP s.a. (<http://openerp.com>).
# Copyright (C) 2010-2013 OpenERP s.a. (<http://openerp.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@ -49,6 +49,7 @@ class board_board(osv.osv):
('value', 'in', refs),
], context=context)
menu_ids = map(itemgetter('res_id'), IrValues.read(cr, uid, irv_ids, ['res_id'], context=context))
menu_ids = Menus._filter_visible_menus(cr, uid, menu_ids, context=context)
menu_names = Menus.name_get(cr, uid, menu_ids, context=context)
return [dict(id=m[0], name=m[1]) for m in menu_names]

View File

@ -179,6 +179,12 @@ class crm_lead(osv.osv):
return res
def assign_geo_localize(self, cr, uid, ids, latitude=False, longitude=False, context=None):
if latitude and longitude:
self.write(cr, uid, ids, {
'partner_latitude': latitude,
'partner_longitude': longitude
}, context=context)
return True
# Don't pass context to browse()! We need country name in english below
for lead in self.browse(cr, uid, ids):
if not lead.country_id:
@ -188,14 +194,11 @@ class crm_lead(osv.osv):
city=lead.city,
state=lead.state_id.name,
country=lead.country_id.name))
if not latitude and result:
latitude = result[0]
if not longitude and result:
longitude = result[1]
self.write(cr, uid, [lead.id], {
'partner_latitude': latitude,
'partner_longitude': longitude
}, context=context)
if result:
self.write(cr, uid, [lead.id], {
'partner_latitude': result[0],
'partner_longitude': result[1]
}, context=context)
return True
def search_geo_partner(self, cr, uid, ids, context=None):

View File

@ -1234,17 +1234,27 @@ class account_invoice(osv.Model):
def invoice_validate(self, cr, uid, ids, context=None):
res = super(account_invoice, self).invoice_validate(cr, uid, ids, context=context)
purchase_order_obj = self.pool.get('purchase.order')
po_ids = purchase_order_obj.search(cr, uid, [('invoice_ids', 'in', ids)], context=context)
# read access on purchase.order object is not required
if not purchase_order_obj.check_access_rights(cr, uid, 'read', raise_exception=False):
user_id = SUPERUSER_ID
else:
user_id = uid
po_ids = purchase_order_obj.search(cr, user_id, [('invoice_ids', 'in', ids)], context=context)
for po_id in po_ids:
purchase_order_obj.message_post(cr, uid, po_id, body=_("Invoice received"), context=context)
purchase_order_obj.message_post(cr, user_id, po_id, body=_("Invoice received"), context=context)
return res
def confirm_paid(self, cr, uid, ids, context=None):
res = super(account_invoice, self).confirm_paid(cr, uid, ids, context=context)
purchase_order_obj = self.pool.get('purchase.order')
po_ids = purchase_order_obj.search(cr, uid, [('invoice_ids', 'in', ids)], context=context)
# read access on purchase.order object is not required
if not purchase_order_obj.check_access_rights(cr, uid, 'read', raise_exception=False):
user_id = SUPERUSER_ID
else:
user_id = uid
po_ids = purchase_order_obj.search(cr, user_id, [('invoice_ids', 'in', ids)], context=context)
if po_ids:
purchase_order_obj.message_post(cr, uid, po_ids, body=_("Invoice paid"), context=context)
purchase_order_obj.message_post(cr, user_id, po_ids, body=_("Invoice paid"), context=context)
return res
class account_invoice_line(osv.Model):

View File

@ -27,6 +27,7 @@ import re
from openerp import tools
from openerp.osv import fields,osv
from openerp import SUPERUSER_ID
_logger = logging.getLogger(__name__)
@ -142,9 +143,10 @@ class ir_attachment(osv.osv):
if attach.store_fname:
self._file_delete(cr, uid, location, attach.store_fname)
fname = self._file_write(cr, uid, location, value)
super(ir_attachment, self).write(cr, uid, [id], {'store_fname': fname, 'file_size': file_size}, context=context)
# SUPERUSER_ID as probably don't have write access, trigger during create
super(ir_attachment, self).write(cr, SUPERUSER_ID, [id], {'store_fname': fname, 'file_size': file_size}, context=context)
else:
super(ir_attachment, self).write(cr, uid, [id], {'db_datas': value, 'file_size': file_size}, context=context)
super(ir_attachment, self).write(cr, SUPERUSER_ID, [id], {'db_datas': value, 'file_size': file_size}, context=context)
return True
_name = 'ir.attachment'
@ -186,8 +188,6 @@ class ir_attachment(osv.osv):
In the 'document' module, it is overriden to relax this hard rule, since
more complex ones apply there.
"""
if not ids:
return
res_ids = {}
if ids:
if isinstance(ids, (int, long)):
@ -290,7 +290,7 @@ class ir_attachment(osv.osv):
return super(ir_attachment, self).unlink(cr, uid, ids, context)
def create(self, cr, uid, values, context=None):
self.check(cr, uid, [], mode='create', context=context, values=values)
self.check(cr, uid, [], mode='write', context=context, values=values)
if 'file_size' in values:
del values['file_size']
return super(ir_attachment, self).create(cr, uid, values, context)

View File

@ -102,13 +102,10 @@ class res_config_configurable(osv.osv_memory):
res = next.action_launch(context=context)
res['nodestroy'] = False
return res
# reload the client; open the first available root menu
menu_obj = self.pool['ir.ui.menu']
menu_ids = menu_obj.search(cr, uid, [('parent_id', '=', False)], context=context)
return {
'type': 'ir.actions.client',
'tag': 'reload',
'params': {'menu_id': menu_ids and menu_ids[0] or False},
}
def start(self, cr, uid, ids, context=None):