← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 890110] [NEW] new field default value is calculated only once during initialisation

 

Public bug reported:

OpenERP server 6.0.3

Steps to reproduce:

1) create new sequence

		<record id="partner_code_sequence_code" model="ir.sequence.type">
			<field name="name">Partner code sequence</field>
			<field name="code">res.partner.code</field>
		</record>
		<record id="partner_code_sequence" model="ir.sequence">
			<field name="name">Partner code sequence</field>
			<field name="code">res.partner.code</field>
			<field name="active">True</field>
			<field name="prefix"></field>
			<field name="padding">9</field>
			<field name="number_increment">1</field>
			<field name="number_next">1</field>
		</record>

2) inherit res.partner, add new field with default value from sequence

class res_partner(osv.osv):
	_inherit='res.partner'
	_columns = {
		'code': fields.char('Code', 9, required=True),
	}
	_defaults = {
		'code': lambda self, cr, uid, *a: self.pool.get('ir.sequence').get(
			cr, uid, 'res.partner.code'),
	}
res_partner()

3) update database

Actual result: all existing partners have code "000000001"
Expected result: value of 'code' field calculated for each partner

** Affects: openobject-server
     Importance: Undecided
         Status: New

-- 
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/890110

Title:
  new field default value is calculated only once during initialisation

Status in OpenERP Server:
  New

Bug description:
  OpenERP server 6.0.3

  Steps to reproduce:

  1) create new sequence

  		<record id="partner_code_sequence_code" model="ir.sequence.type">
  			<field name="name">Partner code sequence</field>
  			<field name="code">res.partner.code</field>
  		</record>
  		<record id="partner_code_sequence" model="ir.sequence">
  			<field name="name">Partner code sequence</field>
  			<field name="code">res.partner.code</field>
  			<field name="active">True</field>
  			<field name="prefix"></field>
  			<field name="padding">9</field>
  			<field name="number_increment">1</field>
  			<field name="number_next">1</field>
  		</record>

  2) inherit res.partner, add new field with default value from sequence

  class res_partner(osv.osv):
  	_inherit='res.partner'
  	_columns = {
  		'code': fields.char('Code', 9, required=True),
  	}
  	_defaults = {
  		'code': lambda self, cr, uid, *a: self.pool.get('ir.sequence').get(
  			cr, uid, 'res.partner.code'),
  	}
  res_partner()

  3) update database

  Actual result: all existing partners have code "000000001"
  Expected result: value of 'code' field calculated for each partner

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


Follow ups

References