Skip to content

Commit

Permalink
Merge remote-tracking branch 'odoo/11.0' into 11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
OCA-git-bot committed Oct 7, 2019
2 parents 5ca7bc6 + 09bbc03 commit d7623dd
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 18 deletions.
6 changes: 6 additions & 0 deletions addons/hr_attendance/i18n/hr_attendance.pot
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,12 @@ msgstr ""
msgid "Settings"
msgstr ""

#. module: hr_attendance
#: code:addons/hr_attendance/models/hr_employee.py:155
#, python-format
msgid "Such grouping is not allowed."
msgstr ""

#. module: hr_attendance
#: sql_constraint:hr.employee:0
msgid "The Badge ID must be unique, this one is already assigned to another employee."
Expand Down
6 changes: 6 additions & 0 deletions addons/hr_attendance/models/hr_employee.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,9 @@ def _init_column(self, column_name):
query = 'UPDATE "%s" SET "%s"=%%s WHERE id = %s' % (
self._table, column_name, employee_id[0])
self.env.cr.execute(query, (default_value,))

@api.model
def read_group(self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True):
if 'pin' in groupby or 'pin' in self.env.context.get('group_by', '') or self.env.context.get('no_group_by'):
raise exceptions.UserError(_('Such grouping is not allowed.'))
return super(HrEmployee, self).read_group(domain, fields, groupby, offset=offset, limit=limit, orderby=orderby, lazy=lazy)
6 changes: 5 additions & 1 deletion addons/hr_attendance/static/src/js/kiosk_mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ var QWeb = core.qweb;

var KioskMode = Widget.extend({
events: {
"click .o_hr_attendance_button_employees": function(){ this.do_action('hr_attendance.hr_employee_attendance_action_kanban'); },
"click .o_hr_attendance_button_employees": function() {
this.do_action('hr_attendance.hr_employee_attendance_action_kanban', {
additional_context: {'no_group_by': true},
});
},
},

start: function () {
Expand Down
15 changes: 9 additions & 6 deletions addons/mail/static/src/js/chatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,7 @@ var Chatter = Widget.extend(chat_mixin, {
this.$topbar = this.$('.o_chatter_topbar');

// render and append the buttons
this.$topbar.append(QWeb.render('mail.Chatter.Buttons', {
new_message_btn: !!this.fields.thread,
log_note_btn: this.hasLogButton,
schedule_activity_btn: !!this.fields.activity,
isMobile: config.device.isMobile,
}));
this.$topbar.append(this._renderButtons());

// start and append the widgets
var fieldDefs = _.invoke(this.fields, 'appendTo', $('<div>'));
Expand Down Expand Up @@ -214,6 +209,14 @@ var Chatter = Widget.extend(chat_mixin, {
}
}).always($spinner.remove.bind($spinner));
},
_renderButtons: function () {
return QWeb.render('mail.Chatter.Buttons', {
new_message_btn: !!this.fields.thread,
log_note_btn: this.hasLogButton,
schedule_activity_btn: !!this.fields.activity,
isMobile: config.device.isMobile,
});
},
_setState: function (record) {
if (!this.record || this.record.res_id !== record.res_id) {
this.context = {
Expand Down
9 changes: 3 additions & 6 deletions addons/membership/models/partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,9 @@ def _compute_membership_stop(self):
'associate_member.membership_state')
def _compute_membership_cancel(self):
for partner in self:
if partner.membership_state == 'canceled':
partner.membership_cancel = self.env['membership.membership_line'].search([
('partner', '=', partner.id)
], limit=1, order='date_cancel').date_cancel
else:
partner.membership_cancel = False
partner.membership_cancel = self.env['membership.membership_line'].search([
('partner', '=', partner.id)
], limit=1, order='date_cancel desc').date_cancel

def _membership_state(self):
"""This Function return Membership State For Given Partner. """
Expand Down
4 changes: 2 additions & 2 deletions addons/sale_timesheet/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from odoo.exceptions import ValidationError
from odoo.osv import expression
from odoo.tools.safe_eval import safe_eval
from odoo.tools import float_is_zero
from odoo.tools import float_is_zero, plaintext2html


class SaleOrder(models.Model):
Expand Down Expand Up @@ -223,7 +223,7 @@ def _timesheet_create_task_prepare_values(self):
'planned_hours': planned_hours,
'remaining_hours': planned_hours,
'partner_id': self.order_id.partner_id.id,
'description': self.name + '<br/>',
'description': plaintext2html(self.name) if self.name else False,
'project_id': project.id,
'sale_line_id': self.id,
'company_id': self.company_id.id,
Expand Down
25 changes: 23 additions & 2 deletions odoo/addons/base/ir/ir_mail_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,10 @@ def build_email(self, email_from, email_to, subject, body, email_cc=None, email_
:rtype: email.message.Message (usually MIMEMultipart)
:return: the new RFC2822 email message
"""
email_from = email_from or tools.config.get('email_from')
email_from = email_from or self._get_default_from_address()
assert email_from, "You must either provide a sender address explicitly or configure "\
"a global sender address in the server configuration or with the "\
"using the combintion of `mail.catchall.domain` and `mail.default.from` "\
"ICPs, in the server configuration file or with the "\
"--email-from startup parameter."

# Note: we must force all strings to to 8-bit utf-8 when crafting message,
Expand Down Expand Up @@ -388,6 +389,26 @@ def _get_default_bounce_address(self):
if postmaster and domain:
return '%s@%s' % (postmaster, domain)

@api.model
def _get_default_from_address(self):
"""Compute the default from address.
Used for the "header from" address when no other has been received.
:return str/None:
Combines config parameters ``mail.default.from`` and
``mail.catchall.domain`` to generate a default sender address.
If some of those parameters is not defined, it will default to the
``--email-from`` CLI/config parameter.
"""
get_param = self.env['ir.config_parameter'].sudo().get_param
domain = get_param('mail.catchall.domain')
email_from = get_param("mail.default.from")
if email_from and domain:
return "%s@%s" % (email_from, domain)
return tools.config.get("email_from")

@api.model
def send_email(self, message, mail_server_id=None, smtp_server=None, smtp_port=None,
smtp_user=None, smtp_password=None, smtp_encryption=None, smtp_debug=False,
Expand Down
27 changes: 26 additions & 1 deletion odoo/addons/base/tests/test_mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

import unittest

from odoo.tools import html_sanitize, append_content_to_html, plaintext2html, email_split, misc
from unittest.mock import patch

from odoo.tools import html_sanitize, append_content_to_html, config, plaintext2html, email_split, misc
from odoo.tests.common import SavepointCase
from . import test_mail_examples


Expand Down Expand Up @@ -328,3 +331,25 @@ def test_email_split(self):
]
for text, expected in cases:
self.assertEqual(email_split(text), expected, 'email_split is broken')


class EmailConfigCase(SavepointCase):
@patch.dict("odoo.tools.config.options", {"email_from": "settings@example.com"})
def test_default_email_from(self, *args):
"""Email from setting is respected."""
# ICP setting is more important
ICP = self.env["ir.config_parameter"].sudo()
ICP.set_param("mail.catchall.domain", "example.org")
ICP.set_param("mail.default.from", "icp")
message = self.env["ir.mail_server"].build_email(
False, "recipient@example.com", "Subject",
"The body of an email",
)
self.assertEqual(message["From"], "icp@example.org")
# Without ICP, the config file/CLI setting is used
ICP.set_param("mail.default.from", False)
message = self.env["ir.mail_server"].build_email(
False, "recipient@example.com", "Subject",
"The body of an email",
)
self.assertEqual(message["From"], "settings@example.com")

0 comments on commit d7623dd

Please sign in to comment.