在生产订单里,通过按钮(type=“object”)跳转到技术评审单,有以下区别:
- 当有一条数据时,跳转到form视图
-当有多条条数据时,跳转到tree视图(只有此多条数据)
def action_view_technical(self):
'链接到技术评审单'
data = []
self.ensure_one()
action = self.env.ref('production_management.production_technical_review_action').read()[0]
for rec in self.order_line:
data.append(rec.id)
production = self.env['production.technical.review'].search(
[('sale_id', '=', self.id), ('sale_line_id', 'in', data)])
if self.technical_count > 1:
action['domain'] = [('sale_id', '=', self.id), ('sale_line_id', 'in', data)]
elif self.technical_count == 1:
form_view = [(self.env.ref('production_management.production_technical_review_form').id, 'form')]
if 'views' in action:
action['views'] = form_view + [(state, view) for state, view in action['views'] if view != 'form']
else:
action['views'] = form_view
action['res_id'] = production.id
action['context'] = dict(self._context, default_origin=self.name, create=False)
return action