Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
5 Trả lời
5729 Lượt xem

two queries regarding adding new product,

1. My products are always link to one specific customer. so while adding the product, i want to select that specific customer.

2. My customer gives the unique code of their products, so, while adding the product, i want to enter customer product code, and this code should be unique to that specific customer.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Define  @api.constrains('customer_id','product_code')  definition in this definition you can write a logic


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Maybe this add-on can help?  

https://apps.odoo.com/apps/modules/11.0/customer_product_code/

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hello

use below code.

@api.one
@api.constrains('customer_id', 'default_code') # customer_id is field and default_code is product code.
def _check_customer_product_code(self):
    if self.customer_id and self.default_code:
        code_lst = self.search([('customer_id', '=', self.customer_id.id)]).mapped('default_code')
        if len(code_lst) != len(set(code_lst)):
            raise Warning("Your error msg.")
Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

thank you for your reply 

but unfortunately, I am new and completely non technical, and don't know python coding. 

i can just change or amend minor codes in field/model by activating developer mode. 

can you please explain it in detail?

thank you

Ảnh đại diện
Huỷ bỏ

then i want to know the customer_id,product_code fields declaration

i mean type of the fields

Python Basics for Odoo Customization: https://plus.google.com/collection/AN9iWE

Odoo Customization Tips: http://learnopenerp.blogspot.com

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 9 17
8884
1
thg 3 15
7016
2
thg 6 25
1179
0
thg 3 25
1124
0
thg 2 25
907