Accept Merge Request #694: (feature/制造代码优化 -> develop)
Merge Request: 优化代码,修改库存货架货位为标签 Created By: @马广威 Accepted By: @马广威 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/694?initial=true
This commit is contained in:
@@ -3,7 +3,6 @@ import logging
|
|||||||
import requests
|
import requests
|
||||||
from odoo import fields, models
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@@ -203,12 +202,12 @@ class FinishStatusChange(models.Model):
|
|||||||
[('id', 'child_of', self.picking_type_id.warehouse_id.view_location_id.id),
|
[('id', 'child_of', self.picking_type_id.warehouse_id.view_location_id.id),
|
||||||
('usage', '!=', 'supplier')])
|
('usage', '!=', 'supplier')])
|
||||||
if self.env['stock.move'].search([
|
if self.env['stock.move'].search([
|
||||||
('state', 'in', ['confirmed', 'partially_available', 'waiting', 'assigned']),
|
('state', 'in', ['confirmed', 'partially_available', 'waiting', 'assigned']),
|
||||||
('product_qty', '>', 0),
|
('product_qty', '>', 0),
|
||||||
('location_id', 'in', wh_location_ids),
|
('location_id', 'in', wh_location_ids),
|
||||||
('move_orig_ids', '=', False),
|
('move_orig_ids', '=', False),
|
||||||
('picking_id', 'not in', self.ids),
|
('picking_id', 'not in', self.ids),
|
||||||
('product_id', 'in', lines.product_id.ids)], limit=1):
|
('product_id', 'in', lines.product_id.ids)], limit=1):
|
||||||
action = self.action_view_reception_report()
|
action = self.action_view_reception_report()
|
||||||
action['context'] = {'default_picking_ids': self.ids}
|
action['context'] = {'default_picking_ids': self.ids}
|
||||||
return action
|
return action
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import logging
|
|||||||
import json
|
import json
|
||||||
from re import split as regex_split
|
from re import split as regex_split
|
||||||
from re import findall as regex_findall
|
from re import findall as regex_findall
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime
|
||||||
import requests
|
import requests
|
||||||
from odoo import SUPERUSER_ID, _, api, fields, models
|
from odoo import SUPERUSER_ID, _, api, fields, models
|
||||||
from odoo.tools import float_compare
|
from odoo.tools import float_compare
|
||||||
@@ -149,8 +149,8 @@ class StockRule(models.Model):
|
|||||||
raise ProcurementException(errors)
|
raise ProcurementException(errors)
|
||||||
|
|
||||||
for company_id, productions_values in productions_values_by_company.items():
|
for company_id, productions_values in productions_values_by_company.items():
|
||||||
# create the MO as SUPERUSER because the current user may not have the rights to do it (mto product
|
# create the MO as SUPERUSER because the current user may not have the rights to do it
|
||||||
# launched by a sale for example)
|
# (mto product launched by a sale for example)
|
||||||
'''创建制造订单'''
|
'''创建制造订单'''
|
||||||
productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create(
|
productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(company_id).create(
|
||||||
productions_values)
|
productions_values)
|
||||||
@@ -201,18 +201,17 @@ class StockRule(models.Model):
|
|||||||
|
|
||||||
sale_order = self.env['sale.order'].sudo().search([('name', '=', production.origin)])
|
sale_order = self.env['sale.order'].sudo().search([('name', '=', production.origin)])
|
||||||
if sale_order:
|
if sale_order:
|
||||||
bb = sale_order.deadline_of_delivery
|
self.env['sf.production.plan'].sudo().with_company(company_id). \
|
||||||
productions = self.env['sf.production.plan'].with_user(SUPERUSER_ID).sudo().with_company(company_id). \
|
create({
|
||||||
create({
|
'name': production.name,
|
||||||
'name': production.name,
|
'order_deadline': sale_order.deadline_of_delivery,
|
||||||
'order_deadline': sale_order.deadline_of_delivery,
|
'production_id': production.id,
|
||||||
'production_id': production.id,
|
'date_planned_start': production.date_planned_start,
|
||||||
'date_planned_start': production.date_planned_start,
|
'origin': production.origin,
|
||||||
'origin': production.origin,
|
'product_qty': production.product_qty,
|
||||||
'product_qty': production.product_qty,
|
'product_id': production.product_id.id,
|
||||||
'product_id': production.product_id.id,
|
'state': 'draft',
|
||||||
'state': 'draft',
|
})
|
||||||
})
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class CustomKanbanController extends KanbanController {
|
|||||||
const button = ev.currentTarget;
|
const button = ev.currentTarget;
|
||||||
const id = button.getAttribute('data-id');
|
const id = button.getAttribute('data-id');
|
||||||
|
|
||||||
console.log('true_id', id);
|
// console.log('true_id', id);
|
||||||
// const context = {production_line_show: 'shengchanxian1'}
|
// const context = {production_line_show: 'shengchanxian1'}
|
||||||
this.env.services.rpc('/web/dataset/call_kw', {
|
this.env.services.rpc('/web/dataset/call_kw', {
|
||||||
model: 'mrp.workcenter',
|
model: 'mrp.workcenter',
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
'depends': ['sf_manufacturing'],
|
'depends': ['sf_manufacturing'],
|
||||||
'data': [
|
'data': [
|
||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
|
# 'security/rules.xml',
|
||||||
'views/view.xml',
|
'views/view.xml',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ from odoo.exceptions import UserError, ValidationError
|
|||||||
class sf_production_plan(models.Model):
|
class sf_production_plan(models.Model):
|
||||||
_name = 'sf.production.plan'
|
_name = 'sf.production.plan'
|
||||||
_description = 'sf_production_plan'
|
_description = 'sf_production_plan'
|
||||||
|
_inherit = ['mail.thread']
|
||||||
_order = 'create_date desc'
|
_order = 'create_date desc'
|
||||||
|
|
||||||
state = fields.Selection([
|
state = fields.Selection([
|
||||||
@@ -20,6 +21,7 @@ class sf_production_plan(models.Model):
|
|||||||
('finished', '已完成')
|
('finished', '已完成')
|
||||||
], string='工单状态', tracking=True)
|
], string='工单状态', tracking=True)
|
||||||
name = fields.Char(string='工单编号')
|
name = fields.Char(string='工单编号')
|
||||||
|
active = fields.Boolean(string='已归档', default=True)
|
||||||
# selected = fields.Boolean(default=False)
|
# selected = fields.Boolean(default=False)
|
||||||
# order_number = fields.Char(string='订单号')
|
# order_number = fields.Char(string='订单号')
|
||||||
order_deadline = fields.Datetime(string='订单交期')
|
order_deadline = fields.Datetime(string='订单交期')
|
||||||
@@ -49,6 +51,26 @@ class sf_production_plan(models.Model):
|
|||||||
sequence = fields.Integer(string='序号', copy=False, readonly=True, index=True)
|
sequence = fields.Integer(string='序号', copy=False, readonly=True, index=True)
|
||||||
current_operation_name = fields.Char(string='当前工序名称', size=64, default='生产计划')
|
current_operation_name = fields.Char(string='当前工序名称', size=64, default='生产计划')
|
||||||
|
|
||||||
|
# @api.model
|
||||||
|
# def _search(self, args, offset=0, limit=None, order=None, count=False, access_rights_uid=None):
|
||||||
|
# """
|
||||||
|
# 默认修改筛选
|
||||||
|
# """
|
||||||
|
# return super(sf_production_plan, self.with_context(active_test=False))._search(
|
||||||
|
# args, offset, limit, order, count, access_rights_uid)
|
||||||
|
|
||||||
|
def archive(self):
|
||||||
|
"""
|
||||||
|
归档
|
||||||
|
"""
|
||||||
|
self.write({'active': False})
|
||||||
|
|
||||||
|
def unarchive(self):
|
||||||
|
"""
|
||||||
|
取消归档
|
||||||
|
"""
|
||||||
|
self.write({'active': True})
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def get_import_templates(self):
|
def get_import_templates(self):
|
||||||
"""returns the xlsx import template file"""
|
"""returns the xlsx import template file"""
|
||||||
|
|||||||
@@ -1,8 +1,3 @@
|
|||||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||||
access_sf_production_plan,sf.production.plan,model_sf_production_plan,base.group_user,1,1,1,1
|
access_sf_production_plan,sf.production.plan,model_sf_production_plan,base.group_user,1,0,0,0
|
||||||
access_sf_machine_schedule,sf.machine.schedule,model_sf_machine_schedule,base.group_user,1,1,1,1
|
access_sf_production_plan_for_dispatch,sf.production.plan for dispatch,model_sf_production_plan,sf_base.group_plan_dispatch,1,1,1,0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
|
9
sf_plan/security/rules.xml
Normal file
9
sf_plan/security/rules.xml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<odoo>
|
||||||
|
<record id="plan_order_rule_own" model="ir.rule">
|
||||||
|
<field name="name">Own Orders Only</field>
|
||||||
|
<field name="model_id" ref="model_sf_production_plan"/>
|
||||||
|
<field name="groups" eval="[(4, ref('sf_base.group_plan_dispatch'))]"/>
|
||||||
|
<!-- <field name="domain_force">[('user_id', '=', user.id)]</field> -->
|
||||||
|
<field name="domain_force">[('create_uid', '=', user.id)]</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
@@ -6,9 +6,6 @@
|
|||||||
<field name="model">sf.production.plan</field>
|
<field name="model">sf.production.plan</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="订单计划">
|
<tree string="订单计划">
|
||||||
<!-- <field name="selected" widget="boolean_toggle"/> -->
|
|
||||||
<!-- sequence、pl_no、pl_name、quantity、plan_start_time、plan_end_time、actual_start_time、actual_end_time、state、create_uid、create_date -->
|
|
||||||
<!-- <field name="sequence"/> -->
|
|
||||||
<field name="state" widget="badge" decoration-warning="state == 'draft'" decoration-success="state == 'done'"/>
|
<field name="state" widget="badge" decoration-warning="state == 'draft'" decoration-success="state == 'done'"/>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="origin"/>
|
<field name="origin"/>
|
||||||
@@ -18,8 +15,8 @@
|
|||||||
<field name="date_planned_start"/>
|
<field name="date_planned_start"/>
|
||||||
<field name="date_planned_finished"/>
|
<field name="date_planned_finished"/>
|
||||||
<field name="schedule_setting"/>
|
<field name="schedule_setting"/>
|
||||||
<button name="do_production_schedule" class="btn schedule_done" string="生产排程" type="object" attrs="{'invisible': [('state', 'not in', ['draft'])]}"/>
|
<button name="do_production_schedule" class="btn schedule_done" string="生产排程" type="object" attrs="{'invisible': [('state', 'not in', ['draft'])]}" groups="sf_base.group_plan_dispatch"/>
|
||||||
<button name="cancel_production_schedule" class="btn schedule_cancel" string="取消排程" type="object" attrs="{'invisible': [('state', 'not in', ['done'])]}"/>
|
<button name="cancel_production_schedule" class="btn schedule_cancel" string="取消排程" type="object" attrs="{'invisible': [('state', 'not in', ['done'])]}" groups="sf_base.group_plan_dispatch"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
@@ -31,8 +28,11 @@
|
|||||||
<form string="订单计划">
|
<form string="订单计划">
|
||||||
<header>
|
<header>
|
||||||
<!-- <button string="执行排程" name="do_production_schedule" type="object" class="oe_highlight" icon="fa-step-forward"/> -->
|
<!-- <button string="执行排程" name="do_production_schedule" type="object" class="oe_highlight" icon="fa-step-forward"/> -->
|
||||||
<button string="执行排程" name="do_production_schedule" type="object" class="oe_highlight" options='{"calendar_view": true, "date_begin": "2020-01-01", "date_end": "2020-12-31"}'/>
|
<button string="执行排程" name="do_production_schedule" type="object" class="oe_highlight" options='{"calendar_view": true, "date_begin": "2020-01-01", "date_end": "2020-12-31"}' groups="sf_base.group_plan_dispatch"/>
|
||||||
<button string="取消排程" name="cancel_production_schedule" type="object" class="oe_highlight"/>
|
<button string="取消排程" name="cancel_production_schedule" type="object" class="oe_highlight" groups="sf_base.group_plan_dispatch"/>
|
||||||
|
<button name="archive" type="object" string="归档" icon="fa-archive" class="oe_highlight" attrs="{'invisible': [('active', '=', False)]}"/>
|
||||||
|
<button name="unarchive" type="object" string="取消归档" icon="fa-archive" class="oe_highlight" attrs="{'invisible': [('active', '=', True)]}"/>
|
||||||
|
|
||||||
<!-- <button string="销售单" name="test_sale_order" type="object" class="oe_highlight"/> -->
|
<!-- <button string="销售单" name="test_sale_order" type="object" class="oe_highlight"/> -->
|
||||||
<!-- <button string="测试流程" name="liucheng_cs" type="object" class="oe_highlight"/> -->
|
<!-- <button string="测试流程" name="liucheng_cs" type="object" class="oe_highlight"/> -->
|
||||||
<field name="state" widget="statusbar" statusbar_visible="draft,done,processing,finished"/>
|
<field name="state" widget="statusbar" statusbar_visible="draft,done,processing,finished"/>
|
||||||
@@ -45,6 +45,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<group>
|
<group>
|
||||||
<group string="基本信息">
|
<group string="基本信息">
|
||||||
|
<field name="active" invisible="1"/>
|
||||||
<field name="production_id" widget="many2one_button"/>
|
<field name="production_id" widget="many2one_button"/>
|
||||||
<field name="product_id"/>
|
<field name="product_id"/>
|
||||||
<field name="origin"/>
|
<field name="origin"/>
|
||||||
@@ -60,6 +61,17 @@
|
|||||||
<field name="actual_end_time"/>
|
<field name="actual_end_time"/>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
<field name="shift" widget="time"/>
|
<field name="shift" widget="time"/>
|
||||||
|
|
||||||
|
<!-- Chatter -->
|
||||||
|
<!-- <div class="oe_chatter"> -->
|
||||||
|
<!-- <field name="message_follower_ids" widget="mail_followers"/> -->
|
||||||
|
<!-- <field name="message_ids" widget="mail_thread"/> -->
|
||||||
|
<!-- <field name="activity_ids"/> -->
|
||||||
|
<!-- </div> -->
|
||||||
|
<div class="oe_chatter">
|
||||||
|
<field name="message_follower_ids"/>
|
||||||
|
<field name="message_ids"/>
|
||||||
|
</div>
|
||||||
</group>
|
</group>
|
||||||
<!-- <group string="规格信息" col="1"> -->
|
<!-- <group string="规格信息" col="1"> -->
|
||||||
<!-- <group col="3"> -->
|
<!-- <group col="3"> -->
|
||||||
@@ -104,6 +116,9 @@
|
|||||||
<field name="model">sf.production.plan</field>
|
<field name="model">sf.production.plan</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<search string="订单计划">
|
<search string="订单计划">
|
||||||
|
<!-- Your other filters go here -->
|
||||||
|
<filter name="archived" string="已归档" domain="[('active','=',False)]"/>
|
||||||
|
<filter name="not archived" string="未归档" domain="[('active','=',True)]"/>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="product_qty"/>
|
<field name="product_qty"/>
|
||||||
<field name="date_planned_start"/>
|
<field name="date_planned_start"/>
|
||||||
@@ -261,6 +276,7 @@
|
|||||||
name="计划"
|
name="计划"
|
||||||
sequence="150"
|
sequence="150"
|
||||||
action="sf_production_plan_action"
|
action="sf_production_plan_action"
|
||||||
|
groups="sf_base.group_plan_dispatch"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- <record model="ir.ui.menu" id="mrp_custom_menu" inherit_id="mrp.menu_mrp_manufacturing"> -->
|
<!-- <record model="ir.ui.menu" id="mrp_custom_menu" inherit_id="mrp.menu_mrp_manufacturing"> -->
|
||||||
|
|||||||
@@ -13,8 +13,9 @@
|
|||||||
'depends': ['stock', 'web', ],
|
'depends': ['stock', 'web', ],
|
||||||
'data': [
|
'data': [
|
||||||
# 'security/group_security.xml',
|
# 'security/group_security.xml',
|
||||||
# 'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
'views/view.xml',
|
'views/view.xml',
|
||||||
|
'views/shelf_location.xml',
|
||||||
],
|
],
|
||||||
'demo': [
|
'demo': [
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -12,10 +12,13 @@ class SfLocation(models.Model):
|
|||||||
barcode = fields.Char('Barcode', copy=False, size=15)
|
barcode = fields.Char('Barcode', copy=False, size=15)
|
||||||
|
|
||||||
# 仓库类别(selection:库区、库位、货位)
|
# 仓库类别(selection:库区、库位、货位)
|
||||||
|
# location_type = fields.Selection([
|
||||||
|
# ('库区', '库区'),
|
||||||
|
# ('货架', '货架'),
|
||||||
|
# ('货位', '货位')
|
||||||
|
# ], string='存储类型')
|
||||||
location_type = fields.Selection([
|
location_type = fields.Selection([
|
||||||
('库区', '库区'),
|
('库区', '库区')
|
||||||
('货架', '货架'),
|
|
||||||
('货位', '货位')
|
|
||||||
], string='存储类型')
|
], string='存储类型')
|
||||||
# 库区类型(selection:拣货区、存货区、收货区、退货区、次品区)
|
# 库区类型(selection:拣货区、存货区、收货区、退货区、次品区)
|
||||||
area_type = fields.Selection([
|
area_type = fields.Selection([
|
||||||
@@ -25,6 +28,10 @@ class SfLocation(models.Model):
|
|||||||
('退货区', '退货区'),
|
('退货区', '退货区'),
|
||||||
('次品区', '次品区')
|
('次品区', '次品区')
|
||||||
], string='库区类型')
|
], string='库区类型')
|
||||||
|
# 当前位置
|
||||||
|
current_location_id = fields.Many2one('sf.shelf.location', string='当前位置')
|
||||||
|
# 目的位置
|
||||||
|
destination_location_id = fields.Many2one('sf.shelf.location', string='目的位置')
|
||||||
# 存储类型(selection:库区、货架)
|
# 存储类型(selection:库区、货架)
|
||||||
# storage_type = fields.Selection([
|
# storage_type = fields.Selection([
|
||||||
# ('库区', '库区'),
|
# ('库区', '库区'),
|
||||||
@@ -207,6 +214,108 @@ class SfLocation(models.Model):
|
|||||||
# + str(j + 1)
|
# + str(j + 1)
|
||||||
|
|
||||||
|
|
||||||
|
class ShelfLocation(models.Model):
|
||||||
|
_name = 'sf.shelf.location'
|
||||||
|
_description = '货架货位'
|
||||||
|
|
||||||
|
name = fields.Char('名称', required=True, size=20)
|
||||||
|
barcode = fields.Char('编码', copy=False, size=15)
|
||||||
|
|
||||||
|
# 仓库类别(selection:库区、库位、货位)
|
||||||
|
location_type = fields.Selection([
|
||||||
|
('货架', '货架'),
|
||||||
|
('货位', '货位')
|
||||||
|
], string='存储类型')
|
||||||
|
# 绑定库区
|
||||||
|
location_id = fields.Many2one('stock.location', string='所属库区', domain=[('location_type', '=', '库区')])
|
||||||
|
# 产品类别 (关联:product.category)
|
||||||
|
product_type = fields.Many2many('product.category', string='产品类别')
|
||||||
|
# 货架独有字段:通道、方向、货架高度(m)、货架层数、层数容量
|
||||||
|
channel = fields.Char(string='通道')
|
||||||
|
direction = fields.Selection([
|
||||||
|
('R', 'R'),
|
||||||
|
('L', 'L')
|
||||||
|
], string='方向')
|
||||||
|
shelf_height = fields.Float(string='货架高度(m)')
|
||||||
|
shelf_layer = fields.Integer(string='货架层数')
|
||||||
|
layer_capacity = fields.Integer(string='层数容量')
|
||||||
|
|
||||||
|
# 货位独有字段:货位状态、产品(关联产品对象)、产品序列号(关联产品序列号对象)
|
||||||
|
location_status = fields.Selection([
|
||||||
|
('空闲', '空闲'),
|
||||||
|
('占用', '占用'),
|
||||||
|
('禁用', '禁用')
|
||||||
|
], string='货位状态', default='空闲')
|
||||||
|
# product_id = fields.Many2one('product.template', string='产品')
|
||||||
|
product_id = fields.Many2one('product.product', string='产品', compute='_compute_product_id', readonly=True)
|
||||||
|
product_sn_id = fields.Many2one('stock.lot', string='产品序列号')
|
||||||
|
|
||||||
|
hide_shelf = fields.Boolean(compute='_compute_hide_what', string='隐藏货架')
|
||||||
|
hide_location = fields.Boolean(compute='_compute_hide_what', string='隐藏货位')
|
||||||
|
|
||||||
|
@api.depends('product_sn_id')
|
||||||
|
def _compute_product_id(self):
|
||||||
|
"""
|
||||||
|
根据产品序列号,获取产品
|
||||||
|
"""
|
||||||
|
for record in self:
|
||||||
|
if record.product_sn_id:
|
||||||
|
record.product_id = record.product_sn_id.product_id
|
||||||
|
record.location_status = '占用'
|
||||||
|
else:
|
||||||
|
record.product_id = False
|
||||||
|
# record.location_status = '空闲'
|
||||||
|
|
||||||
|
@api.depends('location_type')
|
||||||
|
def _compute_hide_what(self):
|
||||||
|
"""
|
||||||
|
根据仓库类别,隐藏不需要的字段
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
for record in self:
|
||||||
|
record.hide_shelf = False
|
||||||
|
record.hide_location = False
|
||||||
|
if record.location_type and record.location_type == '货架':
|
||||||
|
record.hide_shelf = True
|
||||||
|
elif record.location_type and record.location_type == '货位':
|
||||||
|
record.hide_location = True
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# 生成货位
|
||||||
|
def create_location(self):
|
||||||
|
"""
|
||||||
|
当仓库类型为货架时,自动生成其下面的货位,数量为货架层数*层数容量
|
||||||
|
"""
|
||||||
|
if self.location_type == '货架':
|
||||||
|
for i in range(self.shelf_layer):
|
||||||
|
for j in range(self.layer_capacity):
|
||||||
|
self.create({
|
||||||
|
'name': self.name + '-' + str(i + 1) + '层' + '-' + str(j + 1) + '位置',
|
||||||
|
'location_id': self.id,
|
||||||
|
'location_type': '货位',
|
||||||
|
'barcode': self.generate_barcode(i, j),
|
||||||
|
'location_status': '空闲'
|
||||||
|
})
|
||||||
|
|
||||||
|
def generate_barcode(self, i, j):
|
||||||
|
"""
|
||||||
|
生成货位条码
|
||||||
|
"""
|
||||||
|
# 这里是你生成barcode的代码
|
||||||
|
# area_type_barcode = self.location_id.barcode
|
||||||
|
area_type_barcode = self.barcode
|
||||||
|
i_str = str(i + 1).zfill(3) # 确保是两位数,如果不足两位,左侧补0
|
||||||
|
j_str = str(j + 1).zfill(3) # 确保是两位数,如果不足两位,左侧补0
|
||||||
|
return area_type_barcode + self.channel + self.direction + '-' + self.barcode + '-' + i_str + '-' + j_str
|
||||||
|
|
||||||
|
# def generate_barcode(self, i, j):
|
||||||
|
# # 这里是你生成barcode的代码
|
||||||
|
# area_type_barcode = self.location_id.barcode
|
||||||
|
# return area_type_barcode + self.channel + self.direction + '-' + self.barcode + '-' + str(i + 1) + '-'
|
||||||
|
# + str(j + 1)
|
||||||
|
|
||||||
|
|
||||||
class SfProcurementGroup(models.Model):
|
class SfProcurementGroup(models.Model):
|
||||||
_inherit = 'procurement.group'
|
_inherit = 'procurement.group'
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||||
access_stock_location,stock.location,model_stock_location,base.group_user,1,1,1,1
|
access_sf_shelf_location,sf.shelf.location,model_sf_shelf_location,base.group_user,1,1,1,1
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
|
201
sf_warehouse/views/shelf_location.xml
Normal file
201
sf_warehouse/views/shelf_location.xml
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
<record id="view_shelf_location_tree" model="ir.ui.view">
|
||||||
|
<field name="name">Shelf Location tree</field>
|
||||||
|
<field name="model">sf.shelf.location</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<tree string="Shelf Location">
|
||||||
|
<field name="name" string="名称"/>
|
||||||
|
<field name="barcode" string="编码"/>
|
||||||
|
<field name="location_type"/>
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="view_shelf_location_form" model="ir.ui.view">
|
||||||
|
<field name="name">Shelf Location form</field>
|
||||||
|
<field name="model">sf.shelf.location</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form string="Shelf Location">
|
||||||
|
<header>
|
||||||
|
<button string="生成货位" name="create_location" type="object" class="oe_highlight" attrs="{'invisible': [('hide_shelf', '=', False)]}"/>
|
||||||
|
</header>
|
||||||
|
<sheet>
|
||||||
|
<group>
|
||||||
|
<field name="hide_shelf" invisible="1"/>
|
||||||
|
<field name="hide_location" invisible="1"/>
|
||||||
|
<field name="name" string="名称"/>
|
||||||
|
<field name="barcode" string="编码"/>
|
||||||
|
<field name="location_type"/>
|
||||||
|
<field name="location_id"/>
|
||||||
|
<field name="channel" attrs="{'invisible': [('hide_shelf', '=', False)], 'required': [('hide_shelf', '!=', False)]}"/>
|
||||||
|
<field name="direction" attrs="{'invisible': [('hide_shelf', '=', False)], 'required': [('hide_shelf', '!=', False)]}"/>
|
||||||
|
<field name="product_sn_id" attrs="{'invisible': [('hide_location', '=', False)], 'required': [('hide_location', '!=', False), ('location_status', '=', '空闲')]}"/>
|
||||||
|
<!-- <field name="product_type" widget="many2many_tags"/> -->
|
||||||
|
<field name="shelf_height" attrs="{'invisible': [('hide_shelf', '=', False)], 'required': [('hide_shelf', '!=', False)]}"/>
|
||||||
|
<field name="shelf_layer" attrs="{'invisible': [('hide_shelf', '=', False)], 'required': [('hide_shelf', '!=', False)]}"/>
|
||||||
|
<field name="layer_capacity" attrs="{'invisible': [('hide_shelf', '=', False)], 'required': [('hide_shelf', '!=', False)]}"/>
|
||||||
|
<field name="product_id" attrs="{'invisible': [('hide_location', '=', False)], 'required': [('hide_location', '!=', False), ('location_status', '=', '占用')]}"/>
|
||||||
|
<field name="location_status" attrs="{'invisible': [('hide_location', '=', False)], 'required': [('hide_location', '!=', False)]}"/>
|
||||||
|
</group>
|
||||||
|
</sheet>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!-- 自己生成 -->
|
||||||
|
<!-- <record id="view_shelf_location_search" model="ir.ui.view"> -->
|
||||||
|
<!-- <field name="name">Shelf Location</field> -->
|
||||||
|
<!-- <field name="model">sf.shelf.location</field> -->
|
||||||
|
<!-- <field name="arch" type="xml"> -->
|
||||||
|
<!-- <search string="Shelf Location"> -->
|
||||||
|
<!-- <field name="name" string="名称"/> -->
|
||||||
|
<!-- <field name="barcode" string="编码"/> -->
|
||||||
|
<!-- <field name="location_type"/> -->
|
||||||
|
<!-- <field name="channel"/> -->
|
||||||
|
<!-- <field name="direction"/> -->
|
||||||
|
<!-- <field name="shelf_height"/> -->
|
||||||
|
<!-- <field name="shelf_layer"/> -->
|
||||||
|
<!-- <field name="layer_capacity"/> -->
|
||||||
|
<!-- </search> -->
|
||||||
|
<!-- </field> -->
|
||||||
|
<!-- </record> -->
|
||||||
|
<!-- -->
|
||||||
|
<!-- <record id="view_shelf_location_kanban" model="ir.ui.view"> -->
|
||||||
|
<!-- <field name="name">Shelf Location</field> -->
|
||||||
|
<!-- <field name="model">sf.shelf.location</field> -->
|
||||||
|
<!-- <field name="arch" type="xml"> -->
|
||||||
|
<!-- <kanban class="o_kanban_mobile" js_class="custom_kanban"> -->
|
||||||
|
<!-- <field name="name"/> -->
|
||||||
|
<!-- <field name="barcode"/> -->
|
||||||
|
<!-- <field name="location_type"/> -->
|
||||||
|
<!-- <field name="channel"/> -->
|
||||||
|
<!-- <field name="direction"/> -->
|
||||||
|
<!-- <field name="shelf_height"/> -->
|
||||||
|
<!-- <field name="shelf_layer"/> -->
|
||||||
|
<!-- <field name="layer_capacity"/> -->
|
||||||
|
<!-- </kanban> -->
|
||||||
|
<!-- </field> -->
|
||||||
|
<!-- </record> -->
|
||||||
|
<!-- -->
|
||||||
|
<!-- <record id="action_shelf_location" model="ir.actions.act_window"> -->
|
||||||
|
<!-- <field name="name">Shelf Location</field> -->
|
||||||
|
<!-- <field name="res_model">sf.shelf.location</field> -->
|
||||||
|
<!-- <field name="view_mode">tree,form,kanban</field> -->
|
||||||
|
<!-- <field name="search_view_id" ref="view_shelf_location_search"/> -->
|
||||||
|
<!-- </record> -->
|
||||||
|
<!-- -->
|
||||||
|
<!-- <menuitem id="menu_shelf_location" name="Shelf Location" parent="sf_stock.menu_stock" sequence="1"/> -->
|
||||||
|
<!-- <menuitem id="menu_shelf_location_tree" name="Shelf Location" parent="menu_shelf_location" action="action_shelf_location" sequence="1"/> -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <record id="view_location_search_sf_inherit" model="ir.ui.view"> -->
|
||||||
|
<!-- <field name="name">stock.location.search.sf.inherit</field> -->
|
||||||
|
<!-- <field name="model">stock.location</field> -->
|
||||||
|
<!-- <field name="inherit_id" ref="stock.view_location_search"/> -->
|
||||||
|
<!-- <field name="arch" type="xml"> -->
|
||||||
|
<!-- <xpath expr="//search[1]" position="inside"> -->
|
||||||
|
<!-- <searchpanel class="account_root"> -->
|
||||||
|
<!-- <field name="location_type" icon="fa-filter"/> -->
|
||||||
|
<!-- <field name="location_id" select="multi" domain="[('location_type', '=', '货架')]"/> -->
|
||||||
|
<!-- </searchpanel> -->
|
||||||
|
<!-- </xpath> -->
|
||||||
|
<!-- </field> -->
|
||||||
|
<!-- </record> -->
|
||||||
|
<!-- <record id="example_kanban_view" model="ir.ui.view"> -->
|
||||||
|
<!-- <field name="name">example.kanban</field> -->
|
||||||
|
<!-- <field name="model">stock.location</field> -->
|
||||||
|
<!-- <field name="arch" type="xml"> -->
|
||||||
|
<!-- <kanban class="o_kanban_mobile" js_class="custom_kanban"> -->
|
||||||
|
<!-- <templates> -->
|
||||||
|
<!-- <t t-name="kanban-box"> -->
|
||||||
|
<!-- <div t-attf-class="oe_kanban_card oe_kanban_global_click -->
|
||||||
|
<!-- #{record.location_status.raw_value == '空闲' ? 'kanban_color_1' : ''} -->
|
||||||
|
<!-- #{record.location_status.raw_value == '占用' ? 'kanban_color_2' : ''} -->
|
||||||
|
<!-- #{record.location_status.raw_value == '禁用' ? 'kanban_color_3' : ''}"> -->
|
||||||
|
<!-- --><!-- 标题 -->
|
||||||
|
<!-- <div class="o_kanban_card_header"> -->
|
||||||
|
<!-- <div class="o_kanban_card_header_title"> -->
|
||||||
|
<!-- <field name="name"/> -->
|
||||||
|
<!-- </div> -->
|
||||||
|
<!-- </div> -->
|
||||||
|
<!-- --><!-- 内容 -->
|
||||||
|
<!-- <div class="o_kanban_record_bottom"> -->
|
||||||
|
<!-- <field name="location_status"/> -->
|
||||||
|
<!-- </div> -->
|
||||||
|
<!-- <div class="o_kanban_record_bottom"> -->
|
||||||
|
<!-- <field name="product_sn_id"/> -->
|
||||||
|
<!-- <span> | </span> -->
|
||||||
|
<!-- <field name="product_id"/> -->
|
||||||
|
<!-- </div> -->
|
||||||
|
<!-- </div> -->
|
||||||
|
<!-- </t> -->
|
||||||
|
<!-- <t t-name="kanban-box"> -->
|
||||||
|
<!-- <div t-attf-class="oe_kanban_card oe_kanban_global_click -->
|
||||||
|
<!-- #{record.location_status.raw_value == '空闲' ? 'kanban_color_1' : ''} -->
|
||||||
|
<!-- #{record.location_status.raw_value == '占用' ? 'kanban_color_2' : ''} -->
|
||||||
|
<!-- #{record.location_status.raw_value == '禁用' ? 'kanban_color_3' : ''}"> -->
|
||||||
|
<!-- --><!-- --><!-- 看板内容 -->
|
||||||
|
<!-- </div> -->
|
||||||
|
<!-- <div t-attf-class="oe_kanban_card"> -->
|
||||||
|
<!-- --><!-- --><!-- 标题 -->
|
||||||
|
<!-- <div class="o_kanban_card_header"> -->
|
||||||
|
<!-- <div class="o_kanban_card_header_title"> -->
|
||||||
|
<!-- <field name="name"/> -->
|
||||||
|
<!-- </div> -->
|
||||||
|
<!-- </div> -->
|
||||||
|
<!-- --><!-- --><!-- 内容 -->
|
||||||
|
<!-- <div class="o_kanban_record_bottom"> -->
|
||||||
|
<!-- <field name="location_status"/> -->
|
||||||
|
<!-- </div> -->
|
||||||
|
<!-- <div class="o_kanban_record_bottom"> -->
|
||||||
|
<!-- <field name="product_sn_id"/> -->
|
||||||
|
<!-- <span> | </span> -->
|
||||||
|
<!-- <field name="product_id"/> -->
|
||||||
|
<!-- </div> -->
|
||||||
|
<!-- </div> -->
|
||||||
|
<!-- </t> -->
|
||||||
|
<!-- </templates> -->
|
||||||
|
<!-- </kanban> -->
|
||||||
|
<!-- </field> -->
|
||||||
|
<!-- </record> -->
|
||||||
|
|
||||||
|
<!-- <record id="kanban_action_id" model="ir.actions.act_window"> -->
|
||||||
|
<!-- <field name="name">货位状态</field> -->
|
||||||
|
<!-- <field name="type">ir.actions.act_window</field> -->
|
||||||
|
<!-- <field name="res_model">stock.location</field> -->
|
||||||
|
<!-- <field name="view_mode">kanban,form</field> -->
|
||||||
|
<!-- </record> -->
|
||||||
|
|
||||||
|
<record id="action_sf_shelf_location" model="ir.actions.act_window">
|
||||||
|
<field name="name">货架货位</field>
|
||||||
|
<field name="type">ir.actions.act_window</field>
|
||||||
|
<field name="res_model">sf.shelf.location</field>
|
||||||
|
<field name="view_mode">tree,form</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!-- <record id="example_action" model="ir.actions.act_window"> -->
|
||||||
|
<!-- <field name="name">Example</field> -->
|
||||||
|
<!-- <field name="type">ir.actions.act_window</field> -->
|
||||||
|
<!-- <field name="res_model">stock.location</field> -->
|
||||||
|
<!-- <field name="view_mode">kanban</field> -->
|
||||||
|
<!-- <field name="searchpanel">true</field> -->
|
||||||
|
<!-- <field name="searchpanel_field_label">货架</field> -->
|
||||||
|
<!-- <field name="searchpanel_field_name">parent_id</field> -->
|
||||||
|
<!-- <field name="searchpanel_field_group_by">['parent_id']</field> -->
|
||||||
|
<!-- <field name="domain">[('location_type', '=', '货位')]</field> -->
|
||||||
|
<!-- </record> -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <menuitem id="menu_stock_location" name="货位状态" parent="stock.menu_stock_root" -->
|
||||||
|
<!-- sequence="50" -->
|
||||||
|
<!-- action="kanban_action_id"/> -->
|
||||||
|
|
||||||
|
<menuitem id="menu_sf_shelf_location" name="货架货位" parent="stock.menu_warehouse_config"
|
||||||
|
sequence="2"
|
||||||
|
action="action_sf_shelf_location"/>
|
||||||
|
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</odoo>
|
||||||
@@ -32,6 +32,8 @@
|
|||||||
<field name="product_sn_id" attrs="{'invisible': [('hide_location', '=', False)], 'required': [('hide_location', '!=', False), ('location_status', '=', '空闲')]}"/>
|
<field name="product_sn_id" attrs="{'invisible': [('hide_location', '=', False)], 'required': [('hide_location', '!=', False), ('location_status', '=', '空闲')]}"/>
|
||||||
<!-- <field name="time_test" widget="timepicker"/>-->
|
<!-- <field name="time_test" widget="timepicker"/>-->
|
||||||
<field name="area_type" attrs="{'invisible': [('hide_area', '=', False)], 'required': [('hide_area', '!=', False)]}"/>
|
<field name="area_type" attrs="{'invisible': [('hide_area', '=', False)], 'required': [('hide_area', '!=', False)]}"/>
|
||||||
|
<field name="current_location_id" attrs="{'invisible': [('hide_area', '=', False)]}"/>
|
||||||
|
<field name="destination_location_id" attrs="{'invisible': [('hide_area', '=', False)]}"/>
|
||||||
|
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
|
|||||||
Reference in New Issue
Block a user