Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
3 Vastaukset
9375 Näkymät

Hello.

The scenario is: ODOO community 11.0

The requirement is: Having two custom fields in a model, StartDate and EndDate, how to validate that EndDate can´t be smaller than StartDate. 

Constraint (How to accomplish the task?): Without creating an extension to module or any new module. Just modifying the model directly from Setting->Database Structure -> Models.

Any idea?

Thanks for help.

Avatar
Hylkää
Paras vastaus

I have the exact same question and the answer didn't help. We don't want to compute a field, juste test is the date is after another field date.

Avatar
Hylkää
Tekijä Paras vastaus

Thanks for you answer. But I could not did settle how to place there a validation instead a computed result value.

Avatar
Hylkää
Paras vastaus

 Setting->Database Structure -> Fields (Search your EndDate) -> Advance Properties, you will see Dependencies and Compute field, there is a little help text in there:

 Computed fields are defined with the fields Dependencies and Compute.

The field Dependencies lists the fields that the current field depends on. It is a comma-separated list of field names, like name, size. You can also refer to fields accessible through other relational fields, for instance partner_id.company_id.name.

The field Compute is the Python code to compute the value of the field on a set of records. The value of the field must be assigned to each record with a dictionary-like assignment.

    for record in self:
        record['size'] = len(record.name)

You can use this to compute constraint checking your StartDate and achieve the goal.

Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
maalisk. 15
3920
1
kesäk. 23
2279
1
huhtik. 23
11348
1
kesäk. 22
2592
2
elok. 20
9059