コード例 #1
0
 def _finalize_data_to_load(self, fields, data):
     # clear up attachment and committee data. will and them after create pr
     clear_up_fields = [
         'attachment_ids',
         'committee_ids'
     ]
     for clear_up_field in clear_up_fields:
         if clear_up_field in fields:
             i = fields.index(clear_up_field)
             del fields[i]
             del data[i]
     if 'line_ids' in fields:
         line_ids_index = []
         datas = []
         arrange_dat = []
         dat_tuple = ()
         is_first = True
         for line in data[fields.index('line_ids')]:
             if is_first:
                 i = fields.index('line_ids')
                 del fields[i]
                 del data[i]
                 fields += ['line_ids/' + key for key in line.keys()]
                 # collect child key index
                 for key in line.keys():
                     found_idx = fields.index('line_ids/' + key)
                     if found_idx:
                         line_ids_index.append(found_idx)
             datas += [tuple(data + line.values())]
             is_first = False
         # clear header data in line row
         is_first = True
         for line_dat in enumerate(datas):
             if is_first:
                 is_first = False
                 arrange_dat.append(line_dat[1])
                 continue
             for col_dat in enumerate(line_dat[1]):
                 if col_dat[0] not in line_ids_index:
                     dat_tuple += (u'',)
                 else:
                     dat_tuple += (col_dat[1],)
             arrange_dat.append(dat_tuple)
             dat_tuple = ()
         return fields, arrange_dat
     else:
         return fields, [tuple(data)]   # one line sales order
コード例 #2
0
 def _add_line_data(self, fields, data):
     if 'line_ids/fund_id.id' not in fields:
         new_data = []
         for data_line in data:
             data_line = data_line + (u'NSTDA', )
             new_data.append(data_line)
         fields.append('line_ids/fund_id')
         return fields, new_data
     else:
         fund = self.env.ref('base.fund_nstda')  # NSTDA Fund
         fund_idx = fields.index('line_ids/fund_id.id')
         new_data = []
         for data_line in data:
             if not data_line[fund_idx]:
                 lst = list(data_line)
                 lst[fund_idx] = fund.id
                 data_line = tuple(lst)
             new_data.append(data_line)
         return fields, new_data
コード例 #3
0
ファイル: purchase_request.py プロジェクト: pabi2/pb2_pabi
 def _add_line_data(self, fields, data):
     if 'line_ids/fund_id.id' not in fields:
         new_data = []
         for data_line in data:
             data_line = data_line + (u'NSTDA',)
             new_data.append(data_line)
         fields.append('line_ids/fund_id')
         return fields, new_data
     else:
         fund = self.env.ref('base.fund_nstda')  # NSTDA Fund
         fund_idx = fields.index('line_ids/fund_id.id')
         new_data = []
         for data_line in data:
             if not data_line[fund_idx]:
                 lst = list(data_line)
                 lst[fund_idx] = fund.id
                 data_line = tuple(lst)
             new_data.append(data_line)
         return fields, new_data