如何计算 Odoo 8 中的 'number of time a field is edited or updated'?
How to count the 'number of time a field is edited or updated' in Odoo 8?
我想统计一个字段在一个表单中被编辑了多少次,该计数应该传递给同一个表单中另一个名为 'Number of Edits' 的字段。
此代码工作正常..
def write(self, cr, uid, ids, vals, context=None):
quotation_obj=self.browse(cr, uid, ids,context=context)
if partner_id:
count = quotation_obj.number_of_edits + 1
vals.update({'number_of_edits': count})
return super(sale_order, self).write(cr, uid, ids, vals, context=context)
这是完整的代码
def write(self, cr, uid, ids, vals, context=None):
partner_id=vals.get('partner_id')
quotation_obj=self.browse(cr, uid, ids,context=context)
if not partner_id:
#if partner id not found, find the employee ids
emp_ids=vals.get('employee_ids')
if emp_ids:
# for line in emp_ids:
# employee_ids=line[2]
# else:#update the employee ids
# employee_ids=quotation_obj.employee_ids
for line in emp_ids:
self.pool.get('res.partner').write(cr, uid, quotation_obj.partner_id.id, {'employee_ids': [(4, line[2])]}, context=context)
if partner_id:
emp_ids=vals.get('employee_ids')
if emp_ids:
for line in emp_ids:
self.pool.get('res.partner').write(cr, uid, partner_id, {'employee_ids': [(4, line[2])]}, context=context)
if partner_id:
count = quotation_obj.number_of_edits + 1
vals.update({'number_of_edits': count})
return super(sale_order, self).write(cr, uid, ids, vals, context=context)
我想统计一个字段在一个表单中被编辑了多少次,该计数应该传递给同一个表单中另一个名为 'Number of Edits' 的字段。
此代码工作正常..
def write(self, cr, uid, ids, vals, context=None):
quotation_obj=self.browse(cr, uid, ids,context=context)
if partner_id:
count = quotation_obj.number_of_edits + 1
vals.update({'number_of_edits': count})
return super(sale_order, self).write(cr, uid, ids, vals, context=context)
这是完整的代码
def write(self, cr, uid, ids, vals, context=None):
partner_id=vals.get('partner_id')
quotation_obj=self.browse(cr, uid, ids,context=context)
if not partner_id:
#if partner id not found, find the employee ids
emp_ids=vals.get('employee_ids')
if emp_ids:
# for line in emp_ids:
# employee_ids=line[2]
# else:#update the employee ids
# employee_ids=quotation_obj.employee_ids
for line in emp_ids:
self.pool.get('res.partner').write(cr, uid, quotation_obj.partner_id.id, {'employee_ids': [(4, line[2])]}, context=context)
if partner_id:
emp_ids=vals.get('employee_ids')
if emp_ids:
for line in emp_ids:
self.pool.get('res.partner').write(cr, uid, partner_id, {'employee_ids': [(4, line[2])]}, context=context)
if partner_id:
count = quotation_obj.number_of_edits + 1
vals.update({'number_of_edits': count})
return super(sale_order, self).write(cr, uid, ids, vals, context=context)