'product_uom_id' : fields.many2one('product.uom', 'UoM'),
'product_id' : fields.many2one('product.product', 'Product'),
'account_id' : fields.many2one('account.analytic.account', 'Analytic Account', required=True, ondelete='cascade', select=True),
- 'general_account_id' : fields.many2one('account.account', 'General account', required=True, ondelete='cascade'),
- 'move_id' : fields.many2one('account.move.line', 'General entry', ondelete='cascade', select=True),
- 'journal_id' : fields.many2one('account.analytic.journal', 'Analytic journal', required=True, ondelete='cascade', select=True),
+ 'general_account_id' : fields.many2one('account.account', 'General Account', required=True, ondelete='cascade'),
+ 'move_id' : fields.many2one('account.move.line', 'Move Line', ondelete='cascade', select=True),
+ 'journal_id' : fields.many2one('account.analytic.journal', 'Analytic Journal', required=True, ondelete='cascade', select=True),
'code' : fields.char('Code', size=8),
'user_id' : fields.many2one('res.users', 'User',),
'ref': fields.char('Ref.', size=32),
import time
from osv import fields
from osv import osv
+from osv.orm import except_orm
class hr_employee(osv.osv):
'date' : lambda self,cr,uid,ctx: ctx.get('date', time.strftime('%Y-%m-%d')),
'user_id' : lambda obj, cr, uid, ctx : ctx.get('user_id', uid),
}
-
+ def create(self, cr, uid, vals, context={}):
+ try:
+ res = super(hr_analytic_timesheet, self).create(cr, uid, vals, context)
+ return res
+ except Exception,e:
+ if 'journal_id' in e.args[0]:
+ raise except_orm(_('ValidateError'),
+ _('No analytic journal available for this employee.\nDefine an employee for the selected user and assign an analytic journal.'))
+ else:
+ raise
def on_change_user_id(self, cr, uid, ids, user_id):
if not user_id:
'product_uom_id' : self._getEmployeeUnit(cr, user_id, context= {}),
'general_account_id' :self. _getGeneralAccount(cr, user_id, context= {}),
'journal_id' : self._getAnalyticJournal(cr, user_id, context= {}),
- }}
-
-
-
+ }}
hr_analytic_timesheet()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: