def empowering_patch(self, cursor, uid, ids, data=None, context=None):
     polissa_f = ['name', 'etag']
     em = self.pool.get('empowering.api').service
     result = []
     for polissa in self.read(cursor, uid, ids, polissa_f, context=context):
         if not polissa['etag']:
             self.empowering_post(cursor, uid, [polissa['id']])
             continue
         amon_converter = AmonConverter(PoolWrapper(self.pool, cursor, uid))
         if not data:
             data = amon_converter.contract_to_amon(polissa['id'])[0]
         res = em.contract(polissa['name']).update(data, polissa['etag'])
         result.append(none_to_false(res))
         if check_response(res, data):
             self.write(cursor, uid, [polissa['id']], {'etag': res['_etag']})
     return result
Exemplo n.º 2
0
 def empowering_patch(self, cursor, uid, ids, data=None, context=None):
     polissa_f = ['name', 'etag']
     em = self.pool.get('empowering.api').service
     result = []
     for polissa in self.read(cursor, uid, ids, polissa_f, context=context):
         if not polissa['etag']:
             self.empowering_post(cursor, uid, [polissa['id']])
             continue
         amon_converter = AmonConverter(PoolWrapper(self.pool, cursor, uid))
         if not data:
             data = amon_converter.contract_to_amon(polissa['id'])[0]
         res = em.contract(polissa['name']).update(data, polissa['etag'])
         result.append(none_to_false(res))
         if check_response(res, data):
             self.write(cursor, uid, [polissa['id']],
                        {'etag': res['_etag']})
     return result
 def empowering_post(self, cursor, uid, ids, context=None):
     res = []
     amon_converter = AmonConverter(PoolWrapper(self.pool, cursor, uid))
     em = self.pool.get('empowering.api').service
     for pol in self.read(cursor, uid, ids, ['modcontractuals_ids', 'name']):
         first = True
         upd = []
         for modcon_id in reversed(pol['modcontractuals_ids']):
             amon_data = amon_converter.contract_to_amon(pol['id'], {
                 'modcon_id': modcon_id
             })[0]
             if first:
                 response = em.contracts().create(amon_data)
                 first = False
             else:
                 etag = upd[-1]['_etag']
                 response = em.contract(pol['name']).update(amon_data, etag)
             if check_response(response, amon_data):
                 upd.append(response)
         if upd:
             res.append(upd[-1])
             self.write(cursor, uid, [pol['id']], {'etag': upd[-1]['_etag']})
     return res
Exemplo n.º 4
0
 def empowering_post(self, cursor, uid, ids, context=None):
     res = []
     amon_converter = AmonConverter(PoolWrapper(self.pool, cursor, uid))
     em = self.pool.get('empowering.api').service
     for pol in self.read(cursor, uid, ids,
                          ['modcontractuals_ids', 'name']):
         first = True
         upd = []
         for modcon_id in reversed(pol['modcontractuals_ids']):
             amon_data = amon_converter.contract_to_amon(
                 pol['id'], {'modcon_id': modcon_id})[0]
             if first:
                 response = em.contracts().create(amon_data)
                 first = False
             else:
                 etag = upd[-1]['_etag']
                 response = em.contract(pol['name']).update(amon_data, etag)
             if check_response(response, amon_data):
                 upd.append(response)
         if upd:
             res.append(upd[-1])
             self.write(cursor, uid, [pol['id']],
                        {'etag': upd[-1]['_etag']})
     return res