From eab1d3b77a84e69158254bc6c37ab52724e7f8c3 Mon Sep 17 00:00:00 2001 From: Stepan Savelyev Date: Sat, 28 Dec 2019 15:09:32 +0500 Subject: [PATCH] [ADD] field sequence --- models/res_partner_contract_field.py | 1 + wizard/res_partner_contract_wizard.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/models/res_partner_contract_field.py b/models/res_partner_contract_field.py index 7a8dbcc..d251f24 100644 --- a/models/res_partner_contract_field.py +++ b/models/res_partner_contract_field.py @@ -10,3 +10,4 @@ class ContractField(models.Model): string="Technical Name", help="Name uses in template", required=True, ) description = fields.Char(string="Description", translate=True, default="",) + sequence = fields.Integer(string="Sequence",) diff --git a/wizard/res_partner_contract_wizard.py b/wizard/res_partner_contract_wizard.py index 8a13140..65e0d14 100644 --- a/wizard/res_partner_contract_wizard.py +++ b/wizard/res_partner_contract_wizard.py @@ -5,6 +5,7 @@ import logging from odoo import _, api, fields, models from odoo.exceptions import UserError +from ..utils import MODULE_NAME from ..utils.docxtpl import get_document_from_values_stream _logger = logging.getLogger(__name__) @@ -97,7 +98,7 @@ class ContractWizard(models.TransientModel): .id, 0, ) - for field, value in sorted(contract_context_values.items()) + for field, value in sorted(contract_context_values.items(), key=lambda tpl: self.env.ref("{}.contract_field_{}".format(MODULE_NAME, tpl[0])).sequence) ] # Set up template domain