def build_external_ref(self, cr, uid, id, context=None): if isinstance(id,list): id = id[0] output_file = TemporaryFile('w+b') fieldnames = self._prepare_external_referential_fieldnames(cr, uid, context=context) csv = FileCsvWriter(output_file, fieldnames, encoding="utf-8", writeheader=True, delimiter=',', quotechar='"') referential = self.browse(cr, uid, id, context=context) row = self._prepare_external_referential_vals(cr, uid, referential, context=context) csv.writerow(row) return self.pool.get('pop.up.file').open_output_file(cr, uid, 'external.referential.csv', output_file, 'Referential Type Export', context=context)
def create_mapping_file(self, cr, uid, id, context=None): if isinstance(id,list): id = id[0] output_file = TemporaryFile('w+b') fieldnames = self.pool.get('external.referential')._prepare_mappingline_fieldnames(cr, uid, context=context) csv = FileCsvWriter(output_file, fieldnames, encoding="utf-8", writeheader=True, delimiter=',', quotechar='"') mapping = self.browse(cr, uid, id, context=context) for line in mapping.mapping_ids: row =self.pool.get('external.referential')._prepare_mappingline_template_vals(cr, uid, line, context=context) csv.writerow(row) return self.pool.get('pop.up.file').open_output_file(cr, uid, 'external.mappinglines.template.csv', output_file, 'Mapping Line Export', context=context)
def build_external_ref_categ(self, cr, uid, id, context=None): if isinstance(id, list): id = id[0] output_file = TemporaryFile("w+b") fieldnames = ["id", "name"] csv = FileCsvWriter(output_file, fieldnames, encoding="utf-8", writeheader=True, delimiter=",", quotechar='"') referential = self.browse(cr, uid, id, context=context) row = {"id": referential.type_id.categ_id.name, "name": referential.type_id.categ_id.name} csv.writerow(row) return self.pool.get("pop.up.file").open_output_file( cr, uid, "external.referential.category.csv", output_file, "Referential category export", context=context )
def build_external_ref_categ(self, cr, uid, id, context=None): if isinstance(id,list): id = id[0] output_file = TemporaryFile('w+b') fieldnames = ['id', 'name'] csv = FileCsvWriter(output_file, fieldnames, encoding="utf-8", writeheader=True, delimiter=',', quotechar='"') referential = self.browse(cr, uid, id, context=context) row = { 'id': referential.type_id.categ_id.name, 'name': referential.type_id.categ_id.name, } csv.writerow(row) return self.pool.get('pop.up.file').open_output_file(cr, uid, 'external.referential.category.csv', output_file, 'Referential category export', context=context)
def build_external_mapping_template(self, cr, uid, id, context=None): if isinstance(id, list): id = id[0] output_file = TemporaryFile("w+b") fieldnames = self._prepare_mapping_fieldnames(cr, uid, context=context) csv = FileCsvWriter(output_file, fieldnames, encoding="utf-8", writeheader=True, delimiter=",", quotechar='"') referential = self.browse(cr, uid, id, context=context) for mapping in referential.mapping_ids: row = self._prepare_mapping_template_vals(cr, uid, mapping, context=context) csv.writerow(row) return self.pool.get("pop.up.file").open_output_file( cr, uid, "external.mapping.template.csv", output_file, "Mapping Template Export", context=context )