[ADD] form-visible attribute of a transient field
This commit is contained in:
parent
62b0a9ea9d
commit
0627e36185
@ -274,6 +274,7 @@ action = ctx
|
||||
<field name="technical_name">mm</field>
|
||||
<field name="description">Number</field>
|
||||
<field name="sequence">16</field>
|
||||
<field name="visible">False</field>
|
||||
</record>
|
||||
|
||||
<record id="contract_field_MM" model="res.partner.contract.field">
|
||||
@ -288,6 +289,7 @@ action = ctx
|
||||
<field name="technical_name">yy</field>
|
||||
<field name="description">Short</field>
|
||||
<field name="sequence">40</field>
|
||||
<field name="visible">False</field>
|
||||
</record>
|
||||
|
||||
<record id="contract_field_yyyy" model="res.partner.contract.field">
|
||||
|
@ -11,3 +11,4 @@ class ContractField(models.Model):
|
||||
)
|
||||
description = fields.Char(string="Description", translate=True, default="",)
|
||||
sequence = fields.Integer(string="Sequence",)
|
||||
visible = fields.Boolean(string="Visible", default=True,)
|
||||
|
@ -18,4 +18,5 @@ class ContractFieldTransient(models.TransientModel):
|
||||
description = fields.Char(
|
||||
related="contract_field_id.description", string="Description", readonly=True,
|
||||
)
|
||||
visible = fields.Boolean(related="contract_field_id.visible",)
|
||||
value = fields.Char(string="Value", default="",)
|
||||
|
@ -40,6 +40,9 @@ class ContractWizard(models.TransientModel):
|
||||
"_contract_wizard_id",
|
||||
string="Contract Fields",
|
||||
)
|
||||
transient_field_ids_hidden = fields.One2many(
|
||||
"res.partner.contract.field.transient", "_contract_wizard_id",
|
||||
)
|
||||
|
||||
@api.onchange("document_template")
|
||||
def _onchange_document_template(self):
|
||||
@ -110,6 +113,12 @@ class ContractWizard(models.TransientModel):
|
||||
).sequence,
|
||||
)
|
||||
]
|
||||
self.transient_field_ids_hidden = (
|
||||
self.transient_field_ids - self.transient_field_ids.filtered("visible")
|
||||
)
|
||||
self.transient_field_ids = (
|
||||
self.transient_field_ids - self.transient_field_ids_hidden
|
||||
)
|
||||
|
||||
# Set up template domain
|
||||
template_type = {
|
||||
@ -137,7 +146,9 @@ class ContractWizard(models.TransientModel):
|
||||
|
||||
fields = {
|
||||
transient_field.technical_name: transient_field.value
|
||||
for transient_field in self.transient_field_ids
|
||||
for transient_field in (
|
||||
self.transient_field_ids + self.transient_field_ids_hidden
|
||||
)
|
||||
if transient_field.technical_name and transient_field.value
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
<field name="technical_name" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
<field name="transient_field_ids_hidden" invisible="1"/>
|
||||
</group>
|
||||
|
||||
<footer/>
|
||||
@ -67,6 +68,7 @@
|
||||
<field name="technical_name" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
<field name="transient_field_ids_hidden" invisible="1"/>
|
||||
</group>
|
||||
|
||||
<footer/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user