Skip to content

Commit

Permalink
[MERGE] forward port of branch saas-4 up to a4bc65c
Browse files Browse the repository at this point in the history
  • Loading branch information
KangOl committed Jun 27, 2014
2 parents 368936d + a4bc65c commit 8dfd5ea
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 42 deletions.
10 changes: 5 additions & 5 deletions addons/base_action_rule/base_action_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ def _wrap_create(self, old_create, model):
""" Return a wrapper around `old_create` calling both `old_create` and
`_process`, in that order.
"""
def create(cr, uid, vals, context=None):
def create(cr, uid, vals, context=None, **kwargs):
# avoid loops or cascading actions
if context and context.get('action'):
return old_create(cr, uid, vals, context=context)

context = dict(context or {}, action=True)
new_id = old_create(cr, uid, vals, context=context)
new_id = old_create(cr, uid, vals, context=context, **kwargs)

# retrieve the action rules to run on creation
action_dom = [('model', '=', model), ('kind', 'in', ['on_create', 'on_create_or_write'])]
Expand All @@ -180,10 +180,10 @@ def _wrap_write(self, old_write, model):
""" Return a wrapper around `old_write` calling both `old_write` and
`_process`, in that order.
"""
def write(cr, uid, ids, vals, context=None):
def write(cr, uid, ids, vals, context=None, **kwargs):
# avoid loops or cascading actions
if context and context.get('action'):
return old_write(cr, uid, ids, vals, context=context)
return old_write(cr, uid, ids, vals, context=context, **kwargs)

context = dict(context or {}, action=True)
ids = [ids] if isinstance(ids, (int, long, str)) else ids
Expand All @@ -199,7 +199,7 @@ def write(cr, uid, ids, vals, context=None):
pre_ids[action] = self._filter(cr, uid, action, action.filter_pre_id, ids, context=context)

# execute write
old_write(cr, uid, ids, vals, context=context)
old_write(cr, uid, ids, vals, context=context, **kwargs)

# check postconditions, and execute actions on the records that satisfy them
for action in actions:
Expand Down
2 changes: 1 addition & 1 deletion addons/hr_recruitment/hr_recruitment_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
<record id="mt_job_applicant_new" model="mail.message.subtype">
<field name="name">Applicant Created</field>
<field name="res_model">hr.job</field>
<field name="default" eval="False"/>
<field name="default" eval="True"/>
<field name="parent_id" eval="ref('mt_applicant_new')"/>
<field name="relation_field">job_id</field>
</record>
Expand Down
16 changes: 6 additions & 10 deletions addons/hr_timesheet_sheet/static/src/js/timesheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ openerp.hr_timesheet_sheet = function(instance) {
events: {
"click .oe_timesheet_weekly_account a": "go_to",
},
ignore_fields: function() {
return ['line_id'];
},
init: function() {
this._super.apply(this, arguments);
var self = this;
Expand Down Expand Up @@ -323,11 +326,8 @@ openerp.hr_timesheet_sheet = function(instance) {
generate_o2m_value: function() {
var self = this;
var ops = [];

var ignored_fields = self.ignore_fields();
_.each(self.accounts, function(account) {
var auth_keys = _.extend(_.clone(account.account_defaults), {
name: true, amount:true, unit_amount: true, date: true, account_id:true,
});
_.each(account.days, function(day) {
_.each(day.lines, function(line) {
if (line.unit_amount !== 0) {
Expand All @@ -338,12 +338,8 @@ openerp.hr_timesheet_sheet = function(instance) {
tmp[k] = v[0];
}
});
// we have to remove some keys, because analytic lines are shitty
_.each(_.keys(tmp), function(key) {
if (auth_keys[key] === undefined) {
tmp[key] = undefined;
}
});
// we remove line_id as the reference to the _inherits field will no longer exists
tmp = _.omit(tmp, ignored_fields);
ops.push(tmp);
}
});
Expand Down
2 changes: 1 addition & 1 deletion addons/l10n_be_coda/l10n_be_coda.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def write(self, cr, uid, ids, vals, context=None):
"""
Same as create function above, but for write function
"""
if 'partner_id' in vals:
if vals.get('partner_id'):
for line in self.pool.get('account.bank.statement.line').browse(cr, uid, ids, context=context):
if line.coda_account_number:
acc_number_ids = self.pool.get('res.partner.bank').search(cr, uid, [('acc_number', '=', line.coda_account_number)])
Expand Down
1 change: 1 addition & 0 deletions addons/l10n_fr_hr_payroll/report/fiche_paye.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class fiche_paye_parser(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(fiche_paye_parser, self).__init__(cr, uid, name, context)
self.localcontext.update({
'lang': "fr_FR",
'get_payslip_lines': self.get_payslip_lines,
'get_total_by_rule_category': self.get_total_by_rule_category,
'get_employer_line': self.get_employer_line,
Expand Down
4 changes: 2 additions & 2 deletions addons/mail/mail_message_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@
<div class="oe_kanban_global_click">
<div t-attf-class="oe_attachment" t-if="record.file_type_icon.value != 'webimage'">
<img t-att-src="'/mail/static/src/img/mimetypes/' + record.file_type_icon.value + '.png'"></img>
<div class='oe_name'><t t-raw='record.name.value' />bb</div>
<div class='oe_name'><t t-raw='record.name.value' /></div>
</div>
<div t-attf-class="oe_attachment oe_preview" t-if="record.file_type_icon.value == 'webimage'">
<img t-att-src="kanban_image('ir.attachment', 'datas', record.id.value)" class="oe_kanban_image"/>
<div class='oe_name'><t t-raw='record.name.value' />aa</div>
<div class='oe_name'><t t-raw='record.name.value' /></div>
</div>
</div>
</t>
Expand Down
1 change: 1 addition & 0 deletions addons/web/static/src/js/view_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -1605,6 +1605,7 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we
.filter(function (column) { return column.tag === 'field';})
.pluck('name').value(),
function (groups) {
self.view.$pager.hide();
$el[0].appendChild(
self.render_groups(groups));
if (post_render) { post_render(); }
Expand Down
1 change: 0 additions & 1 deletion addons/web/static/src/js/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,6 @@ instance.web.ViewManager = instance.web.Widget.extend({
var view_promise;
var form = this.views['form'];
if (!view || (form && form.controller && !form.controller.can_be_discarded())) {
self.trigger('switch_mode', view_type, no_store, view_options);
return $.Deferred().reject();
}
if (!no_store) {
Expand Down
8 changes: 6 additions & 2 deletions addons/web_calendar/static/src/js/web_calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -663,13 +663,17 @@ openerp.web_calendar = function(instance) {
date_start_day = new Date(event.start.getFullYear(),event.start.getMonth(),event.start.getDate(),7);
date_stop_day = new Date(event_end.getFullYear(),event_end.getMonth(),event_end.getDate(),19);
}
data[this.date_start] = instance.web.parse_value(date_start_day, this.fields[this.date_start]);
if (this.date_stop) {
data[this.date_stop] = instance.web.parse_value(date_stop_day, this.fields[this.date_stop]);
}
diff_seconds = Math.round((date_stop_day.getTime() - date_start_day.getTime()) / 1000);

}
else {
data[this.date_start] = event.start;
data[this.date_start] = instance.web.parse_value(event.start, this.fields[this.date_start]);
if (this.date_stop) {
data[this.date_stop] = event_end;
data[this.date_stop] = instance.web.parse_value(event_end, this.fields[this.date_stop]);
}
diff_seconds = Math.round((event_end.getTime() - event.start.getTime()) / 1000);
}
Expand Down
5 changes: 5 additions & 0 deletions addons/website/models/ir_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ def _handle_exception(self, exception, code=500):
if isinstance(exception.qweb.get('cause'), openerp.exceptions.AccessError):
code = 403

if isinstance(exception, werkzeug.exceptions.HTTPException) and code is None:
# Hand-crafted HTTPException likely coming from abort(),
# usually for a redirect response -> return it directly
return exception

if code == 500:
logger.error("500 Internal Server Error:\n\n%s", values['traceback'])
if 'qweb_exception' in values:
Expand Down
4 changes: 2 additions & 2 deletions addons/website/views/website_templates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@
<t t-foreach="website.menu_id.child_id" t-as="submenu">
<t t-call="website.submenu"/>
</t>
<li class="divider" groups="base.group_user,base.group_portal" t-ignore="true"/>
<li class="dropdown" t-ignore="true" groups="base.group_user,base.group_portal">
<li class="divider" t-ignore="true" t-if="website.user_id != user_id"/>
<li class="dropdown" t-ignore="true" t-if="website.user_id != user_id">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<b>
<span t-esc="user_id.name"/>
Expand Down
2 changes: 1 addition & 1 deletion openerp/modules/loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def _load_data(cr, module_name, idref, mode, kind):
# Set new modules and dependencies
modobj.write(cr, SUPERUSER_ID, [module_id], {'state': 'installed', 'latest_version': ver})
# Update translations for all installed languages
modobj.update_translations(cr, SUPERUSER_ID, [module_id], None)
modobj.update_translations(cr, SUPERUSER_ID, [module_id], None, {'overwrite': openerp.tools.config["overwrite_existing_translations"]})

package.state = 'installed'
for kind in ('init', 'demo', 'update'):
Expand Down
6 changes: 4 additions & 2 deletions openerp/report/report_sxw.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,10 @@ def setLang(self, lang):
def _get_lang_dict(self):
pool_lang = self.pool['res.lang']
lang = self.localcontext.get('lang', 'en_US') or 'en_US'
lang_ids = pool_lang.search(self.cr,self.uid,[('code','=',lang)])[0]
lang_obj = pool_lang.browse(self.cr,self.uid,lang_ids)
lang_ids = pool_lang.search(self.cr,self.uid,[('code','=',lang)])
if not lang_ids:
lang_ids = pool_lang.search(self.cr,self.uid,[('code','=','en_US')])
lang_obj = pool_lang.browse(self.cr,self.uid,lang_ids[0])
self.lang_dict.update({'lang_obj':lang_obj,'date_format':lang_obj.date_format,'time_format':lang_obj.time_format})
self.default_lang[lang] = self.lang_dict.copy()
return True
Expand Down
36 changes: 21 additions & 15 deletions openerp/service/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,24 @@ def exp_get_progress(id):
exc, tb = a['exception'], a['traceback']
raise Exception, exc, tb


def _drop_conn(cr, db_name):
# Try to terminate all other connections that might prevent
# dropping the database
try:
# PostgreSQL 9.2 renamed pg_stat_activity.procpid to pid:
# http://www.postgresql.org/docs/9.2/static/release-9-2.html#AEN110389
pid_col = 'pid' if cr._cnx.server_version >= 90200 else 'procpid'

cr.execute("""SELECT pg_terminate_backend(%(pid_col)s)
FROM pg_stat_activity
WHERE datname = %%s AND
%(pid_col)s != pg_backend_pid()""" % {'pid_col': pid_col},
(db_name,))
except Exception:
pass


def exp_drop(db_name):
if db_name not in exp_list(True):
return False
Expand All @@ -160,21 +178,8 @@ def exp_drop(db_name):

db = openerp.sql_db.db_connect('postgres')
with closing(db.cursor()) as cr:
cr.autocommit(True) # avoid transaction block
# Try to terminate all other connections that might prevent
# dropping the database
try:
# PostgreSQL 9.2 renamed pg_stat_activity.procpid to pid:
# http://www.postgresql.org/docs/9.2/static/release-9-2.html#AEN110389
pid_col = 'pid' if cr._cnx.server_version >= 90200 else 'procpid'

cr.execute("""SELECT pg_terminate_backend(%(pid_col)s)
FROM pg_stat_activity
WHERE datname = %%s AND
%(pid_col)s != pg_backend_pid()""" % {'pid_col': pid_col},
(db_name,))
except Exception:
pass
cr.autocommit(True) # avoid transaction block
_drop_conn(cr, db_name)

try:
cr.execute('DROP DATABASE "%s"' % db_name)
Expand Down Expand Up @@ -331,6 +336,7 @@ def exp_rename(old_name, new_name):
db = openerp.sql_db.db_connect('postgres')
with closing(db.cursor()) as cr:
cr.autocommit(True) # avoid transaction block
_drop_conn(cr, old_name)
try:
cr.execute('ALTER DATABASE "%s" RENAME TO "%s"' % (old_name, new_name))
_logger.info('RENAME DB: %s -> %s', old_name, new_name)
Expand Down

0 comments on commit 8dfd5ea

Please sign in to comment.