[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/477/head
parent
e6249e0dc7
commit
6588185a17
|
@ -138,9 +138,11 @@ class ActivityStatement(models.AbstractModel):
|
||||||
@api.multi
|
@api.multi
|
||||||
def _get_report_values(self, docids, data):
|
def _get_report_values(self, docids, data):
|
||||||
if not data:
|
if not data:
|
||||||
|
data = {}
|
||||||
|
if 'company_id' not in data:
|
||||||
wiz = self.env["activity.statement.wizard"].with_context(
|
wiz = self.env["activity.statement.wizard"].with_context(
|
||||||
active_ids=docids, model="res.partner"
|
active_ids=docids, model="res.partner"
|
||||||
)
|
)
|
||||||
data = wiz.create({})._prepare_statement()
|
data.update(wiz.create({})._prepare_statement())
|
||||||
data['amount_field'] = 'amount'
|
data['amount_field'] = 'amount'
|
||||||
return super()._get_report_values(docids, data)
|
return super()._get_report_values(docids, data)
|
||||||
|
|
|
@ -117,9 +117,11 @@ class OutstandingStatement(models.AbstractModel):
|
||||||
@api.multi
|
@api.multi
|
||||||
def _get_report_values(self, docids, data):
|
def _get_report_values(self, docids, data):
|
||||||
if not data:
|
if not data:
|
||||||
|
data = {}
|
||||||
|
if 'company_id' not in data:
|
||||||
wiz = self.env["outstanding.statement.wizard"].with_context(
|
wiz = self.env["outstanding.statement.wizard"].with_context(
|
||||||
active_ids=docids, model="res.partner"
|
active_ids=docids, model="res.partner"
|
||||||
)
|
)
|
||||||
data = wiz.create({})._prepare_statement()
|
data.update(wiz.create({})._prepare_statement())
|
||||||
data['amount_field'] = 'open_amount'
|
data['amount_field'] = 'open_amount'
|
||||||
return super()._get_report_values(docids, data)
|
return super()._get_report_values(docids, data)
|
||||||
|
|
|
@ -10,10 +10,17 @@ class StatementCommon(models.AbstractModel):
|
||||||
_name = 'statement.common.wizard'
|
_name = 'statement.common.wizard'
|
||||||
_description = 'Statement Reports 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()
|
name = fields.Char()
|
||||||
company_id = fields.Many2one(
|
company_id = fields.Many2one(
|
||||||
comodel_name='res.company',
|
comodel_name='res.company',
|
||||||
default=lambda self: self.env.user.company_id,
|
default=_get_company,
|
||||||
string='Company',
|
string='Company',
|
||||||
required=True,
|
required=True,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue