Browse Source

[IMP] Allow to attach from compose wizard

By default we checked for an empty data dict in _get_report_values
however the mail template sends a file type and editor key by default.

We now check if the required company_id is in the dictionary. We also support
supplying force_company in context for setting the company for auto generated
emails.
pull/654/head
Graeme Gellatly 5 years ago
committed by mreficent
parent
commit
47aee73e0d
  1. 4
      partner_statement/report/activity_statement.py
  2. 4
      partner_statement/report/outstanding_statement.py
  3. 9
      partner_statement/wizard/statement_common.py

4
partner_statement/report/activity_statement.py

@ -138,9 +138,11 @@ class ActivityStatement(models.AbstractModel):
@api.multi
def _get_report_values(self, docids, data):
if not data:
data = {}
if 'company_id' not in data:
wiz = self.env["activity.statement.wizard"].with_context(
active_ids=docids, model="res.partner"
)
data = wiz.create({})._prepare_statement()
data.update(wiz.create({})._prepare_statement())
data['amount_field'] = 'amount'
return super()._get_report_values(docids, data)

4
partner_statement/report/outstanding_statement.py

@ -117,9 +117,11 @@ class OutstandingStatement(models.AbstractModel):
@api.multi
def _get_report_values(self, docids, data):
if not data:
data = {}
if 'company_id' not in data:
wiz = self.env["outstanding.statement.wizard"].with_context(
active_ids=docids, model="res.partner"
)
data = wiz.create({})._prepare_statement()
data.update(wiz.create({})._prepare_statement())
data['amount_field'] = 'open_amount'
return super()._get_report_values(docids, data)

9
partner_statement/wizard/statement_common.py

@ -10,10 +10,17 @@ class StatementCommon(models.AbstractModel):
_name = 'statement.common.wizard'
_description = 'Statement Reports Common Wizard'
def _get_company(self):
return (
self.env['res.company'].browse(
self.env.context.get('force_company')) or
self.env.user.company_id
)
name = fields.Char()
company_id = fields.Many2one(
comodel_name='res.company',
default=lambda self: self.env.user.company_id,
default=_get_company,
string='Company',
required=True,
)

Loading…
Cancel
Save