← Back to team overview

openerp-india team mailing list archive

[Bug 821583] Re: many2one function fields are recomputed every time even with store=True

 

Hi Olivier, sorry for responding so late (too much mail in my mail box :S)
Thank for your anwser.
I think option 2 is reasonable for the moment and will work for me.

Regarding my behaviour I know it's kind of strange to have a different result If I use the result in the store field or if I compute it.
But In fact I need a field that sometime is used as a computed field and sometime use as a normal one2many field.
Indeed some e-commerce solution introduce the concept of shop_group and some not.
If I have a shop_group, the link between the shop and the referential is given by reading the value of the referential of the shop group. If I don't have any shop_group the user must set manually the referential in the shop.

One solution to avoid the problem will to store the value of the referential in an other field "direct_referential". So when I compute the field it will use :
- the value from the shop_group if a shop was set
OR
- the value in the field "direct_referential". 

At the start I didn't choose that solution because I was thinking it's
was a little useless to have two column in the database with the same
value. And I was thinking to use the behaviour of storing as memory. But
finally I think your right even if storing field works in some case this
can introduce corrupted data, (for example if we launch a recomputation
of stored field). I will think about it and refactor my code.

Thanks for your time.

-- 
You received this bug notification because you are a member of OpenERP
Indian Team, which is subscribed to OpenERP Server.
https://bugs.launchpad.net/bugs/821583

Title:
  many2one function fields are recomputed every time even with
  store=True

Status in OpenERP Server:
  Confirmed

Bug description:
  Hi
  I am migrating my customer from v5 to v6
  I make some imporvement for is V6 and I have a problem with the function field

  I try to create a function fields with the type many2one and the
  option store=True. The problem is that the field is still read from
  the function and never from the database. It look like the option
  store=True is never use in reading.

  exemple add this field to sale_shop

      def _get_test_id(self, cr, uid, ids, name, args, context=None):
          print 'get test'
          res={}
          for id in ids:
              res[id] = 1
          return res

          'test': fields.function(_get_test_id, type='many2one',
                  relation='product.product', string='Product', method=True,
                  store=True),

  And open the sale shop. You will see that each time the sale_shop is
  open the field test is read from the function "_get_test_id" and not
  directly from the database.

  I have this bug with the last version of openerp 6.0

  I also send a mail to the support team.
  Best Regard

To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-server/+bug/821583/+subscriptions