Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/制造代码优化

# Conflicts:
#	sf_warehouse/models/model.py
This commit is contained in:
mgw
2024-04-09 20:42:15 +08:00
34 changed files with 1292 additions and 706 deletions

View File

@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
import re
import datetime
import logging
import base64
@@ -19,14 +21,6 @@ class SfLocation(models.Model):
name = fields.Char('Location Name', required=True, size=20)
barcode = fields.Char('Barcode', copy=False, size=15)
check_state = fields.Selection([
('enable', '启用'),
('close', '关闭')
], string='审核状态', default='close')
def action_check(self):
self.check_state = 'enable'
# 仓库类别selection库区、库位、货位
# location_type = fields.Selection([
# ('库区', '库区'),
@@ -444,6 +438,8 @@ class Sf_stock_move_line(models.Model):
current_product_id = fields.Integer(compute='_compute_location_dest_id_value', store=True)
there_is_no_sn = fields.Boolean('是否有序列号', default=False)
rfid = fields.Char('Rfid', readonly=True)
def action_revert_inventory(self):
# 检查用户是否有执行操作的权限
if not self.env.user.has_group('sf_warehouse.group_sf_stock_user'):
@@ -774,21 +770,30 @@ class SfStockPicking(models.Model):
# line.current_location_id.location_status = '空闲'
line.current_location_id.product_num = 0
for move in self.move_ids:
if move and move.product_id.cutting_tool_material_id.name == '刀柄' or '托盘' in (
move.product_id.fixture_material_id.name or ''):
for item in move.move_line_nosuggest_ids:
if item.location_dest_id.name == '进货':
if not item.rfid:
raise ValidationError('你需要提供%s的Rfid' % move.product_id.name)
self.env['stock.lot'].search([('name', '=', item.lot_name)]).write({'rfid': item.rfid})
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)
# 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):
@@ -854,117 +859,43 @@ class SfProcurementGroup(models.Model):
return res
class SfWarehouse(models.Model):
_inherit = 'stock.warehouse'
check_state = fields.Selection([
('enable', '启用'),
('close', '关闭')
], string='审核状态', default='close')
def action_check(self):
self.check_state = 'enable'
class SfRule(models.Model):
_inherit = 'stock.rule'
check_state = fields.Selection([
('enable', '启用'),
('close', '关闭')
], string='审核状态', default='close')
def action_check(self):
self.check_state = 'enable'
class SfRoute(models.Model):
_inherit = 'stock.route'
check_state = fields.Selection([
('enable', '启用'),
('close', '关闭')
], string='审核状态', default='close')
def action_check(self):
self.check_state = 'enable'
class SfPickingType(models.Model):
_inherit = 'stock.picking.type'
check_state = fields.Selection([
('enable', '启用'),
('close', '关闭')
], string='审核状态', default='close')
def action_check(self):
self.check_state = 'enable'
class SfBarcodeNomenclature(models.Model):
_inherit = 'barcode.nomenclature'
check_state = fields.Selection([
('enable', '启用'),
('close', '关闭')
], string='审核状态', default='close')
def action_check(self):
self.check_state = 'enable'
class SfPutawayRule(models.Model):
_inherit = 'stock.putaway.rule'
check_state = fields.Selection([
('enable', '同意'),
('close', '不同意')
], string='审核状态', default='close')
def action_check(self):
self.check_state = 'enable'
class SfWarehouseOrderpoint(models.Model):
_inherit = 'stock.warehouse.orderpoint'
check_state = fields.Selection([
('enable', '同意'),
('close', '不同意')
], string='审核状态', default='close')
def action_check(self):
self.check_state = 'enable'
class SfStockQuant(models.Model):
_inherit = 'stock.quant'
check_state = fields.Selection([
('enable', '同意'),
('close', '不同意')
], string='审核状态', default='close')
def action_check(self):
self.check_state = 'enable'
class SfStockScrap(models.Model):
_inherit = 'stock.scrap'
check_state = fields.Selection([
('enable', '启用'),
('close', '关闭')
], string='审核状态', default='close')
def action_check(self):
self.check_state = 'enable'
def _default_show_operations(self):
return self.user_has_groups('stock.group_production_lot,'
'stock.group_stock_multi_locations,'
'stock.group_tracking_lot',
'sf_warehouse.group_sf_stock_user',
'sf_warehouse.group_sf_stock_manager')
class CustomStockMove(models.Model):
_name = 'stock.move'
_inherit = ['stock.move', 'printing.utils']
_inherit = ['stock.move', 'printing.utils', 'barcodes.barcode_events_mixin']
def on_barcode_scanned(self, barcode):
"""
采购入库扫码绑定Rfid码
"""
for record in self:
if record:
if '刀柄' in (record.product_id.cutting_tool_material_id.name or '') or '托盘' in (
record.product_id.fixture_material_id.name or ''):
for move_line_nosuggest_id in record.move_line_nosuggest_ids:
if move_line_nosuggest_id.rfid:
if move_line_nosuggest_id.rfid == barcode:
if record.product_id.cutting_tool_material_id.name:
raise ValidationError('该刀柄的Rfid已经录入请勿重复录入')
else:
raise ValidationError('该托盘的Rfid已经录入请勿重复录入')
else:
line_id = int(re.sub(r"\D", "", str(move_line_nosuggest_id.id)))
self.env['stock.move.line'].sudo().search([('id', '=', line_id)]).write({'rfid': barcode})
move_line_nosuggest_id.rfid = barcode
break
else:
raise ValidationError('该产品不需要录入Rfid')
def action_assign_serial_show_details(self):
# 首先执行原有逻辑

View File

@@ -39,15 +39,16 @@
<field name="current_location_id" force_save="1"/>
</xpath>
<xpath expr="//field[@name='location_dest_id']" position="after">
<field name="destination_location_id" />
<!-- <field name="location_dest_id_product_type"/> -->
<!-- <field name="location_dest_id"/> -->
<field name="destination_location_id"/>
<!-- <field name="location_dest_id_product_type"/> -->
<!-- <field name="location_dest_id"/> -->
<field name="location_dest_id_value" invisible="1"/>
<!-- <button name="button_test" string="测试" type="object" class="oe_highlight"/> -->
<!-- <button name="button_test" string="测试" type="object" class="oe_highlight"/> -->
</xpath>
</field>
</record>
<record id="sf_stock_move_line_form" model="ir.ui.view">
<field name="name">sf.stock.move.line.form</field>
<field name="model">stock.move.line</field>
@@ -71,6 +72,9 @@
<field name="model">stock.move.line</field>
<field name="inherit_id" ref="stock.view_stock_move_line_operation_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='lot_name']" position="after">
<field name="rfid"/>
</xpath>
<xpath expr="//field[@name='product_uom_id']" position="after">
<field name="lot_qr_code" widget="image"/>
<button name="print_single_method" string="打印编码" type="object" class="oe_highlight"/>
@@ -111,10 +115,10 @@
groups="sf_warehouse.group_sf_stock_user" data-hotkey="k"/>
</xpath>
<!-- <xpath expr="//form//sheet//notebook//page//field[@name='move_ids_without_package']" position="before"> -->
<!-- <field name="check_in" invisible="True"/> -->
<!-- <button name="print_all_barcode" string="打印所有编码" type="object" attrs="{'invisible': [('check_in', '!=', 'IN')]}"/> -->
<!-- </xpath> -->
<!-- <xpath expr="//form//sheet//notebook//page//field[@name='move_ids_without_package']" position="before"> -->
<!-- <field name="check_in" invisible="True"/> -->
<!-- <button name="print_all_barcode" string="打印所有编码" type="object" attrs="{'invisible': [('check_in', '!=', 'IN')]}"/> -->
<!-- </xpath> -->
</field>
</record>
@@ -153,11 +157,23 @@
<field name="model">stock.move</field>
<field name="inherit_id" ref="stock.view_stock_move_operations"/>
<field name="arch" type="xml">
<!-- <xpath expr="//form//field[@name='move_line_ids']" position="before"> -->
<!-- <button name="print_all_barcode" type="object" string="打印所有编码"/> -->
<!-- </xpath> -->
<!-- <xpath expr="//form//field[@name='move_line_ids']" position="before"> -->
<!-- <button name="print_all_barcode" type="object" string="打印所有编码"/> -->
<!-- </xpath> -->
<xpath expr="//form//field[@name='product_id']" position="before">
<button name="print_all_barcode" type="object" string="打印所有编码" class="oe_highlight"/> -->
<button name="print_all_barcode" type="object" string="打印所有编码" class="oe_highlight"/>
-->
</xpath>
</field>
</record>
<record id="mrp_subcontracting_view_stock_move_barcode_scanned" model="ir.ui.view">
<field name="name">mrp.subcontracting.stock.move.barcode.scanned.form</field>
<field name="model">stock.move</field>
<field name="inherit_id" ref="stock.view_stock_move_nosuggest_operations"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='move_line_nosuggest_ids']" position="before">
<field name="_barcode_scanned" widget="barcode_handler"/>
</xpath>
</field>
</record>

View File

@@ -67,16 +67,16 @@
</notebook>
</xpath>
<xpath expr="//sheet" position="before">
<header>
<field name="check_state" invisible="1"/>
<button name="action_check" string="审核" type="object"
attrs="{'invisible': [('check_state','=', 'enable')]}"
groups="sf_warehouse.group_sf_stock_manager"
class="oe_highlight"/>
</header>
<!-- <xpath expr="//sheet" position="before">-->
<!-- <header>-->
<!-- <field name="check_state" invisible="1"/>-->
<!-- <button name="action_check" string="审核" type="object"-->
<!-- attrs="{'invisible': [('check_state','=', 'enable')]}"-->
<!-- groups="sf_warehouse.group_sf_stock_manager"-->
<!-- class="oe_highlight"/>-->
<!-- </header>-->
</xpath>
<!-- </xpath>-->
</field>
</record>
@@ -188,23 +188,23 @@
<!-- </record>-->
<!--仓库根据权限增加审核按钮-->
<record id="view_warehouse_form_sf_inherit" model="ir.ui.view">
<field name="name">stock.warehouse.form.sf.inherit</field>
<field name="model">stock.warehouse</field>
<field name="inherit_id" ref="stock.view_warehouse"/>
<field name="arch" type="xml">
<xpath expr="//sheet" position="before">
<header>
<field name="check_state" invisible="1"/>
<button name="action_check" string="审核" type="object"
attrs="{'invisible': [('check_state','=', 'enable')]}"
groups="sf_warehouse.group_sf_stock_manager"
class="oe_highlight"/>
</header>
<!-- <record id="view_warehouse_form_sf_inherit" model="ir.ui.view">-->
<!-- <field name="name">stock.warehouse.form.sf.inherit</field>-->
<!-- <field name="model">stock.warehouse</field>-->
<!-- <field name="inherit_id" ref="stock.view_warehouse"/>-->
<!-- <field name="arch" type="xml">-->
<!-- <xpath expr="//sheet" position="before">-->
<!-- <header>-->
<!-- <field name="check_state" invisible="1"/>-->
<!-- <button name="action_check" string="审核" type="object"-->
<!-- attrs="{'invisible': [('check_state','=', 'enable')]}"-->
<!-- groups="sf_warehouse.group_sf_stock_manager"-->
<!-- class="oe_highlight"/>-->
<!-- </header>-->
</xpath>
</field>
</record>
<!-- </xpath>-->
<!-- </field>-->
<!-- </record>-->
<!-- <record id="view_warehouse_tree_sf_inherit" model="ir.ui.view">-->
<!-- <field name="name">stock.warehouse.tree.sf.inherit</field>-->
@@ -220,23 +220,23 @@
<!--路线根据权限增加审核按钮-->
<record id="view_route_form_sf_inherit" model="ir.ui.view">
<field name="name">stock.route.form.sf.inherit</field>
<field name="model">stock.route</field>
<field name="inherit_id" ref="stock.stock_location_route_form_view"/>
<field name="arch" type="xml">
<xpath expr="//sheet" position="before">
<header>
<field name="check_state" invisible="1"/>
<button name="action_check" string="审核" type="object"
attrs="{'invisible': [('check_state','=', 'enable')]}"
groups="sf_warehouse.group_sf_stock_manager"
class="oe_highlight"/>
</header>
<!-- <record id="view_route_form_sf_inherit" model="ir.ui.view">-->
<!-- <field name="name">stock.route.form.sf.inherit</field>-->
<!-- <field name="model">stock.route</field>-->
<!-- <field name="inherit_id" ref="stock.stock_location_route_form_view"/>-->
<!-- <field name="arch" type="xml">-->
<!-- <xpath expr="//sheet" position="before">-->
<!-- <header>-->
<!-- <field name="check_state" invisible="1"/>-->
<!-- <button name="action_check" string="审核" type="object"-->
<!-- attrs="{'invisible': [('check_state','=', 'enable')]}"-->
<!-- groups="sf_warehouse.group_sf_stock_manager"-->
<!-- class="oe_highlight"/>-->
<!-- </header>-->
</xpath>
</field>
</record>
<!-- </xpath>-->
<!-- </field>-->
<!-- </record>-->
<!-- <record id="view_route_tree_sf_inherit" model="ir.ui.view">-->
<!-- <field name="name">stock.route.tree.sf.inherit</field>-->
@@ -251,23 +251,23 @@
<!-- </record>-->
<!--规则根据权限增加审核按钮-->
<record id="view_rule_form_sf_inherit" model="ir.ui.view">
<field name="name">stock.rule.form.sf.inherit</field>
<field name="model">stock.rule</field>
<field name="inherit_id" ref="stock.view_stock_rule_form"/>
<field name="arch" type="xml">
<xpath expr="//sheet" position="before">
<header>
<field name="check_state" invisible="1"/>
<button name="action_check" string="审核" type="object"
attrs="{'invisible': [('check_state','=', 'enable')]}"
groups="sf_warehouse.group_sf_stock_manager"
class="oe_highlight"/>
</header>
<!-- <record id="view_rule_form_sf_inherit" model="ir.ui.view">-->
<!-- <field name="name">stock.rule.form.sf.inherit</field>-->
<!-- <field name="model">stock.rule</field>-->
<!-- <field name="inherit_id" ref="stock.view_stock_rule_form"/>-->
<!-- <field name="arch" type="xml">-->
<!-- <xpath expr="//sheet" position="before">-->
<!-- <header>-->
<!-- <field name="check_state" invisible="1"/>-->
<!-- <button name="action_check" string="审核" type="object"-->
<!-- attrs="{'invisible': [('check_state','=', 'enable')]}"-->
<!-- groups="sf_warehouse.group_sf_stock_manager"-->
<!-- class="oe_highlight"/>-->
<!-- </header>-->
</xpath>
</field>
</record>
<!-- </xpath>-->
<!-- </field>-->
<!-- </record>-->
<!-- <record id="view_rule_tree_sf_inherit" model="ir.ui.view">-->
<!-- <field name="name">stock.rule.tree.sf.inherit</field>-->
@@ -282,23 +282,23 @@
<!-- </record>-->
<!--作业类型根据权限增加审核按钮-->
<record id="view_picking_type_form_sf_inherit" model="ir.ui.view">
<field name="name">stock.picking.type.form.sf.inherit</field>
<field name="model">stock.picking.type</field>
<field name="inherit_id" ref="stock.view_picking_type_form"/>
<field name="arch" type="xml">
<xpath expr="//sheet" position="before">
<header>
<field name="check_state" invisible="1"/>
<button name="action_check" string="审核" type="object"
attrs="{'invisible': [('check_state','=', 'enable')]}"
groups="sf_warehouse.group_sf_stock_manager"
class="oe_highlight"/>
</header>
<!-- <record id="view_picking_type_form_sf_inherit" model="ir.ui.view">-->
<!-- <field name="name">stock.picking.type.form.sf.inherit</field>-->
<!-- <field name="model">stock.picking.type</field>-->
<!-- <field name="inherit_id" ref="stock.view_picking_type_form"/>-->
<!-- <field name="arch" type="xml">-->
<!-- <xpath expr="//sheet" position="before">-->
<!-- <header>-->
<!-- <field name="check_state" invisible="1"/>-->
<!-- <button name="action_check" string="审核" type="object"-->
<!-- attrs="{'invisible': [('check_state','=', 'enable')]}"-->
<!-- groups="sf_warehouse.group_sf_stock_manager"-->
<!-- class="oe_highlight"/>-->
<!-- </header>-->
</xpath>
</field>
</record>
<!-- </xpath>-->
<!-- </field>-->
<!-- </record>-->
<!-- <record id="view_picking_type_tree_sf_inherit" model="ir.ui.view">-->
<!-- <field name="name">stock.picking.type.tree.sf.inherit</field>-->