[FIX] cant delete a templates
This commit is contained in:
parent
0ecb2ce2f0
commit
e426ee5564
@ -134,7 +134,7 @@ class DocumentTemplate(models.Model):
|
|||||||
|
|
||||||
name = fields.Char()
|
name = fields.Char()
|
||||||
attachment_id = fields.Many2one(
|
attachment_id = fields.Many2one(
|
||||||
"ir.attachment", string="Template Attachment", required=True,
|
"ir.attachment", string="Template Attachment", ondelete="cascade", required=True,
|
||||||
)
|
)
|
||||||
document_type = fields.Selection(
|
document_type = fields.Selection(
|
||||||
string="Type of document",
|
string="Type of document",
|
||||||
|
@ -3,6 +3,7 @@ import base64
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from odoo import _, api, fields, models
|
from odoo import _, api, fields, models
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
from ..utils import MODULE_NAME
|
from ..utils import MODULE_NAME
|
||||||
from ..utils.docxtpl import get_document_from_values_stream
|
from ..utils.docxtpl import get_document_from_values_stream
|
||||||
@ -27,7 +28,7 @@ class ContractWizard(models.TransientModel):
|
|||||||
company_id = fields.Many2one("res.partner", string="Company")
|
company_id = fields.Many2one("res.partner", string="Company")
|
||||||
partner_id = fields.Many2one("res.partner", string="Partner")
|
partner_id = fields.Many2one("res.partner", string="Partner")
|
||||||
document_template = fields.Many2one(
|
document_template = fields.Many2one(
|
||||||
"res.partner.document.template", string="Document Template", required=True,
|
"res.partner.document.template", string="Document Template",
|
||||||
)
|
)
|
||||||
transient_field_ids = fields.One2many(
|
transient_field_ids = fields.One2many(
|
||||||
"res.partner.contract.field.transient",
|
"res.partner.contract.field.transient",
|
||||||
@ -38,6 +39,11 @@ class ContractWizard(models.TransientModel):
|
|||||||
"res.partner.contract.field.transient", "_contract_wizard_id",
|
"res.partner.contract.field.transient", "_contract_wizard_id",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@api.constrains("document_template")
|
||||||
|
def _check_document_template(self):
|
||||||
|
if not self.document_template:
|
||||||
|
raise ValidationError("You did not set up the template...")
|
||||||
|
|
||||||
@api.onchange("document_template")
|
@api.onchange("document_template")
|
||||||
def _onchange_document_template(self):
|
def _onchange_document_template(self):
|
||||||
"""Creates transient fields for generate contract template
|
"""Creates transient fields for generate contract template
|
||||||
|
Loading…
x
Reference in New Issue
Block a user