[IMP] filename of document
This commit is contained in:
parent
0d00879f8d
commit
1918f66627
@ -153,19 +153,33 @@ class ContractWizard(models.TransientModel):
|
|||||||
binary_data = get_document_from_values_stream(path_to_template, fields).read()
|
binary_data = get_document_from_values_stream(path_to_template, fields).read()
|
||||||
encoded_data = base64.b64encode(binary_data)
|
encoded_data = base64.b64encode(binary_data)
|
||||||
|
|
||||||
attachment_name = "{name}-{number}.{ext}".format(
|
if self.target._name == "res.partner.contract":
|
||||||
number=self.target.name,
|
contract = self.target
|
||||||
ext="docx",
|
attachment_name = "{type} {number} {from_} {date}".format(
|
||||||
name=(
|
type=dict(self.document_template._fields['document_type'].selection).get(self.document_template.document_type),
|
||||||
_("Contract")
|
number=contract.name,
|
||||||
if self.target._name == "res.partner.contract"
|
from_=_("from"),
|
||||||
else (
|
date=contract.get_date().strftime("%d.%m.%Y"),
|
||||||
_("Annex")
|
)
|
||||||
if self.target._name == "res.partner.contract.annex"
|
elif self.target._name == "res.partner.contract.annex":
|
||||||
else ("Unknown")
|
annex = self.target
|
||||||
|
attachment_name = "{type} №{name}".format(
|
||||||
|
type=dict(self.document_template._fields['document_type'].selection).get(self.document_template.document_type),
|
||||||
|
name={
|
||||||
|
"specification": "{number} {type} {name}",
|
||||||
|
"approval_list": "{number}.1 {type} {name}-1",
|
||||||
|
"act_at": "{number}.2 {type} {name}-2",
|
||||||
|
"act_ad": "{number}.3 {type} {name}-3",
|
||||||
|
}.get(self.document_template.document_type_name).format(
|
||||||
|
number=annex.number,
|
||||||
|
type=dict(self.document_template._fields['document_type_name'].selection).get(self.document_template.document_type_name),
|
||||||
|
name=annex.name,
|
||||||
)
|
)
|
||||||
),
|
)
|
||||||
)
|
else:
|
||||||
|
attachment_name = "Unknown"
|
||||||
|
|
||||||
|
attachment_name = "{}.docx".format(attachment_name)
|
||||||
|
|
||||||
document_as_attachment = self.env["ir.attachment"].create(
|
document_as_attachment = self.env["ir.attachment"].create(
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user