c2c-oerpscenario team mailing list archive
-
c2c-oerpscenario team
-
Mailing list archive
-
Message #32471
[Bug 816889] Re: Problem with related fields
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,
** Changed in: openobject-server
Status: Fix Committed => Invalid
--
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to OpenERP Project Group.
https://bugs.launchpad.net/bugs/816889
Title:
Problem with related fields
Status in OpenERP Server:
Invalid
Bug description:
client 6.1 rev. 1928
server 6.1 rev. 3520
Extension of the class product_supplierinfo by 2 Columns:
"prod code" ----- will show the items which the supplier delivers
"price" ----- to show the price of the first article in the supplierpartner form
With the new column "price" in object product_supplierinfo I can not
save a price. The value remains at 0
class product_supplierinfo(osv.osv):
_name = "product.supplierinfo"
_inherit = "product.supplierinfo"
_columns = {
'prod_code' : fields.related('product_id', type="many2one", relation="product.template", string='Bezeichnung'),
'price' : fields.related('pricelist_ids', 'price', type='float', string='Price'),
}
product_supplierinfo()
Extension of product-formview
<record id="product_supplierinfo_tree_view_1" model="ir.ui.view">
<field name="name">rockel_product.supplierinfo.tree.view1</field>
<field name="model">product.supplierinfo</field>
<field name="type">tree</field>
<field name="priority" eval="1"/>
<field name="arch" type="xml">
<tree string="Supplier Partner Information">
<field name="name"/>
<field name="sequence"/>
<field name="delay"/>
<field name="min_qty"/>
<field name="product_code"/>
<field name="product_name"/>
-------> <field name="price"/>
</tree>
</field>
</record>
With above formextension i get this error:
Environment Information :
System : Linux-2.6.35.13-92.fc14.i686-i686-with-fedora-14-Laughlin
OS Name : posix
Operating System Release : 2.6.35.13-92.fc14.i686
Operating System Version : #1 SMP Sat May 21 17:39:42 UTC 2011
Operating System Architecture : 32bit
Operating System Locale : de_DE.UTF8
Python Version : 2.7.0
OpenERP-Client Version : 6.1-dev
Last revision No. & ID :1928 nch@xxxxxxxxxxx-20110725063933-la4j8lwm25suiy0w
Traceback (most recent call last):
File "/home/openerp/trunk/server/openerp/netsvc.py", line 440, in dispatch
result = ExportService.getService(service_name).dispatch(method, auth, params)
File "/home/openerp/trunk/server/openerp/service/web_services.py", line 588, in dispatch
res = fn(db, uid, *params)
File "/home/openerp/trunk/server/openerp/osv/osv.py", line 118, in wrapper
return f(self, dbname, *args, **kwargs)
File "/home/openerp/trunk/server/openerp/osv/osv.py", line 172, in execute
res = self.execute_cr(cr, uid, obj, method, *args, **kw)
File "/home/openerp/trunk/server/openerp/osv/osv.py", line 163, in execute_cr
return getattr(object, method)(cr, uid, *args, **kw)
File "/home/openerp/trunk/server/openerp/osv/orm.py", line 1994, in fields_view_get
xarch, xfields = self.__view_look_dom_arch(cr, user, result['arch'], view_id, context=ctx)
File "/home/openerp/trunk/server/openerp/osv/orm.py", line 1656, in __view_look_dom_arch
fields_def = self.__view_look_dom(cr, user, node, view_id, False, fields, context=context)
File "/home/openerp/trunk/server/openerp/osv/orm.py", line 1605, in __view_look_dom
fields.update(self.__view_look_dom(cr, user, f, view_id, in_tree_view, model_fields, context))
File "/home/openerp/trunk/server/openerp/osv/orm.py", line 1558, in __view_look_dom
field = model_fields[node.get('name')]
KeyError: 'price'
Extension of partner form:
<record id="supplier_productinfo_tree_view" model="ir.ui.view">
<field name="name">rockel.supplier.productinfo.tree.view</field>
<field name="model">product.supplierinfo</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Supplier Product Information">
<field name="prod_code"/>
<field name="sequence"/>
<field name="delay"/>
<field name="min_qty"/>
<field name="product_code"/>
<field name="product_name"/>
</tree>
</field>
</record>
<record id="supplier_productinfo_form_view" model="ir.ui.view">
<field name="name">rockel.supplier.productinfo.form.view</field>
<field name="model">product.supplierinfo</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Supplier Product Information">
--------> <field name="prod_code"/>
<field name="sequence"/>
<field name="product_code"/>
<field name="product_name"/>
<field name="delay"/>
<field name="min_qty"/>
<field colspan="4" groups="base.group_extended" name="pricelist_ids" nolabel="1" widget="one2many_list">
<tree editable="bottom" string="Pricelist">
<field name="min_quantity"/>
<field name="price"/>
</tree>
<form>
<field name="min_quantity"/>
<field name="price"/>
</form>
</field>
</form>
</field>
</record>
When i press the search button in field prod_code in
supplier_productinfo_form_view i get this error:
Environment Information :
System : Linux-2.6.35.13-92.fc14.i686-i686-with-fedora-14-Laughlin
OS Name : posix
Operating System Release : 2.6.35.13-92.fc14.i686
Operating System Version : #1 SMP Sat May 21 17:39:42 UTC 2011
Operating System Architecture : 32bit
Operating System Locale : de_DE.UTF8
Python Version : 2.7.0
OpenERP-Client Version : 6.1-dev
Last revision No. & ID :1928 nch@xxxxxxxxxxx-20110725063933-la4j8lwm25suiy0w
Traceback (most recent call last):
File "/home/openerp/trunk/server/openerp/netsvc.py", line 440, in dispatch
result = ExportService.getService(service_name).dispatch(method, auth, params)
File "/home/openerp/trunk/server/openerp/service/web_services.py", line 588, in dispatch
res = fn(db, uid, *params)
File "/home/openerp/trunk/server/openerp/osv/osv.py", line 118, in wrapper
return f(self, dbname, *args, **kwargs)
File "/home/openerp/trunk/server/openerp/osv/osv.py", line 172, in execute
res = self.execute_cr(cr, uid, obj, method, *args, **kw)
File "/home/openerp/trunk/server/openerp/osv/osv.py", line 163, in execute_cr
return getattr(object, method)(cr, uid, *args, **kw)
File "/home/openerp/trunk/server/openerp/osv/orm.py", line 1994, in fields_view_get
xarch, xfields = self.__view_look_dom_arch(cr, user, result['arch'], view_id, context=ctx)
File "/home/openerp/trunk/server/openerp/osv/orm.py", line 1656, in __view_look_dom_arch
fields_def = self.__view_look_dom(cr, user, node, view_id, False, fields, context=context)
File "/home/openerp/trunk/server/openerp/osv/orm.py", line 1605, in __view_look_dom
fields.update(self.__view_look_dom(cr, user, f, view_id, in_tree_view, model_fields, context))
File "/home/openerp/trunk/server/openerp/osv/orm.py", line 1558, in __view_look_dom
field = model_fields[node.get('name')]
KeyError: 'prod_code'
In Version 6.02 it works.
To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-server/+bug/816889/+subscriptions
References