1、功能刀具拆解单新增拆解单号,优化拆解单
This commit is contained in:
@@ -679,6 +679,22 @@ class FunctionalToolDismantle(models.Model):
|
||||
raise ValidationError('该功能刀具因为%s拆解,无需录入库位' % self.dismantle_cause)
|
||||
|
||||
name = fields.Char('名称', related='functional_tool_id.name')
|
||||
code = fields.Char('拆解单号', default=lambda self: self._get_code(), readonly=True)
|
||||
|
||||
def _get_code(self):
|
||||
"""
|
||||
自动生成拆解单编码
|
||||
"""
|
||||
new_time = str(fields.Date.today())
|
||||
datetime = new_time[2:4] + new_time[5:7] + new_time[-2:]
|
||||
functional_tool_dismantle = self.env['sf.functional.tool.dismantle'].sudo().search(
|
||||
[('code', 'ilike', datetime)], limit=1, order="id desc")
|
||||
if not functional_tool_dismantle:
|
||||
num = "%03d" % 1
|
||||
else:
|
||||
m = int(functional_tool_dismantle.code[-3:]) + 1
|
||||
num = "%03d" % m
|
||||
return 'GNDJ-CJD-%s-%s' % (datetime, num)
|
||||
|
||||
functional_tool_id = fields.Many2one('sf.functional.cutting.tool.entity', '功能刀具', required=True,
|
||||
domain=[('functional_tool_status', '!=', '已拆除')])
|
||||
@@ -824,7 +840,7 @@ class FunctionalToolDismantle(models.Model):
|
||||
|
||||
def confirmation_disassembly(self):
|
||||
logging.info('%s刀具确认开始拆解' % self.dismantle_cause)
|
||||
t_id = self.id
|
||||
code = self.code
|
||||
if self.functional_tool_id.functional_tool_status == '已拆除':
|
||||
raise ValidationError('Rfid为【%s】的功能刀具已经拆解,请勿重复操作!' % self.functional_tool_id.rfid_dismantle)
|
||||
location = self.env['stock.location'].search([('name', '=', '刀具组装位置')])
|
||||
@@ -849,19 +865,19 @@ class FunctionalToolDismantle(models.Model):
|
||||
# 除刀柄外物料报废 入库到Scrap
|
||||
if self.integral_product_id:
|
||||
self.integral_product_id.dismantle_stock_moves(False, self.integral_lot_id, location,
|
||||
location_dest_scrap, t_id)
|
||||
location_dest_scrap, code)
|
||||
elif self.blade_product_id:
|
||||
self.blade_product_id.dismantle_stock_moves(False, self.blade_lot_id, location, location_dest_scrap,
|
||||
t_id)
|
||||
code)
|
||||
if self.bar_product_id:
|
||||
self.bar_product_id.dismantle_stock_moves(False, self.bar_lot_id, location, location_dest_scrap,
|
||||
t_id)
|
||||
code)
|
||||
elif self.pad_product_id:
|
||||
self.pad_product_id.dismantle_stock_moves(False, self.pad_lot_id, location, location_dest_scrap,
|
||||
t_id)
|
||||
code)
|
||||
if self.chuck_product_id:
|
||||
self.chuck_product_id.dismantle_stock_moves(False, self.chuck_lot_id, location, location_dest_scrap,
|
||||
t_id)
|
||||
code)
|
||||
# ===========功能刀具[磨削]拆解==============
|
||||
# elif self.dismantle_cause in ['刀具需磨削']:
|
||||
# location_dest = self.env['stock.location'].search([('name', '=', '磨削房')])
|
||||
@@ -881,19 +897,19 @@ class FunctionalToolDismantle(models.Model):
|
||||
# 除刀柄外物料拆解 入库到具体货位
|
||||
if self.integral_freight_id:
|
||||
self.integral_product_id.dismantle_stock_moves(self.integral_freight_id, self.integral_lot_id, location,
|
||||
location_dest, t_id)
|
||||
location_dest, code)
|
||||
elif self.blade_freight_id:
|
||||
self.blade_product_id.dismantle_stock_moves(self.blade_freight_id, self.blade_lot_id, location,
|
||||
location_dest, t_id)
|
||||
location_dest, code)
|
||||
if self.bar_freight_id:
|
||||
self.bar_product_id.dismantle_stock_moves(self.bar_freight_id, self.bar_lot_id, location,
|
||||
location_dest, t_id)
|
||||
location_dest, code)
|
||||
elif self.pad_freight_id:
|
||||
self.pad_product_id.dismantle_stock_moves(self.pad_freight_id, self.pad_lot_id, location,
|
||||
location_dest, t_id)
|
||||
location_dest, code)
|
||||
if self.chuck_freight_id:
|
||||
self.chuck_product_id.dismantle_stock_moves(self.chuck_freight_id, self.chuck_lot_id, location,
|
||||
location_dest, t_id)
|
||||
location_dest, code)
|
||||
# ===============删除功能刀具的Rfid字段的值, 赋值给Rfid(已拆解)字段=====
|
||||
self.functional_tool_id.write({
|
||||
'rfid_dismantle': self.functional_tool_id.rfid,
|
||||
@@ -914,10 +930,10 @@ class FunctionalToolDismantle(models.Model):
|
||||
class ProductProduct(models.Model):
|
||||
_inherit = 'product.product'
|
||||
|
||||
def dismantle_stock_moves(self, shelf_location_id, lot_id, location_id, location_dest_id, t_id):
|
||||
def dismantle_stock_moves(self, shelf_location_id, lot_id, location_id, location_dest_id, code):
|
||||
# 创建功能刀具拆解单产品库存移动记录
|
||||
stock_move_id = self.env['stock.move'].sudo().create({
|
||||
'name': 'DJCJ/%s' % t_id,
|
||||
'name': code,
|
||||
'product_id': self.id,
|
||||
'location_id': location_id.id,
|
||||
'location_dest_id': location_dest_id.id,
|
||||
|
||||
@@ -778,6 +778,7 @@
|
||||
<field name="model">sf.functional.tool.dismantle</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree create="1">
|
||||
<field name="code"/>
|
||||
<field name="rfid"/>
|
||||
<field name="functional_tool_id"/>
|
||||
<field name="tool_type_id" invisible="1"/>
|
||||
@@ -805,13 +806,14 @@
|
||||
<sheet>
|
||||
<div class="oe_title">
|
||||
<h1>
|
||||
<field name="functional_tool_id" placeholder="请选择将要拆解的功能刀具"
|
||||
options="{'no_create': True}" attrs="{'readonly': [('state', '=', '已拆解')]}"/>
|
||||
<field name="code"/>
|
||||
</h1>
|
||||
</div>
|
||||
<field name="_barcode_scanned" widget="barcode_handler"/>
|
||||
<group>
|
||||
<group>
|
||||
<field name="functional_tool_id" placeholder="请选择将要拆解的功能刀具"
|
||||
options="{'no_create': True}" attrs="{'readonly': [('state', '=', '已拆解')]}"/>
|
||||
<field name="rfid" attrs="{'invisible': [('state', '=', '已拆解')]}"/>
|
||||
<field name="rfid_dismantle" attrs="{'invisible': [('state', '!=', '已拆解')]}"/>
|
||||
<field name="tool_type_id"/>
|
||||
@@ -946,6 +948,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<search>
|
||||
<field name="functional_tool_id"/>
|
||||
<field name="code" string="拆解单编码"/>
|
||||
<filter name="no_dismantle_state" string="未拆解" domain="[('state','!=','已拆解')]"/>
|
||||
<filter name="dismantle_state" string="已拆解" domain="[('state','=','已拆解')]"/>
|
||||
<separator/>
|
||||
|
||||
Reference in New Issue
Block a user