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