我有以下方法:
@api.depends('order_lines', 'order_lines.isbn')
def _get_products(self):
isbn = self.env['product.product']
for prodtmpl in self.order_lines:
isbn |= prodtmpl.isbn
return isbn
@api.model
def _get_act_window_dict(self, name):
mod_obj = self.env['ir.model.data']
result = mod_obj.xmlid_to_object(name)
if not result:
result = {
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'stock.quant',
'name': 'Stock On Hand',
'type': 'ir.actions.act_window',
}
else:
result = result[0].read()[0]
return result
@api.multi
def action_open_isbn(self):
isbn = self._get_products()
result = self._get_act_window_dict('stock.product_open_quants')
result['domain'] = "[('isbn','in',[" + ','.join(map(str, isbn.ids)) + "])]"
result['context'] = "{'search_default_locationgroup': 1, 'search_default_internal_loc': 1}"
return result
在方法get_act_window_dict
上,它应该返回数量产品,比如product.template
的现有数量
但它让我想到:
^{pr2}$我试过这样做:
@api.model
def _get_act_window_dict(self, name):
mod_obj = self.env['ir.model.data']
result = mod_obj.xmlid_to_object(name)
if not result:
result = {
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'stock.quant',
'name': 'Stock On Hand',
'isbn': 'product_id',
'type': 'ir.actions.act_window',
}
else:
result = result[0].read()[0]
return result
将isbn
作为product_id
添加到dict结果中,但结果相同。在
有什么想法吗?在
PS:这是我类上的isbn
字段:
isbn = fields.Many2one('product.product', string="ISBN", domain="[('is_isbn', '=', True)]")
当然,它不是以isbn
的形式存在于stock.quant
上,但它对product
来说是一个很大的问题,所以它应该以某种方式通过。在
这条线:
应该是:
^{pr2}$没有字段isbn在股票数量. 既然isbn是目标产品.产品,我想产品编号是一样的股票数量在
相关问题 更多 >
编程相关推荐