[Erp5-dev] proposed patch for Person
Jérôme Perrin
jerome at nexedi.com
Sat Mar 3 15:38:35 CET 2007
Le Jeudi 22 Février 2007 19:17, bartek a écrit :
> Hello
>
> I noticed an undesired behaviour - setTitle on Person object duly sets
> the title, which is then not displayed in the form, because it uses
> first_name and last_name. And there is an inconsistency, because
> getTitel returns first_name + last_name, while setTitle sets the title.
>
> I hit this problem when I used RelationStringField which allowed
> creation - I typed the name, created new Person and it came up empty,
> which is not what one would expect.
>
> What I'd suggest is the attached patch - setTitle should be the exact
> reverse of getTitle, and the rest of setters is redundant.
>
> I didn't commit it, please comment if you think it is ok or not.
In r13208, I added some tests for the minimal level of first name / last
name / title interaction which I think we need here (Person_view doesn't
allow to edit title, but only last_name & first_name). Thoses tests still
passes with your patch, but I'm afraid of side effects that changing the
behaviour could cause. At least, with this patch I have seen some of my unit
tests for a project importing persons from an external source failing.
The problem is only with relation field, right ? Maybe this problem can be
fixed when the relation field creates the document. Now, it just call
newContent on module, and pass arguments[1] to newContent.
One way could be to add a "Create Document Method" on relation fields that
would be a script that guess first_name, last_name from title and creates the
document then set properties.
We have the same problem each time we want to allow creation for documents
where the property is calculated (eg. reference for bank accounts), but still
I'm not sure if we use it so much that it would explain adding yet more
complexity to relation field.
[1] Anybody knows why it have to immediate reindex object ?
(MultiRelationField.py line 412)
Jérome
More information about the Erp5-dev
mailing list