[6.1, trunk] One2many widget does not honour being 'required'

Bug #1013636 reported by Stefan Rijnhart (Opener)
72
This bug affects 15 people
Affects Status Importance Assigned to Milestone
Odoo GTK Client (MOVED TO GITHUB)
Confirmed
Wishlist
OpenERP sa GTK client R&D
Odoo Web (MOVED TO GITHUB)
Confirmed
Wishlist
OpenERP R&D Web Team
Therp Backports (Deprecated)
Fix Released
Undecided
Stefan Rijnhart (Opener)
Web-6.1
Fix Committed
Undecided
Stefan Rijnhart (Opener)

Bug Description

Hi,

both 6.1 and trunk do not signal correctly when a required one2many field is being left empty.

An example from the base module is to go to Settings -> Technical -> Database Structure -> Models. Create a new model, but do not enter any fields. The model can be saved without an error message, even though Fields is a required field on ir.model.

I would expect the client to raise an error 'The following fields are invalid: Fields'

cheers,
Stefan.

Related branches

Changed in openerp-web:
status: New → Confirmed
importance: Undecided → Low
assignee: nobody → OpenERP R&D Web Team (openerp-dev-web)
Changed in openobject-client:
status: New → Confirmed
importance: Undecided → Low
assignee: nobody → OpenERP sa GTK client R&D (openerp-dev-gtk)
Revision history for this message
Nicolas Vanhoren (OpenERP) (niv-openerp) wrote :

Hello. By design, the o2m (and the m2m) does not handle the required flag. We do not consider that a 'required' x2m relationship would have lot of sense.

Changed in openobject-client:
status: Confirmed → Invalid
status: Invalid → Opinion
Changed in openerp-web:
status: Confirmed → Opinion
Revision history for this message
Ronald Portier (Therp) (rportier1962) wrote :

IMHO There are certainly situations were this makes sense.

Traditional example: order should contain at least one order line.

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Hi Nicolas,

thank you for your reaction. You mention the behaviour of the many2many widget in your answer. However, that widget does actually properly support the required flag. It is where I copied the code from, in the same file.

As this is in my view inconsistent, can you explain in more detail what is the rationale to ignore this attribute on many2one fields?

My business case btw. is a client who does not want any partners without an address in their system.

Cheers,
Stefan.

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

s/many2one/one2many/, obviously

Revision history for this message
Peter Langenberg (peter-langenberg) wrote :

I agree 100 % with Stefan and Ronald.

Revision history for this message
Lorenzo Battistini (elbati) wrote : Re: [Openerp-expert-framework] Can one2many fields be required?

On 07/18/2012 04:04 PM, Stefan Rijnhart wrote:
> Dear framework experts,
>
> our customer appreciates that no partner is entered into the system
> without an address and a category. The category is not a problem, as the
> many2many widget supports the 'required' flag. The address is a problem,
> as the web client does not support the 'required' flag on one2many fields.
>
> This was reported and a simple, elegant solution was suggested at
> https://bugs.launchpad.net/openerp-web/+bug/1013636
>

Hello Stefan,
I think this is clearly a bug, not an opinion.

--
Lorenzo Battistini <email address hidden>
Via Pasture Genovesi, 16 - 6949 - Comano - Switzerland
Agile Business Group sagl http://www.agilebg.com

Revision history for this message
Niels Huylebroeck (red15) wrote :

If not a bug I would still consider this to be a very welcome (not to mention backwards-compatible) feature addition (dare I say it ?)

Revision history for this message
Ferdinand (office-chricar) wrote :

Just had a discussion yesterday with a prospect.
in his company partners need at least ONE address

Hence I support Stefans opinion (as it is neither complicated and a patch exists and it does not harm)

Revision history for this message
Mario Arias (the-clone-master) wrote :

This is definitely a bug.

Implementing the patch does not make every one2many fields required, only on those the developer sets the "required" flag, so there is no harm on it, and most important, adds consistency to OpenERP behavior....

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Resetting to 'confirmed' as per framework experts' opinion.

Thanks for the support.

Changed in openobject-client:
status: Opinion → Confirmed
Changed in openerp-web:
status: Opinion → Confirmed
Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :

Hello,

I'm just adding my +1: I see no point in OpenERP SA focusing on the "ergonomics" of OpenERP while letting such ergonomics holes unfixed. So yes, I would suggest that a "required" one2many field cannot be left empty.

Revision history for this message
Antony Lesuisse (OpenERP) (al-openerp) wrote :

This is a feature request according to our policy. And yet, not a very useful one, as in most case, you want users to be able to save draft versions of a document without lines. If you really need this behaviour you may override write().

That said, contributions are welcome, and if you submit a merge proposal implementing that feature for the webclient in a non intrusive and elegant way we might consider it for trunk.

In the mean time please dont requalify, it's confirmed wishlist.

Policy http://doc.openerp.com/v6.1/contribute/11_bug_tracker.html

Changed in openerp-web:
importance: Low → Wishlist
Revision history for this message
Lorenzo Battistini (elbati) wrote : Re: [Bug 1013636] Re: [6.1, trunk] One2many widget does not honour being 'required'

On 07/21/2012 01:53 PM, Antony Lesuisse (OpenERP) wrote:
> This is a feature request according to our policy. And yet, not a very
> useful one, as in most case, you want users to be able to save draft
> versions of a document without lines. If you really need this behaviour
> you may override write().

Hello Antony,
particular behaviors can be certainly handled by write method. These
will be implementation choices.
But if developer sets the field to be *required=True* (as per Stefan's
example of *ir.model* model: *'field_id':
fields.one2many('ir.model.fields', 'model_id', 'Fields', required=True)*
), why should the user be able to create a model without fields?

--
Lorenzo Battistini

Revision history for this message
Vivek poddar (vivekimsit) wrote :

Hi,

I agree with elbati, this is a customization feature. It depends on the client requirement to make a field required or not. And if we have this flexibilty in the form of "required=True" then why we are hardcoding it?

Thanks and Regards!

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Hi Antony,

thank you for reconsidering. I hope that it is clear that a number of members from the community would like to see this change either because they find it useful or from the perspective of API consistency.

You can find the proposed branch attached to this issue.

Best regards,
Stefan.

Revision history for this message
Antony Lesuisse (OpenERP) (al-openerp) wrote :

Oh i didn't see the patch. What visual feedback is used to tell the user that the o2m is invalid ?

Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :

Also I just would like to comment on the argument used to justify the
current bahavior: "one may want to save some record as draft without
lines". Well IMHO this is no valid justification as you could use it for
any other kind of mandatory field; for instance using the same argument you
could justify not checking if partner_id is present on a sale order
petexting youb may want to save a draft version of the order. And IMHO the
debate if that's a bug or an improvement is sterile, it's obviously a basic
feature to have, that makes at least as much sense as the CSS fluff being
invested on currently.
On Jul 22, 2012 7:45 AM, "Antony Lesuisse (OpenERP)" <email address hidden> wrote:

> Oh i didn't see the patch. What visual feedback is used to tell the user
> that the o2m is invalid ?
>
> --
> You received this bug notification because you are a member of OpenERP
> Drivers, which is subscribed to OpenERP GTK Client.
> https://bugs.launchpad.net/bugs/1013636
>
> Title:
> [6.1, trunk] One2many widget does not honour being 'required'
>
> Status in OpenERP Web:
> Confirmed
> Status in OpenERP GTK Client:
> Confirmed
>
> Bug description:
> Hi,
>
> both 6.1 and trunk do not signal correctly when a required one2many
> field is being left empty.
>
> An example from the base module is to go to Settings -> Technical ->
> Database Structure -> Models. Create a new model, but do not enter any
> fields. The model can be saved without an error message, even though
> Fields is a required field on ir.model.
>
> I would expect the client to raise an error 'The following fields are
> invalid: Fields'
>
> cheers,
> Stefan.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/openerp-web/+bug/1013636/+subscriptions
>

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Hi Antony,

thank you for pointing out that visual hints are desired. I added a new branch that adds visual hints similar to regular text fields: blue background for being required, red background for being invalid.

Regards,
Stefan.

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :
Revision history for this message
Nhomar - Vauxoo (nhomar) wrote :

+1 For Stefan:

It is simple:

1.- Before it works in this way.
2.- Now it is not working.

Why? Antony said in comment #12

We all community are not agreed.

Bug is confirmed.

Just FYI, at least you say that you will depreciate some thing on ORM you can not supose wvwrybody works in the way you think.

Sorry Antony.

Changed in openobject-client:
importance: Low → Wishlist
Revision history for this message
Nhomar - Vauxoo (nhomar) wrote :

Fabien, with this kind of decisition every time you are pushing everybody trust less on the objective of OpenERP.

At least you can say, why a field delared as Required will pass without alert! logic is simple.

Revision history for this message
Mario Arias (the-clone-master) wrote :

A "Wishlist" is when the request is something "new" that isn't part of OpenERP...

In this case, required one2many fields was an existing feature...
Also, there is a very simple and safe patch available, that gives back the now missing feature...

Fabien, please listen to the community and accept this patch !

-Mario

Changed in therp-backports:
status: New → Confirmed
Changed in therp-backports:
assignee: nobody → Stefan Rijnhart (Therp) (stefan-therp)
status: Confirmed → Fix Committed
Changed in therp-backports:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.