diff options
| author | Mqdd <ahmadmiqdad27@gmail.com> | 2025-11-20 17:04:21 +0700 |
|---|---|---|
| committer | Mqdd <ahmadmiqdad27@gmail.com> | 2025-11-20 17:04:21 +0700 |
| commit | be5bd2bd1d772e148f20e6a75a05a0ac07cfe285 (patch) | |
| tree | 5e756668581d15f8d3df6fea107aed5b44584e62 | |
| parent | 8c2a2f3c767f40af23d6ae749d604f55acf6c924 (diff) | |
tempcrm_mqdd
| -rw-r--r-- | indoteknik_custom/models/sourcing_job_order.py | 38 | ||||
| -rwxr-xr-x | indoteknik_custom/security/ir.model.access.csv | 1 | ||||
| -rw-r--r-- | indoteknik_custom/views/sourcing.xml | 27 |
3 files changed, 65 insertions, 1 deletions
diff --git a/indoteknik_custom/models/sourcing_job_order.py b/indoteknik_custom/models/sourcing_job_order.py index b65d45bf..d50256b4 100644 --- a/indoteknik_custom/models/sourcing_job_order.py +++ b/indoteknik_custom/models/sourcing_job_order.py @@ -118,6 +118,16 @@ class SourcingJobOrder(models.Model): now_jakarta = datetime.now(jakarta_tz) return now_jakarta.date() + def action_open_download_template(self): + wizard = self.env['sourcing.job.order.line.template.wizard'].create({}) + return { + 'type': 'ir.actions.act_window', + 'res_model': 'sourcing.job.order.line.template.wizard', + 'view_mode': 'form', + 'res_id': wizard.id, # ✅ ini WAJIB supaya file bisa didownload + 'target': 'new', + } + @api.depends('eta_sales', 'eta_complete', 'create_date', 'state') def _compute_progress_status(self): for rec in self: @@ -1111,7 +1121,7 @@ class SourcingJobOrderLineImportWizard(models.TransientModel): # Relations tax = Tax.search([('name', 'ilike', val('Tax'))], limit=1) - vendor = Vendor.search([('name', '=', val('Vendor'))], limit=1) + vendor = Vendor.search([('name', 'ilike', val('Vendor'))], limit=1) category = Category.search([('name', 'ilike', val('Product Category'))], limit=1) # Many2many: Categories @@ -1223,3 +1233,29 @@ class SourcingJobOrderLineExportWizard(models.TransientModel): 'target': 'new', } + +class SourcingJobOrderLineTemplateWizard(models.TransientModel): + _name = 'sourcing.job.order.line.template.wizard' + _description = 'Download Template SJO Line' + + file = fields.Binary("File", readonly=True) + filename = fields.Char("Filename", readonly=True) + + def action_generate_template(self): + res = super().default_get(fields) + output = io.BytesIO() + wb = xlwt.Workbook() + ws = wb.add_sheet('Template') + + headers = ['Nama Barang', 'SKU', 'Expected Price'] + for idx, header in enumerate(headers): + ws.write(0, idx, header) + + wb.save(output) + output.seek(0) + + res.update({ + 'file': base64.b64encode(output.read()), + 'filename': 'sjo_template.xls', + }) + return res
\ No newline at end of file diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv index 04e3c2e3..64c8954a 100755 --- a/indoteknik_custom/security/ir.model.access.csv +++ b/indoteknik_custom/security/ir.model.access.csv @@ -218,5 +218,6 @@ access_sourcing_job_order_line_user,sourcing.job.order.line,model_sourcing_job_o access_sourcing_reject_wizard,sourcing.reject.wizard,model_sourcing_reject_wizard,base.group_user,1,1,1,1 access_sourcing_job_order_line_import_wizard,sourcing.job.order.line.import.wizard,model_sourcing_job_order_line_import_wizard,base.group_user,1,1,1,1 access_sourcing_job_order_line_export_wizard,sourcing.job.order.line.export.wizard,model_sourcing_job_order_line_export_wizard,base.group_user,1,1,1,1 +access_sourcing_job_order_line_template_wizard,sourcing.job.order.line.template.wizard,model_sourcing_job_order_line_template_wizard,base.group_user,1,1,1,1 access_wizard_export_sjo_to_so,wizard.export.sjo.to.so,model_wizard_export_sjo_to_so,base.group_user,1,1,1,1 access_stock_picking_sj_document,stock.picking.sj.document,model_stock_picking_sj_document,base.group_user,1,1,1,1 diff --git a/indoteknik_custom/views/sourcing.xml b/indoteknik_custom/views/sourcing.xml index ac952ae3..48400ff7 100644 --- a/indoteknik_custom/views/sourcing.xml +++ b/indoteknik_custom/views/sourcing.xml @@ -102,6 +102,31 @@ <field name="target">new</field> </record> +<record id="view_sjo_line_template_wizard_form" model="ir.ui.view"> + <field name="name">sjo.line.template.wizard.form</field> + <field name="model">sourcing.job.order.line.template.wizard</field> + <field name="arch" type="xml"> + <form string="Download Template Excel"> + <group> + <p> + Klik tombol di bawah untuk download file template import. + </p> + <field name="file" filename="filename" widget="binary" readonly="1"/> + </group> + <footer> + <button string="Close" class="btn-secondary" special="cancel"/> + </footer> + </form> + </field> +</record> + + +<record id="action_sjo_line_template_wizard" model="ir.actions.act_window"> + <field name="name">Download Template</field> + <field name="res_model">sourcing.job.order.line.template.wizard</field> + <field name="view_mode">form</field> + <field name="target">new</field> +</record> <record id="view_wizard_export_sjo_to_so_form" model="ir.ui.view"> <field name="name">wizard.export.sjo.to.so.form</field> @@ -269,6 +294,8 @@ decoration-success="'🟢' in progress_status" decoration-danger="'🔴' in progress_status" decoration-muted="'⚫' in progress_status"/> +<button name="%(action_sjo_line_template_wizard)d" string="Download Template" type="action" class="btn-secondary"/> + </group> </group> |
