Issue 9726

Title
Use default value to set missing value via depends
Priority
bug
Status
resolved
Nosy list
ced, reviewbot, roundup-bot
Assigned to
ced
Keywords
backport, review

Created on 2020-10-16.13:23:02 by ced, last changed 4 days ago by roundup-bot.

Messages

New changeset 7b3249155383 by Cédric Krier in branch 'default':
Set default value for missing depends field
https://hg.tryton.org/tryton-env/rev/7b3249155383
New changeset 65b6783a3b63 by Cédric Krier in branch 'default':
Set default value for missing depends field
https://hg.tryton.org/trytond/rev/65b6783a3b63

New changeset ad25105834ed by Cédric Krier in branch 'default':
Test default value for missing depends field
https://hg.tryton.org/trytond/rev/ad25105834ed
Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2020-10-16.13:23:02
fields.depends set None for missing values. But when we instantiate a record and call a method decorated with depends, some field may be set to None which will be used when saved.
This happens for example with ShipmentOut._sync_outgoing_move a Move is instantiated and on_change_with_unit_price_required is called. But if the stock_consignment is activated, it adds a depend to the field state. So the state is set to None which makes the save failing because the state value must be draft or staging on creation (and it is required).
So for me the depends decorator should use the default value of the field if there is one (which mimic the ModelSQL.create behavior).
History
Date User Action Args
2020-10-21 23:24:37roundup-botsetmessages: + msg61133
2020-10-21 23:24:27roundup-botsetmessages: + msg61132
nosy: + roundup-bot
status: testing -> resolved
2020-10-16 15:29:46reviewbotsetnosy: + reviewbot
messages: + msg60993
2020-10-16 15:20:10cedsetstatus: in-progress -> testing
reviews: 314481004
keyword: + backport, review
2020-10-16 13:23:02cedcreate

Showing 10 items. Show all history (warning: this could be VERY long)