Skip to content

Commit b1c0bc0

Browse files
committed
[MERGE] forward port of branch saas-4 up to 65f68c1
2 parents 7770ca8 + 65f68c1 commit b1c0bc0

File tree

13 files changed

+75
-42
lines changed

13 files changed

+75
-42
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ _build/
33

44
# dotfiles
55
.*
6+
!.gitignore
67
# compiled python files
78
*.py[co]
89
# setup.py egg_info
@@ -12,7 +13,8 @@ _build/
1213
# hg stuff
1314
*.orig
1415
status
15-
16+
# odoo filestore
17+
openerp/filestore
1618
# generated for windows installer?
1719
install/win32/*.bat
1820
install/win32/meta.py

addons/delivery/sale.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def delivery_set(self, cr, uid, ids, context=None):
7474
if not grid_id:
7575
raise osv.except_osv(_('No Grid Available!'), _('No grid matching for this carrier!'))
7676

77-
if order.state != 'draft':
77+
if order.state not in ('draft', 'sent'):
7878
raise osv.except_osv(_('Order not in Draft State!'), _('The order state have to be draft to add delivery lines.'))
7979

8080
grid = grid_obj.browse(cr, uid, grid_id, context=context)

addons/edi/static/src/js/edi.js

+14-16
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,15 @@ instance.edi.EdiImport = instance.web.Widget.extend({
3939
});
4040
}
4141
else {
42-
$('<div>').dialog({
43-
modal: true,
44-
title: 'Import Successful!',
45-
buttons: {
46-
Ok: function() {
47-
$(this).dialog("close");
48-
window.location = "/";
42+
new instance.web.Dialog(this,{
43+
title: 'Import Successful!',
44+
buttons: {
45+
Ok: function() {
46+
this.parents('.modal').modal('hide');
47+
window.location = "/";
48+
}
4949
}
50-
}
51-
}).html(_t('The document has been successfully imported!'));
50+
},$('<div>').html(_t('The document has been successfully imported!'))).open();
5251
}
5352
},
5453
on_imported_error: function(response){
@@ -58,13 +57,12 @@ instance.edi.EdiImport = instance.web.Widget.extend({
5857
msg += "\n " + _t("Reason:") + response.data.message;
5958
}
6059
var params = {error: response, message: msg};
61-
$(instance.web.qweb.render("CrashManager.warning", params)).dialog({
62-
title: _t("Document Import Notification"),
63-
modal: true,
64-
buttons: {
65-
Ok: function() { $(this).dialog("close"); }
66-
}
67-
});
60+
new instance.web.Dialog(this,{
61+
title: _t("Document Import Notification"),
62+
buttons: {
63+
Ok: function() { this.parents('.modal').modal('hide');}
64+
}
65+
},$(instance.web.qweb.render("CrashManager.warning", params))).open();
6866
}
6967
});
7068

addons/event_sale/event_sale.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ def _events_from_registrations(self, cr, uid, ids, context=None):
159159
help="The maximum registration level is equal to the sum of the maximum registration of event ticket." +
160160
"If you have too much registrations you are not able to confirm your event. (0 to ignore this rule )",
161161
type='integer',
162-
readonly=True),
162+
readonly=True,
163+
store={
164+
'event.event': (lambda self, cr, uid, ids, c = {}: ids, ['event_ticket_ids'], 20),
165+
'event.event.ticket': (_get_ticket_events, ['seats_max'], 10),
166+
}),
163167
'seats_available': fields.function(Event._get_seats, oldname='register_avail', string='Available Seats',
164168
type='integer', multi='seats_reserved',
165169
store={

addons/gamification/models/goal.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,8 @@ def update(self, cr, uid, ids, context=None):
333333

334334
if definition.computation_mode == 'sum':
335335
field_name = definition.field_id.name
336-
res = obj.read_group(cr, uid, domain, [field_name], [field_name], context=context)
336+
# TODO for master: group on user field in batch mode
337+
res = obj.read_group(cr, uid, domain, [field_name], [], context=context)
337338
new_value = res and res[0][field_name] or 0.0
338339

339340
else: # computation mode = count

addons/mail/mail_thread.py

+20-10
Original file line numberDiff line numberDiff line change
@@ -889,9 +889,10 @@ def message_route(self, cr, uid, message, message_dict, model=None, thread_id=No
889889
thread_references = references or in_reply_to
890890

891891
# 1. message is a reply to an existing message (exact match of message_id)
892+
ref_match = thread_references and tools.reference_re.search(thread_references)
892893
msg_references = thread_references.split()
893894
mail_message_ids = mail_msg_obj.search(cr, uid, [('message_id', 'in', msg_references)], context=context)
894-
if mail_message_ids:
895+
if ref_match and mail_message_ids:
895896
original_msg = mail_msg_obj.browse(cr, SUPERUSER_ID, mail_message_ids[0], context=context)
896897
model, thread_id = original_msg.model, original_msg.res_id
897898
route = self.message_route_verify(
@@ -905,7 +906,6 @@ def message_route(self, cr, uid, message, message_dict, model=None, thread_id=No
905906
return [route]
906907

907908
# 2. message is a reply to an existign thread (6.1 compatibility)
908-
ref_match = thread_references and tools.reference_re.search(thread_references)
909909
if ref_match:
910910
reply_thread_id = int(ref_match.group(1))
911911
reply_model = ref_match.group(2) or fallback_model
@@ -945,8 +945,9 @@ def message_route(self, cr, uid, message, message_dict, model=None, thread_id=No
945945
(mail_message.model, mail_message.res_id, custom_values, uid, None),
946946
update_author=True, assert_model=True, create_fallback=True, allow_private=True, context=context)
947947
if route:
948-
_logger.info('Routing mail from %s to %s with Message-Id %s: direct reply to a private message: %s, custom_values: %s, uid: %s',
949-
email_from, email_to, message_id, mail_message.id, custom_values, uid)
948+
_logger.info(
949+
'Routing mail from %s to %s with Message-Id %s: direct reply to a private message: %s, custom_values: %s, uid: %s',
950+
email_from, email_to, message_id, mail_message.id, custom_values, uid)
950951
return [route]
951952

952953
# 3. Look for a matching mail.alias entry
@@ -975,11 +976,12 @@ def message_route(self, cr, uid, message, message_dict, model=None, thread_id=No
975976
user_id = uid
976977
_logger.info('No matching user_id for the alias %s', alias.alias_name)
977978
route = (alias.alias_model_id.model, alias.alias_force_thread_id, eval(alias.alias_defaults), user_id, alias)
978-
_logger.info('Routing mail from %s to %s with Message-Id %s: direct alias match: %r',
979-
email_from, email_to, message_id, route)
980979
route = self.message_route_verify(cr, uid, message, message_dict, route,
981980
update_author=True, assert_model=True, create_fallback=True, context=context)
982981
if route:
982+
_logger.info(
983+
'Routing mail from %s to %s with Message-Id %s: direct alias match: %r',
984+
email_from, email_to, message_id, route)
983985
routes.append(route)
984986
return routes
985987

@@ -993,15 +995,16 @@ def message_route(self, cr, uid, message, message_dict, model=None, thread_id=No
993995
thread_id = int(thread_id)
994996
except:
995997
thread_id = False
996-
_logger.info('Routing mail from %s to %s with Message-Id %s: fallback to model:%s, thread_id:%s, custom_values:%s, uid:%s',
997-
email_from, email_to, message_id, fallback_model, thread_id, custom_values, uid)
998998
route = self.message_route_verify(cr, uid, message, message_dict,
999999
(fallback_model, thread_id, custom_values, uid, None),
10001000
update_author=True, assert_model=True, context=context)
10011001
if route:
1002+
_logger.info(
1003+
'Routing mail from %s to %s with Message-Id %s: fallback to model:%s, thread_id:%s, custom_values:%s, uid:%s',
1004+
email_from, email_to, message_id, fallback_model, thread_id, custom_values, uid)
10021005
return [route]
10031006

1004-
# AssertionError if no routes found and if no bounce occured
1007+
# ValueError if no routes found and if no bounce occured
10051008
raise ValueError(
10061009
'No possible route found for incoming message from %s to %s (Message-Id %s:). '
10071010
'Create an appropriate mail.alias or force the destination model.' %
@@ -1171,7 +1174,14 @@ def _message_extract_payload(self, message, save_original=False):
11711174
body = u''
11721175
if save_original:
11731176
attachments.append(('original_email.eml', message.as_string()))
1174-
if not message.is_multipart() or 'text/' in message.get('content-type', ''):
1177+
1178+
# Be careful, content-type may contain tricky content like in the
1179+
# following example so test the MIME type with startswith()
1180+
#
1181+
# Content-Type: multipart/related;
1182+
# boundary="_004_3f1e4da175f349248b8d43cdeb9866f1AMSPR06MB343eurprd06pro_";
1183+
# type="text/html"
1184+
if not message.is_multipart() or message.get('content-type', '').startswith("text/"):
11751185
encoding = message.get_content_charset()
11761186
body = message.get_payload(decode=True)
11771187
body = tools.ustr(body, encoding, errors='replace')

addons/mass_mailing/wizard/mail_compose_message.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,15 @@ def get_mail_values(self, cr, uid, wizard, res_ids, context=None):
4343
}, context=context)
4444
mass_mailing = self.pool['mail.mass_mailing'].browse(cr, uid, mass_mailing_id, context=context)
4545
for res_id in res_ids:
46-
res[res_id]['mailing_id'] = mass_mailing.id
47-
res[res_id]['statistics_ids'] = [(0, 0, {
48-
'model': wizard.model,
49-
'res_id': res_id,
50-
'mass_mailing_id': mass_mailing.id,
51-
})]
46+
res[res_id].update({
47+
'mailing_id': mass_mailing.id,
48+
'statistics_ids': [(0, 0, {
49+
'model': wizard.model,
50+
'res_id': res_id,
51+
'mass_mailing_id': mass_mailing.id,
52+
})],
53+
# email-mode: keep original message for routing
54+
'notification': mass_mailing.reply_to_mode == 'thread',
55+
'auto_delete': True,
56+
})
5257
return res

addons/purchase/purchase.py

+5
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,8 @@ def action_cancel(self, cr, uid, ids, context=None):
661661
_('You must first cancel all invoices related to this purchase order.'))
662662
self.pool.get('account.invoice') \
663663
.signal_invoice_cancel(cr, uid, map(attrgetter('id'), purchase.invoice_ids))
664+
self.pool['purchase.order.line'].write(cr, uid, [l.id for l in purchase.order_line],
665+
{'state': 'cancel'})
664666
self.write(cr, uid, ids, {'state': 'cancel'})
665667
self.set_order_line_status(cr, uid, ids, 'cancel', context=context)
666668
self.signal_purchase_cancel(cr, uid, ids)
@@ -982,6 +984,9 @@ def copy_data(self, cr, uid, id, default=None, context=None):
982984
return super(purchase_order_line, self).copy_data(cr, uid, id, default, context)
983985

984986
def unlink(self, cr, uid, ids, context=None):
987+
for line in self.browse(cr, uid, ids, context=context):
988+
if line.state not in ['draft', 'cancel']:
989+
raise osv.except_osv(_('Invalid Action!'), _('Cannot delete a purchase order line which is in state \'%s\'.') %(line.state,))
985990
procurement_obj = self.pool.get('procurement.order')
986991
procurement_ids_to_cancel = procurement_obj.search(cr, uid, [('purchase_line_id', 'in', ids)], context=context)
987992
if procurement_ids_to_cancel:

addons/sale/sale.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -538,14 +538,18 @@ def action_invoice_create(self, cr, uid, ids, grouped=False, states=None, date_i
538538
if grouped:
539539
res = self._make_invoice(cr, uid, val[0][0], reduce(lambda x, y: x + y, [l for o, l in val], []), context=context)
540540
invoice_ref = ''
541+
origin_ref = ''
541542
for o, l in val:
542-
invoice_ref += o.name + '|'
543+
invoice_ref += (o.client_order_ref or o.name) + '|'
544+
origin_ref += (o.origin or o.name) + '|'
543545
self.write(cr, uid, [o.id], {'state': 'progress'})
544546
cr.execute('insert into sale_order_invoice_rel (order_id,invoice_id) values (%s,%s)', (o.id, res))
545547
#remove last '|' in invoice_ref
546-
if len(invoice_ref) >= 1:
548+
if len(invoice_ref) >= 1:
547549
invoice_ref = invoice_ref[:-1]
548-
invoice.write(cr, uid, [res], {'origin': invoice_ref, 'name': invoice_ref})
550+
if len(origin_ref) >= 1:
551+
origin_ref = origin_ref[:-1]
552+
invoice.write(cr, uid, [res], {'origin': origin_ref, 'name': invoice_ref})
549553
else:
550554
for order, il in val:
551555
res = self._make_invoice(cr, uid, order, il, context=context)

addons/stock/stock.py

+3
Original file line numberDiff line numberDiff line change
@@ -2276,6 +2276,9 @@ def action_done(self, cr, uid, ids, context=None):
22762276

22772277
#Check moves that were pushed
22782278
if move.move_dest_id.state in ('waiting', 'confirmed'):
2279+
# FIXME is opw 607970 still present with new WMS?
2280+
# (see commits 1ef2c181033bd200906fb1e5ce35e234bf566ac6
2281+
# and 41c5ceb8ebb95c1b4e98d8dd1f12b8e547a24b1d)
22792282
other_upstream_move_ids = self.search(cr, uid, [('id', '!=', move.id), ('state', 'not in', ['done', 'cancel']),
22802283
('move_dest_id', '=', move.move_dest_id.id)], context=context)
22812284
#If no other moves for the move that got pushed:

addons/web_kanban/static/src/js/kanban.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -779,9 +779,9 @@ instance.web_kanban.KanbanGroup = instance.web.Widget.extend({
779779
});
780780
var am = instance.webclient.action_manager;
781781
var form = am.dialog_widget.views.form.controller;
782-
form.on("on_button_cancel", am.dialog, am.dialog.close);
782+
form.on("on_button_cancel", am.dialog, function() { return am.dialog.$dialog_box.modal('hide'); });
783783
form.on('record_saved', self, function() {
784-
am.dialog.close();
784+
am.dialog.$dialog_box.modal('hide');
785785
self.view.do_reload();
786786
});
787787
},

openerp/addons/base/security/ir.model.access.csv

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
"access_multi_company_default manager","multi_company_default Manager","model_multi_company_default","group_erp_manager",1,1,1,1
109109
"access_ir_filter all","ir_filters all","model_ir_filters",,1,1,1,1
110110
"access_ir_config_parameter","ir_config_parameter","model_ir_config_parameter",,1,0,0,0
111+
"access_ir_config_parameter_system","ir_config_parameter_system","model_ir_config_parameter","group_system",1,1,1,1
111112
"access_ir_mail_server","ir_mail_server","model_ir_mail_server","group_system",1,1,1,1
112113
"access_ir_actions_client","ir_actions_client all","model_ir_actions_client",,1,0,0,0
113114
"access_ir_needaction_mixin","ir_needaction_mixin","model_ir_needaction_mixin",,1,1,1,1

openerp/osv/orm.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2449,7 +2449,7 @@ def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, con
24492449
fetched_data = cr.dictfetchall()
24502450

24512451
if not groupby_fields:
2452-
return {r.pop('id'): r for r in fetched_data}
2452+
return fetched_data
24532453

24542454
many2onefields = [gb['field'] for gb in annotated_groupbys if gb['type'] == 'many2one']
24552455
if many2onefields:

0 commit comments

Comments
 (0)