콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
3438 화면

I have 3 custom models (model_one,model_one_line and model_two)

In my model_one, I have a tree view that displays the o2m field which data are from the model_one_line (model_one is o2m to model_one_line and model_one_line is m2o to model_one).

The data from the model_one_line were fetched from stock.move, Now I displayed The o2m field of model_one(product,pcs,kgs,amount), in every product there's a corresponding customers who bought it.


So I created the model_two which is for customer for every product (model_one_line is o2m to model_two and model_two is m2o of model_one_line * I added these fields on model_two and model_one_line), I want to when I click a row from model_one, a new tree view appeared and displayed the customers based on the product of the row I clicked, 


How can I achieved this?I already have the view for the model_two and it's already displays nothing for now. This is my first time encounter a task o2m inside a o2m.



아바타
취소
베스트 답변

Hello,

You can achieve this by using onchange of product_id in model: 'model_one_line'. Suppose name of customer's o2m in both models model_one_line and 'product.product' is 'customer_ids' corresponding customers who bought product.You can write the code something like this.

class ProductProduct(models.Model):
_name = 'product.product'

customer_ids = fields.One2many('res.partner', domain=[('active', '=', True),('customer', '=', True)])


class model_one_line(models.Model):
_name = 'model_one_line'

customer_ids = fields.One2many('res.partner', domain=[('active', '=', True),('customer', '=', True)])

@api.onchange('product_id')
def product_id_change(self):
for line in self:
line.customer_ids = line.product_id.customer_ids


Regards,




Email: odoo@aktivsoftware.com

Skype: kalpeshmaheshwari

   



아바타
취소
관련 게시물 답글 화면 활동
2
3월 16
29648
0
3월 15
4912
1
5월 22
3114
0
2월 19
4237
2
8월 24
960