From dd0158651c5fa665cde6c534e7f4283f86adafc9 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 3 Feb 2025 14:46:38 +0700 Subject: add type on barcoding product --- indoteknik_custom/models/barcoding_product.py | 8 ++++++++ indoteknik_custom/views/barcoding_product.xml | 7 +++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/indoteknik_custom/models/barcoding_product.py b/indoteknik_custom/models/barcoding_product.py index 6bbf9fde..e1b8f41f 100644 --- a/indoteknik_custom/models/barcoding_product.py +++ b/indoteknik_custom/models/barcoding_product.py @@ -12,6 +12,14 @@ class BarcodingProduct(models.Model): barcoding_product_line = fields.One2many('barcoding.product.line', 'barcoding_product_id', string='Barcoding Product Lines', auto_join=True) product_id = fields.Many2one('product.product', string="Product", tracking=3) quantity = fields.Float(string="Quantity", tracking=3) + type = fields.Selection([('print', 'Print Barcode'), ('barcoding', 'Add Barcode To Product')], string='Type', default='print') + barcode = fields.Char(string="Barcode") + + @api.constrains('barcode') + def _send_barcode_to_product(self): + for record in self: + if record.barcode and not record.product_id.barcode: + record.product_id.barcode = record.barcode @api.onchange('product_id', 'quantity') def _onchange_product_or_quantity(self): diff --git a/indoteknik_custom/views/barcoding_product.xml b/indoteknik_custom/views/barcoding_product.xml index 566655ff..c7473d39 100644 --- a/indoteknik_custom/views/barcoding_product.xml +++ b/indoteknik_custom/views/barcoding_product.xml @@ -8,6 +8,7 @@ + @@ -32,11 +33,13 @@ - + + + - + -- cgit v1.2.3