이 내 구조 :Odoo 10의 객체에서 ID를 가져 오는 방법은 무엇입니까?
class Imprint_Location(models.Model):
_name = 'imprint.location'
name = fields.Char()
product_id = fields.Many2one('product.template')
class Imprint_Charges(models.Model):
_name = 'imprint.charge'
_rec_name = 'location_id'
product_id_c = fields.Many2one('product.template', required=True)
location_id = fields.Many2one('imprint.location', required=True)
@api.multi
@api.onchange('product_id_c', 'location_id')
def product_filter(self):
res = {}
print '\n\n-------\n\n', self, self.product_id_c, '\n\n-------\n\n'
if self.product_id_c:
res['domain'] = {'location_id': [('product_id', '=', self.product_id_c.id)]}
print res
return res
class Product_Template(models.Model):
_inherit = 'product.template'
imprint_location_ids = fields.One2many('imprint.location', 'product_id')
sale_imprint_charge_ids = fields.One2many('imprint.charge', 'product_id_c')
지금 내가 product.template
의 페이지를 정의하고 페이지 내에서 <tree editable="bottom">
에 sale_imprint_charge_ids
이고 내가 product_id_c
필드를 선택하고 있지 않다있다 [이 필드에 표시되지 않습니다 정의 된 트리].
지금 여기 내 문제는 내가 imprint.charge
을 위해 잘 작동하지만 난 다음 product.template
에서 입력 할 때 내가
TypeError: <odoo.models.NewId object at 0x7fbb8bc21b90> is not JSON serializable
product_filter
방법을 정의 폼보기에서이 옵션을 선택하면
에서 객체가 <odoo.models.NewId object at 0x7fbb8bc21b90>
을 전달하므로 self.product_id_c
인 경우 product.template(<odoo.models.NewId object at 0x7fbb8bc21b90>)
이 인쇄되므로 직렬화 할 수 없습니다. 출력을 비어있는 목록 []
을주는 self.product_id_c.ids
을 시도했다.
개체에서 product.template
ID를 얻거나 id
자체를 전달하여 일부 방법을 재정의하는 방법은 무엇입니까?
필드 'location_id'를 필터링해야합니다 ... 해당 제품의 필드 만 표시하고 싶습니다. 결과는 목록이 될 수 있으며 사용자가 선택할'location_id '를 선택하길 원합니다 – maharshi
여전히'product.template'에서 빈 레코드 셋을 얻습니다. 그것은'id'가 아닌'object'를 전달합니다. – maharshi