Commit 646009c7 by 夏超

[add] 增加工单指派工位

parent 290b08ea
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from . import models from . import models
from . import controllers from . import controllers
from . import wizard
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
'views/button_js.xml', 'views/button_js.xml',
'views/iniherit_work_order_view.xml', 'views/iniherit_work_order_view.xml',
'views/inherit_roke_product.xml', 'views/inherit_roke_product.xml',
'views/inherit_roke_routing_line.xml' 'views/inherit_roke_routing_line.xml',
'wizard/assign_workcenter_wizard_view.xml',
], ],
'qweb': [ 'qweb': [
"static/src/xml/roke_craft_design.xml", "static/src/xml/roke_craft_design.xml",
......
...@@ -7,6 +7,7 @@ class InheritWorkOrder(models.Model): ...@@ -7,6 +7,7 @@ class InheritWorkOrder(models.Model):
document_ids = fields.Many2many(related="task_id.document_ids", string="作业指导") document_ids = fields.Many2many(related="task_id.document_ids", string="作业指导")
task_file_ids = fields.Many2many(related="task_id.file_ids") task_file_ids = fields.Many2many(related="task_id.file_ids")
special_process = fields.Selection(related="routing_line_id.special_process")
next_wo_id = fields.Many2one("roke.work.order", string="下道工单", store=True, compute="_compute_next_work_order") next_wo_id = fields.Many2one("roke.work.order", string="下道工单", store=True, compute="_compute_next_work_order")
...@@ -30,3 +31,18 @@ class InheritWorkOrder(models.Model): ...@@ -30,3 +31,18 @@ class InheritWorkOrder(models.Model):
v.next_wo_id = v.repair_wr_id.work_order_id.id v.next_wo_id = v.repair_wr_id.work_order_id.id
else: else:
v.next_wo_id = next_wo[0].id v.next_wo_id = next_wo[0].id
def action_assign_work_center(self):
self.ensure_one()
# 检查是否是特殊工序
# 打开指派向导
return {
'name': '指派工作中心',
'type': 'ir.actions.act_window',
'res_model': 'assign.work.center.wizard',
'view_mode': 'form',
'target': 'new',
'context': {
'default_work_order_id': self.id,
}
}
...@@ -18,6 +18,3 @@ ...@@ -18,6 +18,3 @@
</field> </field>
</record> </record>
</odoo> </odoo>
...@@ -5,11 +5,26 @@ ...@@ -5,11 +5,26 @@
<field name="model">roke.work.order</field> <field name="model">roke.work.order</field>
<field name="inherit_id" ref="roke_mes_production.view_roke_work_order_form"/> <field name="inherit_id" ref="roke_mes_production.view_roke_work_order_form"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<!-- <xpath expr="//page/group[@name='attachment']" position="before">-->
<xpath expr="//page/group[@name='attachment']" position="after"> <xpath expr="//page/group[@name='attachment']" position="after">
<field name="task_file_ids" widget="many2many_pic_preview"/> <field name="task_file_ids" widget="many2many_pic_preview"/>
</xpath> </xpath>
</field> </field>
</record> </record>
<record id="inherit_view_roke_work_order_edit_tree" model="ir.ui.view">
<field name="name">inherit.roke.work.order.edit_tree.view</field>
<field name="model">roke.work.order</field>
<field name="inherit_id" ref="roke_mes_production.view_roke_work_order_edit_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='routing_line_id']" position="after">
<field name="special_process" invisible="1"/>
</xpath>
<xpath expr="//button[@name='multi_create_work_record']" position="after">
<button name="action_assign_work_center"
type="object" class="oe_highlight oe_read_only" string="指派"
attrs="{'invisible': [('special_process', '!=', '是')]}"/>
</xpath>
</field>
</record>
</odoo> </odoo>
from . import assign_workcenter_wizard
from odoo import models, fields, api
class AssignWorkcenterWizard(models.TransientModel):
_name = 'assign.work.center.wizard'
_description = '指派工作中心向导'
workshop_id = fields.Many2one('roke.workshop', string='产线')
work_center_id = fields.Many2one('roke.work.center', string='工位')
work_order_id = fields.Many2one('roke.work.order', string='工单')
def action_confirm(self):
self.ensure_one()
if self.work_order_id and self.work_center_id:
self.work_order_id.write({
'work_center_id': self.work_center_id.id
})
return {'type': 'ir.actions.act_window_close'}
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_assign_work_center_wizard_form" model="ir.ui.view">
<field name="name">assign.work.center.wizard.form</field>
<field name="model">assign.work.center.wizard</field>
<field name="arch" type="xml">
<form string="指派工作中心">
<group>
<group>
<field name="workshop_id"/>
<field name="work_order_id" invisible="1"/>
</group>
<group>
<field name="work_center_id" domain="[('workshop_id', '=', workshop_id)]"/>
</group>
</group>
<footer>
<button string="确认" name="action_confirm" type="object" class="btn-primary"/>
<button string="取消" class="btn-secondary" special="cancel"/>
</footer>
</form>
</field>
</record>
</odoo>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment