콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
5276 화면
  1. class awb_sss_table(osv.osv):
  2.     _name = 'awb.sss.table'
  3.     _description = 'SSS Contribution Table'
  4.     _columns = {
  5.                 'min_range': fields.float('Minimum Range', help = "minimum range of salary", readonly=True),
  6.                 'max_range': fields.float('Maximum Range', help = "maximum range of salary", readonly=True),
  7.                 'total_contribution': fields.float('Total Contribution', help = "total contribution of employee depending on salary", readonly=True)
  8.                }
  9.     def create_sss(self, cr, uid, vals, context=None):
  10.         vals = []
  11.         sss_model = self.pool.get('awb.sss.table')
  12.         
  13.         sss_model.create(cr, uid, {'min_range': 1000.0, 'max_range': 1249.99, 'total_contribution': 120.0}, context=context)
  14. awb_sss_table()

 

there's no error but the data is not saved in my custom model. please help thanks

아바타
취소

"sss_model = self.pool.get('awb.sss.table')" is also unnecessary, since you're already in the awb.sss.table object. Rather than doing sss_model.create(), you can just do self.create(). Why are you adding a static set of defaults? You might as well just set _defaults={'min_range':1000,'max_range':1249.99,'total_contribution':120} and ignore the create_sss() function entirely.

베스트 답변

Hi Paolo, the problem is you need to return the control to standard create method of your object.

def create_sss(self, cr, uid, vals, context=None):
       vals = []
       sss_model = self.pool.get('awb.sss.table')
       return super(awb_sss_table,self).create(cr, uid, {'min_range': 1000.0, 'max_range': 1249.99, 'total_contribution': 120.0}, context=context)

 

아바타
취소

super() is not necessary because the function is named create_sss(). If the function was named create() because you wanted to add some additional processing before or after the actual record creation.

관련 게시물 답글 화면 활동
0
4월 24
2105
0
12월 19
4825
5
12월 19
3872
0
8월 19
4
5
8월 19
2942