[MERGE] sale,account,project,issue: Notifications review for portal users

This commit is contained in:
Yannick Tivisse
2016-08-30 10:20:47 +02:00
18 changed files with 136 additions and 37 deletions
@@ -19,6 +19,7 @@
% set access_action = object.get_access_action()
% set access_name = 'View invoice' if access_action and access_action['type'] == 'ir.actions.act_url' else 'See invoice'
% set access_url = access_action['type'] == 'ir.actions.act_url' and access_action['url'] or '/report/pdf/account.report_invoice/' + str(object.id)
% set is_online = access_action and access_action['type'] == 'ir.actions.act_url'
<p>Dear
% if object.partner_id.is_company and object.child_ids:
@@ -35,9 +36,12 @@ amounting in <strong>${object.amount_total} ${object.currency_id.name}</strong>
from ${object.company_id.name}.
</p>
% if is_inline:
<p style="margin-left: 30px;">
<a href="${access_url}" style="padding: 5px 10px; font-size: 12px; line-height: 18px; color: #FFFFFF; border-color:#a24689; text-decoration: none; display: inline-block; margin-bottom: 0px; font-weight: 400; text-align: center; vertical-align: middle; cursor: pointer; white-space: nowrap; background-image: none; background-color: #a24689; border: 1px solid #a24689; border-radius:3px" class="o_default_snippet_text">${access_name}</a>
</p>
% endif
<p>If you have any question, do not hesitate to contact us.</p>
<p>Best regards,</p>
]]></field>
+2
View File
@@ -1069,6 +1069,8 @@ class AccountInvoice(models.Model):
continue
if not recipient.user_ids:
group_data['partner'] |= recipient
elif all(recipient.user_ids.mapped('share')):
group_data['partner'] |= recipient
else:
group_data['user'] |= recipient
done_ids.add(recipient.id)
-1
View File
@@ -28,7 +28,6 @@ by default, you simply need to configure a Paypal account in the Accounting/Invo
'depends': ['sale', 'portal', 'payment'],
'data': [
'security/portal_sale_security.xml',
'security/ir.model.access.csv',
'views/sale_order_views.xml',
],
'auto_install': True,
@@ -22,12 +22,3 @@ class AccountInvoice(models.Model):
action='/mail/view',
model=self._name,
res_id=self.id)[self.partner_id.id]
@api.multi
def get_formview_action(self):
# NOTE : if this method is call as sudo, the only to determine if the user is portal is to check the uid from context
# This was introduced with https://github.com/odoo/odoo/commit/f5fedbcb18a57ee9aeab952f3ff95f692f7a863c, and should be better fixed.
uid = self.env.context.get('uid', self.env.user.id)
if self.env['res.users'].sudo().browse(uid).share:
return self.env['ir.actions.act_window'].for_xml_id('portal_sale', 'portal_action_invoices')
return super(AccountInvoice, self).get_formview_action()
-10
View File
@@ -22,13 +22,3 @@ class SaleOrder(models.Model):
action='/mail/view',
model=self._name,
res_id=self.id)[self.partner_id.id]
@api.multi
def get_formview_action(self):
# NOTE : if this method is call as sudo, the only to determine if the user is portal is to check the uid from context
# This was introduced with https://github.com/odoo/odoo/commit/f5fedbcb18a57ee9aeab952f3ff95f692f7a863c, and should be better fixed.
uid = self.env.context.get('uid', self.env.user.id)
if self.env['res.users'].sudo().browse(uid).share:
action_xmlid = 'action_quotations_portal' if self.state in ('draft', 'sent') else 'action_orders_portal'
return self.env['ir.actions.act_window'].for_xml_id('portal_sale', action_xmlid)
return super(SaleOrder, self).get_formview_action()
@@ -259,6 +259,8 @@ class ProjectIssue(models.Model):
group_data['group_project_user'] |= recipient
elif not recipient.user_ids:
group_data['partner'] |= recipient
elif all(recipient.user_ids.mapped('share')):
group_data['partner'] |= recipient
else:
group_data['user'] |= recipient
done_ids.add(recipient.id)
+2
View File
@@ -36,9 +36,11 @@ amounting in <strong>${object.amount_total} ${object.pricelist_id.currency_id.na
from ${object.company_id.name}.
</p>
% if is_online:
<p style="margin-left: 30px; margin-top: 10 px; margin-bottom: 10px;">
<a href="${access_url}" style="padding: 5px 10px; font-size: 12px; line-height: 18px; color: #FFFFFF; border-color:#a24689; text-decoration: none; display: inline-block; margin-bottom: 0px; font-weight: 400; text-align: center; vertical-align: middle; cursor: pointer; white-space: nowrap; background-image: none; background-color: #a24689; border: 1px solid #a24689; border-radius:3px" class="o_default_snippet_text">${access_name}</a>
</p>
% endif
<p>If you have any question, do not hesitate to contact us.</p>
<p>Best regards,</p>
]]></field>
+2 -1
View File
@@ -487,12 +487,13 @@ class SaleOrder(models.Model):
@api.multi
def _notification_group_recipients(self, message, recipients, done_ids, group_data):
group_user = self.env.ref('base.group_user')
for recipient in recipients:
if recipient.id in done_ids:
continue
if not recipient.user_ids:
group_data['partner'] |= recipient
elif all(recipient.user_ids.mapped('share')):
group_data['partner'] |= recipient
else:
group_data['user'] |= recipient
done_ids.add(recipient.id)
@@ -13,6 +13,7 @@ Add your sales document in the frontend portal. Your customers will be able to c
],
'data': [
'views/templates.xml',
'security/ir.model.access.csv',
],
'demo': [
'data/demo.xml'
@@ -381,19 +381,4 @@
</t>
</template>
<template id="sale_backend_link" inherit_id='website_portal_sale.portal_my_orders' customize_show="True" name="Link to Sales Backend" active="False">
<xpath expr="//h3[@class='page-header']" position="inside">
<a href="/web#action=portal_sale.action_orders_portal" target="_blank" class="btn btn-default btn-xs pull-right"> Access the complete Sale application</a>
</xpath>
</template>
<template id="sales_backend_access" inherit_id='website_portal_sale.orders_followup' customize_show="True" name="Backend Access" active="False">
<xpath expr="//div[@id='optional_placeholder']" position="inside">
<h4 class="text-muted text-center mt64 mb64">
If you wish to access the complete application to manage your orders, you can follow
<a href="/web#action=portal_sale.action_orders_portal">this link</a>.
</h4>
</xpath>
</template>
</odoo>
+1
View File
@@ -2,3 +2,4 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import controllers
import models
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import project
+58
View File
@@ -0,0 +1,58 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models
class Project(models.Model):
_inherit = ['project.project']
@api.multi
def get_access_action(self):
""" Override method that generated the link to access the document. Instead
of the classic form view, redirect to the post on the website directly """
self.ensure_one()
return {
'type': 'ir.actions.act_url',
'url': '/my/project/%s' % self.id,
'target': 'self',
'res_id': self.id,
}
@api.multi
def _notification_group_recipients(self, message, recipients, done_ids, group_data):
""" Override the method to place the portal customers in the 'user' group data as a portal view now exists"""
for recipient in recipients:
if recipient.id in done_ids:
continue
if recipient.user_ids and all(recipient.user_ids.mapped('share')):
group_data['user'] |= recipient
done_ids.add(recipient.id)
return super(Project, self)._notification_group_recipients(message, recipients, done_ids, group_data)
class Task(models.Model):
_inherit = ['project.task']
@api.multi
def get_access_action(self):
""" Override method that generated the link to access the document. Instead
of the classic form view, redirect to the post on the website directly """
self.ensure_one()
return {
'type': 'ir.actions.act_url',
'url': '/my/task/%s' % self.id,
'target': 'self',
'res_id': self.id,
}
@api.multi
def _notification_group_recipients(self, message, recipients, done_ids, group_data):
""" Override the method to place the portal customers in the 'user' group data as a portal view now exists"""
for recipient in recipients:
if recipient.id in done_ids:
continue
if recipient.user_ids and all(recipient.user_ids.mapped('share')):
group_data['user'] |= recipient
done_ids.add(recipient.id)
return super(Task, self)._notification_group_recipients(message, recipients, done_ids, group_data)
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from openerp import _, api, models
from openerp import api, models
class Issue(models.Model):
@@ -19,3 +19,19 @@ class Issue(models.Model):
'target': 'self',
'res_id': self.id,
}
@api.multi
def _notification_group_recipients(self, message, recipients, done_ids, group_data):
""" Override the mail.thread method to handle project users and officers
recipients. Indeed those will have specific action in their notification
emails: creating tasks, assigning it. """
group_project_user_id = self.env.ref('project.group_project_user').id
for recipient in recipients:
if recipient.id in done_ids:
continue
if recipient.user_ids and group_project_user_id in recipient.user_ids[0].groups_id.ids:
group_data['group_project_user'] |= recipient
elif recipient.user_ids and all(recipient.user_ids.mapped('share')):
group_data['user'] |= recipient
done_ids.add(recipient.id)
return super(Issue, self)._notification_group_recipients(message, recipients, done_ids, group_data)
+1
View File
@@ -1,3 +1,4 @@
import account_invoice
import ir_http
import rating
import product
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models
class AccountInvoice(models.Model):
_inherit = 'account.invoice'
@api.multi
def _notification_group_recipients(self, message, recipients, done_ids, group_data):
""" Override the method to place the portal customers in the 'user' group data as a portal view now exists"""
for recipient in recipients:
if recipient.id in done_ids:
continue
if recipient.user_ids and all(recipient.user_ids.mapped('share')):
group_data['user'] |= recipient
done_ids.add(recipient.id)
return super(AccountInvoice, self)._notification_group_recipients(message, recipients, done_ids, group_data)
@api.multi
def get_access_action(self):
""" Override method that generated the link to access the document. Instead
of the classic form view, redirect to the online invoice if exists. """
self.ensure_one()
return {
'type': 'ir.actions.act_url',
'url': '/my/invoices', # No controller /my/invoices/<int>, only a report pdf
'target': 'self',
'res_id': self.id,
}
+11
View File
@@ -123,6 +123,17 @@ class SaleOrder(models.Model):
accessory_products -= order.website_order_line.mapped('product_id')
return random.sample(accessory_products, min(len(accessory_products), 3))
@api.multi
def _notification_group_recipients(self, message, recipients, done_ids, group_data):
""" Override the method to place the portal customers in the 'user' group data as a portal view now exists"""
for recipient in recipients:
if recipient.id in done_ids:
continue
if recipient.user_ids and all(recipient.user_ids.mapped('share')):
group_data['user'] |= recipient
done_ids.add(recipient.id)
return super(SaleOrder, self)._notification_group_recipients(message, recipients, done_ids, group_data)
class Website(models.Model):
_inherit = 'website'