agv调度开发
This commit is contained in:
@@ -1233,6 +1233,66 @@ class ResMrpWorkOrder(models.Model):
|
||||
else:
|
||||
raise UserError("无关联制造订单或关联序列号,无法打印。请检查!")
|
||||
|
||||
@api.model
|
||||
def get_views(self, views, options=None):
|
||||
res = super().get_views(views, options)
|
||||
if res['views'].get('list', {}) and self.env.context.get('search_default_workcenter_id'):
|
||||
workcenter = self.env['mrp.workcenter'].browse(self.env.context.get('search_default_workcenter_id'))
|
||||
tree_view = res['views']['list']
|
||||
if workcenter.name == '工件拆卸中心':
|
||||
arch = etree.fromstring(tree_view['arch'])
|
||||
# 查找 tree 标签
|
||||
tree_element = arch.xpath("//tree")[0]
|
||||
|
||||
# 查找或创建 header 标签
|
||||
header_element = tree_element.find('header')
|
||||
if header_element is None:
|
||||
header_element = etree.Element('header')
|
||||
tree_element.insert(0, header_element)
|
||||
|
||||
# 创建并添加按钮元素
|
||||
button_element = etree.Element('button', {
|
||||
'name': 'button_delivery',
|
||||
'type': 'object',
|
||||
'string': '拆卸',
|
||||
'class': 'btn-primary',
|
||||
# 'className': 'btn-primary',
|
||||
'modifiers': '{"force_show": 1}'
|
||||
})
|
||||
header_element.append(button_element)
|
||||
|
||||
# 更新 tree_view 的 arch
|
||||
tree_view['arch'] = etree.tostring(arch, encoding='unicode')
|
||||
return res
|
||||
|
||||
def button_delivery(self):
|
||||
production_ids = []
|
||||
workorder_ids = []
|
||||
production_type = '运送空料架'
|
||||
max_num = 4 # 最大配送数量
|
||||
if len(self) > max_num:
|
||||
raise UserError('仅限于拆卸1-4个制造订单,请重新选择')
|
||||
for item in self:
|
||||
if item.state != 'ready':
|
||||
raise UserError('请选择状态为【就绪】的工单进行解除装夹')
|
||||
|
||||
production_ids.append(item.production_id.id)
|
||||
workorder_ids.append(item.id)
|
||||
return {
|
||||
'name': _('确认'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'sf.workpiece.delivery.wizard',
|
||||
'target': 'new',
|
||||
'context': {
|
||||
# 'default_delivery_ids': [(6, 0, delivery_ids)],
|
||||
'default_production_ids': [(6, 0, production_ids)],
|
||||
'default_type': production_type,
|
||||
'default_workorder_ids': [(6, 0, workorder_ids)],
|
||||
'default_workcenter_id': self.env.context.get('default_workcenter_id'),
|
||||
'default_confirm_button': '确认拆卸'
|
||||
}}
|
||||
|
||||
|
||||
class CNCprocessing(models.Model):
|
||||
_name = 'sf.cnc.processing'
|
||||
@@ -1612,6 +1672,7 @@ class WorkPieceDelivery(models.Model):
|
||||
'default_production_ids': [(6, 0, production_ids)],
|
||||
'default_type': production_type,
|
||||
'default_workorder_ids': [(6, 0, workorder_ids)],
|
||||
'default_confirm_button': '确认配送'
|
||||
}}
|
||||
|
||||
|
||||
|
||||
@@ -19,6 +19,39 @@
|
||||
</t>
|
||||
</t>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//div/t[@t-if='nbSelected']" position="replace">
|
||||
<t t-if="nbSelected">
|
||||
<t t-foreach="archInfo.headerButtons" t-as="button" t-key="button.id">
|
||||
<t t-if="button.modifiers.force_show == 0">
|
||||
<ListViewHeaderButton
|
||||
list="model.root"
|
||||
clickParams="button.clickParams"
|
||||
defaultRank="button.defaultRank"
|
||||
domain="props.domain"
|
||||
icon="button.icon"
|
||||
string="button.string"
|
||||
title="button.title"
|
||||
/>
|
||||
</t>
|
||||
</t>
|
||||
<t t-if="!env.isSmall">
|
||||
<t t-call="web.ListView.Selection"/>
|
||||
</t>
|
||||
<t t-foreach="archInfo.headerButtons" t-as="button" t-key="button.id">
|
||||
<t t-if="button.modifiers.force_show == 1">
|
||||
<ListViewHeaderButton
|
||||
list="model.root"
|
||||
clickParams="button.clickParams"
|
||||
defaultRank="button.defaultRank"
|
||||
domain="props.domain"
|
||||
icon="button.icon"
|
||||
string="button.string"
|
||||
title="button.title"
|
||||
className="button.className+' ms-2'"
|
||||
/>
|
||||
</t>
|
||||
</t>
|
||||
</t>
|
||||
</xpath>
|
||||
</t>
|
||||
</templates>
|
||||
@@ -9,6 +9,7 @@
|
||||
<!-- <field name="delivery_ids" invisible="True"/>-->
|
||||
<field name="workorder_ids" invisible="True"/>
|
||||
<field name="type" invisible="True"/>
|
||||
<field name="confirm_button" invisible="1"/>
|
||||
<field name="_barcode_scanned" widget="barcode_handler"/>
|
||||
<group col="1">
|
||||
<field name="production_ids" readonly="1" widget="many2many_tags" string="制造订单号"/>
|
||||
@@ -17,7 +18,8 @@
|
||||
<field name="workcenter_id" options="{'no_create': True}"/>
|
||||
</group>
|
||||
<footer>
|
||||
<button string="配送" name="confirm" type="object" class="oe_highlight"/>
|
||||
<button string="确认配送" name="confirm" type="object" class="oe_highlight" attrs="{'invisible': [('confirm_button', '!=', '确认配送')]}"/>
|
||||
<button string="确认拆卸" name="confirm" type="object" class="oe_highlight" attrs="{'invisible': [('confirm_button', '!=', '确认拆卸')]}"/>
|
||||
<button string="取消" class="btn btn-secondary" special="cancel"/>
|
||||
</footer>
|
||||
</sheet>
|
||||
|
||||
@@ -20,11 +20,14 @@ class WorkpieceDeliveryWizard(models.TransientModel):
|
||||
feeder_station_start_id = fields.Many2one('sf.agv.site', '起点接驳站')
|
||||
feeder_station_destination_id = fields.Many2one('sf.agv.site', '目的接驳站')
|
||||
workcenter_id = fields.Many2one(string='所属区域', comodel_name='mrp.workcenter', tracking=True)
|
||||
confirm_button = fields.Char('按钮名称')
|
||||
|
||||
@api.onchange('type')
|
||||
def _onchange_type(self):
|
||||
routes = self.env['sf.agv.task.route'].search([('route_type', '=', self.type)])
|
||||
if self.type:
|
||||
routes = self.env['sf.agv.task.route'].search([('route_type', '=', self.type)])
|
||||
if self.workcenter_id:
|
||||
routes = routes.filtered(lambda a: a.start_site_id.workcenter_id.id == self.workcenter_id.id)
|
||||
start_site_ids = routes.mapped('start_site_id.id')
|
||||
workcenter_ids = routes.mapped('end_site_id.workcenter_id.id')
|
||||
if workcenter_ids:
|
||||
|
||||
Reference in New Issue
Block a user