mirror of
https://github.com/bringout/oca-ocb-sale.git
synced 2026-04-27 00:12:03 +02:00
19.0 vanilla
This commit is contained in:
parent
79f83631d5
commit
73afc09215
6267 changed files with 1534193 additions and 1130106 deletions
|
|
@ -3,11 +3,10 @@
|
|||
|
||||
from markupsafe import Markup
|
||||
from odoo import api, fields, models, _, tools
|
||||
from odoo.osv import expression
|
||||
from odoo.fields import Domain
|
||||
|
||||
|
||||
class MassMailing(models.Model):
|
||||
_name = 'mailing.mailing'
|
||||
class MailingMailing(models.Model):
|
||||
_inherit = 'mailing.mailing'
|
||||
|
||||
sale_quotation_count = fields.Integer('Quotation Count', compute='_compute_sale_quotation_count')
|
||||
|
|
@ -17,22 +16,22 @@ class MassMailing(models.Model):
|
|||
def _compute_sale_quotation_count(self):
|
||||
quotation_data = self.env['sale.order'].sudo()._read_group(
|
||||
[('source_id', 'in', self.source_id.ids), ('order_line', '!=', False)],
|
||||
['source_id'], ['source_id'],
|
||||
['source_id'], ['__count'],
|
||||
)
|
||||
mapped_data = {datum['source_id'][0]: datum['source_id_count'] for datum in quotation_data}
|
||||
mapped_data = {source.id: count for source, count in quotation_data}
|
||||
for mass_mailing in self:
|
||||
mass_mailing.sale_quotation_count = mapped_data.get(mass_mailing.source_id.id, 0)
|
||||
|
||||
@api.depends('mailing_domain')
|
||||
def _compute_sale_invoiced_amount(self):
|
||||
domain = expression.AND([
|
||||
domain = Domain.AND([
|
||||
[('source_id', 'in', self.source_id.ids)],
|
||||
[('state', 'not in', ['draft', 'cancel'])]
|
||||
])
|
||||
moves_data = self.env['account.move'].sudo()._read_group(
|
||||
domain, ['source_id', 'amount_untaxed_signed'], ['source_id'],
|
||||
domain, ['source_id'], ['amount_untaxed_signed:sum'],
|
||||
)
|
||||
mapped_data = {datum['source_id'][0]: datum['amount_untaxed_signed'] for datum in moves_data}
|
||||
mapped_data = {source.id: amount_untaxed_signed for source, amount_untaxed_signed in moves_data}
|
||||
for mass_mailing in self:
|
||||
mass_mailing.sale_invoiced_amount = mapped_data.get(mass_mailing.source_id.id, 0)
|
||||
|
||||
|
|
@ -53,11 +52,11 @@ class MassMailing(models.Model):
|
|||
'name': _("Sales Analysis"),
|
||||
'res_model': 'sale.report',
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'graph,pivot,tree,form',
|
||||
'view_mode': 'list,pivot,graph,form',
|
||||
}
|
||||
|
||||
def action_redirect_to_invoiced(self):
|
||||
domain = expression.AND([
|
||||
domain = Domain.AND([
|
||||
[('source_id', '=', self.source_id.id)],
|
||||
[('state', 'not in', ['draft', 'cancel'])]
|
||||
])
|
||||
|
|
@ -79,18 +78,18 @@ class MassMailing(models.Model):
|
|||
'name': _("Invoices Analysis"),
|
||||
'res_model': 'account.invoice.report',
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'graph,pivot,tree,form',
|
||||
'view_mode': 'list,pivot,graph,form',
|
||||
}
|
||||
|
||||
def _prepare_statistics_email_values(self):
|
||||
self.ensure_one()
|
||||
values = super(MassMailing, self)._prepare_statistics_email_values()
|
||||
values = super()._prepare_statistics_email_values()
|
||||
if not self.user_id:
|
||||
return values
|
||||
|
||||
self_with_company = self.with_company(self.user_id.company_id)
|
||||
currency = self.user_id.company_id.currency_id
|
||||
formated_amount = tools.format_decimalized_amount(self_with_company.sale_invoiced_amount, currency)
|
||||
formated_amount = tools.misc.format_decimalized_amount(self_with_company.sale_invoiced_amount, currency)
|
||||
|
||||
values['kpi_data'][1]['kpi_col2'] = {
|
||||
'value': self.sale_quotation_count,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue