30 lines
1.3 KiB
Python
30 lines
1.3 KiB
Python
from odoo import models, fields
|
|
from odoo.http import request
|
|
|
|
|
|
class ToolInventory(models.Model):
|
|
_inherit = 'sf.tool.inventory'
|
|
_description = '功能刀具清单'
|
|
knife_handle_model = fields.Selection([('BT30', 'BT30'), ('BT40', 'BT40'), ('BT50', 'BT50'), ('GSK30', 'GSK30'), ('GSK40', 'GSK40'), ('GSK50', 'GSK50')], string='使用刀柄型号', required=True)
|
|
jikimo_bom_ids = fields.One2many('jikimo.bom','tool_inventory_id', 'bom单')
|
|
blade_length = fields.Float('刃长(mm)')
|
|
def bom_mainfest(self):
|
|
jikimo_bom_ids = self.mapped('jikimo_bom_ids')
|
|
if not jikimo_bom_ids:
|
|
self._bom_mainfest()
|
|
return self.bom_mainfest()
|
|
request.session['jikimo_bom_product'] = {'bom_id': int(self.jikimo_bom_ids)}
|
|
|
|
return {
|
|
'type': 'ir.actions.act_window',
|
|
'name': '刀具组装清单',
|
|
'res_model': 'jikimo.bom',
|
|
'view_mode': 'form',
|
|
'view_id': self.env.ref('sf_tool_management.view_jikimo_bom_form').id,
|
|
'res_id': int(self.jikimo_bom_ids),
|
|
'target': 'current', # Use 'new' to open in a new window/tab
|
|
}
|
|
|
|
# 创建bom单
|
|
def _bom_mainfest(self):
|
|
self.env['jikimo.bom'].create({'tool_inventory_id':self.id}) |