1、优化功能刀具安全库存数量计算方法;2、货位看板模型添加功能刀具Rfid、名称字段
This commit is contained in:
22
sf_tool_management/models/stock.py
Normal file
22
sf_tool_management/models/stock.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from odoo import api, fields, models, _
|
||||
|
||||
|
||||
class ShelfLocation(models.Model):
|
||||
_inherit = 'sf.shelf.location'
|
||||
|
||||
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)
|
||||
|
||||
@api.depends('product_id')
|
||||
def _compute_tool(self):
|
||||
for item in self:
|
||||
if item.product_id:
|
||||
if item.product_id.categ_id.name == '功能刀具':
|
||||
tool_id = self.env['sf.functional.cutting.tool.entity'].sudo().search(
|
||||
[('barcode_id', '=', item.product_sn_id.id)])
|
||||
item.tool_rfid = tool_id.rfid
|
||||
item.tool_name_id = tool_id.id
|
||||
return True
|
||||
item.tool_rfid = ''
|
||||
item.tool_name_id = False
|
||||
Reference in New Issue
Block a user