24 lines
951 B
Python
24 lines
951 B
Python
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)])
|
|
if tool_id:
|
|
item.tool_rfid = tool_id.rfid
|
|
item.tool_name_id = tool_id.id
|
|
continue
|
|
item.tool_rfid = ''
|
|
item.tool_name_id = False
|