Merge branch 'master-akshar-05072018' into 'master-patch-july-2018'

Master akshar 05072018

See merge request flectra-hq/flectra!110
This commit is contained in:
Parthiv Patel 2018-07-19 13:23:06 +00:00
commit c5dd18a0f4
6 changed files with 27 additions and 14 deletions

View File

@ -545,7 +545,8 @@ class Lead(models.Model):
for field in fields:
value = getattr(self, field.name, False)
if field.ttype == 'selection':
value = dict(field.get_values(self.env)).get(value, value)
selections = self.fields_get()[field.name]['selection']
value = next((v[1] for v in selections if v[0] == value), value)
elif field.ttype == 'many2one':
if value:
value = value.sudo().name_get()[0][1]

View File

@ -131,7 +131,6 @@ class MailMail(models.Model):
messages to send (by default all 'outgoing'
messages are sent).
"""
if not self.ids:
filters = ['&',
('state', '=', 'outgoing'),
'|',
@ -140,7 +139,11 @@ class MailMail(models.Model):
if 'filters' in self._context:
filters.extend(self._context['filters'])
# TODO: make limit configurable
ids = self.search(filters, limit=10000).ids
filtered_ids = self.search(filters, limit=10000).ids
if not ids:
ids = filtered_ids
else:
ids = list(set(filtered_ids) & set(ids))
res = None
try:
# auto-commit except in testing mode

View File

@ -1743,6 +1743,8 @@ class MailThread(models.AbstractModel):
continue
if isinstance(content, pycompat.text_type):
content = content.encode('utf-8')
elif content is None:
continue
data_attach = {
'name': name,
'datas': base64.b64encode(content),
@ -1768,7 +1770,7 @@ class MailThread(models.AbstractModel):
if not attachment:
attachment = fname_mapping.get(node.get('data-filename'), '')
if attachment:
node.set('src', '/web/image/%s' % attachment.id)
node.set('src', '/web/image/%s?access_token=%s' % (attachment.id, attachment.access_token))
postprocessed = True
if postprocessed:
body = lxml.html.tostring(root, pretty_print=False, encoding='UTF-8')

View File

@ -20,7 +20,7 @@
invisible="not context.get('mail_invite_follower_channel_only')"
options="{'no_create': True}"/>
<field name="send_mail" invisible="context.get('mail_invite_follower_channel_only')"/>
<field name="message" attrs="{'invisible': [('send_mail','!=',True)]}" options="{'style-inline': true}" class="test_message"/>
<field name="message" attrs="{'invisible': [('send_mail','!=',True)]}" options="{'style-inline': true, 'no-attachment': true}" class="test_message"/>
</group>
<footer>
<button string="Add Followers"

View File

@ -37,7 +37,9 @@ class WebsiteSaleDelivery(WebsiteSale):
def _get_shop_payment_values(self, order, **kwargs):
values = super(WebsiteSaleDelivery, self)._get_shop_payment_values(order, **kwargs)
if not order._get_delivery_methods():
has_stockable_products = any(line.product_id.type in ['consu', 'product'] for line in order.order_line)
if not order._get_delivery_methods() and has_stockable_products:
values['errors'].append(
(_('Sorry, we are unable to ship your order'),
_('No shipping method is available for your current order and shipping address. '
@ -54,6 +56,7 @@ class WebsiteSaleDelivery(WebsiteSale):
delivery_carriers = order._get_delivery_methods()
values['deliveries'] = delivery_carriers.sudo()
values['delivery_has_stockable'] = has_stockable_products
values['delivery_action_id'] = request.env.ref('delivery.action_delivery_carrier_form').id
return values

View File

@ -57,6 +57,10 @@
</a>
</div>
</xpath>
<!-- we shouldn't be able to pay if there is no way to deliver -->
<xpath expr="//div[@id='payment_method']" position="attributes">
<attribute name="t-att-style">'display: none!important' if not deliveries and delivery_has_stockable else ''</attribute>
</xpath>
</template>
<template id="portal_order_page_shipping_tracking" name="Shipping tracking on orders followup" inherit_id="website_sale_stock.portal_order_page_shipping">