diff --git a/jikimo_frontend/__manifest__.py b/jikimo_frontend/__manifest__.py
index 65a11379..c3598323 100644
--- a/jikimo_frontend/__manifest__.py
+++ b/jikimo_frontend/__manifest__.py
@@ -10,9 +10,9 @@
""",
'category': 'sf',
'website': 'https://www.sf.jikimo.com',
- 'depends': ['web', 'purchase'],
+ 'depends': ['web', 'purchase', 'base_setup'],
'data': [
-
+ 'views/bye_odoo.xml',
],
'demo': [
],
@@ -23,6 +23,8 @@
'web.assets_backend': [
'jikimo_frontend/static/src/fields/custom_many2many_checkboxes/*',
'jikimo_frontend/static/src/fields/Many2OneRadioField/*',
+ # 移除odoo相关标识
+ 'jikimo_frontend/static/src/bye_odoo/*',
'jikimo_frontend/static/src/scss/custom_style.scss',
# 'jikimo_frontend/static/src/views/list_nums/list_nbCols.js',
'jikimo_frontend/static/src/views/list_nums/list_nums.xml',
diff --git a/jikimo_frontend/data/demo_data.xml b/jikimo_frontend/data/demo_data.xml
new file mode 100644
index 00000000..3c388606
--- /dev/null
+++ b/jikimo_frontend/data/demo_data.xml
@@ -0,0 +1,23 @@
+
+
+
+
+ JKM
+ B-25
+ USA
+
+
+ 1229
+ +8801-712901764
+ info@kolpolok.com
+ www.kolpoloktechnologies.com
+
+
+
+ Custom
+
+
+
+
+
+
diff --git a/jikimo_frontend/static/src/bye_odoo/extended_user_menu.js b/jikimo_frontend/static/src/bye_odoo/extended_user_menu.js
new file mode 100644
index 00000000..bac689f1
--- /dev/null
+++ b/jikimo_frontend/static/src/bye_odoo/extended_user_menu.js
@@ -0,0 +1,16 @@
+/** @odoo-module **/
+import { UserMenu } from "@web/webclient/user_menu/user_menu";
+import { patch } from "@web/core/utils/patch";
+import { registry } from "@web/core/registry";
+const userMenuRegistry = registry.category("user_menuitems");
+
+
+patch(UserMenu.prototype, "legion_hide_odoo.UserMenu", {
+ setup() {
+ this._super.apply(this, arguments);
+ userMenuRegistry.remove("documentation");
+ userMenuRegistry.remove("support");
+ userMenuRegistry.remove("odoo_account");
+ },
+
+});
diff --git a/jikimo_frontend/static/src/bye_odoo/favicon.js b/jikimo_frontend/static/src/bye_odoo/favicon.js
new file mode 100644
index 00000000..9ef4f4da
--- /dev/null
+++ b/jikimo_frontend/static/src/bye_odoo/favicon.js
@@ -0,0 +1,11 @@
+/** @odoo-module **/
+
+import { WebClient } from "@web/webclient/webclient";
+import { patch } from "web.utils";
+
+patch(WebClient.prototype, "kolpolok_custom_title_and_favicon.WebClient", {
+ setup() {
+ this._super();
+ this.title.setParts({ zopenerp: "JIKIMO" });
+ },
+});
\ No newline at end of file
diff --git a/jikimo_frontend/static/src/img/favicon.ico b/jikimo_frontend/static/src/img/favicon.ico
new file mode 100644
index 00000000..95c0fba1
Binary files /dev/null and b/jikimo_frontend/static/src/img/favicon.ico differ
diff --git a/jikimo_frontend/static/src/img/jikimo-logo.ico b/jikimo_frontend/static/src/img/jikimo-logo.ico
new file mode 100644
index 00000000..b5bf7cd7
Binary files /dev/null and b/jikimo_frontend/static/src/img/jikimo-logo.ico differ
diff --git a/jikimo_frontend/static/src/img/jikimo.ico b/jikimo_frontend/static/src/img/jikimo.ico
new file mode 100644
index 00000000..69e69db9
Binary files /dev/null and b/jikimo_frontend/static/src/img/jikimo.ico differ
diff --git a/jikimo_frontend/views/bye_odoo.xml b/jikimo_frontend/views/bye_odoo.xml
new file mode 100644
index 00000000..0930f551
--- /dev/null
+++ b/jikimo_frontend/views/bye_odoo.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ jikimo.res.config.settings.view.form.inherit.base.setup
+ res.config.settings
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sf_base/__manifest__.py b/sf_base/__manifest__.py
index 59ad967a..ceedcdd0 100644
--- a/sf_base/__manifest__.py
+++ b/sf_base/__manifest__.py
@@ -24,6 +24,7 @@
'views/tool_menu.xml',
'views/menu_fixture_view.xml',
'views/change_base_view.xml',
+ 'views/Printer.xml',
],
'demo': [
diff --git a/sf_base/commons/Printer.py b/sf_base/commons/Printer.py
new file mode 100644
index 00000000..563d9dea
--- /dev/null
+++ b/sf_base/commons/Printer.py
@@ -0,0 +1,28 @@
+from odoo import models, fields
+
+
+class Printer(models.Model):
+ _name = 'printer'
+ _description = 'Printer'
+
+ name = fields.Char(string='名称', required=True)
+ ip_address = fields.Char(string='IP 地址', required=True)
+ port = fields.Integer(string='端口', default=9100)
+
+
+class TableStyle(models.Model):
+ _name = 'table.style'
+ _description = '标签样式'
+
+ name = fields.Char(string='名称', required=True)
+ # todo
+
+
+class PrinterConfiguration(models.Model):
+ _name = 'printer.configuration'
+ _description = 'Printer Configuration'
+
+ name = fields.Char(string='名称', required=True)
+ printer_id = fields.Many2one('printer', string='打印机')
+ model = fields.Many2one('ir.model', string='模型名称')
+# # 其他相关字段...
diff --git a/sf_base/commons/__init__.py b/sf_base/commons/__init__.py
index e4193cf0..63b820e7 100644
--- a/sf_base/commons/__init__.py
+++ b/sf_base/commons/__init__.py
@@ -1 +1,2 @@
from . import common
+from . import Printer
diff --git a/sf_base/commons/common.py b/sf_base/commons/common.py
index b423e160..9f359c9c 100644
--- a/sf_base/commons/common.py
+++ b/sf_base/commons/common.py
@@ -2,7 +2,7 @@
import time, datetime
import hashlib
from odoo import models
-
+import socket
class Common(models.Model):
_name = 'sf.sync.common'
@@ -29,3 +29,66 @@ class Common(models.Model):
d = dt + datetime.timedelta(hours=8)
nTime = d.strftime("%Y-%m-%d %H:%M:%S")
return nTime
+
+
+class PrintingUtils(models.AbstractModel):
+ _name = 'printing.utils'
+ _description = 'Utility class for printing functionalities'
+
+ def generate_zpl_code(self, code):
+ # 实现生成ZPL代码的逻辑
+ # 初始化ZPL代码字符串
+ zpl_code = "^XA\n"
+ zpl_code += "^CW1,E:SIMSUN.TTF^FS\n"
+ zpl_code += "^CI28\n"
+
+ # 设置二维码位置
+ zpl_code += "^FO50,50\n" # 调整二维码位置,使其与资产编号在同一行
+ zpl_code += f"^BQN,2,6^FDLM,B0093{code}^FS\n"
+
+ # 设置资产编号文本位置
+ zpl_code += "^FO300,60\n" # 资产编号文本的位置,与二维码在同一行
+ zpl_code += "^A1N,45,45^FD编码名称: ^FS\n"
+
+ # 设置{code}文本位置
+ # 假设{code}文本需要位于资产编号和二维码下方,中间位置
+ # 设置{code}文本位置并启用自动换行
+ zpl_code += "^FO300,120\n" # {code}文本的起始位置
+ zpl_code += "^FB400,4,0,L,0\n" # 定义一个宽度为500点的文本框,最多4行,左对齐
+ zpl_code += f"^A1N,40,40^FD{code}^FS\n"
+
+ # 在{code}文本框周围绘制线框
+ # 假设线框的外部尺寸为宽度500点,高度200点
+ # zpl_code += "^FO300,110^GB500,200,2^FS\n" # 绘制线框,边框粗细为2点
+
+ zpl_code += "^PQ1,0,1,Y\n"
+ zpl_code += "^XZ\n"
+ return zpl_code
+
+ def send_to_printer(self, host, port, zpl_code):
+
+ # 实现发送ZPL代码到打印机的逻辑
+ # 将ZPL代码转换为字节串
+ print('zpl_code', zpl_code)
+ zpl_bytes = zpl_code.encode('utf-8')
+ print(zpl_bytes)
+
+ # 创建socket对象
+ mysocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ try:
+ mysocket.connect((host, port)) # 连接到打印机
+ mysocket.send(zpl_bytes) # 发送ZPL代码
+ print("ZPL code sent to printer successfully.")
+ except Exception as e:
+ print(f"Error with the connection: {e}")
+ finally:
+ mysocket.close() # 关闭连接
+
+ def print_qr_code(self, lot_name, host, port):
+ # 实现打印二维码的逻辑
+ # 这里需要传入 lot_name 参数,因为我们不能直接访问 self.lot_id.name
+ zpl_code = self.generate_zpl_code(lot_name)
+ # 发送ZPL代码到打印机
+ # host = "192.168.50.110" # 可以作为参数传入,或者在此配置
+ # port = 9100 # 可以作为参数传入,或者在此配置
+ self.send_to_printer(host, port, zpl_code)
diff --git a/sf_base/security/ir.model.access.csv b/sf_base/security/ir.model.access.csv
index 92bebe5b..4eaddff0 100644
--- a/sf_base/security/ir.model.access.csv
+++ b/sf_base/security/ir.model.access.csv
@@ -188,3 +188,7 @@ access_sf_machine_brand_tags_group_sale_director,sf_machine_brand_tags_group_sal
access_sf_machine_brand_tags_group_plan_director,sf_machine_brand_tags_group_plan_director,model_sf_machine_brand_tags,sf_base.group_plan_director,1,0,0,0
access_sf_machine_brand_tags_group_purchase,sf_machine_brand_tags_group_purchase,model_sf_machine_brand_tags,sf_base.group_purchase,1,0,0,0
access_sf_machine_brand_tags_group_purchase_director,sf_machine_brand_tags_group_purchase_director,model_sf_machine_brand_tags,sf_base.group_purchase_director,1,0,0,0
+
+
+access_printer,printer,model_printer,base.group_user,1,1,1,1
+access_printer_configuration,printer.configuration,model_printer_configuration,base.group_user,1,1,1,1
\ No newline at end of file
diff --git a/sf_base/views/Printer.xml b/sf_base/views/Printer.xml
new file mode 100644
index 00000000..0e199b32
--- /dev/null
+++ b/sf_base/views/Printer.xml
@@ -0,0 +1,112 @@
+
+
+
+
+ printer.tree
+ printer
+
+
+
+
+
+
+
+
+
+
+
+ printer.form
+ printer
+
+
+
+
+
+
+ printer.configuration.tree
+ printer.configuration
+
+
+
+
+
+
+
+
+
+
+
+ printer.configuration.form
+ printer.configuration
+
+
+
+
+
+
+
+
+ 打印机
+ printer
+ tree,form
+
+
+
+
+ 打印配置
+ printer.configuration
+ tree,form
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sf_manufacturing/models/stock.py b/sf_manufacturing/models/stock.py
index 9cfcffc5..3166441a 100644
--- a/sf_manufacturing/models/stock.py
+++ b/sf_manufacturing/models/stock.py
@@ -219,7 +219,8 @@ class StockRule(models.Model):
class ProductionLot(models.Model):
- _inherit = 'stock.lot'
+ _name = 'stock.lot'
+ _inherit = ['stock.lot', 'printing.utils']
@api.model
def generate_lot_names1(self, display_name, first_lot, count):
@@ -307,36 +308,53 @@ class ProductionLot(models.Model):
record.qr_code_image = encoded_image
- def print_qr_code(self):
- self.ensure_one() # 确保这个方法只为一个记录调用
- # if not self.lot_id:
- # raise UserError("没有找到序列号。")
- # 假设_lot_qr_code方法已经生成了二维码并保存在字段中
+ def print_single_method(self):
+
+ self.ensure_one()
qr_code_data = self.qr_code_image
if not qr_code_data:
raise UserError("没有找到二维码数据。")
+ lot_name = self.name
+ # host = "192.168.50.110" # 可以根据实际情况修改
+ # port = 9100 # 可以根据实际情况修改
- # 生成下载链接或直接触发下载
- # 此处的实现依赖于你的具体需求,以下是触发下载的一种示例
- attachment = self.env['ir.attachment'].sudo().create({
- 'datas': self.qr_code_image,
- 'type': 'binary',
- 'description': '二维码图片',
- 'name': self.name + '.png',
- # 'res_id': invoice.id,
- # 'res_model': 'stock.picking',
- 'public': True,
- 'mimetype': 'application/x-png',
- # 'model_name': 'stock.picking',
- })
- # 返回附件的下载链接
- download_url = '/web/content/%s?download=true' % attachment.id
- base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
- return {
- 'type': 'ir.actions.act_url',
- 'url': str(base_url) + download_url,
- 'target': 'self',
- }
+ # 获取默认打印机配置
+ printer_config = self.env['printer.configuration'].search([('model', '=', self._name)], limit=1)
+ if not printer_config:
+ raise UserError('请先配置打印机')
+ host = printer_config.printer_id.ip_address
+ port = printer_config.printer_id.port
+ self.print_qr_code(lot_name, host, port)
+
+ # self.ensure_one() # 确保这个方法只为一个记录调用
+ # # if not self.lot_id:
+ # # raise UserError("没有找到序列号。")
+ # # 假设_lot_qr_code方法已经生成了二维码并保存在字段中
+ # qr_code_data = self.qr_code_image
+ # if not qr_code_data:
+ # raise UserError("没有找到二维码数据。")
+ #
+ # # 生成下载链接或直接触发下载
+ # # 此处的实现依赖于你的具体需求,以下是触发下载的一种示例
+ # attachment = self.env['ir.attachment'].sudo().create({
+ # 'datas': self.qr_code_image,
+ # 'type': 'binary',
+ # 'description': '二维码图片',
+ # 'name': self.name + '.png',
+ # # 'res_id': invoice.id,
+ # # 'res_model': 'stock.picking',
+ # 'public': True,
+ # 'mimetype': 'application/x-png',
+ # # 'model_name': 'stock.picking',
+ # })
+ # # 返回附件的下载链接
+ # download_url = '/web/content/%s?download=true' % attachment.id
+ # base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
+ # return {
+ # 'type': 'ir.actions.act_url',
+ # 'url': str(base_url) + download_url,
+ # 'target': 'self',
+ # }
class StockPicking(models.Model):
diff --git a/sf_manufacturing/views/stock_lot_views.xml b/sf_manufacturing/views/stock_lot_views.xml
index f637d401..bd04005c 100644
--- a/sf_manufacturing/views/stock_lot_views.xml
+++ b/sf_manufacturing/views/stock_lot_views.xml
@@ -10,7 +10,7 @@
diff --git a/sf_warehouse/models/model.py b/sf_warehouse/models/model.py
index 8e0a3116..43f84d69 100644
--- a/sf_warehouse/models/model.py
+++ b/sf_warehouse/models/model.py
@@ -9,7 +9,7 @@ import requests
from odoo import api, fields, models, _
from odoo.osv import expression
-from odoo.exceptions import UserError
+from odoo.exceptions import UserError, ValidationError
class SfLocation(models.Model):
@@ -388,7 +388,6 @@ class ShelfLocation(models.Model):
record.product_id = False
# record.location_status = '空闲'
-
# 调取获取货位信息接口
def get_sf_shelf_location_info(self):
# sf_sync_config = self.env['res.config.settings'].get_values()
@@ -414,7 +413,8 @@ class ShelfLocation(models.Model):
class Sf_stock_move_line(models.Model):
- _inherit = 'stock.move.line'
+ _name = 'stock.move.line'
+ _inherit = ['stock.move.line', 'printing.utils']
current_location_id = fields.Many2one(
'sf.shelf.location', string='当前货位', compute='_compute_current_location_id', store=True)
@@ -465,36 +465,127 @@ class Sf_stock_move_line(models.Model):
else:
record.lot_qr_code = False
- def print_qr_code(self):
- self.ensure_one() # 确保这个方法只为一个记录调用
- # if not self.lot_id:
- # raise UserError("没有找到序列号。")
- # 假设_lot_qr_code方法已经生成了二维码并保存在字段中
+ def print_single_method(self):
+ self.ensure_one()
qr_code_data = self.lot_qr_code
if not qr_code_data:
raise UserError("没有找到二维码数据。")
+ lot_name = self.lot_name
+ # host = "192.168.50.110" # 可以根据实际情况修改
+ # port = 9100 # 可以根据实际情况修改
- # 生成下载链接或直接触发下载
- # 此处的实现依赖于你的具体需求,以下是触发下载的一种示例
- attachment = self.env['ir.attachment'].sudo().create({
- 'datas': self.lot_qr_code,
- 'type': 'binary',
- 'description': '二维码图片',
- 'name': self.lot_name + '.png',
- # 'res_id': invoice.id,
- # 'res_model': 'stock.picking',
- 'public': True,
- 'mimetype': 'application/x-png',
- # 'model_name': 'stock.picking',
- })
- # 返回附件的下载链接
- download_url = '/web/content/%s?download=true' % attachment.id
- base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
- return {
- 'type': 'ir.actions.act_url',
- 'url': str(base_url) + download_url,
- 'target': 'self',
+ # 获取默认打印机配置
+ printer_config = self.env['printer.configuration'].search([('model', '=', self._name)], limit=1)
+ if not printer_config:
+ raise UserError('请先配置打印机')
+ host = printer_config.printer_id.ip_address
+ port = printer_config.printer_id.port
+ self.print_qr_code(lot_name, host, port)
+
+ # 返回当前wizard页面
+ # base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
+ # return {
+ # 'type': 'ir.actions.act_url',
+ # 'url': str(base_url) + download_url,
+ # 'target': 'self',
+ # }
+ # 获取当前wizard的视图ID或其他标识信息
+ view_id = self.env.context.get('view_id')
+ # 构造返回wizard页面的action字典
+ action = {
+ 'type': 'ir.actions.act_window',
+ 'name': '返回 Wizard',
+ 'res_model': 'stock.move', # 替换为你的wizard模型名称
+ 'view_mode': 'form',
+ 'view_id': view_id, # 如果需要基于特定的视图返回
+ 'target': 'new', # 如果需要在新的窗口或标签页打开
+ 'res_id': self.id, # 如果你想要返回当前记录的视图
}
+ return action
+
+ # def generate_zpl_code(self, code):
+ # # 初始化ZPL代码字符串
+ # zpl_code = "^XA\n"
+ # zpl_code += "^CW1,E:SIMSUN.TTF^FS\n"
+ # zpl_code += "^CI28\n"
+ #
+ # # 设置二维码位置
+ # zpl_code += "^FO50,50\n" # 调整二维码位置,使其与资产编号在同一行
+ # zpl_code += f"^BQN,2,6^FDLM,B0093{code}^FS\n"
+ #
+ # # 设置资产编号文本位置
+ # zpl_code += "^FO300,60\n" # 资产编号文本的位置,与二维码在同一行
+ # zpl_code += "^A1N,45,45^FD编码名称: ^FS\n"
+ #
+ # # 设置{code}文本位置
+ # # 假设{code}文本需要位于资产编号和二维码下方,中间位置
+ # # 设置{code}文本位置并启用自动换行
+ # zpl_code += "^FO300,120\n" # {code}文本的起始位置
+ # zpl_code += "^FB500,4,0,L,0\n" # 定义一个宽度为500点的文本框,最多4行,左对齐
+ # zpl_code += f"^A1N,40,40^FD{code}^FS\n"
+ #
+ # # 在{code}文本框周围绘制线框
+ # # 假设线框的外部尺寸为宽度500点,高度200点
+ # # zpl_code += "^FO300,110^GB500,200,2^FS\n" # 绘制线框,边框粗细为2点
+ #
+ # zpl_code += "^PQ1,0,1,Y\n"
+ # zpl_code += "^XZ\n"
+ # return zpl_code
+ #
+ # def send_to_printer(self, host, port, zpl_code):
+ # # 将ZPL代码转换为字节串
+ # print('zpl_code', zpl_code)
+ # zpl_bytes = zpl_code.encode('utf-8')
+ # print(zpl_bytes)
+ #
+ # # 创建socket对象
+ # mysocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ # try:
+ # mysocket.connect((host, port)) # 连接到打印机
+ # mysocket.send(zpl_bytes) # 发送ZPL代码
+ # print("ZPL code sent to printer successfully.")
+ # except Exception as e:
+ # print(f"Error with the connection: {e}")
+ # finally:
+ # mysocket.close() # 关闭连接
+ #
+ # def print_qr_code(self):
+ # self.ensure_one() # 确保这个方法只为一个记录调用
+ # # if not self.lot_id:
+ # # raise UserError("没有找到序列号。")
+ # # 假设_lot_qr_code方法已经生成了二维码并保存在字段中
+ # qr_code_data = self.lot_qr_code
+ # if not qr_code_data:
+ # raise UserError("没有找到二维码数据。")
+ # # 生成ZPL代码
+ # zpl_code = self.generate_zpl_code(self.lot_id.name)
+ # # 设置打印机的IP地址和端口号
+ # host = "192.168.50.110"
+ # port = 9100
+ # # 发送ZPL代码到打印机
+ # self.send_to_printer(host, port, zpl_code)
+ #
+ # # # 生成下载链接或直接触发下载
+ # # # 此处的实现依赖于你的具体需求,以下是触发下载的一种示例
+ # # attachment = self.env['ir.attachment'].sudo().create({
+ # # 'datas': self.lot_qr_code,
+ # # 'type': 'binary',
+ # # 'description': '二维码图片',
+ # # 'name': self.lot_name + '.png',
+ # # # 'res_id': invoice.id,
+ # # # 'res_model': 'stock.picking',
+ # # 'public': True,
+ # # 'mimetype': 'application/x-png',
+ # # # 'model_name': 'stock.picking',
+ # # })
+ # # # 返回附件的下载链接
+ # # download_url = '/web/content/%s?download=true' % attachment.id
+ # # base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
+ # # return {
+ # # 'type': 'ir.actions.act_url',
+ # # 'url': str(base_url) + download_url,
+ # # 'target': 'self',
+ # # }
# # # 定义一个方法,用于根据序列号生成二维码
# # @api.depends('lot_id')
@@ -630,6 +721,17 @@ class Sf_stock_move_line(models.Model):
class SfStockPicking(models.Model):
_inherit = 'stock.picking'
+ check_in = fields.Char(string='查询是否为入库单', compute='_check_is_in')
+
+ @api.depends('name')
+ def _check_is_in(self):
+ """
+ 判断是否为出库单
+ """
+ if self.name:
+ is_check_in = self.name.split('/')
+ self.check_in = is_check_in[1]
+
def button_validate(self):
"""
重写验证方法,当验证时意味着调拨单已经完成,已经移动到了目标货位,所以需要将当前货位的状态改为空闲
@@ -642,6 +744,20 @@ class SfStockPicking(models.Model):
line.current_location_id.location_status = '空闲'
return res
+ # def print_all_barcode(self):
+ # """
+ # 打印所有编码
+ # """
+ # print('================')
+ # for record in self.move_ids_without_package:
+ # print('record', record)
+ # print('record.move_line_ids', record.move_line_ids)
+ #
+ # # record.move_line_ids.print_qr_code()
+ #
+ # print('record.move_line_ids.lot_id', record.move_line_ids.lot_id)
+ # print('record.move_line_ids.lot_id.name', record.move_line_ids.lot_id.name)
+
class SfProcurementGroup(models.Model):
_inherit = 'procurement.group'
@@ -815,7 +931,8 @@ class SfStockScrap(models.Model):
class CustomStockMove(models.Model):
- _inherit = 'stock.move'
+ _name = 'stock.move'
+ _inherit = ['stock.move', 'printing.utils']
def action_assign_serial_show_details(self):
# 首先执行原有逻辑
@@ -844,3 +961,31 @@ class CustomStockMove(models.Model):
binary_data = buffer.getvalue()
data = base64.b64encode(binary_data).decode() # 确保返回的是字符串形式的数据
return data
+
+ def print_all_barcode(self):
+ """
+ 打印所有编码
+ """
+ print('================')
+ for record in self.move_line_ids:
+ print('record', record)
+ if not record.lot_name:
+ continue
+ record.ensure_one()
+ # qr_code_data = record.lot_qr_code
+ # if not qr_code_data:
+ # raise UserError("没有找到二维码数据。")
+ lot_name = record.lot_name
+ # todo 待控制
+ if not lot_name:
+ raise ValidationError("请先分配序列号")
+ # host = "192.168.50.110" # 可以根据实际情况修改
+ # port = 9100 # 可以根据实际情况修改
+
+ # 获取默认打印机配置
+ printer_config = self.env['printer.configuration'].search([('model', '=', self._name)], limit=1)
+ if not printer_config:
+ raise UserError('请先配置打印机')
+ host = printer_config.printer_id.ip_address
+ port = printer_config.printer_id.port
+ record.print_qr_code(lot_name, host, port)
diff --git a/sf_warehouse/views/change_stock_move_views.xml b/sf_warehouse/views/change_stock_move_views.xml
index e7d63d67..77021663 100644
--- a/sf_warehouse/views/change_stock_move_views.xml
+++ b/sf_warehouse/views/change_stock_move_views.xml
@@ -65,7 +65,7 @@
-
+
@@ -103,6 +103,11 @@
groups="sf_warehouse.group_sf_stock_user" data-hotkey="k"/>
+
+
+
+
+
@@ -135,5 +140,19 @@
+
+ sf.stock.move.operations.form
+ stock.move
+
+
+
+
+
+
+ -->
+
+
+
+