Browse Source

[MIG][FIX] base_custom_info: Several adjustments:

- Put force_save=1 for allowing the web client to send readonly values to server
- Switch widget="selection" to "many2one" default with options because it's not
  supported anymore in tree view
- Move value_id to parent view.
12.0-mig-module_prototyper_last
Pedro M. Baeza 5 years ago
committed by Alexandre Díaz
parent
commit
339a8ec1d2
  1. 1
      base_custom_info/models/custom_info.py
  2. 2
      base_custom_info/models/custom_info_value.py
  3. 19
      base_custom_info/views/custom_info_value_view.xml

1
base_custom_info/models/custom_info.py

@ -59,7 +59,6 @@ class CustomInfo(models.AbstractModel):
"res_id": self.id, "res_id": self.id,
"value": prop.default_value, "value": prop.default_value,
}) })
# HACK https://github.com/odoo/odoo/issues/13076
newvalue._inverse_value() newvalue._inverse_value()
newvalue._compute_value() newvalue._compute_value()
values += newvalue values += newvalue

2
base_custom_info/models/custom_info_value.py

@ -65,7 +65,7 @@ class CustomInfoValue(models.Model):
value_bool = fields.Boolean(string="Yes/No value", index=True) value_bool = fields.Boolean(string="Yes/No value", index=True)
value_id = fields.Many2one( value_id = fields.Many2one(
comodel_name="custom.info.option", string="Selection value", comodel_name="custom.info.option", string="Selection value",
ondelete="cascade", domain="[('property_ids', 'in', [property_id])]",
ondelete="cascade", domain="[('property_ids', '=', property_id)]",
) )
@api.multi @api.multi

19
base_custom_info/views/custom_info_value_view.xml

@ -9,11 +9,17 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree string="Custom Property Values" create="0" delete="0"> <tree string="Custom Property Values" create="0" delete="0">
<field name="owner_id" /> <field name="owner_id" />
<field name="property_id"/>
<field name="category_id"/>
<field name="property_id" force_save="1"/>
<field name="category_id" force_save="1"/>
<field name="required" invisible="1"/> <field name="required" invisible="1"/>
<field name="field_type" invisible="1"/>
<field name="value" <field name="value"
attrs="{'required': [('required', '=', True)]}"
attrs="{'invisible': [('field_type', '=', 'id')], 'required': [('required', '=', True), ('field_type', '!=', 'id')]}"
/>
<field name="value_id"
force_save="1"
options="{'no_create': True, 'no_open': True}"
attrs="{'invisible': [('field_type', '!=', 'id')], 'required': [('required', '=', True), ('field_type', '=', 'id')]}"
/> />
</tree> </tree>
</field> </field>
@ -29,13 +35,6 @@
<attribute name="editable">bottom</attribute> <attribute name="editable">bottom</attribute>
</tree> </tree>
<field name="owner_id" position="replace" /> <field name="owner_id" position="replace" />
<field name="value" position="after">
<field name="field_type" invisible="1"/>
<field name="value_id"
widget="selection"
attrs="{'invisible': [('field_type', '!=', 'id')], 'required': [('required', '=', True), ('field_type', '=', 'id')]}"
/>
</field>
</field> </field>
</record> </record>

Loading…
Cancel
Save