summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-01-23 10:03:15 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-01-23 10:03:15 +0700
commit2a47fdafcb12440c68e346d35d465b0a0c800945 (patch)
tree4cf4b28477b46ab7080f7e1d222d515b6a1999ff
parent11a561355208a403d635b16d6c306cc9f19eb714 (diff)
push
-rwxr-xr-xindoteknik_custom/__manifest__.py1
-rwxr-xr-xindoteknik_custom/models/__init__.py1
-rw-r--r--indoteknik_custom/models/barcoding_product.py36
-rw-r--r--indoteknik_custom/models/stock_picking.py8
-rwxr-xr-xindoteknik_custom/security/ir.model.access.csv4
-rw-r--r--indoteknik_custom/views/barcoding_product.xml72
6 files changed, 116 insertions, 6 deletions
diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py
index 1ffe9419..67a41a08 100755
--- a/indoteknik_custom/__manifest__.py
+++ b/indoteknik_custom/__manifest__.py
@@ -151,6 +151,7 @@
'views/form_vendor_approval_multi_reject.xml',
'views/user_pengajuan_tempo.xml',
'views/stock_backorder_confirmation_views.xml',
+ 'views/barcoding_product.xml',
'report/report.xml',
'report/report_banner_banner.xml',
'report/report_banner_banner2.xml',
diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py
index 3990e81c..ed9e91da 100755
--- a/indoteknik_custom/models/__init__.py
+++ b/indoteknik_custom/models/__init__.py
@@ -139,3 +139,4 @@ from . import va_multi_approve
from . import va_multi_reject
from . import stock_immediate_transfer
from . import coretax_fatur
+from . import barcoding_product
diff --git a/indoteknik_custom/models/barcoding_product.py b/indoteknik_custom/models/barcoding_product.py
new file mode 100644
index 00000000..41444646
--- /dev/null
+++ b/indoteknik_custom/models/barcoding_product.py
@@ -0,0 +1,36 @@
+from odoo import models, api, fields
+from odoo.exceptions import AccessError, UserError, ValidationError
+from datetime import timedelta, date, datetime
+import logging
+
+_logger = logging.getLogger(__name__)
+
+class BarcodingProduct(models.Model):
+ _name = "barcoding.product"
+ _description = "Barcoding Product"
+
+ 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)
+
+ @api.onchange('product_id', 'quantity')
+ def _onchange_product_or_quantity(self):
+ """Update barcoding_product_line based on product_id and quantity"""
+ if self.product_id and self.quantity > 0:
+ # Clear existing lines
+ self.barcoding_product_line = [(5, 0, 0)]
+
+ # Add a new line with the current product and quantity
+ self.barcoding_product_line = [(0, 0, {
+ 'product_id': self.product_id.id,
+ 'barcoding_product_id': self.id,
+ }) for _ in range(int(self.quantity))]
+
+
+class BarcodingProductLine(models.Model):
+ _name = 'barcoding.product.line'
+ _description = 'Barcoding Product Line'
+ _order = 'barcoding_product_id, id'
+
+ barcoding_product_id = fields.Many2one('barcoding.product', string='Barcoding Product Ref', required=True, ondelete='cascade', index=True, copy=False)
+ product_id = fields.Many2one('product.product', string="Product") \ No newline at end of file
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py
index 4c19cb3a..cc86c451 100644
--- a/indoteknik_custom/models/stock_picking.py
+++ b/indoteknik_custom/models/stock_picking.py
@@ -1164,8 +1164,7 @@ class CheckProduct(models.Model):
if not moves:
raise UserError((
- "The product '%s' is not available in the related stock picking's moves. "
- "Please check and try again."
+ "The product '%s' tidak ada di operations. "
) % record.product_id.display_name)
total_qty_in_moves = sum(moves.mapped('product_uom_qty'))
@@ -1184,14 +1183,13 @@ class CheckProduct(models.Model):
if total_quantity > total_qty_in_moves:
raise UserError((
- "Quantity Product '%s' sudah melebihi quantity demand: (%s)."
+ "Quantity Product '%s' sudah melebihi quantity demand."
) % (record.product_id.display_name))
-
else:
# Check if the quantity exceeds the allowed total
if record.quantity > total_qty_in_moves:
raise UserError((
- "Quantity Product '%s' sudah melebihi quantity demand: (%s)."
+ "Quantity Product '%s' sudah melebihi quantity demand."
) % (record.product_id.display_name))
# Set the quantity to the entered value
diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv
index a26bce31..73877052 100755
--- a/indoteknik_custom/security/ir.model.access.csv
+++ b/indoteknik_custom/security/ir.model.access.csv
@@ -158,4 +158,6 @@ access_User_pengajuan_tempo_line,access.user.pengajuan.tempo.line,model_user_pen
access_user_pengajuan_tempo,access.user.pengajuan.tempo,model_user_pengajuan_tempo,,1,1,1,1
access_reject_reason_wizard,reject.reason.wizard,model_reject_reason_wizard,,1,1,1,0
access_confirm_approval_wizard,confirm.approval.wizard,model_confirm_approval_wizard,,1,1,1,0
-access_barcode_product,access.barcode.product,model_barcode_product,,1,1,1,1 \ No newline at end of file
+access_barcode_product,access.barcode.product,model_barcode_product,,1,1,1,1
+access_barcoding_product,access.barcoding.product,model_barcoding_product,,1,1,1,1
+access_barcoding_product_line,access.barcoding.product.line,model_barcoding_product_line,,1,1,1,1 \ No newline at end of file
diff --git a/indoteknik_custom/views/barcoding_product.xml b/indoteknik_custom/views/barcoding_product.xml
new file mode 100644
index 00000000..8df007f2
--- /dev/null
+++ b/indoteknik_custom/views/barcoding_product.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<odoo>
+ <data>
+ <record id="barcoding_product_tree" model="ir.ui.view">
+ <field name="name">barcoding.product.tree</field>
+ <field name="model">barcoding.product</field>
+ <field name="arch" type="xml">
+ <tree default_order="create_date desc">
+ <field name="product_id"/>
+ <field name="quantity"/>
+ </tree>
+ </field>
+ </record>
+
+ <record id="barcoding_product_line_tree" model="ir.ui.view">
+ <field name="name">barcoding.product.line.tree</field>
+ <field name="model">barcoding.product.line</field>
+ <field name="arch" type="xml">
+ <tree>
+ <field name="product_id"/>
+ </tree>
+ </field>
+ </record>
+
+ <record id="barcoding_product_form" model="ir.ui.view">
+ <field name="name">barcoding.product.form</field>
+ <field name="model">barcoding.product</field>
+ <field name="arch" type="xml">
+ <form >
+ <sheet>
+ <group>
+ <group>
+ <field name="product_id" required="1"/>
+ <field name="quantity" required="1"/>
+ </group>
+ </group>
+ <notebook>
+ <page string="Line">
+ <field name="barcoding_product_line"/>
+ </page>
+ </notebook>
+ </sheet>
+ </form>
+ </field>
+ </record>
+
+ <record id="barcoding_product_view_search" model="ir.ui.view">
+ <field name="name">barcoding.product.search.view</field>
+ <field name="model">barcoding.product</field>
+ <field name="arch" type="xml">
+ <search string="Search Barcoding Product">
+ <field name="product_id"/>
+ </search>
+ </field>
+ </record>
+
+ <record id="barcoding_product_action" model="ir.actions.act_window">
+ <field name="name">Barcoding Product</field>
+ <field name="type">ir.actions.act_window</field>
+ <field name="res_model">barcoding.product</field>
+ <field name="view_mode">tree,form</field>
+ </record>
+
+ <menuitem
+ id="menu_barcoding_product"
+ name="Barcoding Product"
+ parent="stock.menu_stock_warehouse_mgmt"
+ sequence="4"
+ action="barcoding_product_action"
+ />
+ </data>
+</odoo>