Compare commits
67 Commits
feature/71
...
feature/72
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
22f36d095c | ||
|
|
fe8df494f9 | ||
|
|
32cd68e15f | ||
|
|
f0e47371ed | ||
|
|
6dde814acc | ||
|
|
71ab241e94 | ||
|
|
0a13acbb68 | ||
|
|
4b026535f8 | ||
|
|
99ac89f995 | ||
|
|
35b1d648c3 | ||
|
|
fe3492ceb5 | ||
|
|
4274b9fe99 | ||
|
|
4ddabdefa1 | ||
|
|
364127beb3 | ||
|
|
109ea8729d | ||
|
|
32de726164 | ||
|
|
79f89f068b | ||
|
|
52189cff72 | ||
|
|
aadccce47e | ||
|
|
abd88fd721 | ||
|
|
2c2fa87719 | ||
|
|
7d8b7048a8 | ||
|
|
e7b312fb22 | ||
|
|
bc641bde3a | ||
|
|
d73ffab9b5 | ||
|
|
4b1c0bc3b5 | ||
|
|
45730e2dd4 | ||
|
|
8903f32cf8 | ||
|
|
8bd1c8a095 | ||
|
|
abf9a0997b | ||
|
|
aec2d1c516 | ||
|
|
127efb67d7 | ||
|
|
78edf1f7eb | ||
|
|
e6e13a5970 | ||
|
|
55cc4906ef | ||
|
|
427b548939 | ||
|
|
8c9db7e8c8 | ||
|
|
990f73ea4e | ||
|
|
d21e0c7fd9 | ||
|
|
b4ed65a75c | ||
|
|
53ba2ec589 | ||
|
|
566bc0e1e2 | ||
|
|
5f216684f0 | ||
|
|
e86bd59a43 | ||
|
|
e55625e4b6 | ||
|
|
790dd3dd05 | ||
|
|
84846fb3da | ||
|
|
f45a46255b | ||
|
|
fe5b005e45 | ||
|
|
fc33280509 | ||
|
|
60ed04cf77 | ||
|
|
3439b47b0c | ||
|
|
33c5d648b5 | ||
|
|
c7b50d9706 | ||
|
|
05caed1d91 | ||
|
|
8b66fda899 | ||
|
|
1456d4303b | ||
|
|
9d2f23de7c | ||
|
|
9393a48e70 | ||
|
|
749f44d6df | ||
|
|
7af7079a5c | ||
|
|
531bc2e090 | ||
|
|
bc3ab21d75 | ||
|
|
d1811ea24b | ||
|
|
b426d5d505 | ||
|
|
61034c3424 | ||
|
|
10e995ec7f |
@@ -521,11 +521,6 @@ div:has(.o_required_modifier) > label::before {
|
||||
}
|
||||
}
|
||||
|
||||
// 设置表格横向滚动
|
||||
.o_list_renderer.o_renderer {
|
||||
max-width: 100%;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
// 设置表单页面label文本不换行
|
||||
.o_form_view .o_group .o_wrap_label .o_form_label {
|
||||
|
||||
@@ -39,11 +39,7 @@ class SfProductionDemandPlan(models.Model):
|
||||
company_id = fields.Many2one(
|
||||
related='sale_order_id.company_id',
|
||||
store=True, index=True, precompute=True)
|
||||
partner_id = fields.Many2one(
|
||||
comodel_name='res.partner',
|
||||
related='sale_order_line_id.order_partner_id',
|
||||
string="客户",
|
||||
store=True, index=True)
|
||||
customer_name = fields.Char('客户', related='sale_order_id.customer_name')
|
||||
order_remark = fields.Text(related='sale_order_id.remark',
|
||||
string="订单备注", store=True)
|
||||
glb_url = fields.Char(related='sale_order_line_id.glb_url', string='glb文件地址')
|
||||
@@ -64,7 +60,7 @@ class SfProductionDemandPlan(models.Model):
|
||||
product_uom_qty = fields.Float(
|
||||
string="需求数量",
|
||||
related='sale_order_line_id.product_uom_qty', store=True)
|
||||
deadline_of_delivery = fields.Date('客户交期', related='sale_order_id.deadline_of_delivery', store=True)
|
||||
deadline_of_delivery = fields.Date('客户交期', related='sale_order_line_id.delivery_end_date', store=True)
|
||||
inventory_quantity_auto_apply = fields.Float(
|
||||
string="成品库存",
|
||||
compute='_compute_inventory_quantity_auto_apply'
|
||||
@@ -73,7 +69,11 @@ class SfProductionDemandPlan(models.Model):
|
||||
"交货数量", related='sale_order_line_id.qty_delivered')
|
||||
qty_to_deliver = fields.Float(
|
||||
"待交货数量", related='sale_order_line_id.qty_to_deliver')
|
||||
model_long = fields.Char('尺寸', compute='_compute_model_long')
|
||||
model_long = fields.Char('尺寸(mm)', compute='_compute_model_long')
|
||||
blank_type = fields.Selection([('圆料', '圆料'), ('方料', '方料')], string='坯料分类',
|
||||
related='product_id.blank_type')
|
||||
blank_precision = fields.Selection([('精坯', '精坯'), ('粗坯', '粗坯')], string='坯料类型', related='product_id.blank_precision')
|
||||
embryo_long = fields.Char('坯料尺寸(mm)', compute='_compute_embryo_long')
|
||||
materials_id = fields.Char('材料', compute='_compute_materials_id', store=True)
|
||||
model_machining_precision = fields.Selection(selection=_get_machining_precision, string='精度',
|
||||
related='product_id.model_machining_precision')
|
||||
@@ -197,6 +197,17 @@ class SfProductionDemandPlan(models.Model):
|
||||
else:
|
||||
line.model_long = None
|
||||
|
||||
@api.depends('product_id.model_long', 'product_id.model_width', 'product_id.model_height', 'product_id.blank_type')
|
||||
def _compute_embryo_long(self):
|
||||
for line in self:
|
||||
if line.product_id:
|
||||
if line.product_id.blank_type == '圆料':
|
||||
line.embryo_long = f"Ø{round(line.product_id.model_width, 3)}*{round(line.product_id.model_long, 3)}"
|
||||
else:
|
||||
line.embryo_long = f"{round(line.product_id.model_long, 3)}*{round(line.product_id.model_width, 3)}*{round(line.product_id.model_height, 3)}"
|
||||
else:
|
||||
line.embryo_long = None
|
||||
|
||||
@api.depends('product_id.materials_id')
|
||||
def _compute_materials_id(self):
|
||||
for line in self:
|
||||
@@ -278,9 +289,15 @@ class SfProductionDemandPlan(models.Model):
|
||||
if record.sale_order_id and record.sale_order_id.mrp_production_ids:
|
||||
manufacturing_orders = record.sale_order_id.mrp_production_ids.filtered(
|
||||
lambda mo: mo.product_id == record.product_id)
|
||||
|
||||
if manufacturing_orders and manufacturing_orders.move_raw_ids:
|
||||
# 获取完成的制造订单
|
||||
done_manufacturing = manufacturing_orders.filtered(lambda mo: mo.state == 'done')
|
||||
product_qty = sum(done_manufacturing.mapped('product_qty'))
|
||||
# 需求数量-完成数量
|
||||
product_uom_qty = record.product_uom_qty - product_qty
|
||||
total_reserved_availability = sum(manufacturing_orders.mapped('move_raw_ids.reserved_availability'))
|
||||
if float_compare(total_reserved_availability, record.product_uom_qty,
|
||||
if float_compare(total_reserved_availability, product_uom_qty,
|
||||
precision_rounding=record.product_id.uom_id.rounding) >= 0:
|
||||
record.material_check = '1' # 已齐套
|
||||
else:
|
||||
@@ -305,7 +322,7 @@ class SfProductionDemandPlan(models.Model):
|
||||
[('name', '=', '1#CNC自动生产线')], limit=1)
|
||||
if sf_production_line:
|
||||
now = datetime.now()
|
||||
time_part = (now + timedelta(minutes=3)).time()
|
||||
time_part = (now + timedelta(hours=2)).time()
|
||||
date_part = fields.Date.from_string(self.planned_start_date)
|
||||
date_planned_start = datetime.combine(date_part, time_part)
|
||||
pro_plan_list.production_line_id = sf_production_line.id
|
||||
@@ -320,7 +337,6 @@ class SfProductionDemandPlan(models.Model):
|
||||
'name': _("打印"),
|
||||
'domain': [('demand_plan_id', 'in', self.ids)],
|
||||
'views': [[self.env.ref('sf_demand_plan.action_plan_print_tree').id, 'list']],
|
||||
'search_view_id': self.env.ref('sf_demand_plan.action_plan_print_search').id,
|
||||
'target': 'new',
|
||||
}
|
||||
|
||||
@@ -387,29 +403,30 @@ class SfProductionDemandPlan(models.Model):
|
||||
outsourcing_purchase_request.extend(pr_ids.ids)
|
||||
if record.supply_method == 'outsourcing' and not record.sale_order_line_id.is_incoming_material:
|
||||
bom_line_ids = record.product_id.bom_ids.bom_line_ids
|
||||
# BOM_数量
|
||||
total_product_qty = sum(line.product_qty for line in bom_line_ids)
|
||||
bom_product_ids = bom_line_ids.mapped('product_id')
|
||||
product_purchase_orders = self.env['purchase.order'].sudo().search([
|
||||
('state', 'in', ('purchase', 'done')),
|
||||
('order_line.product_id', 'in', bom_product_ids.ids)
|
||||
])
|
||||
# 购订单_数量
|
||||
total_outsourcing_purchase_quantity = sum(
|
||||
sum(
|
||||
order.order_line.filtered(
|
||||
lambda line: line.product_id in bom_product_ids
|
||||
).mapped('product_qty')
|
||||
if bom_line_ids:
|
||||
# BOM_数量
|
||||
total_product_qty = sum(line.product_qty for line in bom_line_ids)
|
||||
bom_product_ids = bom_line_ids.mapped('product_id')
|
||||
product_purchase_orders = self.env['purchase.order'].sudo().search([
|
||||
('state', 'in', ('purchase', 'done')),
|
||||
('order_line.product_id', 'in', bom_product_ids.ids)
|
||||
])
|
||||
# 购订单_数量
|
||||
total_outsourcing_purchase_quantity = sum(
|
||||
sum(
|
||||
order.order_line.filtered(
|
||||
lambda line: line.product_id in bom_product_ids
|
||||
).mapped('product_qty')
|
||||
)
|
||||
for order in product_purchase_orders
|
||||
)
|
||||
for order in product_purchase_orders
|
||||
)
|
||||
quantity = total_outsourcing_purchase_quantity / total_product_qty
|
||||
if float_compare(quantity, record.product_uom_qty,
|
||||
precision_rounding=record.product_id.uom_id.rounding) == -1:
|
||||
purchase_request = self.env['purchase.request'].sudo().search(
|
||||
[('line_ids.product_id', 'in', bom_product_ids.ids),
|
||||
('line_ids.purchase_state', 'not in', ('purchase', 'done')), ('state', '!=', 'done')])
|
||||
outsourcing_purchase_request.extend(purchase_request.ids)
|
||||
quantity = total_outsourcing_purchase_quantity / total_product_qty
|
||||
if float_compare(quantity, record.product_uom_qty,
|
||||
precision_rounding=record.product_id.uom_id.rounding) == -1:
|
||||
purchase_request = self.env['purchase.request'].sudo().search(
|
||||
[('line_ids.product_id', 'in', bom_product_ids.ids),
|
||||
('line_ids.purchase_state', 'not in', ('purchase', 'done')), ('state', '!=', 'done')])
|
||||
outsourcing_purchase_request.extend(purchase_request.ids)
|
||||
record.outsourcing_purchase_request = json.dumps(outsourcing_purchase_request)
|
||||
if outsourcing_purchase_request:
|
||||
record.hide_action_purchase_orders = True
|
||||
|
||||
@@ -13,6 +13,7 @@ odoo.define('sf_demand.print_demand', function (require) {
|
||||
this.getParent()?.$buttons.hide();
|
||||
|
||||
return this._super.apply(this, arguments).then(function () {
|
||||
if(!self.state.data || !self.state.data.length) return
|
||||
// 添加图片预览容器到页面左侧
|
||||
if (!$('.table-image-preview-container').length) {
|
||||
self.$el.parent().addClass('custom-table-image-container')
|
||||
@@ -22,29 +23,53 @@ odoo.define('sf_demand.print_demand', function (require) {
|
||||
<iframe class="table-image-preview-container" src=""/>
|
||||
</div>`
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
if(!$('.denmand_set').length) {
|
||||
|
||||
const checked = self.getParent().radioCheck || 'all'
|
||||
|
||||
self.$el.prepend(`
|
||||
<form class="denmand_set">
|
||||
<span>更多设置:</span>
|
||||
<input type="radio" id="male" name="set" value="图纸">
|
||||
<label for="male">图纸</label>
|
||||
<input type="radio" id="female" name="set" value="程序单">
|
||||
<label for="female">程序单</label>
|
||||
<input type="radio" id="other" name="set" value="all" >
|
||||
<label for="other">图纸/程序单</label>
|
||||
</form>
|
||||
`)
|
||||
setTimeout(() => {
|
||||
$(`input[name=set][value=${checked}]`).prop('checked', true)
|
||||
$('.denmand_set').trigger('click')
|
||||
}, 100);
|
||||
self.$el.prepend(`
|
||||
<div class="print-button-container" style="margin-bottom:10px;">
|
||||
<button class="btn btn-primary o_print_custom">
|
||||
<i class="fa fa-print"></i> 打印
|
||||
</button>
|
||||
<button class="btn btn-secondary o_cancel_custom">
|
||||
取消
|
||||
取消
|
||||
</button>
|
||||
</div>
|
||||
`);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
start: function() {
|
||||
setTimeout(() => {
|
||||
this.$el.find('.o_data_row').eq(0).trigger('click')
|
||||
this.getParent().$el?.find('.o_cp_top_right,.o_cp_bottom').hide()
|
||||
}, 500);
|
||||
return this._super();
|
||||
},
|
||||
events: _.extend({}, ListRenderer.prototype.events, {
|
||||
'click .o_data_row': '_onCustomRowClick',
|
||||
'click .o_print_custom': '_onPrintClick',
|
||||
'click .o_cancel_custom': '_onCancelClick'
|
||||
'click .o_cancel_custom': '_onCancelClick',
|
||||
'click .denmand_set': '_onDenmandChange',
|
||||
}),
|
||||
_onCancelClick() {
|
||||
this.getParent()?.getParent()?.dialogs.closeAll()
|
||||
@@ -89,14 +114,12 @@ odoo.define('sf_demand.print_demand', function (require) {
|
||||
}
|
||||
},
|
||||
getSelectedIds: function() {
|
||||
return this.state.data.map(_ => {
|
||||
return this.state.data.filter(_ => !_.hide).map(_ => {
|
||||
return _.data.id
|
||||
})
|
||||
},
|
||||
_onPrintClick(e) {
|
||||
var print_ids = this.getSelectedIds();
|
||||
|
||||
|
||||
this._rpc({
|
||||
model: 'sf.demand.plan.print.wizard',
|
||||
method: 'demand_plan_print',
|
||||
@@ -114,10 +137,28 @@ odoo.define('sf_demand.print_demand', function (require) {
|
||||
// self.do_warn("打印失败", error.data.message || "未知错误");
|
||||
}).finally(e => {
|
||||
this.getParent().reload()
|
||||
|
||||
})
|
||||
|
||||
},
|
||||
_onDenmandChange(e) {
|
||||
const isChecked = $(e.currentTarget).find('input:checked').val()
|
||||
this.getParent().radioCheck = isChecked
|
||||
this.$el.find('tbody').find('.o_data_row').show()
|
||||
|
||||
this.state.data.forEach(_ => {
|
||||
_.hide = false
|
||||
})
|
||||
const self = this
|
||||
if(!isChecked || isChecked == 'all') return
|
||||
this.$el.find('tbody').children('.o_data_row').each(function() {
|
||||
if($(this).find('td[name=type]').text() != isChecked) {
|
||||
const i = $(this).index()
|
||||
|
||||
self.state.data[i].hide = true
|
||||
$(this).hide()
|
||||
}
|
||||
})
|
||||
},
|
||||
getFileUrl(attachment_type, data, key) {
|
||||
let fileUrl
|
||||
switch (attachment_type) {
|
||||
|
||||
@@ -63,4 +63,27 @@
|
||||
.o_print_custom {
|
||||
right: 66px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.denmand_set {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 50px;
|
||||
> span {
|
||||
font-weight: bold;
|
||||
}
|
||||
input {
|
||||
margin-left: 30px;
|
||||
}
|
||||
label {
|
||||
margin-left: 5px;
|
||||
}
|
||||
input,label {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
th[data-name=processing_time] + th::before{
|
||||
content: '待执行单据';
|
||||
line-height: 38px;
|
||||
}
|
||||
|
||||
@@ -3,17 +3,18 @@
|
||||
<field name="name">sf.production.demand.plan.tree</field>
|
||||
<field name="model">sf.production.demand.plan</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="需求计划" default_order="sequence desc,create_date desc" editable="bottom"
|
||||
class="demand_plan_tree">
|
||||
<tree string="需求计划" default_order="sequence desc,id desc" editable="bottom"
|
||||
class="demand_plan_tree freeze-columns-before-part_number">
|
||||
<header>
|
||||
<button string="打印" name="button_action_print" type="object"
|
||||
class="btn-primary"/>
|
||||
<button string="创建工艺设计任务" name="%(sf_manufacturing.action_create_technology_design_task_wizard)d"
|
||||
type="action" class="btn-secondary" context="{'active_model': 'sf.production.demand.plan', 'active_ids': active_ids}"/>
|
||||
</header>
|
||||
<field name="sequence" widget="handle"/>
|
||||
<field name="id" optional="hide"/>
|
||||
<field name="priority"/>
|
||||
<field name="status"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="customer_name"/>
|
||||
<field name="order_remark"/>
|
||||
<field name="glb_url" optional="hide"/>
|
||||
<field name="product_id"/>
|
||||
@@ -28,6 +29,9 @@
|
||||
<field name="qty_delivered"/>
|
||||
<field name="qty_to_deliver"/>
|
||||
<field name="model_long"/>
|
||||
<field name="blank_type" optional="hide"/>
|
||||
<field name="blank_precision"/>
|
||||
<field name="embryo_long"/>
|
||||
<field name="materials_id"/>
|
||||
<field name="model_machining_precision"/>
|
||||
<field name="model_process_parameters_ids" widget="many2many_tags"/>
|
||||
@@ -41,7 +45,10 @@
|
||||
<field name="date_order"/>
|
||||
<field name="contract_code"/>
|
||||
<field name="plan_remark"/>
|
||||
<field name="processing_time"/>
|
||||
<field name="priority" decoration-danger="priority == '1'"
|
||||
decoration-warning="priority == '2'"
|
||||
decoration-info="priority == '3'"
|
||||
decoration-success="priority == '4'"/>
|
||||
<field name="material_check" optional="hide"/>
|
||||
<field name="hide_action_open_mrp_production" invisible="1"/>
|
||||
<field name="hide_action_purchase_orders" invisible="1"/>
|
||||
@@ -60,6 +67,7 @@
|
||||
<field name="planned_start_date"/>
|
||||
<field name="actual_start_date"/>
|
||||
<field name="actual_end_date"/>
|
||||
<field name="processing_time"/>
|
||||
<field name="create_date" optional="hide" string="创建时间"/>
|
||||
<field name="create_uid" optional="hide" string="创建人"/>
|
||||
<field name="write_date" string="更新时间"/>
|
||||
@@ -80,7 +88,7 @@
|
||||
<field name="product_id"/>
|
||||
<field name="part_name"/>
|
||||
<field name="part_number"/>
|
||||
<field name="partner_id"/>
|
||||
<field name="customer_name"/>
|
||||
<field name="supply_method"/>
|
||||
<field name="materials_id"/>
|
||||
<field name="model_process_parameters_ids"/>
|
||||
@@ -89,7 +97,8 @@
|
||||
<group expand="0" string="Group By">
|
||||
<filter name="group_by_priority" string="优先级" domain="[]" context="{'group_by': 'priority'}"/>
|
||||
<filter name="group_by_status" string="状态" domain="[]" context="{'group_by': 'status'}"/>
|
||||
<filter name="group_by_partner_id" string="客户" domain="[]" context="{'group_by': 'partner_id'}"/>
|
||||
<filter name="group_by_customer_name" string="客户" domain="[]"
|
||||
context="{'group_by': 'customer_name'}"/>
|
||||
<filter name="group_by_is_incoming_material" string="客供料" domain="[]"
|
||||
context="{'group_by': 'is_incoming_material'}"/>
|
||||
<filter name="group_by_supply_method" string="供货方式" domain="[]"
|
||||
@@ -120,4 +129,9 @@
|
||||
action="sf_production_demand_plan_action"
|
||||
parent="sf_plan.sf_production_plan_menu"
|
||||
/>
|
||||
|
||||
<!-- 调拨动作中屏蔽验证-->
|
||||
<record id="stock.action_validate_picking" model="ir.actions.server">
|
||||
<field name="binding_model_id" eval="False"/>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -27,7 +27,6 @@ class SfDemandPlanPrintWizard(models.TransientModel):
|
||||
], string='状态', default='not_start')
|
||||
machining_drawings = fields.Binary('2D加工图纸', related='product_id.machining_drawings', store=True)
|
||||
|
||||
workorder_id = fields.Many2one('mrp.workorder', string='工单')
|
||||
cnc_worksheet = fields.Binary('程序单')
|
||||
|
||||
@api.model
|
||||
@@ -77,7 +76,7 @@ class MrpWorkorder(models.Model):
|
||||
for record in self:
|
||||
if 'cnc_worksheet' in vals:
|
||||
demand_plan_print = self.env['sf.demand.plan.print.wizard'].sudo().search(
|
||||
[('workorder_id', '=', record.id)])
|
||||
[('model_id', '=', record.model_id), ('type', '=', '2')])
|
||||
if demand_plan_print:
|
||||
self.env['sf.demand.plan.print.wizard'].sudo().write(
|
||||
{'cnc_worksheet': record.cnc_worksheet, 'filename_url': record.cnc_worksheet_name})
|
||||
@@ -89,7 +88,6 @@ class MrpWorkorder(models.Model):
|
||||
'demand_plan_id': demand_plan.id,
|
||||
'model_id': demand_plan.model_id,
|
||||
'type': '2',
|
||||
'workorder_id': record.id,
|
||||
'cnc_worksheet': record.cnc_worksheet,
|
||||
'filename_url': record.cnc_worksheet_name
|
||||
}
|
||||
|
||||
@@ -14,21 +14,4 @@
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_plan_print_search" model="ir.ui.view">
|
||||
<field name="name">sf.demand.plan.print.wizard.search</field>
|
||||
<field name="model">sf.demand.plan.print.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<search>
|
||||
<field name="type"/>
|
||||
<filter string="图纸" name="filter_type_1" domain="[('type', '=', '1')]"/>
|
||||
<filter string="程序单" name="filter_type_2" domain="[('type', '=', '2')]"/>
|
||||
<filter string="图纸、程序单" name="filter_type_all" domain="[('type', 'in', ('1','2'))]"/>
|
||||
<separator/>
|
||||
<group expand="0" string="Group By">
|
||||
<filter name="group_by_type" string="类型" domain="[]" context="{'group_by': 'type'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -3,6 +3,7 @@ import logging
|
||||
|
||||
import re
|
||||
from odoo import models, fields, api
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class ResProductCategory(models.Model):
|
||||
@@ -47,11 +48,14 @@ class ResMrpBomMo(models.Model):
|
||||
item.subcontractor_name = ''
|
||||
|
||||
def bom_create_line_has(self, embryo):
|
||||
product = self.product_tmpl_id
|
||||
if product.unit_number in (0, None, False):
|
||||
raise ValidationError(f'产品{product.name}单件用量的值不能为{product.unit_number}')
|
||||
vals = {
|
||||
'bom_id': self.id,
|
||||
'product_id': embryo.id,
|
||||
'product_tmpl_id': embryo.product_tmpl_id.id,
|
||||
'product_qty': 1,
|
||||
'product_qty': product.unit_number,
|
||||
'product_uom_id': 1
|
||||
}
|
||||
return self.env['mrp.bom.line'].sudo().create(vals)
|
||||
@@ -122,7 +126,7 @@ class ResMrpBomMo(models.Model):
|
||||
# 查bom的原材料
|
||||
def get_raw_bom(self, product):
|
||||
raw_bom = self.env['product.product'].search(
|
||||
[('categ_id.type', '=', '原材料'), ('materials_type_id', '=', product.materials_type_id.id)],limit=1)
|
||||
[('categ_id.type', '=', '原材料'), ('materials_type_id', '=', product.materials_type_id.id)], limit=1)
|
||||
return raw_bom
|
||||
|
||||
|
||||
|
||||
@@ -73,15 +73,20 @@ class ResProductTemplate(models.Model):
|
||||
copy_product_id.product_tmpl_id.active = True
|
||||
model_type = self.env['sf.model.type'].search([], limit=1)
|
||||
attachment = self.attachment_create(item['model_name'], item['model_data'])
|
||||
# 判断参数中是否包含 坯料尺寸(长、宽、高)
|
||||
blank_bool = any(value is not None and value != 0 for value in (
|
||||
item.get('blank_length'), item.get('blank_width'), item.get('blank_height'))) if all(
|
||||
key in item for key in ('blank_length', 'blank_width', 'blank_height')) else False
|
||||
vals = {
|
||||
'name': '%s-%s-%s' % ('P', order_id.name, i),
|
||||
'blank_type': item.get('blank_type'),
|
||||
'model_long': item['model_long'] + model_type.embryo_tolerance,
|
||||
'model_width': item['model_width'] + model_type.embryo_tolerance,
|
||||
'model_height': item['model_height'] + model_type.embryo_tolerance,
|
||||
'model_volume': (item['model_long'] + model_type.embryo_tolerance) * (
|
||||
item['model_width'] + model_type.embryo_tolerance) * (
|
||||
item['model_height'] + model_type.embryo_tolerance),
|
||||
'model_long': item.get('blank_length') if blank_bool else item['model_long'] + model_type.embryo_tolerance,
|
||||
'model_width': item.get('blank_width') if blank_bool else item['model_width'] + model_type.embryo_tolerance,
|
||||
'model_height': item.get('blank_height') if blank_bool else item['model_height'] + model_type.embryo_tolerance,
|
||||
'model_volume': ((item['model_long'] + model_type.embryo_tolerance) *
|
||||
(item['model_width'] + model_type.embryo_tolerance) *
|
||||
(item['model_height'] + model_type.embryo_tolerance)) if not blank_bool else (
|
||||
item.get('blank_length') * item.get('blank_width') * item.get('blank_height')),
|
||||
'product_model_type_id': model_type.id,
|
||||
'model_processing_panel': 'R',
|
||||
'model_machining_precision': item['model_machining_precision'],
|
||||
|
||||
@@ -95,6 +95,8 @@
|
||||
<page string="加工参数">
|
||||
<group>
|
||||
<group string="模型">
|
||||
<field name="blank_type" readonly="1"/>
|
||||
<field name="blank_precision" readonly="1"/>
|
||||
<label for="model_long" string="坯料尺寸[mm]"/>
|
||||
<div class="o_address_format">
|
||||
<label for="model_long" string="长"/>
|
||||
@@ -104,7 +106,7 @@
|
||||
<label for="model_height" string="高"/>
|
||||
<field name="model_height" class="o_address_zip"/>
|
||||
</div>
|
||||
<field name="blank_type" readonly="1"/>
|
||||
<field name="unit_number" readonly="1"/>
|
||||
<field name="model_volume" string="体积[mm³]"/>
|
||||
<field name="product_model_type_id" string="模型类型"/>
|
||||
<field name="model_processing_panel" placeholder="例如R,U" string="加工面板"
|
||||
|
||||
@@ -377,7 +377,11 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
line_list_obj = request.env['sf.production.line'].sudo().search([('name', 'ilike', 'CNC')])
|
||||
line_list = list(map(lambda x: x.name, line_list_obj))
|
||||
# print('line_list: %s' % line_list)
|
||||
res['LineList'] = line_list
|
||||
res['LineList'] = ['业绩总览']
|
||||
res['LineList'] += line_list
|
||||
res['LineList'].append('人工线下加工中心')
|
||||
# 增加“业绩总览”与“人工线下加工中心”
|
||||
|
||||
|
||||
except Exception as e:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||
@@ -401,37 +405,55 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
|
||||
try:
|
||||
plan_obj = request.env['sf.production.plan'].sudo()
|
||||
production_obj = request.env['mrp.production'].sudo()
|
||||
# production_obj = request.env['mrp.production'].sudo()
|
||||
work_order_obj = request.env['mrp.workorder'].sudo()
|
||||
line_list = ast.literal_eval(kw['line_list'])
|
||||
|
||||
line_list_obj = request.env['sf.production.line'].sudo().search([('name', 'ilike', 'CNC')])
|
||||
cnc_line_list = list(map(lambda x: x.name, line_list_obj))
|
||||
# print('line_list: %s' % line_list)
|
||||
for line in line_list:
|
||||
|
||||
if line == '业绩总览':
|
||||
work_order_domain = [('routing_type', 'in', ['人工线下加工', 'CNC加工'])]
|
||||
plan_domain = []
|
||||
elif line == '人工线下加工中心':
|
||||
work_order_domain = [('routing_type', '=', '人工线下加工')]
|
||||
plan_domain = [('production_type', '=', '人工线下加工')]
|
||||
else:
|
||||
work_order_domain = [
|
||||
('production_line_id.name', '=', line),
|
||||
('routing_type', '=', 'CNC加工')
|
||||
]
|
||||
plan_domain = [('production_line_id.name', '=', line)]
|
||||
# # 工单计划量
|
||||
# plan_data_total_counts = production_obj.search_count(
|
||||
# [('production_line_id.name', '=', line), ('state', 'not in', ['cancel']),
|
||||
# ('active', '=', True)])
|
||||
|
||||
# 工单计划量切换为CNC工单
|
||||
plan_data_total_counts = work_order_obj.search_count(
|
||||
[('production_line_id.name', '=', line), ('id', '!=', 8061),
|
||||
('state', 'in', ['ready', 'progress', 'done']), ('routing_type', '=', 'CNC加工')])
|
||||
plan_data_total = work_order_obj.search(work_order_domain + [
|
||||
('id', '!=', 8061),
|
||||
('state', 'in', ['ready', 'progress', 'done'])
|
||||
])
|
||||
|
||||
plan_data_total_counts = sum(plan_data_total.mapped('qty_produced'))
|
||||
|
||||
# # 工单完成量
|
||||
# plan_data_finish_counts = plan_obj.search_count(
|
||||
# [('production_line_id.name', '=', line), ('state', 'in', ['finished'])])
|
||||
|
||||
# 工单完成量切换为CNC工单
|
||||
plan_data_finish_counts = work_order_obj.search_count(
|
||||
[('production_line_id.name', '=', line),
|
||||
('state', 'in', ['done']), ('routing_type', '=', 'CNC加工')])
|
||||
plan_data_finish = work_order_obj.search(work_order_domain + [
|
||||
('state', 'in', ['done'])
|
||||
])
|
||||
|
||||
plan_data_finish_counts = sum(plan_data_finish.mapped('qty_produced'))
|
||||
|
||||
# 超期完成量
|
||||
# 搜索所有已经完成的工单
|
||||
plan_data_overtime = work_order_obj.search([
|
||||
('production_line_id.name', '=', line),
|
||||
('state', 'in', ['done']),
|
||||
('routing_type', '=', 'CNC加工')
|
||||
plan_data_overtime = work_order_obj.search(work_order_domain + [
|
||||
('state', 'in', ['done'])
|
||||
])
|
||||
|
||||
# 使用 filtered 进行字段比较
|
||||
@@ -440,36 +462,38 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
)
|
||||
|
||||
# 获取数量
|
||||
plan_data_overtime_counts = len(plan_data_overtime_counts)
|
||||
# plan_data_overtime_counts = len(plan_data_overtime_counts)
|
||||
plan_data_overtime_counts = sum(plan_data_overtime_counts.mapped('qty_produced'))
|
||||
|
||||
# 查找符合条件的生产计划记录
|
||||
plan_data = plan_obj.search([
|
||||
('production_line_id.name', '=', line),
|
||||
])
|
||||
# plan_data = plan_obj.search(plan_domain)
|
||||
|
||||
# 过滤出那些检测结果状态为 '返工' 或 '报废' 的记录
|
||||
# faulty_plans = plan_data.filtered(lambda p: any(
|
||||
# result.test_results in ['返工', '报废'] for result in p.production_id.detection_result_ids
|
||||
# ))
|
||||
|
||||
faulty_plans = request.env['quality.check'].sudo().search([
|
||||
('operation_id.name', '=', 'CNC加工'),
|
||||
('quality_state', 'in', ['fail'])
|
||||
faulty_plans = work_order_obj.search(work_order_domain + [
|
||||
('state', 'in', ['scrap', 'rework'])
|
||||
])
|
||||
|
||||
# 查找制造订单取消与归档的数量
|
||||
cancel_order_count = production_obj.search_count(
|
||||
[('production_line_id.name', '=', line), ('state', 'in', ['cancel']),
|
||||
('active', '=', False)])
|
||||
# cancel_order_count = production_obj.search_count(
|
||||
# [('production_line_id.name', '=', line), ('state', 'in', ['cancel']),
|
||||
# ('active', '=', False)])
|
||||
|
||||
# 计算符合条件的记录数量
|
||||
# plan_data_fault_counts = len(faulty_plans) + cancel_order_count
|
||||
plan_data_fault_counts = len(faulty_plans)
|
||||
# plan_data_fault_counts = len(faulty_plans)
|
||||
plan_data_fault_counts = sum(faulty_plans.mapped('qty_produced'))
|
||||
|
||||
# 工单返工数量
|
||||
|
||||
plan_data_rework_counts = plan_obj.search_count(
|
||||
[('production_line_id.name', '=', line), ('production_id.state', 'in', ['rework'])])
|
||||
plan_data_rework = work_order_obj.search(work_order_domain + [
|
||||
('state', 'in', ['rework'])
|
||||
])
|
||||
|
||||
plan_data_rework_counts = sum(plan_data_rework.mapped('qty_produced'))
|
||||
|
||||
# 工单完成率
|
||||
finishe_rate = round(
|
||||
@@ -479,8 +503,9 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
plan_data_progress_deviation = plan_data_total_counts - plan_data_finish_counts - plan_data_fault_counts
|
||||
|
||||
# 完成记录
|
||||
plan_data_finish_orders = plan_obj.search(
|
||||
[('production_line_id.name', '=', line), ('state', 'in', ['finished'])])
|
||||
plan_data_finish_orders = plan_obj.search(plan_domain + [
|
||||
('state', 'in', ['finished'])
|
||||
])
|
||||
|
||||
# # 检测量
|
||||
# detection_nums = 0
|
||||
@@ -534,25 +559,25 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
delay_rate = round((delay_num / plan_data_finish_counts if plan_data_finish_counts > 0 else 0), 3)
|
||||
on_time_rate = 1 - delay_rate
|
||||
|
||||
if plan_data:
|
||||
data = {
|
||||
'plan_data_total_counts': plan_data_total_counts,
|
||||
'plan_data_finish_counts': plan_data_finish_counts,
|
||||
'plan_data_plan_counts': plan_data_total_counts,
|
||||
'plan_data_fault_counts': plan_data_fault_counts,
|
||||
'nopass_orders_counts': detection_data - len(pass_nums),
|
||||
'finishe_rate': finishe_rate,
|
||||
'plan_data_progress_deviation': plan_data_progress_deviation,
|
||||
'plan_data_rework_counts': plan_data_rework_counts,
|
||||
'on_time_rate': on_time_rate,
|
||||
# 'detection_data': detection_data,
|
||||
'detection_data': plan_data_finish_counts,
|
||||
'pass_rate': (plan_data_finish_counts - plan_data_fault_counts) / plan_data_finish_counts,
|
||||
'plan_data_overtime_counts': plan_data_overtime_counts,
|
||||
'overtime_rate': plan_data_overtime_counts / plan_data_finish_counts
|
||||
if plan_data_finish_counts > 0 else 0,
|
||||
}
|
||||
res['data'][line] = data
|
||||
# if plan_data:
|
||||
data = {
|
||||
'plan_data_total_counts': plan_data_total_counts,
|
||||
'plan_data_finish_counts': plan_data_finish_counts,
|
||||
'plan_data_plan_counts': plan_data_total_counts,
|
||||
'plan_data_fault_counts': plan_data_fault_counts,
|
||||
'nopass_orders_counts': detection_data - len(pass_nums),
|
||||
'finishe_rate': finishe_rate,
|
||||
'plan_data_progress_deviation': plan_data_progress_deviation,
|
||||
'plan_data_rework_counts': plan_data_rework_counts,
|
||||
'on_time_rate': on_time_rate,
|
||||
# 'detection_data': detection_data,
|
||||
'detection_data': plan_data_finish_counts,
|
||||
'pass_rate': (plan_data_finish_counts - plan_data_fault_counts) / plan_data_finish_counts,
|
||||
'plan_data_overtime_counts': plan_data_overtime_counts,
|
||||
'overtime_rate': plan_data_overtime_counts / plan_data_finish_counts
|
||||
if plan_data_finish_counts > 0 else 0,
|
||||
}
|
||||
res['data'][line] = data
|
||||
|
||||
return json.dumps(res) # 注意使用 json.dumps 而不是直接用 json.JSONEncoder().encode()
|
||||
|
||||
@@ -608,16 +633,34 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
date_list.append(current_date)
|
||||
current_date += timedelta(days=1)
|
||||
return date_list
|
||||
|
||||
|
||||
for line in line_list:
|
||||
date_field_name = 'date_finished' # 替换为你模型中的实际字段名
|
||||
order_counts = []
|
||||
if time_unit == 'hour':
|
||||
|
||||
for line in line_list:
|
||||
date_field_name = 'date_finished' # 替换为你模型中的实际字段名
|
||||
order_counts = []
|
||||
|
||||
if time_unit == 'hour':
|
||||
if line == '业绩总览':
|
||||
work_order_domain = [('routing_type', 'in', ['人工线下加工', 'CNC加工'])]
|
||||
elif line == '人工线下加工中心':
|
||||
work_order_domain = [('routing_type', '=', '人工线下加工')]
|
||||
else:
|
||||
work_order_domain = [
|
||||
('production_line_id.name', '=', line),
|
||||
('routing_type', '=', 'CNC加工')
|
||||
]
|
||||
time_intervals = get_time_intervals(begin_time, end_time, time_unit)
|
||||
print('============================= %s' % time_intervals)
|
||||
|
||||
time_count_dict = {}
|
||||
plan_count_dict = {}
|
||||
|
||||
orders = request.env['mrp.workorder'].sudo().search(work_order_domain + [
|
||||
('state', 'in', ['done']),
|
||||
(date_field_name, '>=', begin_time.strftime('%Y-%m-%d %H:%M:%S')),
|
||||
(date_field_name, '<=', end_time.strftime('%Y-%m-%d %H:%M:%S'))
|
||||
])
|
||||
|
||||
for time_interval in time_intervals:
|
||||
start_time, end_time = time_interval
|
||||
@@ -629,66 +672,113 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
# (date_field_name, '<=', end_time.strftime('%Y-%m-%d %H:%M:%S')) # 包括结束时间
|
||||
# ])
|
||||
|
||||
orders = request.env['mrp.workorder'].sudo().search([
|
||||
('routing_type', '=', 'CNC加工'), # 将第一个条件合并进来
|
||||
('production_line_id.name', '=', line),
|
||||
('state', 'in', ['done']),
|
||||
(date_field_name, '>=', start_time.strftime('%Y-%m-%d %H:%M:%S')),
|
||||
(date_field_name, '<=', end_time.strftime('%Y-%m-%d %H:%M:%S'))
|
||||
])
|
||||
interval_orders = orders.filtered(
|
||||
lambda o: o[date_field_name] >= start_time
|
||||
and o[date_field_name] <= end_time
|
||||
)
|
||||
|
||||
# 使用小时和分钟作为键,确保每个小时的数据有独立的键
|
||||
key = start_time.strftime('%H:%M:%S') # 只取小时:分钟:秒作为键
|
||||
time_count_dict[key] = len(orders)
|
||||
# time_count_dict[key] = len(orders)
|
||||
time_count_dict[key] = sum(interval_orders.mapped('qty_produced'))
|
||||
|
||||
# 计划量,目前只能从mail.message中筛选出
|
||||
plan_order_messages = request.env['mail.message'].sudo().search([
|
||||
('model', '=', 'mrp.workorder'),
|
||||
('create_date', '>=', begin_time.strftime('%Y-%m-%d %H:%M:%S')),
|
||||
('create_date', '<=', end_time.strftime('%Y-%m-%d %H:%M:%S')),
|
||||
('tracking_value_ids.field_desc', '=', '状态'),
|
||||
('tracking_value_ids.new_value_char', '=', '就绪')
|
||||
])
|
||||
|
||||
for time_interval in time_intervals:
|
||||
start_time, end_time = time_interval
|
||||
|
||||
# orders = plan_obj.search([
|
||||
# ('production_line_id.name', '=', line),
|
||||
# ('state', 'in', ['done']),
|
||||
# (date_field_name, '>=', start_time.strftime('%Y-%m-%d %H:%M:%S')),
|
||||
# (date_field_name, '<=', end_time.strftime('%Y-%m-%d %H:%M:%S')) # 包括结束时间
|
||||
# ])
|
||||
|
||||
interval_plan_orders = plan_order_messages.filtered(
|
||||
lambda o: o.create_date >= start_time
|
||||
and o.create_date <= end_time
|
||||
)
|
||||
|
||||
interval_orders = request.env['mrp.workorder'].sudo().browse(interval_plan_orders.mapped('res_id'))
|
||||
if line == '业绩总览':
|
||||
interval_orders = interval_orders.filtered(lambda o: o.routing_type in ['人工线下加工', 'CNC加工'])
|
||||
elif line == '人工线下加工中心':
|
||||
interval_orders = interval_orders.filtered(lambda o: o.routing_type == '人工线下加工')
|
||||
else:
|
||||
interval_orders = interval_orders.filtered(lambda o: o.routing_type == 'CNC加工' and o.production_line_id.name == line)
|
||||
|
||||
# 使用小时和分钟作为键,确保每个小时的数据有独立的键
|
||||
key = start_time.strftime('%H:%M:%S') # 只取小时:分钟:秒作为键
|
||||
# time_count_dict[key] = len(orders)
|
||||
plan_count_dict[key] = sum(interval_orders.mapped('qty_produced'))
|
||||
|
||||
# order_counts.append()
|
||||
res['data'][line] = {
|
||||
'finish_order_nums': time_count_dict,
|
||||
'plan_order_nums': 28
|
||||
'plan_order_nums': plan_count_dict
|
||||
}
|
||||
return json.dumps(res)
|
||||
else:
|
||||
|
||||
date_list = get_date_list(begin_time, end_time)
|
||||
for line in line_list:
|
||||
date_field_name = 'date_finished' # 替换为你模型中的实际字段名
|
||||
order_counts = []
|
||||
|
||||
for date in date_list:
|
||||
next_day = date + timedelta(days=1)
|
||||
orders = request.env['mrp.workorder'].sudo().search(
|
||||
[('production_id.production_line_id.name', '=', line), ('state', 'in', ['done']),
|
||||
('routing_type', '=', 'CNC加工'),
|
||||
(date_field_name, '>=', date.strftime('%Y-%m-%d 00:00:00')),
|
||||
(date_field_name, '<', next_day.strftime('%Y-%m-%d 00:00:00'))
|
||||
])
|
||||
if line == '业绩总览':
|
||||
work_order_domain = [('routing_type', 'in', ['人工线下加工', 'CNC加工'])]
|
||||
elif line == '人工线下加工中心':
|
||||
work_order_domain = [('routing_type', '=', '人工线下加工')]
|
||||
else:
|
||||
work_order_domain = [
|
||||
('production_line_id.name', '=', line),
|
||||
('routing_type', '=', 'CNC加工')
|
||||
]
|
||||
|
||||
rework_orders = request.env['mrp.workorder'].sudo().search(
|
||||
[('production_id.production_line_id.name', '=', line), ('state', 'in', ['rework']),
|
||||
('routing_type', '=', 'CNC加工'),
|
||||
(date_field_name, '>=', date.strftime('%Y-%m-%d 00:00:00')),
|
||||
(date_field_name, '<', next_day.strftime('%Y-%m-%d 00:00:00'))
|
||||
])
|
||||
not_passed_orders = request.env['mrp.workorder'].sudo().search(
|
||||
[('production_id.production_line_id.name', '=', line), ('state', 'in', ['scrap', 'cancel']),
|
||||
('routing_type', '=', 'CNC加工'),
|
||||
(date_field_name, '>=', date.strftime('%Y-%m-%d 00:00:00')),
|
||||
(date_field_name, '<', next_day.strftime('%Y-%m-%d 00:00:00'))
|
||||
])
|
||||
order_counts.append({
|
||||
'date': date.strftime('%Y-%m-%d'),
|
||||
'order_count': len(orders),
|
||||
'rework_orders': len(rework_orders),
|
||||
'not_passed_orders': len(not_passed_orders)
|
||||
})
|
||||
# 外面包一层,没什么是包一层不能解决的,包一层就能区分了,类似于包一层div
|
||||
# 外面包一层的好处是,可以把多个数据结构打包在一起,方便前端处理
|
||||
date_list = get_date_list(begin_time, end_time)
|
||||
|
||||
# date_list_dict = {line: order_counts}
|
||||
for date in date_list:
|
||||
next_day = date + timedelta(days=1)
|
||||
orders = request.env['mrp.workorder'].sudo().search(work_order_domain + [
|
||||
('state', 'in', ['done']),
|
||||
(date_field_name, '>=', date.strftime('%Y-%m-%d 00:00:00')),
|
||||
(date_field_name, '<', next_day.strftime('%Y-%m-%d 00:00:00'))
|
||||
])
|
||||
|
||||
res['data'][line] = order_counts
|
||||
rework_orders = request.env['mrp.workorder'].sudo().search(work_order_domain + [
|
||||
('state', 'in', ['rework']),
|
||||
(date_field_name, '>=', date.strftime('%Y-%m-%d 00:00:00')),
|
||||
(date_field_name, '<', next_day.strftime('%Y-%m-%d 00:00:00'))
|
||||
])
|
||||
not_passed_orders = request.env['mrp.workorder'].sudo().search(work_order_domain + [
|
||||
('state', 'in', ['scrap', 'cancel']),
|
||||
(date_field_name, '>=', date.strftime('%Y-%m-%d 00:00:00')),
|
||||
(date_field_name, '<', next_day.strftime('%Y-%m-%d 00:00:00'))
|
||||
])
|
||||
order_counts.append({
|
||||
'date': date.strftime('%Y-%m-%d'),
|
||||
'order_count': sum(orders.mapped('qty_produced')),
|
||||
'rework_orders': sum(rework_orders.mapped('qty_produced')),
|
||||
'not_passed_orders': sum(not_passed_orders.mapped('qty_produced'))
|
||||
})
|
||||
# 外面包一层,没什么是包一层不能解决的,包一层就能区分了,类似于包一层div
|
||||
# 外面包一层的好处是,可以把多个数据结构打包在一起,方便前端处理
|
||||
|
||||
# date_list_dict = {line: order_counts}
|
||||
|
||||
res['data'][line] = order_counts
|
||||
return json.dumps(res)
|
||||
|
||||
# 实时产量
|
||||
@http.route('/api/RealTimeProduct', type='http', auth='public', methods=['GET', 'POST'], csrf=False, cors="*")
|
||||
def RealTimeProduct(self, **kw):
|
||||
"""
|
||||
获取实时产量
|
||||
获取实时产量(作废)
|
||||
:param kw:
|
||||
:return:
|
||||
"""
|
||||
@@ -711,6 +801,21 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
|
||||
# 当班计划量
|
||||
for line in line_list:
|
||||
|
||||
if line == '业绩总览':
|
||||
work_order_domain = [('routing_type', 'in', ['人工线下加工', 'CNC加工'])]
|
||||
plan_domain = []
|
||||
elif line == '人工线下加工中心':
|
||||
work_order_domain = [('routing_type', '=', '人工线下加工')]
|
||||
plan_domain = [('production_type', '=', '人工线下加工')]
|
||||
else:
|
||||
work_order_domain = [
|
||||
('production_line_id.name', '=', line),
|
||||
('routing_type', '=', 'CNC加工')
|
||||
]
|
||||
plan_domain = [('production_line_id.name', '=', line)]
|
||||
|
||||
|
||||
plan_order_nums = plan_obj.search_count(
|
||||
[('production_line_id.name', '=', line), ('state', 'not in', ['draft']),
|
||||
('date_planned_start', '>=', begin_time),
|
||||
@@ -752,10 +857,10 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
:param kw:
|
||||
:return:
|
||||
"""
|
||||
|
||||
# res = {'status': 1, 'message': '成功', 'not_done_data': [], 'done_data': []}
|
||||
res = {'status': 1, 'message': '成功', 'data': {}}
|
||||
plan_obj = request.env['sf.production.plan'].sudo()
|
||||
work_order_obj = request.env['mrp.workorder'].sudo()
|
||||
line_list = ast.literal_eval(kw['line_list'])
|
||||
begin_time_str = kw['begin_time'].strip('"')
|
||||
end_time_str = kw['end_time'].strip('"')
|
||||
@@ -765,28 +870,39 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
not_done_data = []
|
||||
done_data = []
|
||||
final_data = {}
|
||||
not_done_index = 1
|
||||
done_index = 1
|
||||
|
||||
for line in line_list:
|
||||
|
||||
if line == '业绩总览':
|
||||
work_order_domain = [('routing_type', 'in', ['人工线下加工', 'CNC加工'])]
|
||||
elif line == '人工线下加工中心':
|
||||
work_order_domain = [('routing_type', '=', '人工线下加工')]
|
||||
else:
|
||||
work_order_domain = [
|
||||
('production_line_id.name', '=', line),
|
||||
('routing_type', '=', 'CNC加工')
|
||||
]
|
||||
# 未完成订单
|
||||
# not_done_orders = plan_obj.search(
|
||||
# [('production_line_id.name', '=', line), ('state', 'not in', ['finished']),
|
||||
# ('production_id.state', 'not in', ['cancel', 'done']), ('active', '=', True)
|
||||
# ])
|
||||
not_done_orders = request.env['mrp.workorder'].sudo().search(
|
||||
[('production_line_id.name', '=', line), ('state', 'in', ['ready', 'progress']),
|
||||
('routing_type', '=', 'CNC加工')
|
||||
])
|
||||
not_done_orders = work_order_obj.search(work_order_domain +
|
||||
[('state', 'in', ['ready', 'progress'])], order='id asc'
|
||||
)
|
||||
|
||||
# 完成订单
|
||||
# 获取当前时间,并计算24小时前的时间
|
||||
current_time = datetime.now()
|
||||
time_24_hours_ago = current_time - timedelta(hours=24)
|
||||
|
||||
finish_orders = plan_obj.search([
|
||||
('production_line_id.name', '=', line), ('state', 'in', ['finished']),
|
||||
('production_id.state', 'not in', ['cancel']), ('active', '=', True),
|
||||
('actual_end_time', '>=', time_24_hours_ago)
|
||||
])
|
||||
finish_orders = work_order_obj.search(work_order_domain + [
|
||||
('state', 'in', ['finished']),
|
||||
('production_id.state', 'not in', ['cancel']),
|
||||
('date_finished', '>=', time_24_hours_ago)
|
||||
], order='id asc')
|
||||
# print(finish_orders)
|
||||
|
||||
# 获取所有未完成订单的ID列表
|
||||
@@ -795,14 +911,14 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
finish_order_ids = [order.id for order in finish_orders]
|
||||
|
||||
# 对ID进行排序
|
||||
sorted_order_ids = sorted(order_ids)
|
||||
# sorted_order_ids = sorted(order_ids)
|
||||
|
||||
finish_sorted_order_ids = sorted(finish_order_ids)
|
||||
# finish_sorted_order_ids = sorted(finish_order_ids)
|
||||
|
||||
# 创建ID与序号的对应关系
|
||||
id_to_sequence = {order_id: index + 1 for index, order_id in enumerate(sorted_order_ids)}
|
||||
# id_to_sequence = {order_id: index + 1 for index, order_id in enumerate(sorted_order_ids)}
|
||||
|
||||
finish_id_to_sequence = {order_id: index + 1 for index, order_id in enumerate(finish_sorted_order_ids)}
|
||||
# finish_id_to_sequence = {order_id: index + 1 for index, order_id in enumerate(finish_sorted_order_ids)}
|
||||
|
||||
# # 输出结果或进一步处理
|
||||
# for order_id, sequence in id_to_sequence.items():
|
||||
@@ -833,16 +949,17 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
}
|
||||
|
||||
line_dict = {
|
||||
'sequence': id_to_sequence[order.id],
|
||||
'sequence': not_done_index,
|
||||
'workorder_name': order.production_id.name,
|
||||
'blank_name': blank_name,
|
||||
'material': material,
|
||||
'dimensions': dimensions,
|
||||
'order_qty': 1,
|
||||
'order_qty': order.qty_production,
|
||||
'state': state_dict[order.state],
|
||||
|
||||
}
|
||||
not_done_data.append(line_dict)
|
||||
not_done_index += 1
|
||||
|
||||
for finish_order in finish_orders:
|
||||
if not finish_order.actual_end_time:
|
||||
@@ -861,17 +978,18 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
material = material_match.group(1) if material_match else 'No match found'
|
||||
|
||||
line_dict = {
|
||||
'sequence': finish_id_to_sequence[finish_order.id],
|
||||
'sequence': done_index,
|
||||
'workorder_name': finish_order.name,
|
||||
'blank_name': blank_name,
|
||||
'material': material,
|
||||
'dimensions': dimensions,
|
||||
'order_qty': finish_order.product_qty,
|
||||
'order_qty': order.qty_produced,
|
||||
'finish_time': finish_order.actual_end_time.strftime(
|
||||
'%Y-%m-%d %H:%M:%S') if finish_order.actual_end_time else ' '
|
||||
|
||||
}
|
||||
done_data.append(line_dict)
|
||||
done_index += 1
|
||||
|
||||
# 开始包一层
|
||||
res['data'][line] = {'not_done_data': not_done_data, 'done_data': done_data}
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
'wizard/sf_programming_reason_views.xml',
|
||||
'wizard/sale_order_cancel_views.xml',
|
||||
'wizard/process_outsourcing.xml',
|
||||
'wizard/create_technology_design_task_wizard_views.xml',
|
||||
'views/mrp_views_menus.xml',
|
||||
'views/agv_scheduling_views.xml',
|
||||
'views/stock_lot_views.xml',
|
||||
@@ -48,6 +49,8 @@
|
||||
'views/mrp_workorder_batch_replan.xml',
|
||||
'views/purchase_order_view.xml',
|
||||
'views/product_template_views.xml',
|
||||
'views/sf_technology_design_task_views.xml',
|
||||
'views/sf_technology_design_task_dashboard.xml',
|
||||
# 'views/stock_warehouse_orderpoint.xml',
|
||||
],
|
||||
'assets': {
|
||||
|
||||
@@ -36,6 +36,14 @@
|
||||
<field name="padding">5</field>
|
||||
</record>
|
||||
|
||||
<record id="sequence_technology_design_task" model="ir.sequence">
|
||||
<field name="name">工艺设计任务编码规则</field>
|
||||
<field name="code">sf.technology.design.task</field>
|
||||
<field name="prefix">TD/%(year)s%(month)s%(day)s/</field>
|
||||
<field name="padding">4</field>
|
||||
<field name="company_id" eval="False"/>
|
||||
</record>
|
||||
|
||||
<record id="stock_location_locations_virtual_outcontract" model="stock.location">
|
||||
<field name="name">外协</field>
|
||||
<field name="location_id" ref="stock.stock_location_locations_virtual"/>
|
||||
|
||||
@@ -18,4 +18,5 @@ from . import quick_easy_order
|
||||
from . import purchase_order
|
||||
from . import quality_check
|
||||
from . import purchase_request_line
|
||||
from . import sf_technology_design_task
|
||||
# from . import stock_warehouse_orderpoint
|
||||
@@ -27,9 +27,11 @@ class ResProductMo(models.Model):
|
||||
categ_type = fields.Selection(string='产品的类别', related='categ_id.type', store=True)
|
||||
model_name = fields.Char('模型名称')
|
||||
blank_type = fields.Selection([('圆料', '圆料'), ('方料', '方料')], string='坯料分类')
|
||||
blank_precision = fields.Selection([('精坯', '精坯'), ('粗坯', '粗坯')], string='坯料类型')
|
||||
model_long = fields.Float('模型长(mm)', digits=(16, 3))
|
||||
model_width = fields.Float('模型宽(mm)', digits=(16, 3))
|
||||
model_height = fields.Float('模型高(mm)', digits=(16, 3))
|
||||
unit_number = fields.Float('单件用量', digits=(16, 3), default=1)
|
||||
model_volume = fields.Float('模型体积(m³)')
|
||||
model_area = fields.Float('模型表面积(m²)')
|
||||
model_machining_precision = fields.Selection(selection=_get_machining_precision, string='加工精度')
|
||||
@@ -894,15 +896,22 @@ class ResProductMo(models.Model):
|
||||
if not embryo_redundancy_id:
|
||||
raise UserError('请先配置模型类型内的坯料冗余')
|
||||
product_name = self.generate_product_name(order_id, item, i)
|
||||
# 判断参数中是否包含 坯料尺寸(长、宽、高)
|
||||
blank_bool = any(value is not None and value != 0 for value in (
|
||||
item.get('blank_length'), item.get('blank_width'), item.get('blank_height'))) if all(
|
||||
key in item for key in ('blank_length', 'blank_width', 'blank_height')) else False
|
||||
vals = {
|
||||
'name': product_name,
|
||||
'blank_type': item.get('blank_type'),
|
||||
'model_long': self.format_float(item['model_long'] + embryo_redundancy_id.long),
|
||||
'model_width': self.format_float(item['model_width'] + embryo_redundancy_id.width),
|
||||
'model_height': self.format_float(item['model_height'] + embryo_redundancy_id.height),
|
||||
'model_volume': self.format_float((item['model_long'] + embryo_redundancy_id.long) * (
|
||||
item['model_width'] + embryo_redundancy_id.width) * (
|
||||
item['model_height'] + embryo_redundancy_id.height)),
|
||||
'blank_precision': item.get('blank_precision'),
|
||||
'model_long': item.get('blank_length') if blank_bool else self.format_float(item['model_long'] + embryo_redundancy_id.long),
|
||||
'model_width': item.get('blank_width') if blank_bool else self.format_float(item['model_width'] + embryo_redundancy_id.width),
|
||||
'model_height': item.get('blank_height') if blank_bool else self.format_float(item['model_height'] + embryo_redundancy_id.height),
|
||||
'unit_number': item.get('unit_number'),
|
||||
'model_volume': self.format_float(((item['model_long'] + embryo_redundancy_id.long) *
|
||||
(item['model_width'] + embryo_redundancy_id.width) *
|
||||
(item['model_height'] + embryo_redundancy_id.height))) if not blank_bool else (
|
||||
item.get('blank_length') * item.get('blank_width') * item.get('blank_height')),
|
||||
'product_model_type_id': model_type.id,
|
||||
'model_processing_panel': item['processing_panel_detail'],
|
||||
'model_machining_precision': item['model_machining_precision'],
|
||||
@@ -952,7 +961,7 @@ class ResProductMo(models.Model):
|
||||
self.attachment_update(item['quality_standard_name'], copy_product_id.product_tmpl_id.id,
|
||||
'quality_standard', item['quality_standard_mimetype'])
|
||||
return copy_product_id
|
||||
|
||||
|
||||
def format_float(self, value):
|
||||
# 将浮点数转换为字符串
|
||||
value_str = str(value)
|
||||
|
||||
251
sf_manufacturing/models/sf_technology_design_task.py
Normal file
251
sf_manufacturing/models/sf_technology_design_task.py
Normal file
@@ -0,0 +1,251 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import fields, models, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class SfTechnologyDesignTask(models.Model):
|
||||
_name = 'sf.technology.design.task'
|
||||
_description = '工艺设计任务'
|
||||
_order = 'create_date desc'
|
||||
_inherit = ['mail.thread', 'mail.activity.mixin']
|
||||
|
||||
# 基本信息
|
||||
name = fields.Char('任务编号', required=True, copy=False, readonly=True,
|
||||
default=lambda self: _('New'))
|
||||
state = fields.Selection([
|
||||
('pending', '待工艺设计'),
|
||||
('in_progress', '进行中'),
|
||||
('completed', '已完成'),
|
||||
('cancelled', '已取消'),
|
||||
], string='状态', default='pending', tracking=True)
|
||||
|
||||
# 关联需求计划
|
||||
demand_plan_id = fields.Many2one('sf.production.demand.plan', string='需求计划', required=True, ondelete='cascade')
|
||||
|
||||
# 销售订单信息
|
||||
sale_order_id = fields.Many2one('sale.order', string='销售订单', compute='_compute_sale_order_info', store=True)
|
||||
sale_order_line_id = fields.Many2one('sale.order.line', string='销售订单明细', compute='_compute_sale_order_info', store=True)
|
||||
customer_name = fields.Char('客户名称', compute='_compute_sale_order_info', store=True)
|
||||
|
||||
# 产品信息
|
||||
product_id = fields.Many2one('product.product', string='产品名称', compute='_compute_product_info', store=True)
|
||||
part_name = fields.Char('零件名称', compute='_compute_product_info', store=True)
|
||||
part_number = fields.Char('零件图号', compute='_compute_product_info', store=True)
|
||||
model_id = fields.Char('模型ID', compute='_compute_product_info', store=True)
|
||||
|
||||
# 产品类型和文件
|
||||
product_type = fields.Selection([
|
||||
('standard', '标准件'),
|
||||
('custom', '定制件'),
|
||||
('prototype', '样件'),
|
||||
], string='零件类型', default='custom', store=True)
|
||||
model_file = fields.Binary('模型文件', compute='_compute_model_info', store=True)
|
||||
model_filename = fields.Char('模型文件名', compute='_compute_model_info', store=True)
|
||||
|
||||
# 材料信息
|
||||
materials_id = fields.Many2one('sf.production.materials', string='材料及型号', compute='_compute_material_info', store=True)
|
||||
blank_type = fields.Selection([('圆料', '圆料'), ('方料', '方料')], string='坯料分类', compute='_compute_material_info', store=True)
|
||||
blank_precision = fields.Selection([('精坯', '精坯'), ('粗坯', '粗坯')], string='坯料类型', compute='_compute_material_info', store=True)
|
||||
embryo_long = fields.Char('坯料尺寸', compute='_compute_embryo_long', store=True)
|
||||
|
||||
# 加工信息
|
||||
machining_precision = fields.Selection([
|
||||
('0.10', '±0.10mm'),
|
||||
('0.05', '±0.05mm'),
|
||||
('0.03', '±0.03mm'),
|
||||
('0.02', '±0.02mm'),
|
||||
('0.01', '±0.01mm')
|
||||
], string='加工精度', compute='_compute_machining_info', store=True)
|
||||
machining_panel = fields.Char('加工面', compute='_compute_machining_info', store=True)
|
||||
|
||||
# 订单信息
|
||||
product_uom_qty = fields.Float('订单数量', compute='_compute_order_info', store=True)
|
||||
is_incoming_material = fields.Boolean('客供料', compute='_compute_order_info', store=True)
|
||||
|
||||
# 工艺参数
|
||||
clamping_times = fields.Integer('装夹次数', default=1)
|
||||
single_clamping_duration = fields.Float('单次装夹时长(分钟)', default=30.0)
|
||||
cnc_processing_duration = fields.Float('CNC加工时长(分钟)', default=0.0)
|
||||
|
||||
# 质量要求
|
||||
customer_quality_requirements = fields.Text('客户质量要求')
|
||||
processing_drawing_2d = fields.Binary('2D加工图纸')
|
||||
processing_drawing_filename = fields.Char('2D图纸文件名')
|
||||
|
||||
# 时间信息
|
||||
create_date = fields.Datetime('创建时间', default=fields.Datetime.now)
|
||||
start_date = fields.Datetime('开始时间')
|
||||
complete_date = fields.Datetime('完成时间')
|
||||
deadline = fields.Datetime('截止时间')
|
||||
|
||||
# 负责人
|
||||
assigned_to = fields.Many2one('res.users', string='负责人', tracking=True)
|
||||
created_by = fields.Many2one('res.users', string='创建人', default=lambda self: self.env.user, readonly=True)
|
||||
|
||||
# 备注
|
||||
notes = fields.Text('备注')
|
||||
|
||||
@api.depends('demand_plan_id')
|
||||
def _compute_sale_order_info(self):
|
||||
for record in self:
|
||||
if record.demand_plan_id:
|
||||
record.sale_order_id = record.demand_plan_id.sale_order_id
|
||||
record.sale_order_line_id = record.demand_plan_id.sale_order_line_id
|
||||
record.customer_name = record.demand_plan_id.customer_name
|
||||
else:
|
||||
record.sale_order_id = False
|
||||
record.sale_order_line_id = False
|
||||
record.customer_name = ""
|
||||
|
||||
@api.depends('demand_plan_id')
|
||||
def _compute_product_info(self):
|
||||
for record in self:
|
||||
if record.demand_plan_id and record.demand_plan_id.product_id:
|
||||
record.product_id = record.demand_plan_id.product_id
|
||||
if record.product_id.product_tmpl_id:
|
||||
record.part_name = record.product_id.product_tmpl_id.part_name
|
||||
record.part_number = record.product_id.product_tmpl_id.part_number
|
||||
record.model_id = record.product_id.product_tmpl_id.model_id
|
||||
else:
|
||||
record.part_name = ""
|
||||
record.part_number = ""
|
||||
record.model_id = ""
|
||||
else:
|
||||
record.product_id = False
|
||||
record.part_name = ""
|
||||
record.part_number = ""
|
||||
record.model_id = ""
|
||||
|
||||
@api.depends('product_id')
|
||||
def _compute_model_info(self):
|
||||
for record in self:
|
||||
if record.product_id and record.product_id.product_tmpl_id:
|
||||
template = record.product_id.product_tmpl_id
|
||||
record.model_file = template.model_file
|
||||
record.model_filename = template.model_name
|
||||
else:
|
||||
record.model_file = False
|
||||
record.model_filename = ""
|
||||
|
||||
@api.depends('product_id')
|
||||
def _compute_material_info(self):
|
||||
for record in self:
|
||||
if record.product_id and record.product_id.product_tmpl_id:
|
||||
template = record.product_id.product_tmpl_id
|
||||
record.materials_id = template.materials_id
|
||||
record.blank_type = template.blank_type
|
||||
record.blank_precision = template.blank_precision
|
||||
else:
|
||||
record.materials_id = False
|
||||
record.blank_type = False
|
||||
record.blank_precision = False
|
||||
|
||||
@api.depends('product_id')
|
||||
def _compute_machining_info(self):
|
||||
for record in self:
|
||||
if record.product_id and record.product_id.product_tmpl_id:
|
||||
template = record.product_id.product_tmpl_id
|
||||
record.machining_precision = template.model_machining_precision
|
||||
record.machining_panel = template.model_processing_panel
|
||||
else:
|
||||
record.machining_precision = False
|
||||
record.machining_panel = ""
|
||||
|
||||
@api.depends('demand_plan_id')
|
||||
def _compute_order_info(self):
|
||||
for record in self:
|
||||
if record.demand_plan_id:
|
||||
record.product_uom_qty = record.demand_plan_id.product_uom_qty
|
||||
record.is_incoming_material = record.demand_plan_id.is_incoming_material
|
||||
else:
|
||||
record.product_uom_qty = 0.0
|
||||
record.is_incoming_material = False
|
||||
|
||||
@api.depends('product_id')
|
||||
def _compute_embryo_long(self):
|
||||
for record in self:
|
||||
if record.product_id and record.product_id.product_tmpl_id:
|
||||
template = record.product_id.product_tmpl_id
|
||||
record.embryo_long = f"{template.model_long}×{template.model_width}×{template.model_height}"
|
||||
else:
|
||||
record.embryo_long = ""
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
if vals.get('name', _('New')) == _('New'):
|
||||
vals['name'] = self.env['ir.sequence'].next_by_code('sf.technology.design.task') or _('New')
|
||||
return super(SfTechnologyDesignTask, self).create(vals)
|
||||
|
||||
def action_start_design(self):
|
||||
"""开始工艺设计"""
|
||||
self.ensure_one()
|
||||
if self.state != 'pending':
|
||||
raise ValidationError(_('只有待工艺设计的任务才能开始设计'))
|
||||
self.write({
|
||||
'state': 'in_progress',
|
||||
'start_date': fields.Datetime.now(),
|
||||
})
|
||||
self.message_post(body=_('工艺设计任务已开始'))
|
||||
|
||||
def action_complete_design(self):
|
||||
"""完成工艺设计"""
|
||||
self.ensure_one()
|
||||
if self.state != 'in_progress':
|
||||
raise ValidationError(_('只有进行中的任务才能完成'))
|
||||
self.write({
|
||||
'state': 'completed',
|
||||
'complete_date': fields.Datetime.now(),
|
||||
})
|
||||
self.message_post(body=_('工艺设计任务已完成'))
|
||||
|
||||
def action_cancel_task(self):
|
||||
"""取消任务"""
|
||||
self.ensure_one()
|
||||
if self.state in ['completed']:
|
||||
raise ValidationError(_('已完成的任务不能取消'))
|
||||
self.write({
|
||||
'state': 'cancelled',
|
||||
})
|
||||
self.message_post(body=_('工艺设计任务已取消'))
|
||||
|
||||
def action_reset_to_pending(self):
|
||||
"""重置为待工艺设计"""
|
||||
self.ensure_one()
|
||||
if self.state not in ['in_progress', 'cancelled']:
|
||||
raise ValidationError(_('只有进行中或已取消的任务才能重置'))
|
||||
self.write({
|
||||
'state': 'pending',
|
||||
'start_date': False,
|
||||
'complete_date': False,
|
||||
})
|
||||
self.message_post(body=_('工艺设计任务已重置为待设计状态'))
|
||||
|
||||
@api.model
|
||||
def create_from_demand_plan(self, demand_plan_ids):
|
||||
"""从需求计划创建工艺设计任务"""
|
||||
tasks = self.env['sf.technology.design.task']
|
||||
for demand_plan in demand_plan_ids:
|
||||
# 检查是否已存在工艺设计任务
|
||||
existing_task = self.search([
|
||||
('demand_plan_id', '=', demand_plan.id),
|
||||
('state', 'not in', ['cancelled'])
|
||||
], limit=1)
|
||||
|
||||
if not existing_task:
|
||||
task_vals = {
|
||||
'demand_plan_id': demand_plan.id,
|
||||
'deadline': fields.Datetime.now() + fields.timedelta(days=3), # 默认3天期限
|
||||
}
|
||||
task = self.create(task_vals)
|
||||
tasks |= task
|
||||
|
||||
return tasks
|
||||
|
||||
def get_task_count_by_state(self):
|
||||
"""获取各状态的任务数量"""
|
||||
return {
|
||||
'pending': self.search_count([('state', '=', 'pending')]),
|
||||
'in_progress': self.search_count([('state', '=', 'in_progress')]),
|
||||
'completed': self.search_count([('state', '=', 'completed')]),
|
||||
'cancelled': self.search_count([('state', '=', 'cancelled')]),
|
||||
}
|
||||
@@ -195,4 +195,10 @@ access_sf_work_individuation_page_group_plan_dispatch,sf_work_individuation_page
|
||||
access_sf_sale_order_cancel_wizard,sf_sale_order_cancel_wizard,model_sf_sale_order_cancel_wizard,sf_base.group_sf_order_user,1,1,1,0
|
||||
access_sf_sale_order_cancel_line,sf_sale_order_cancel_line,model_sf_sale_order_cancel_line,sf_base.group_sf_order_user,1,0,1,1
|
||||
|
||||
access_product_creation_wizard,product_creation_wizard,model_product_creation_wizard,base.group_user,1,1,1,0
|
||||
access_product_creation_wizard,product_creation_wizard,model_product_creation_wizard,base.group_user,1,1,1,0
|
||||
access_sf_technology_design_task_group_sf_mrp_user,sf_technology_design_task_group_sf_mrp_user,model_sf_technology_design_task,sf_base.group_sf_mrp_user,1,1,1,0
|
||||
access_sf_technology_design_task_group_sf_mrp_manager,sf_technology_design_task_group_sf_mrp_manager,model_sf_technology_design_task,sf_base.group_sf_mrp_manager,1,1,1,1
|
||||
access_sf_technology_design_task_group_plan_dispatch,sf_technology_design_task_group_plan_dispatch,model_sf_technology_design_task,sf_base.group_plan_dispatch,1,1,1,0
|
||||
access_sf_technology_design_task_group_production_engineer,sf_technology_design_task_group_production_engineer,model_sf_technology_design_task,sf_base.group_production_engineer,1,1,1,0
|
||||
access_sf_create_technology_design_task_wizard_group_sf_mrp_user,sf_create_technology_design_task_wizard_group_sf_mrp_user,model_sf_create_technology_design_task_wizard,sf_base.group_sf_mrp_user,1,1,1,0
|
||||
access_sf_create_technology_design_task_wizard_group_sf_mrp_manager,sf_create_technology_design_task_wizard_group_sf_mrp_manager,model_sf_create_technology_design_task_wizard,sf_base.group_sf_mrp_manager,1,1,1,0
|
||||
|
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<!-- 工艺设计任务仪表板视图 -->
|
||||
<record id="view_sf_technology_design_task_dashboard" model="ir.ui.view">
|
||||
<field name="name">sf.technology.design.task.dashboard</field>
|
||||
<field name="model">sf.technology.design.task</field>
|
||||
<field name="arch" type="xml">
|
||||
<kanban class="o_kanban_small_column" default_group_by="state">
|
||||
<field name="name"/>
|
||||
<field name="state"/>
|
||||
<field name="product_id"/>
|
||||
<field name="part_name"/>
|
||||
<field name="assigned_to"/>
|
||||
<field name="deadline"/>
|
||||
<field name="create_date"/>
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div class="oe_kanban_global_click">
|
||||
<div class="oe_kanban_content">
|
||||
<div class="o_kanban_record_top">
|
||||
<div class="o_kanban_record_headings">
|
||||
<strong class="o_kanban_record_title">
|
||||
<field name="name"/>
|
||||
</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div class="o_kanban_record_body">
|
||||
<div class="o_kanban_primary_left">
|
||||
<field name="product_id"/>
|
||||
</div>
|
||||
<div class="o_kanban_primary_right">
|
||||
<field name="part_name"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="o_kanban_record_bottom">
|
||||
<div class="oe_kanban_bottom_left">
|
||||
<field name="assigned_to"/>
|
||||
</div>
|
||||
<div class="oe_kanban_bottom_right">
|
||||
<field name="deadline"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
</kanban>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- 工艺设计任务仪表板动作 -->
|
||||
<record id="action_sf_technology_design_task_dashboard" model="ir.actions.act_window">
|
||||
<field name="name">工艺设计任务仪表板</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">sf.technology.design.task</field>
|
||||
<field name="view_mode">kanban</field>
|
||||
<field name="view_id" ref="view_sf_technology_design_task_dashboard"/>
|
||||
<field name="context">{'search_default_filter_pending': 1}</field>
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_smiling_face">
|
||||
创建第一个工艺设计任务
|
||||
</p>
|
||||
<p>
|
||||
工艺设计任务用于管理产品工艺设计流程,包括从需求计划到工艺完成的整个过程。
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- 工艺设计任务仪表板菜单 -->
|
||||
<menuitem id="menu_sf_technology_design_task_dashboard"
|
||||
name="工艺设计仪表板"
|
||||
sequence="15"
|
||||
action="action_sf_technology_design_task_dashboard"
|
||||
parent="mrp.menu_mrp_manufacturing"/>
|
||||
|
||||
</odoo>
|
||||
280
sf_manufacturing/views/sf_technology_design_task_views.xml
Normal file
280
sf_manufacturing/views/sf_technology_design_task_views.xml
Normal file
@@ -0,0 +1,280 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<!-- 工艺设计任务列表视图 -->
|
||||
<record id="view_sf_technology_design_task_tree" model="ir.ui.view">
|
||||
<field name="name">sf.technology.design.task.tree</field>
|
||||
<field name="model">sf.technology.design.task</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="工艺设计任务" default_order="create_date desc"
|
||||
class="technology_design_task_tree freeze-columns-before-part_number">
|
||||
<header>
|
||||
<button string="开始设计" name="action_start_design" type="object"
|
||||
class="btn-primary" attrs="{'invisible': [('state', '!=', 'pending')]}"/>
|
||||
<button string="完成设计" name="action_complete_design" type="object"
|
||||
class="btn-success" attrs="{'invisible': [('state', '!=', 'in_progress')]}"/>
|
||||
<button string="取消任务" name="action_cancel_task" type="object"
|
||||
class="btn-secondary" attrs="{'invisible': [('state', 'in', ['completed'])]}"/>
|
||||
<button string="重置任务" name="action_reset_to_pending" type="object"
|
||||
class="btn-warning" attrs="{'invisible': [('state', 'not in', ['in_progress', 'cancelled'])]}"/>
|
||||
</header>
|
||||
|
||||
<!-- 主要字段 -->
|
||||
<field name="name" string="任务编号"/>
|
||||
<field name="state" widget="badge"
|
||||
decoration-success="state == 'completed'"
|
||||
decoration-warning="state == 'in_progress'"
|
||||
decoration-danger="state == 'cancelled'"/>
|
||||
<field name="sale_order_id" string="销售单号"/>
|
||||
<field name="product_id" string="产品名称"/>
|
||||
<field name="part_name" string="零件名称"/>
|
||||
<field name="part_number" string="零件图号"/>
|
||||
<field name="product_type" string="零件类型"/>
|
||||
<field name="model_id" string="模型ID" optional="hide"/>
|
||||
<field name="model_filename" string="模型文件" optional="hide"/>
|
||||
<field name="materials_id" string="材料及型号"/>
|
||||
<field name="blank_type" string="坯料分类" optional="hide"/>
|
||||
<field name="blank_precision" string="坯料类型" optional="hide"/>
|
||||
<field name="embryo_long" string="坯料尺寸" optional="hide"/>
|
||||
<field name="machining_precision" string="加工精度" optional="hide"/>
|
||||
<field name="machining_panel" string="加工面" optional="hide"/>
|
||||
<field name="product_uom_qty" string="订单数量"/>
|
||||
<field name="is_incoming_material" string="客供料"/>
|
||||
<field name="clamping_times" string="装夹次数" optional="hide"/>
|
||||
<field name="single_clamping_duration" string="单次装夹时长" optional="hide"/>
|
||||
<field name="cnc_processing_duration" string="CNC加工时长" optional="hide"/>
|
||||
<field name="customer_quality_requirements" string="客户质量要求" optional="hide"/>
|
||||
<field name="processing_drawing_filename" string="2D加工图纸" optional="hide"/>
|
||||
<field name="customer_name" string="客户名称" optional="hide"/>
|
||||
|
||||
<!-- 时间字段 -->
|
||||
<field name="create_date" string="创建时间" optional="hide"/>
|
||||
<field name="start_date" string="开始时间" optional="hide"/>
|
||||
<field name="complete_date" string="完成时间" optional="hide"/>
|
||||
<field name="deadline" string="截止时间" optional="hide"/>
|
||||
|
||||
<!-- 负责人字段 -->
|
||||
<field name="assigned_to" string="负责人" optional="hide"/>
|
||||
<field name="created_by" string="创建人" optional="hide"/>
|
||||
|
||||
<!-- 备注 -->
|
||||
<field name="notes" string="备注" optional="hide"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- 工艺设计任务搜索视图 -->
|
||||
<record id="view_sf_technology_design_task_search" model="ir.ui.view">
|
||||
<field name="name">sf.technology.design.task.search</field>
|
||||
<field name="model">sf.technology.design.task</field>
|
||||
<field name="arch" type="xml">
|
||||
<search>
|
||||
<field name="name"/>
|
||||
<field name="sale_order_id"/>
|
||||
<field name="product_id"/>
|
||||
<field name="part_name"/>
|
||||
<field name="part_number"/>
|
||||
<field name="customer_name"/>
|
||||
<field name="materials_id"/>
|
||||
<field name="assigned_to"/>
|
||||
<field name="created_by"/>
|
||||
|
||||
<filter name="filter_pending" string="待工艺设计" domain="[('state', '=', 'pending')]"/>
|
||||
<filter name="filter_in_progress" string="进行中" domain="[('state', '=', 'in_progress')]"/>
|
||||
<filter name="filter_completed" string="已完成" domain="[('state', '=', 'completed')]"/>
|
||||
<filter name="filter_cancelled" string="已取消" domain="[('state', '=', 'cancelled')]"/>
|
||||
|
||||
<separator/>
|
||||
|
||||
<filter name="filter_my_tasks" string="我的任务" domain="[('assigned_to', '=', uid)]"/>
|
||||
<filter name="filter_overdue" string="已逾期" domain="[('deadline', '<', context_today()), ('state', 'not in', ['completed', 'cancelled'])]"/>
|
||||
|
||||
<group expand="0" string="Group By">
|
||||
<filter name="group_by_state" string="状态" domain="[]" context="{'group_by': 'state'}"/>
|
||||
<filter name="group_by_sale_order" string="销售单号" domain="[]" context="{'group_by': 'sale_order_id'}"/>
|
||||
<filter name="group_by_product" string="产品" domain="[]" context="{'group_by': 'product_id'}"/>
|
||||
<filter name="group_by_customer" string="客户" domain="[]" context="{'group_by': 'customer_name'}"/>
|
||||
<filter name="group_by_assigned_to" string="负责人" domain="[]" context="{'group_by': 'assigned_to'}"/>
|
||||
<filter name="group_by_created_by" string="创建人" domain="[]" context="{'group_by': 'created_by'}"/>
|
||||
<filter name="group_by_create_date" string="创建日期" domain="[]" context="{'group_by': 'create_date:day'}"/>
|
||||
<filter name="group_by_deadline" string="截止日期" domain="[]" context="{'group_by': 'deadline:day'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- 工艺设计任务表单视图 -->
|
||||
<record id="view_sf_technology_design_task_form" model="ir.ui.view">
|
||||
<field name="name">sf.technology.design.task.form</field>
|
||||
<field name="model">sf.technology.design.task</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="工艺设计任务">
|
||||
<header>
|
||||
<button name="action_start_design" string="开始设计" type="object"
|
||||
class="btn-primary" attrs="{'invisible': [('state', '!=', 'pending')]}"/>
|
||||
<button name="action_complete_design" string="完成设计" type="object"
|
||||
class="btn-success" attrs="{'invisible': [('state', '!=', 'in_progress')]}"/>
|
||||
<button name="action_cancel_task" string="取消任务" type="object"
|
||||
class="btn-secondary" attrs="{'invisible': [('state', 'in', ['completed'])]}"/>
|
||||
<button name="action_reset_to_pending" string="重置任务" type="object"
|
||||
class="btn-warning" attrs="{'invisible': [('state', 'not in', ['in_progress', 'cancelled'])]}"/>
|
||||
<field name="state" widget="statusbar"
|
||||
statusbar_visible="pending,in_progress,completed"/>
|
||||
</header>
|
||||
|
||||
<sheet>
|
||||
<div class="oe_title">
|
||||
<h1>
|
||||
<field name="name" readonly="1"/>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<group>
|
||||
<group string="基本信息">
|
||||
<field name="demand_plan_id"/>
|
||||
<field name="sale_order_id"/>
|
||||
<field name="customer_name"/>
|
||||
<field name="assigned_to"/>
|
||||
<field name="created_by"/>
|
||||
</group>
|
||||
<group string="时间信息">
|
||||
<field name="create_date"/>
|
||||
<field name="start_date"/>
|
||||
<field name="complete_date"/>
|
||||
<field name="deadline"/>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
<notebook>
|
||||
<page string="产品信息">
|
||||
<group>
|
||||
<group string="产品详情">
|
||||
<field name="product_id"/>
|
||||
<field name="part_name"/>
|
||||
<field name="part_number"/>
|
||||
<field name="product_type"/>
|
||||
<field name="model_id"/>
|
||||
<field name="model_file" filename="model_filename"/>
|
||||
<field name="model_filename" invisible="1"/>
|
||||
</group>
|
||||
<group string="材料信息">
|
||||
<field name="materials_id"/>
|
||||
<field name="blank_type"/>
|
||||
<field name="blank_precision"/>
|
||||
<field name="embryo_long"/>
|
||||
</group>
|
||||
</group>
|
||||
</page>
|
||||
|
||||
<page string="加工信息">
|
||||
<group>
|
||||
<group string="加工参数">
|
||||
<field name="machining_precision"/>
|
||||
<field name="machining_panel"/>
|
||||
<field name="product_uom_qty"/>
|
||||
<field name="is_incoming_material"/>
|
||||
</group>
|
||||
<group string="工艺参数">
|
||||
<field name="clamping_times"/>
|
||||
<field name="single_clamping_duration"/>
|
||||
<field name="cnc_processing_duration"/>
|
||||
</group>
|
||||
</group>
|
||||
</page>
|
||||
|
||||
<page string="质量要求">
|
||||
<group>
|
||||
<field name="customer_quality_requirements" nolabel="1"/>
|
||||
</group>
|
||||
<group string="图纸文件">
|
||||
<field name="processing_drawing_2d" filename="processing_drawing_filename"/>
|
||||
<field name="processing_drawing_filename" invisible="1"/>
|
||||
</group>
|
||||
</page>
|
||||
|
||||
<page string="备注">
|
||||
<field name="notes" nolabel="1"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
|
||||
<div class="oe_chatter">
|
||||
<field name="message_follower_ids"/>
|
||||
<field name="activity_ids"/>
|
||||
<field name="message_ids"/>
|
||||
</div>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- 工艺设计任务动作 -->
|
||||
<record id="action_sf_technology_design_task" model="ir.actions.act_window">
|
||||
<field name="name">工艺设计任务</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">sf.technology.design.task</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="context">{'search_default_filter_pending': 1}</field>
|
||||
<field name="help" type="html">
|
||||
<p class="o_view_nocontent_smiling_face">
|
||||
创建第一个工艺设计任务
|
||||
</p>
|
||||
<p>
|
||||
工艺设计任务用于管理产品工艺设计流程,包括从需求计划到工艺完成的整个过程。
|
||||
</p>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- 工艺设计任务菜单 -->
|
||||
<menuitem id="menu_sf_technology_design_task"
|
||||
name="工艺设计任务"
|
||||
sequence="20"
|
||||
action="action_sf_technology_design_task"
|
||||
parent="mrp.menu_mrp_manufacturing"/>
|
||||
|
||||
<!-- 工艺设计任务看板视图 -->
|
||||
<record id="view_sf_technology_design_task_kanban" model="ir.ui.view">
|
||||
<field name="name">sf.technology.design.task.kanban</field>
|
||||
<field name="model">sf.technology.design.task</field>
|
||||
<field name="arch" type="xml">
|
||||
<kanban class="o_kanban_small_column" default_group_by="state">
|
||||
<field name="name"/>
|
||||
<field name="state"/>
|
||||
<field name="product_id"/>
|
||||
<field name="part_name"/>
|
||||
<field name="assigned_to"/>
|
||||
<field name="deadline"/>
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div class="oe_kanban_global_click">
|
||||
<div class="oe_kanban_content">
|
||||
<div class="o_kanban_record_top">
|
||||
<div class="o_kanban_record_headings">
|
||||
<strong class="o_kanban_record_title">
|
||||
<field name="name"/>
|
||||
</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div class="o_kanban_record_body">
|
||||
<div class="o_kanban_primary_left">
|
||||
<field name="product_id"/>
|
||||
</div>
|
||||
<div class="o_kanban_primary_right">
|
||||
<field name="part_name"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="o_kanban_record_bottom">
|
||||
<div class="oe_kanban_bottom_left">
|
||||
<field name="assigned_to"/>
|
||||
</div>
|
||||
<div class="oe_kanban_bottom_right">
|
||||
<field name="deadline"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
</kanban>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -6,4 +6,5 @@ from . import production_technology_re_adjust_wizard
|
||||
from . import mrp_workorder_batch_replan_wizard
|
||||
from . import sf_programming_reason
|
||||
from . import sale_order_cancel
|
||||
from . import process_outsourcing
|
||||
from . import process_outsourcing
|
||||
from . import create_technology_design_task_wizard
|
||||
@@ -0,0 +1,58 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import fields, models, api, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class CreateTechnologyDesignTaskWizard(models.TransientModel):
|
||||
_name = 'sf.create.technology.design.task.wizard'
|
||||
_description = '创建工艺设计任务向导'
|
||||
|
||||
demand_plan_ids = fields.Many2many('sf.production.demand.plan', string='需求计划', required=True)
|
||||
assigned_to = fields.Many2one('res.users', string='负责人', default=lambda self: self.env.user)
|
||||
deadline = fields.Datetime('截止时间', required=True)
|
||||
notes = fields.Text('备注')
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields_list):
|
||||
res = super(CreateTechnologyDesignTaskWizard, self).default_get(fields_list)
|
||||
if self.env.context.get('active_model') == 'sf.production.demand.plan':
|
||||
demand_plan_ids = self.env.context.get('active_ids', [])
|
||||
res['demand_plan_ids'] = [(6, 0, demand_plan_ids)]
|
||||
return res
|
||||
|
||||
def action_create_tasks(self):
|
||||
"""创建工艺设计任务"""
|
||||
if not self.demand_plan_ids:
|
||||
raise UserError(_('请选择需求计划'))
|
||||
|
||||
# 检查是否已存在工艺设计任务
|
||||
existing_tasks = self.env['sf.technology.design.task'].search([
|
||||
('demand_plan_id', 'in', self.demand_plan_ids.ids),
|
||||
('state', 'not in', ['cancelled'])
|
||||
])
|
||||
|
||||
if existing_tasks:
|
||||
raise UserError(_('以下需求计划已存在工艺设计任务:\n%s') %
|
||||
'\n'.join([task.demand_plan_id.name for task in existing_tasks]))
|
||||
|
||||
# 创建工艺设计任务
|
||||
tasks = self.env['sf.technology.design.task']
|
||||
for demand_plan in self.demand_plan_ids:
|
||||
task_vals = {
|
||||
'demand_plan_id': demand_plan.id,
|
||||
'assigned_to': self.assigned_to.id,
|
||||
'deadline': self.deadline,
|
||||
'notes': self.notes,
|
||||
}
|
||||
task = self.env['sf.technology.design.task'].create(task_vals)
|
||||
tasks |= task
|
||||
|
||||
# 返回工艺设计任务列表视图
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'name': _('工艺设计任务'),
|
||||
'res_model': 'sf.technology.design.task',
|
||||
'view_mode': 'tree,form',
|
||||
'domain': [('id', 'in', tasks.ids)],
|
||||
'context': {'search_default_filter_pending': 1},
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="view_create_technology_design_task_wizard_form" model="ir.ui.view">
|
||||
<field name="name">sf.create.technology.design.task.wizard.form</field>
|
||||
<field name="model">sf.create.technology.design.task.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="创建工艺设计任务">
|
||||
<group>
|
||||
<field name="demand_plan_ids" widget="many2many_tags"/>
|
||||
<field name="assigned_to"/>
|
||||
<field name="deadline"/>
|
||||
<field name="notes"/>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="action_create_tasks" string="创建任务" type="object" class="btn-primary"/>
|
||||
<button string="取消" class="btn-secondary" special="cancel"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_create_technology_design_task_wizard" model="ir.actions.act_window">
|
||||
<field name="name">创建工艺设计任务</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">sf.create.technology.design.task.wizard</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -92,7 +92,7 @@
|
||||
|
||||
|
||||
<div class="page" style="min-height: 800px; position: relative; padding-bottom: 250px;">
|
||||
|
||||
|
||||
<table class="table table-sm o_main_table mt-4" style="border: 1px solid black;">
|
||||
<tr>
|
||||
<td style="width: 15%; border: 1px solid black;"><strong>产品名称:</strong></td>
|
||||
@@ -113,7 +113,7 @@
|
||||
<td style="border: 1px solid black;"><span t-field="o.check_qty"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<h4 class="text-center mt-4">检验结果</h4>
|
||||
<div class="" style="position: relative;">
|
||||
<table class="table table-sm mt-2" style="border: 1px solid black;">
|
||||
@@ -148,7 +148,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<img src="/sf_quality/static/img/pass.png" style="width: 200px; height: 200px;position: absolute; bottom: 20px; right: 20%;"/>
|
||||
<img src="/sf_quality/static/img/pass.png" style="width: 100px; height: 100px; position: absolute; bottom: -100px; left: 90px;"/>
|
||||
|
||||
</div>
|
||||
<div style="clear: both; margin-top: 30px; padding-top: 10px;">
|
||||
@@ -182,7 +182,7 @@
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row mt-4">
|
||||
<div class="col-6">
|
||||
<p><strong>操作员: </strong> <span t-field="o.measure_operator"/></p>
|
||||
@@ -200,7 +200,7 @@
|
||||
<p></p>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
|
||||
<!-- 页脚固定在底部 -->
|
||||
<!-- <div style="position: absolute; bottom: 0; left: 0; right: 0;"> -->
|
||||
<t t-call="sf_quality.report_quality_footer"/>
|
||||
@@ -275,7 +275,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<img src="/sf_quality/static/img/pass.png" style="width: 200px; height: 200px;position: absolute; bottom: 20px; right: 20%;"/>
|
||||
<img src="/sf_quality/static/img/pass.png" style="width: 100px; height: 100px; position: absolute; bottom: -100px; left: 90px;"/>
|
||||
|
||||
</div>
|
||||
<div style="clear: both; margin-top: 30px; padding-top: 10px;">
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
<attribute name="string">不合格</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//header//button[@name='do_fail'][2]" position="attributes">
|
||||
<attribute name="attrs">{'invisible': ['|','|',('quality_state', '!=', 'pass'),('work_state','in', ('done', 'rework')),'&',('quality_state', '=', 'pass'), ('test_type', '=', '出厂检验报告')]}</attribute>
|
||||
<attribute name="attrs">{'invisible': ['|','|',('quality_state', '!=', 'pass'),('work_state','in', ('done', 'rework')),'&',('quality_state', '=', 'pass'), ('test_type', '=', 'factory_inspection')]}</attribute>
|
||||
<attribute name="string">不合格</attribute>
|
||||
</xpath>
|
||||
|
||||
|
||||
@@ -158,8 +158,7 @@ class ReSaleOrder(models.Model):
|
||||
'is_incoming_material': True if item.get('embryo_redundancy_id') else False,
|
||||
'manual_quotation': item.get('manual_quotation'),
|
||||
'model_id': item['model_id'],
|
||||
'delivery_end_date': item['delivery_end_date'],
|
||||
'customer_delivery_date': item.get('customer_delivery_date'),
|
||||
'delivery_end_date': item['delivery_end_date']
|
||||
}
|
||||
return self.env['sale.order.line'].with_context(skip_procurement=True).create(vals)
|
||||
|
||||
@@ -293,8 +292,7 @@ class ResaleOrderLine(models.Model):
|
||||
manual_quotation = fields.Boolean('人工编程', default=False)
|
||||
model_url = fields.Char('模型文件地址')
|
||||
model_id = fields.Char('模型ID')
|
||||
delivery_end_date = fields.Date('交货截止日期')
|
||||
customer_delivery_date = fields.Date('客户交期')
|
||||
delivery_end_date = fields.Date('客户交期')
|
||||
|
||||
@api.depends('embryo_redundancy_id')
|
||||
def _compute_is_incoming_material(self):
|
||||
|
||||
@@ -127,7 +127,6 @@
|
||||
<xpath expr="//field[@name='order_line']/tree/field[@name='name']" position="replace">
|
||||
<field name="name" widget="section_and_note_text" optional="show"
|
||||
string="参数说明(长/宽/高/体积/精度/材质)"/>
|
||||
<field name="customer_delivery_date" readonly="1"/>
|
||||
<field name="manual_quotation" readonly="1"/>
|
||||
<field name="is_incoming_material" readonly="1"/>
|
||||
</xpath>
|
||||
@@ -142,7 +141,7 @@
|
||||
<attribute name="optional">hide</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='order_line']/tree/field[@name='remark']" position="before">
|
||||
<field name="delivery_end_date" optional="hide"/>
|
||||
<field name="delivery_end_date" optional="show"/>
|
||||
</xpath>
|
||||
|
||||
<field name="user_id" position="attributes">
|
||||
|
||||
@@ -7,8 +7,14 @@ def migrate(cr, version):
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
sf_shelf_model = env["sf.shelf"]
|
||||
sf_shelf_location_model = env["sf.shelf.location"]
|
||||
|
||||
preproduction_shelf_ids = sf_shelf_location_model.get_preproduction_shelf_ids()
|
||||
|
||||
shelves = sf_shelf_model.search([])
|
||||
for shelf in shelves:
|
||||
if shelf.id not in preproduction_shelf_ids:
|
||||
continue
|
||||
|
||||
shelf_barcode = shelf.barcode or ""
|
||||
if not shelf_barcode:
|
||||
continue
|
||||
|
||||
@@ -13,6 +13,7 @@ from odoo import api, fields, models, _
|
||||
from odoo.osv import expression
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
class SfLocation(models.Model):
|
||||
_inherit = 'stock.location'
|
||||
@@ -459,7 +460,40 @@ class ShelfLocation(models.Model):
|
||||
product_sn_ids = fields.One2many('sf.shelf.location.lot', 'shelf_location_id', string='产品批次号')
|
||||
# 产品数量
|
||||
product_num = fields.Integer('总数量', compute='_compute_number', store=True)
|
||||
|
||||
tool_rfid = fields.Char('Rfid', compute='_compute_tool', store=True)
|
||||
tool_name_id = fields.Many2one('sf.functional.cutting.tool.entity', string='功能刀具名称', compute='_compute_tool', store=True)
|
||||
display_rfid = fields.Char('RFID', compute='_compute_display_rfid', store=True)
|
||||
@api.depends('product_sn_id')
|
||||
def _compute_display_rfid(self):
|
||||
"""计算显示 RFID"""
|
||||
for record in self:
|
||||
try:
|
||||
record.display_rfid = record.product_sn_id.rfid if record.product_sn_id else ''
|
||||
except Exception as e:
|
||||
record.display_rfid = ''
|
||||
|
||||
@api.depends('product_id')
|
||||
def _compute_tool(self):
|
||||
"""计算工具 RFID"""
|
||||
for record in self:
|
||||
try:
|
||||
if record.product_id:
|
||||
if record.product_id.categ_id.name == '功能刀具':
|
||||
# 搜索关联的功能刀具实体
|
||||
tool_id = self.env['sf.functional.cutting.tool.entity'].search(
|
||||
[('barcode_id', '=', record.product_sn_id.id)], limit=1
|
||||
)
|
||||
if tool_id:
|
||||
record.tool_rfid = tool_id.rfid
|
||||
record.tool_name_id = tool_id.id
|
||||
continue
|
||||
# 默认值
|
||||
record.tool_rfid = ''
|
||||
record.tool_name_id = False
|
||||
except Exception as e:
|
||||
record.tool_rfid = ''
|
||||
record.tool_name_id = False
|
||||
_logger.error(f"计算 tool_rfid 时出错: {e}")
|
||||
@api.depends('product_num')
|
||||
def _compute_product_num(self):
|
||||
for record in self:
|
||||
@@ -563,8 +597,27 @@ class ShelfLocation(models.Model):
|
||||
else:
|
||||
_layer_capacity = _layer_capacity
|
||||
_layer = _layer+1
|
||||
_layer_capacity = f"{_layer_capacity:02d}"
|
||||
record.kanban_show_layer_info=f"{_layer}-{_layer_capacity}"
|
||||
record.kanban_show_center_control_code=f"{_cc_code}"
|
||||
@api.model
|
||||
def get_preproduction_shelf_ids(self):
|
||||
"""
|
||||
获取预生产区域的货架ID列表
|
||||
Returns:
|
||||
list: 货架ID列表
|
||||
"""
|
||||
query = """
|
||||
SELECT DISTINCT b.shelf_id
|
||||
FROM stock_location a
|
||||
LEFT JOIN sf_shelf_location b ON a.id = b.location_id
|
||||
WHERE a.barcode LIKE 'WH-PREPRODUCTION'
|
||||
"""
|
||||
self.env.cr.execute(query)
|
||||
result = self.env.cr.fetchall()
|
||||
# 将结果转换为ID列表
|
||||
shelf_ids = [record[0] for record in result if record[0]]
|
||||
return shelf_ids
|
||||
|
||||
class SfShelfLocationLot(models.Model):
|
||||
_name = 'sf.shelf.location.lot'
|
||||
@@ -581,6 +634,7 @@ class SfShelfLocationLot(models.Model):
|
||||
for item in self:
|
||||
if item.qty_num > item.qty:
|
||||
raise ValidationError('变更数量不能比库存数量大!!!')
|
||||
|
||||
|
||||
|
||||
class SfStockMoveLine(models.Model):
|
||||
|
||||
@@ -1,128 +1,198 @@
|
||||
// 定义一个 mixin 来处理重复的样式
|
||||
@mixin kanban-common-styles($record-count-each-row,
|
||||
$record-gap: 16px,
|
||||
$color-guide-width: 70px) {
|
||||
// 定义看板公共样式的Mixin
|
||||
@mixin kanban-common-styles($record-count-each-row, $record-gap: 16px) {
|
||||
$record-gap-total-width: $record-gap * ($record-count-each-row - 1);
|
||||
|
||||
|
||||
display: flex !important;
|
||||
flex-wrap: wrap !important;
|
||||
overflow-x: hidden !important;
|
||||
overflow-y: auto !important;
|
||||
padding: 0px !important;
|
||||
padding: 0 !important;
|
||||
gap: $record-gap !important;
|
||||
width: 100% !important;
|
||||
height: 100% !important;
|
||||
|
||||
// 设置卡片样式
|
||||
|
||||
// === 卡片基础样式(完全保留)===
|
||||
.o_kanban_record {
|
||||
flex: 0 0 calc((100% - #{$record-gap-total-width}) / #{$record-count-each-row}) !important;
|
||||
height: calc((100% - #{$record-gap * 6}) / 6) !important; // 平均分配高度
|
||||
margin: 0 !important;
|
||||
padding: 0px !important;
|
||||
background-color: white !important;
|
||||
border: 1px solid #dee2e6 !important;
|
||||
border-radius: 4px !important;
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) !important;
|
||||
min-width: calc((100% - #{$record-gap-total-width}) / #{$record-count-each-row}) !important;
|
||||
max-width: calc((100% - #{$record-gap-total-width}) / #{$record-count-each-row}) !important;
|
||||
|
||||
flex: 0 0 calc((100% - #{$record-gap-total-width}) / #{$record-count-each-row}) !important;
|
||||
height: calc((100% - #{$record-gap * 6}) / 6) !important;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
background-color: white !important;
|
||||
border: 1px solid #dee2e6 !important;
|
||||
border-radius: 4px !important;
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) !important;
|
||||
min-width: calc((100% - #{$record-gap-total-width}) / #{$record-count-each-row}) !important;
|
||||
max-width: calc((100% - #{$record-gap-total-width}) / #{$record-count-each-row}) !important;
|
||||
position: relative;
|
||||
transition: all 0.25s ease !important;
|
||||
overflow: visible !important; // 允许悬停条溢出卡片边界
|
||||
|
||||
// === 状态标签(保留原设计)===
|
||||
.status-label {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
right: 8px;
|
||||
padding: 3px 8px;
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
border: 1px solid #e0e0e0;
|
||||
border-radius: 3px;
|
||||
font-size: 11px;
|
||||
color: #424242;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
// === 优化:悬停信息条(核心改动)===
|
||||
.status-hover-bar {
|
||||
position: absolute;
|
||||
bottom: calc(100% + 8px); // 默认显示在卡片上方
|
||||
left: 0;
|
||||
z-index: 1000;
|
||||
min-width: max-content; // 宽度自适应内容
|
||||
max-width: 300px; // 防止过宽
|
||||
padding: 10px 12px;
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
border: 1px solid #e0e0e0;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
font-size: 12px;
|
||||
color: #424242;
|
||||
white-space: nowrap; // 强制单行显示
|
||||
opacity: 0;
|
||||
pointer-events: none; // 避免阻挡卡片交互
|
||||
transition: opacity 0.2s ease, transform 0.2s ease;
|
||||
transform: translateY(10px);
|
||||
|
||||
// 三角形指示器
|
||||
&::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
left: 15px;
|
||||
border: 6px solid transparent;
|
||||
border-top-color: rgba(0, 0, 0, 0.85);
|
||||
}
|
||||
|
||||
div {
|
||||
margin-bottom: 4px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
}
|
||||
|
||||
// === 悬停触发逻辑 ===
|
||||
&:hover {
|
||||
transform: translateY(-4px) !important;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
|
||||
z-index: 10;
|
||||
|
||||
.status-hover-bar {
|
||||
background: rgba(50, 50, 50, 0.9);
|
||||
color: #fff !important;
|
||||
font-size: 12px;
|
||||
opacity: 0.9;
|
||||
transform: translateY(0);
|
||||
pointer-events: auto; // 悬停时允许交互
|
||||
}
|
||||
}
|
||||
|
||||
// === 边界保护(智能定位)===
|
||||
// 左侧卡片:左对齐
|
||||
&:nth-child(#{$record-count-each-row}n+1) .status-hover-bar {
|
||||
left: 0;
|
||||
right: auto;
|
||||
&::after { left: 15px; }
|
||||
}
|
||||
|
||||
// 右侧卡片:右对齐
|
||||
&:nth-child(#{$record-count-each-row}n) .status-hover-bar {
|
||||
left: auto;
|
||||
right: 0;
|
||||
&::after {
|
||||
left: auto;
|
||||
right: 15px;
|
||||
}
|
||||
}
|
||||
&:nth-child(#{$record-count-each-row}n + #{$record-count-each-row - 1}) .status-hover-bar {
|
||||
left: auto;
|
||||
right: 0;
|
||||
&::after {
|
||||
left: auto;
|
||||
right: 15px;
|
||||
}
|
||||
}
|
||||
// 顶部卡片:悬停条显示在下方
|
||||
&:nth-child(-n+#{$record-count-each-row}) .status-hover-bar {
|
||||
bottom: auto;
|
||||
top: calc(100% + 8px);
|
||||
&::after {
|
||||
top: auto;
|
||||
bottom: 100%;
|
||||
border-top-color: transparent;
|
||||
border-bottom-color: rgba(255, 255, 255, 0.95);
|
||||
}
|
||||
}
|
||||
|
||||
// === 禁用状态样式(保留原效果)===
|
||||
&.kanban_color_3 {
|
||||
opacity: 0.6;
|
||||
&:hover {
|
||||
transform: translateY(-1px) !important;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15) !important;
|
||||
}
|
||||
|
||||
.o_kanban_record_bottom {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.oe_kanban_card.kanban_color_3,
|
||||
.oe_kanban_card.kanban_color_1,
|
||||
.oe_kanban_card.kanban_color_2 {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
.sf_kanban_custom_location_info_style {
|
||||
display: flex !important;
|
||||
justify-content: center !important;
|
||||
align-items: center !important;
|
||||
width: 100%;
|
||||
font-size: 14px;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.sf_kanban_no {
|
||||
display: flex !important;
|
||||
justify-content: center !important;
|
||||
align-items: center !important;
|
||||
font-size: 18px;
|
||||
color: #000000;
|
||||
}
|
||||
opacity: 0.85;
|
||||
.status-hover-bar {
|
||||
background:rgba(0, 0, 0, 0.85);
|
||||
color: white !important;
|
||||
border: 1px solid rgba(255, 255, 255, 0.15) !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 使用 mixin 为不同的列数生成样式
|
||||
.o_kanban_view {
|
||||
.sf_kanban_location_style {
|
||||
// 设置卡片样式
|
||||
.o_kanban_record {
|
||||
|
||||
&:hover {
|
||||
transform: translateY(-1px) !important;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15) !important;
|
||||
}
|
||||
|
||||
.o_kanban_record_bottom {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.oe_kanban_card.kanban_color_3,
|
||||
.oe_kanban_card.kanban_color_1,
|
||||
.oe_kanban_card.kanban_color_2 {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
.sf_kanban_custom_location_info_style {
|
||||
display: flex !important;
|
||||
justify-content: center !important;
|
||||
align-items: center !important;
|
||||
width: 100%;
|
||||
font-size: 14px;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.sf_kanban_no {
|
||||
display: flex !important;
|
||||
justify-content: center !important;
|
||||
align-items: center !important;
|
||||
font-size: 18px;
|
||||
color: #000000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// === 看板视图样式(完全保留)===
|
||||
.o_kanban_view {
|
||||
// 卡片内部结构(不修改)
|
||||
.o_kanban_record {
|
||||
.o_kanban_record_bottom {
|
||||
margin: 0;
|
||||
}
|
||||
.oe_kanban_card.kanban_color_3,
|
||||
.oe_kanban_card.kanban_color_1,
|
||||
.oe_kanban_card.kanban_color_2 {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
.sf_kanban_custom_location_info_style {
|
||||
display: flex !important;
|
||||
justify-content: center !important;
|
||||
align-items: center !important;
|
||||
width: 100%;
|
||||
font-size: 15px;
|
||||
color: #000000;
|
||||
padding:0px;
|
||||
}
|
||||
|
||||
.sf_kanban_no {
|
||||
display: flex !important;
|
||||
justify-content: center !important;
|
||||
align-items: center !important;
|
||||
font-size: 18px;
|
||||
color: #000000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 不同列数的看板样式
|
||||
.sf_kanban_location_style12 {
|
||||
@include kanban-common-styles(12);
|
||||
@include kanban-common-styles(12);
|
||||
}
|
||||
|
||||
.sf_kanban_location_style19 {
|
||||
@include kanban-common-styles(19);
|
||||
@include kanban-common-styles(19);
|
||||
}
|
||||
|
||||
.sf_kanban_location_style4 {
|
||||
@include kanban-common-styles(4);
|
||||
@include kanban-common-styles(4);
|
||||
}
|
||||
|
||||
.sf_kanban_location_style3 {
|
||||
@include kanban-common-styles(3);
|
||||
@include kanban-common-styles(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,8 +28,18 @@ class CustomKanbanController extends KanbanController {
|
||||
isBaseStyle: true
|
||||
});
|
||||
let self = this;
|
||||
// 获取货架分层数据
|
||||
|
||||
onWillStart(async () => {
|
||||
try {
|
||||
this.preproductionShelfIds = await this.orm.call(
|
||||
'sf.shelf.location',
|
||||
'get_preproduction_shelf_ids',
|
||||
[]
|
||||
);
|
||||
} catch (error) {
|
||||
this.preproductionShelfIds = [];
|
||||
}
|
||||
|
||||
this.searchModel.on('update', self, self._onUpdate);
|
||||
await this.loadShelfLayersData();
|
||||
});
|
||||
@@ -50,7 +60,11 @@ class CustomKanbanController extends KanbanController {
|
||||
let domain = this.searchModel.domain;
|
||||
if (domain.length > 0) {
|
||||
let shelfDomain = domain.find(item => item[0] === 'shelf_id');
|
||||
this.onShelfChange(shelfDomain[2]);
|
||||
if (shelfDomain && shelfDomain[2] && this.preproductionShelfIds && this.preproductionShelfIds.includes(shelfDomain[2])) {
|
||||
this.onShelfChange(shelfDomain[2]);
|
||||
} else {
|
||||
this.setKanbanStyle('sf_kanban_location_style');
|
||||
}
|
||||
} else {
|
||||
this.setKanbanStyle('sf_kanban_location_style');
|
||||
}
|
||||
@@ -63,8 +77,7 @@ class CustomKanbanController extends KanbanController {
|
||||
let shelfDomain = domain.find(item => item[0] === 'shelf_id');
|
||||
if (shelfDomain) {
|
||||
let shelfId = shelfDomain[2];
|
||||
// 如果货架ID存在,则设置相应的样式
|
||||
if (shelfId) {
|
||||
if (shelfId && this.preproductionShelfIds.includes(shelfId)) {
|
||||
this.onShelfChange(shelfId);
|
||||
return;
|
||||
}
|
||||
@@ -75,7 +88,6 @@ class CustomKanbanController extends KanbanController {
|
||||
this.setKanbanStyle('sf_kanban_location_style');
|
||||
} catch (error) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 加载所有货架的层数数据
|
||||
@@ -107,10 +119,18 @@ class CustomKanbanController extends KanbanController {
|
||||
// 添加新类
|
||||
if (isHave) kanbanViewEl.classList.add(style);
|
||||
}
|
||||
const ghostCards = document.querySelectorAll('.o_kanban_ghost');
|
||||
ghostCards.forEach(card => {
|
||||
card.remove();
|
||||
});
|
||||
|
||||
// 获取当前的搜索域
|
||||
let domain = this.searchModel.domain;
|
||||
let shelfDomain = domain.find(item => item[0] === 'shelf_id');
|
||||
|
||||
// 只有当shelf_id在preproductionShelfIds中时才删除幽灵看板
|
||||
if (shelfDomain && this.preproductionShelfIds && this.preproductionShelfIds.includes(shelfDomain[2])) {
|
||||
const ghostCards = document.querySelectorAll('.o_kanban_ghost');
|
||||
ghostCards.forEach(card => {
|
||||
card.remove();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
updatePagerLimit(limit) {
|
||||
|
||||
@@ -193,53 +193,78 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="shelf_location_kanban_view" model="ir.ui.view">
|
||||
<field name="name">shelf.location.kanban</field>
|
||||
<field name="model">sf.shelf.location</field>
|
||||
<field name="arch" type="xml">
|
||||
<kanban class="sf_kanban_location_style" js_class="custom_kanban" create="0">
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<t t-set='isBaseStyle' t-value="user_context.isBaseStyle"/>
|
||||
<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' : ''}">
|
||||
<record id="shelf_location_kanban_view" model="ir.ui.view">
|
||||
<field name="name">shelf.location.kanban</field>
|
||||
<field name="model">sf.shelf.location</field>
|
||||
<field name="arch" type="xml">
|
||||
<kanban class="sf_kanban_location_style" js_class="custom_kanban" create="0">
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<t t-set='isBaseStyle' t-value="user_context.isBaseStyle"/>
|
||||
<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 style="display:none">
|
||||
<field name="location_status"/>
|
||||
<field name="tool_name_id"/>
|
||||
</div>
|
||||
|
||||
<!-- 所有情况都需要的数据 (隐藏) -->
|
||||
<div style="display:none">
|
||||
<field name="location_status"/>
|
||||
<t t-if="isBaseStyle">
|
||||
<div class="o_kanban_card_header">
|
||||
<div class="o_kanban_card_header_title">
|
||||
<field name="name"/>
|
||||
</div>
|
||||
|
||||
|
||||
<t t-if="isBaseStyle">
|
||||
<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="product_sn_id"/>
|
||||
<span>|</span>
|
||||
<field name="product_id"/>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<t t-else="">
|
||||
<div class="o_kanban_record_bottom sf_kanban_custom_location_info_style">
|
||||
<field name="kanban_show_layer_info"/>
|
||||
</div>
|
||||
<div class="o_kanban_record_bottom sf_kanban_no">
|
||||
<field name="kanban_show_center_control_code"/>
|
||||
</div>
|
||||
</t>
|
||||
</div>
|
||||
<div class="o_kanban_record_bottom">
|
||||
<field name="product_sn_id"/>
|
||||
<field name="product_id"/>
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
</kanban>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<t t-else="">
|
||||
<div class="o_kanban_record_bottom sf_kanban_custom_location_info_style">
|
||||
<field name="kanban_show_layer_info"/>
|
||||
</div>
|
||||
<!-- 添加RFID字段 -->
|
||||
<!-- <t t-if="record.data and record.data.display_rfid">
|
||||
<div class="o_kanban_record_bottom">
|
||||
<field name="display_rfid"/>
|
||||
</div>
|
||||
</t>
|
||||
<t t-if="record.data and record.data.tool_rfid">
|
||||
<div class="o_kanban_record_bottom">
|
||||
<field name="tool_rfid"/>
|
||||
</div>
|
||||
</t> -->
|
||||
<!-- 悬停时显示的详细信息 -->
|
||||
<div class="status-hover-bar">
|
||||
<t t-if="record.product_id.value">
|
||||
<div>产品: <t t-esc="record.product_id.value"/></div>
|
||||
</t>
|
||||
<t t-if="record.product_sn_id.value">
|
||||
<div>标签ID: <t t-esc="record.product_sn_id.value"/></div>
|
||||
</t>
|
||||
<!-- <t t-if="record.display_rfid.value">
|
||||
<div>rfid: <t t-esc="record.display_rfid.value"/></div>
|
||||
</t>
|
||||
<t t-if="record.tool_rfid.value">
|
||||
<div>rfid: <t t-esc="record.tool_rfid.value"/></div>
|
||||
</t> -->
|
||||
<t t-if="record.tool_name_id and record.tool_name_id.value">
|
||||
<div>功能刀具名称: <t t-esc="record.tool_name_id.value"/></div>
|
||||
</t>
|
||||
<div>状态: <t t-esc="record.location_status.value"/></div>
|
||||
</div>
|
||||
</t>
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
</kanban>
|
||||
</field>
|
||||
</record>
|
||||
<!-- 搜索视图 -->
|
||||
<record id="shelf_location_search_view" model="ir.ui.view">
|
||||
<field name="name">shelf.location.search</field>
|
||||
|
||||
Reference in New Issue
Block a user