openerp-india team mailing list archive
-
openerp-india team
-
Mailing list archive
-
Message #12416
[Bug 1012181] [NEW] [6.1] fields.related and store=True, changes are not propagated
Public bug reported:
For example (based on city module)
class city(osv.osv):
# custom name_get ...
# custom name_search ...
_name = 'city.city'
_description = 'City'
_columns = {
'state_id': fields.many2one('res.country.state', 'State',
domain="[('country_id','=',country_id)]", select=1),
'name': fields.char('City', size=64, required=True, select=1),
'zip': fields.char('ZIP', size=64, required=True, select=1),
'country_id': fields.many2one('res.country', 'Country', select=1),
'code': fields.char('City Code', size=64,
help="The official code for the city"),
}
city()
To not loose backward compatibility with other modules that will look
for zip, country_id or city fields, we add in our module:
class res_partner_address(osv.osv):
_inherit = "res.partner.address"
_columns = {
'city_id': fields.many2one('city.city', 'Location', select=1),
'zip': fields.related('city_id', 'zip', type="char", string="Zip",
store=True),
'city': fields.related('city_id', 'name', type="char", string="City",
store=True),
'state_id': fields.related('city_id', 'state_id', type="many2one",
relation="res.country.state", string="State",
store=True),
'country_id': fields.related('city_id', 'country_id', type="many2one",
relation="res.country", string="Country",
store=True),
}
res_partner_address()
An finally we operate a view change like this:
<data>
<xpath expr="//field[@name='address']//field[@name='city']" position="replace">
<field name="city_id" colspan="4" />
</xpath>
<xpath expr="//field[@name='address']//field[@name='country_id']" position="replace"/>
<xpath expr="//field[@name='address']//field[@name='zip']" position="replace"/>
<xpath expr="//field[@name='address']//field[@name='state_id']" position="replace"/>
</data>
===========================================================================
Now, we have this new object "city.city". If I decide to edit the
"city.city" object field named "zip" and press save, it will not update
the stored 'zip' field of the "res.partner" that is linked to this
"city.city" object.
Is that normal ? changes should be propagated to all related fields!
(note: to update the partner with correct data, I have to go to its
form, edit one field to allow the save button to become red and finally
press save to update it)
** Affects: openobject-server
Importance: Undecided
Status: New
--
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/1012181
Title:
[6.1] fields.related and store=True, changes are not propagated
Status in OpenERP Server:
New
Bug description:
For example (based on city module)
class city(osv.osv):
# custom name_get ...
# custom name_search ...
_name = 'city.city'
_description = 'City'
_columns = {
'state_id': fields.many2one('res.country.state', 'State',
domain="[('country_id','=',country_id)]", select=1),
'name': fields.char('City', size=64, required=True, select=1),
'zip': fields.char('ZIP', size=64, required=True, select=1),
'country_id': fields.many2one('res.country', 'Country', select=1),
'code': fields.char('City Code', size=64,
help="The official code for the city"),
}
city()
To not loose backward compatibility with other modules that will look
for zip, country_id or city fields, we add in our module:
class res_partner_address(osv.osv):
_inherit = "res.partner.address"
_columns = {
'city_id': fields.many2one('city.city', 'Location', select=1),
'zip': fields.related('city_id', 'zip', type="char", string="Zip",
store=True),
'city': fields.related('city_id', 'name', type="char", string="City",
store=True),
'state_id': fields.related('city_id', 'state_id', type="many2one",
relation="res.country.state", string="State",
store=True),
'country_id': fields.related('city_id', 'country_id', type="many2one",
relation="res.country", string="Country",
store=True),
}
res_partner_address()
An finally we operate a view change like this:
<data>
<xpath expr="//field[@name='address']//field[@name='city']" position="replace">
<field name="city_id" colspan="4" />
</xpath>
<xpath expr="//field[@name='address']//field[@name='country_id']" position="replace"/>
<xpath expr="//field[@name='address']//field[@name='zip']" position="replace"/>
<xpath expr="//field[@name='address']//field[@name='state_id']" position="replace"/>
</data>
===========================================================================
Now, we have this new object "city.city". If I decide to edit the
"city.city" object field named "zip" and press save, it will not
update the stored 'zip' field of the "res.partner" that is linked to
this "city.city" object.
Is that normal ? changes should be propagated to all related fields!
(note: to update the partner with correct data, I have to go to its
form, edit one field to allow the save button to become red and
finally press save to update it)
To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-server/+bug/1012181/+subscriptions
Follow ups
References