summaryrefslogtreecommitdiff
path: root/addons/mass_mailing_sale
diff options
context:
space:
mode:
authorHiral Bhavsar <hbh@odoo.com>2019-07-30 09:48:18 +0000
committerThibault Delavallée <tde@odoo.com>2019-08-19 13:23:50 +0000
commitbc6accc5688d3c38a35949751779f808e9c2063f (patch)
tree5c3c6161a050aa7e6f628f7531a6615bead01f86 /addons/mass_mailing_sale
parentbe983c7002cce01085f90f44b7fc8b7608bd9f15 (diff)
[IMP] mass_mailing_sale: remove complex computation of invoices linked to mailing UTM
UTM fields are available in the invoice without sale_crm. That's why just apply search_read on account.move instead of doing --> search on sale order --> map on invoice_ids which is computed --> search_read on account.invoice.report to get sale_invoiced_amount. Currently, stat button 'Invoiced' is not redirecting to invoices tree view because of wrong action and domain parameters. Thus we, set proper action and pass valid parameter to get that invoices tree view. Task 1919391 closes odoo/odoo#35296 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Diffstat (limited to 'addons/mass_mailing_sale')
-rw-r--r--addons/mass_mailing_sale/models/mass_mailing.py22
1 files changed, 8 insertions, 14 deletions
diff --git a/addons/mass_mailing_sale/models/mass_mailing.py b/addons/mass_mailing_sale/models/mass_mailing.py
index 57d58b84990..991b52362b1 100644
--- a/addons/mass_mailing_sale/models/mass_mailing.py
+++ b/addons/mass_mailing_sale/models/mass_mailing.py
@@ -20,16 +20,11 @@ class MassMailing(models.Model):
@api.depends('mailing_domain')
def _compute_sale_invoiced_amount(self):
- has_so_access = self.env['sale.order'].check_access_rights('read', raise_exception=False)
- has_invoice_report_access = self.env['account.invoice.report'].check_access_rights('read', raise_exception=False)
for mass_mailing in self:
- if has_so_access and has_invoice_report_access:
- invoices = self.env['sale.order'].search(self._get_sale_utm_domain()).mapped('invoice_ids')
- res = self.env['account.invoice.report'].search_read(
- [('move_id', 'in', invoices.ids), ('state', 'not in', ['draft', 'cancel'])],
- ['price_subtotal']
- )
- mass_mailing.sale_invoiced_amount = sum(r['price_subtotal'] for r in res)
+ if self.user_has_groups('sales_team.group_sale_salesman') and self.user_has_groups('account.group_account_invoice'):
+ domain = self._get_sale_utm_domain() + [('state', 'not in', ['draft', 'cancel'])]
+ moves = self.env['account.move'].search_read(domain, ['amount_untaxed'])
+ mass_mailing.sale_invoiced_amount = sum(i['amount_untaxed'] for i in moves)
else:
mass_mailing.sale_invoiced_amount = 0
@@ -42,13 +37,12 @@ class MassMailing(models.Model):
@api.multi
def action_redirect_to_invoiced(self):
- action = self.env.ref('account.view_move_form').read()[0]
- invoices = self.env['sale.order'].search(self._get_sale_utm_domain()).mapped('invoice_ids')
+ action = self.env.ref('account.action_move_out_invoice_type').read()[0]
+ moves = self.env['account.move'].search(self._get_sale_utm_domain())
action['domain'] = [
- ('id', 'in', invoices.ids),
+ ('id', 'in', moves.ids),
('type', 'in', ('out_invoice', 'out_refund')),
- ('type', '=', 'posted'),
- ('partner_id', 'child_of', self.id),
+ ('state', 'not in', ['draft', 'cancel']),
]
return action