Я хочу обновить данные с 'state' до 'rented' в классе video_rental_copy, когда я создаю новую строку проката в классе video_rental_rentals. Я не знаю, как поступить. И не могу найти примеров в сети с OpenERP 6.1.
Спасибо
Рамон
class video_rental_copy(osv.osv):
"""..."""
_name = 'video_rental.copy'
_columns = {
'name': fields.char('Reference', size=32, required=True, help='xxx'),
'product_id': fields.many2one('product.product','Film',required=True, help='...'),
'period_id': fields.many2one('video_rental.period','Period',required=True, help='...'),
'state': fields.selection([('rented','Rented'),('free','Free')],'State of the film',readonly=True),
'actived': fields.boolean('Active'),
'rental_id': fields.one2many('video_rental.rentals', 'copy_id', 'Videos',required=False,readonly=True),
}
_sql_constraints = [
('reference', 'unique(name)', 'It already exists another reference with the same reference!'),
]
_defaults = {
'state' : 'free',
'actived' : 'True',
}
video_rental_copy()
class video_rental_rentals(osv.osv):
"""..."""
_name = 'video_rental.rentals'
_columns = {
'copy_id': fields.many2one('video_rental.copy','Copy',required=True, help='...'),
'state': fields.related('copy_id','state',type='char',string='State',store=False),
'period_id': fields.related('copy_id','period_id',type='many2one',relation='video_rental.period',string='Period',store=False,readonly=True),
'days': fields.related('period_id','days',type='integer',relation='video_rental.period',string='Days',store=False,readonly=True),
'partner_id': fields.many2one('res.partner', 'Customer',required=True, help='...'),
'rental_date': fields.datetime('Rental Date',required=True, help='...'),
'limit_date': fields.function(_compute_limit_date,type='datetime',string='Limit Date',store=True),
'return_date': fields.datetime('Return Date',help='...'),
}
_constraints = [
(_check_my_return_date, 'Return date before rental date!', ['return_date']),
(_check_copy_id_state, 'State must be free!', ['state'])
]
def create(self,cr,uid,vals,context=None):
video_rental_copy_obj = self.pool.get('video_rental.copy')
ids = video_rental_copy_obj.search(cr,uid,[('name','=','copy_id')])
values={'state':'rented'}
video_rental_copy_obj.write(self, cr, uid, ids, values, context=None)
res=super(video_rental_rentals,self).create(cr,uid,vals)
return res
video_rental_rentals()
Здесь сообщается об ошибке:
TypeError: write () получила несколько значений для аргумента ключевого слова 'context'