[STYLE] order of methods
This commit is contained in:
parent
cabd775c79
commit
99cdb48a7c
@ -51,13 +51,19 @@ class ContractOrderAnnex(models.Model, IDocument, Extension):
|
||||
payment_part_two = fields.Float(string="Payment 2 Part (%)",)
|
||||
payment_part_three = fields.Float(string="Payment 3 Part (%)",)
|
||||
|
||||
@api.onchange("order_id")
|
||||
def _onchange_order_id(self):
|
||||
contract_number = self.contract_id.name
|
||||
order_number = self.order_id.name or "SO###"
|
||||
@api.multi
|
||||
@api.depends("name")
|
||||
def _compute_display_name(self):
|
||||
for record in self:
|
||||
record.display_name = "№{} {}".format(
|
||||
record.counter or record.contract_id.contract_annex_number, record.name
|
||||
)
|
||||
|
||||
self.name = "{contract}-{order}".format(
|
||||
contract=contract_number, order=order_number,
|
||||
@api.depends("specification_name", "contract_id", "order_id")
|
||||
def _compute_specification_name(self):
|
||||
self.specification_name = _("{name} from {date}").format(
|
||||
name="{}-{}".format(self.contract_id.name, self.order_id.name),
|
||||
date=self.contract_id.get_date().strftime("%d.%m.%Y"),
|
||||
)
|
||||
|
||||
@api.onchange("order_id")
|
||||
@ -74,19 +80,13 @@ class ContractOrderAnnex(models.Model, IDocument, Extension):
|
||||
}
|
||||
}
|
||||
|
||||
@api.multi
|
||||
@api.depends("name")
|
||||
def _compute_display_name(self):
|
||||
for record in self:
|
||||
record.display_name = "№{} {}".format(
|
||||
record.counter or record.contract_id.contract_annex_number, record.name
|
||||
)
|
||||
@api.onchange("order_id")
|
||||
def _onchange_order_id(self):
|
||||
contract_number = self.contract_id.name
|
||||
order_number = self.order_id.name or "SO###"
|
||||
|
||||
@api.depends("specification_name", "contract_id", "order_id")
|
||||
def _compute_specification_name(self):
|
||||
self.specification_name = _("{name} from {date}").format(
|
||||
name="{}-{}".format(self.contract_id.name, self.order_id.name),
|
||||
date=self.contract_id.get_date().strftime("%d.%m.%Y"),
|
||||
self.name = "{contract}-{order}".format(
|
||||
contract=contract_number, order=order_number,
|
||||
)
|
||||
|
||||
@api.model
|
||||
|
@ -29,15 +29,15 @@ class ContractWizard(models.TransientModel):
|
||||
partner_id = fields.Many2one(
|
||||
"res.partner", string="Partner", compute="_compute_partner_id",
|
||||
)
|
||||
document_name = fields.Char(
|
||||
string="Document Name", compute="_compute_document_name"
|
||||
)
|
||||
document_template = fields.Many2one(
|
||||
"res.partner.document.template",
|
||||
string="Document Template",
|
||||
compute="_compute_document_template",
|
||||
readonly=False,
|
||||
)
|
||||
document_name = fields.Char(
|
||||
string="Document Name", compute="_compute_document_name"
|
||||
)
|
||||
transient_field_ids = fields.One2many(
|
||||
"res.partner.contract.field.transient",
|
||||
"_contract_wizard_id",
|
||||
@ -47,11 +47,6 @@ class ContractWizard(models.TransientModel):
|
||||
"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.depends("company_id", "target")
|
||||
def _compute_company_id(self):
|
||||
if self.target:
|
||||
@ -72,6 +67,11 @@ class ContractWizard(models.TransientModel):
|
||||
def _compute_document_template(self):
|
||||
self.document_template = self.env["res.partner.document.template"].search(self._get_template_domain(), limit=1)
|
||||
|
||||
@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')
|
||||
def _domain_document_template(self):
|
||||
return {
|
||||
@ -80,21 +80,6 @@ class ContractWizard(models.TransientModel):
|
||||
}
|
||||
}
|
||||
|
||||
def _get_template_domain(self):
|
||||
template_type = {
|
||||
"res.partner.contract": "contract",
|
||||
"res.partner.contract.annex": "annex",
|
||||
}.get(self.active_model, False)
|
||||
company_type = (
|
||||
self.partner_id.company_form if self.partner_id.is_company else "person"
|
||||
)
|
||||
|
||||
document_template_domain = [
|
||||
("template_type", "=", template_type),
|
||||
("company_type", "=", company_type),
|
||||
]
|
||||
return document_template_domain
|
||||
|
||||
@api.onchange("document_template")
|
||||
def _onchange_document_template(self):
|
||||
"""Creates transient fields for generate contract template
|
||||
@ -142,6 +127,8 @@ class ContractWizard(models.TransientModel):
|
||||
self.transient_field_ids - self.transient_field_ids_hidden
|
||||
)
|
||||
|
||||
# Other
|
||||
|
||||
@api.multi
|
||||
def get_docx_contract(self):
|
||||
template = self.document_template.attachment_id
|
||||
@ -197,6 +184,21 @@ class ContractWizard(models.TransientModel):
|
||||
|
||||
return document_as_attachment
|
||||
|
||||
def _get_template_domain(self):
|
||||
template_type = {
|
||||
"res.partner.contract": "contract",
|
||||
"res.partner.contract.annex": "annex",
|
||||
}.get(self.active_model, False)
|
||||
company_type = (
|
||||
self.partner_id.company_form if self.partner_id.is_company else "person"
|
||||
)
|
||||
|
||||
document_template_domain = [
|
||||
("template_type", "=", template_type),
|
||||
("company_type", "=", company_type),
|
||||
]
|
||||
return document_template_domain
|
||||
|
||||
@property
|
||||
def active_model(self):
|
||||
return self.env.context.get("active_model")
|
||||
|
Loading…
x
Reference in New Issue
Block a user