diff options
| author | Mqdd <ahmadmiqdad27@gmail.com> | 2025-12-02 17:15:23 +0700 |
|---|---|---|
| committer | Mqdd <ahmadmiqdad27@gmail.com> | 2025-12-02 17:15:23 +0700 |
| commit | 860187e158fff35cc8f6bd5169583ff5ccd78ffa (patch) | |
| tree | 11106e4a2c007733a06776f7ceca6a8bd5cb5457 | |
| parent | 632684c20250e864122af1138bdf5c9ea81cafbb (diff) | |
<Miqdad> remove import action
| -rw-r--r-- | indoteknik_custom/models/find_page.py | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/indoteknik_custom/models/find_page.py b/indoteknik_custom/models/find_page.py index 3968caed..c31b8334 100644 --- a/indoteknik_custom/models/find_page.py +++ b/indoteknik_custom/models/find_page.py @@ -44,78 +44,6 @@ class FindPage(models.Model): category_id = fields.Many2one('product.public.category', string='Category', help='Bisa semua level Category') url = fields.Char(string='Url') - def action_import_excel(self): - if not self.excel_file: - raise UserError(_("⚠️ Harap upload file Excel terlebih dahulu.")) - - try: - data = base64.b64decode(self.excel_file) - book = xlrd.open_workbook(file_contents=data) - sheet = book.sheet_by_index(0) - except: - raise UserError(_("❌ Format Excel tidak valid atau rusak.")) - - header = [str(sheet.cell(0, col).value).strip() for col in range(sheet.ncols)] - required_headers = [ - 'category', - 'brand', - 'keyword', - 'url', - ] - - for req in required_headers: - if req not in header: - raise UserError(_("❌ Kolom '%s' tidak ditemukan di file Excel.") % req) - - header_map = {h: idx for idx, h in enumerate(header)} - lines_created = 0 - PublicCategory = self.env['product.public.category'] - url = self.url - keywords = self.keywords - brand = self.env['x_manufactures'] - - for row_idx in range(1, sheet.nrows): - row = sheet.row(row_idx) - def val(field): - return str(sheet.cell(row_idx, header_map[field]).value).strip() - - if not val('category'): - continue # skip kosong - - # Relations - brand = brand.search([('name', 'ilike', val('brand'))], limit=1) - - # Many2many: Categories - class_names = val('Categories').split(';') - class_ids = [] - for name in class_names: - name = name.strip() - if name: - pc = PublicCategory.search([('name', 'ilike', name)], limit=1) - if pc: - class_ids.append(pc.id) - - # Build values - vals = { - 'brand_id': val('brand'), - 'keywords': val('keywords'), - 'url': val('url'), - 'category_id': val('category') - } - - lines_created += 1 - - return { - 'type': 'ir.actions.client', - 'tag': 'display_notification', - 'params': { - 'title': _('✅ Import Selesai'), - 'message': _('%s baris berhasil diimport.') % lines_created, - 'type': 'success', - 'sticky': False, - } - } - def _sync_to_solr(self, limit=10000): urls = self.env['web.find.page'].search([]) documents = [] |
