@@ -21,7 +21,7 @@
|
||||
|
||||
|
||||
{
|
||||
"name" : "Accounting and financial management",
|
||||
"name" : "Accounting and Financial Management",
|
||||
"version" : "1.1",
|
||||
"depends" : ["product", "base", "process"],
|
||||
"author" : "Tiny",
|
||||
|
||||
+12
-5
@@ -51,19 +51,26 @@ def real_id2caldav_id(real_id, recurrent_date):
|
||||
return '%d-%s'%(real_id, recurrent_date)
|
||||
return real_id
|
||||
|
||||
def uid2openobjectid(cr, uidval, oomodel):
|
||||
def uid2openobjectid(cr, uidval, oomodel, rdate):
|
||||
__rege = re.compile(r'OpenObject-([\w|\.]+)_([0-9]+)@(\w+)$')
|
||||
wematch = __rege.match(uidval.encode('utf8'))
|
||||
if not wematch:
|
||||
return False
|
||||
return (False, None)
|
||||
else:
|
||||
model, id, dbname = wematch.groups()
|
||||
if (not model == oomodel) or (not dbname == cr.dbname):
|
||||
return False
|
||||
cr.execute('select distinct(id) from %s' % model.replace('.', '_'))
|
||||
return (False, None)
|
||||
qry = 'select distinct(id) from %s' % model.replace('.', '_')
|
||||
if rdate:
|
||||
qry += " where recurrent_id='%s'" % (rdate)
|
||||
cr.execute(qry)
|
||||
r_id = cr.fetchone()
|
||||
if r_id:
|
||||
return (id, r_id[0])
|
||||
cr.execute(qry)
|
||||
ids = map(lambda x: str(x[0]), cr.fetchall())
|
||||
if id in ids:
|
||||
return id
|
||||
return (id, None)
|
||||
return False
|
||||
|
||||
def openobjectid2uid(cr, uidval, oomodel):
|
||||
|
||||
@@ -194,13 +194,18 @@ rule or repeating pattern for anexception to a recurrence set"),
|
||||
vals = event_obj.import_ical(cr, uid, file_content)
|
||||
ids = []
|
||||
for val in vals:
|
||||
is_exists = common.uid2openobjectid(cr, val['id'], self._name)
|
||||
exists, r_id = common.uid2openobjectid(cr, val['id'], self._name, \
|
||||
val.get('recurrent_id'))
|
||||
if val.has_key('create_date'): val.pop('create_date')
|
||||
val['caldav_url'] = context.get('url') or ''
|
||||
val.pop('id')
|
||||
if is_exists:
|
||||
self.write(cr, uid, [is_exists], val)
|
||||
ids.append(is_exists)
|
||||
if exists and r_id:
|
||||
val.update({'recurrent_uid': exists})
|
||||
self.write(cr, uid, [r_id], val)
|
||||
ids.append(r_id)
|
||||
elif exists:
|
||||
self.write(cr, uid, [exists], val)
|
||||
ids.append(exists)
|
||||
else:
|
||||
case_id = self.create(cr, uid, val)
|
||||
ids.append(case_id)
|
||||
|
||||
@@ -114,7 +114,11 @@ class hr_employee(osv.osv):
|
||||
def attendance_action_change(self, cr, uid, ids, type='action', context={}, dt=False, *args):
|
||||
id = False
|
||||
warning_sign = 'sign'
|
||||
|
||||
|
||||
#Special case when button calls this method :type=context
|
||||
if isinstance(type,dict):
|
||||
type = type.get('type','action')
|
||||
|
||||
if type == 'sign_in':
|
||||
warning_sign = "Sign In"
|
||||
elif type == 'sign_out':
|
||||
@@ -125,7 +129,7 @@ class hr_employee(osv.osv):
|
||||
raise osv.except_osv(_('Warning'), _('You tried to %s with a date anterior to another event !\nTry to contact the administrator to correct attendances.')%(warning_sign,))
|
||||
|
||||
res = {'action' : type, 'employee_id' : emp['id']}
|
||||
|
||||
|
||||
if dt:
|
||||
res['name'] = dt
|
||||
|
||||
|
||||
@@ -99,8 +99,8 @@
|
||||
<field name="arch" type="xml">
|
||||
<field name="parent_id" position="after">
|
||||
<field name="state"/>
|
||||
<button name="sign_in" states="absent" string="Sign In" type="object" icon="gtk-go-back"/>
|
||||
<button name="sign_out" states="present" string="Sign Out" type="object" icon="gtk-go-forward"/>
|
||||
<button name="attendance_action_change" states="absent" string="Sign In" type="object" icon="gtk-go-back" context="{'type':'sign_in'}"/>
|
||||
<button name="attendance_action_change" states="present" string="Sign Out" type="object" icon="gtk-go-forward" context="{'type':'sign_out'}"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
Reference in New Issue
Block a user