Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
701 Weergaven
class ProdTable(models.Model):
_name = 'az.prod.table'
_description = 'Production Order'

prod_id = fields.Char(string='Prod ID', readonly=True)
item_id = fields.Char(string='Item ID', readonly=True)
item_name = fields.Char(string='Item Name', readonly=True)
segment_num = fields.Char(string='Segment Number', readonly=True)
delivery_date = fields.Date(string='Delivery Date', readonly=True)
quantity = fields.Float(string='Quantity', readonly=True)
prod_pool = fields.Char(string='Pool', readonly=True)
invent_unit = fields.Char(string='Inventory Unit', readonly=True)
_logger = logging.getLogger(__name__)
class QrItem(models.Model):
_name = 'az.qr.item'
_description = 'QR Item'

prod_table_id = fields.Many2one('az.prod.table', string='Production Order')
prod_id = fields.Char(string='Prod ID')
item_id = fields.Char(string='Item ID')
license_plate = fields.Char(string='License Plate' )
invent_batch = fields.Char(string='Inventory Batch' )
# invent_status = fields.Char(string='Inventory Status')
invent_status = fields.Selection(selection ='_get_invent_status',string ='Inventory Status')
invent_serial = fields.Char(string='Serial Number')
qr_item_id = fields.Char(string='QR Id', readonly=True )
invent_unit = fields.Char(string='Inventory Unit', readonly=True)
unit_length = fields.Char(string='Unit Length')
length = fields.Float(string='Length')
invent_qty = fields.Float(string='Inventory Quantity', readonly=True)
// qrweaving/static/src/js/delete_confirmation.js
odoo.define('qrweaving.delete_confirmation', function (require) {
'use strict';

const ListController = require('web.ListController');
const Dialog = require('web.Dialog');
const ListView = require('web.ListView');
const viewRegistry = require('web.view_registry');

const DeleteConfirmationListController = ListController.extend({
events: _.extend({}, ListController.prototype.events, {
'click .o_delete_button': '_onDeleteButtonClicked',
}),

/**
* Event handler untuk tombol delete.
* Menampilkan dialog konfirmasi sebelum menghapus record.
*/
async _onDeleteButtonClicked(event) {
event.preventDefault();
event.stopPropagation();

const self = this;
const $button = $(event.currentTarget);
const $row = $button.closest('tr');
const recordId = $row.data('id');

// Mendapatkan record dari model
const record = this.model.get(recordId);

// Menampilkan dialog konfirmasi
const confirmed = await new Promise((resolve) => {
Dialog.confirm(this, "Are you sure you want to delete this record?", {
confirm_callback: () => resolve(true),
cancel_callback: () => resolve(false),
});
});

if (confirmed) {
try {
await this._rpc({
model: record.model,
method: 'unlink',
args: [[record.id]],
});
// Memuat ulang view setelah penghapusan
this.reload();
} catch (error) {
Dialog.alert(this, error.message || "An error occurred while deleting the record.");
}
}
},
});

// Extend ListView untuk menggunakan controller kustom
ListView.include({
config: _.extend({}, ListView.prototype.config, {
Controller: DeleteConfirmationListController,
}),
});
});
_onDeleteButtonClicked not working in my odoo 16 ??
Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
0
mrt. 25
272
0
feb. 25
489
1
dec. 24
2296
2
nov. 24
862
1
okt. 24
1469