Comment 6 for bug 816889

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

Hello Manfred,

I've just tried your product_test module and tested the sames cases as your video shows and I must say that this is not actually a bug. BTW I could not reproduce any of the tracebacks you mention in the bug description, so I assume they are unrelated.

Looking at your videos, you're testing both cases against a 6.1 server, only the version of the client changes. So if there is any change, it should be on the client side only, right? But actually what you're seeing is random, and depends on the version of Python, etc. For example I can reproduce the same behavior as your video for 6.1 shows, but using the 6.0.2 client.

Let me explain: when you press "Save" in the form after changing the price field, the client send an RPC request to the server to save the changes. This is all done in a single call to the write() method (you can see it if you enable RPC debug logging), that receives the values as a map, e.g in the form:

{'packaging': [],
 'seller_ids': [[1, 10,
  {'company_id': 1,
   'delay': 1,
   'min_qty': 1.0,
   'name': 11,
   'price': False,
   'pricelist_ids': [[1,
   2,
  {'min_quantity': 1.0,
   'price': 23.0}]],
  ...
}

The write() method will then process all the values in the map to save then in the database. But the order in which the fields are saved is not absolute, because there is no order for keys in a map/dictionary. So the order in which the fields will be processed depends on many things (like the python version), and can be considered semi-random.

As you have added a read/write related 'price' field on the supplier info object, when its value of '0.0' is saved, it will overwrite the price value of the first price in the lines. You can test that easily by setting a value in the related "price" field while having multiple pricelist lines: you will see the first line gets set to the related field value.
If you want to do this, you need to make sure the related field is never written to. One way to do it is to make it read-only.
If you look at the RPC call for the write() after making the related price field read-only, you will see that it does not receive a value anymore.

To summarize, the behavior you are showing seems perfectly normal, and I should now close this bug.
Do not hesitate to provide more feedback or reopen the bug if I misunderstood the situation.

Thanks,