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

How do i create an inner join between two fields

class DRS(models.Model):
_inherit = "product.template"
# BASIC INFORMATION
supplier = fields.Char()
product_name_eng = fields.Char()
product_name_chi = fields.Char()
product_category = fields.Char()
brand_name_eng = fields.Char()
brand_name_chi = fields.Char()
sup_product_code = fields.Char()
drs_product_code = fields.Char()
mlt = fields.Integer()
allergy_warning = fields.Boolean()
product_material_percentage = fields.Char()
product_link = fields.Char()
# COMPLIANCE INFORMATION
countryoforigin = fields.Char()
medicaldevice = fields.Boolean()
wireless = fields.Char()
otherwireless = fields.Char()
hscode = fields.Char()
importexport = fields.Char()
containmaterial = fields.Char()
potentialhazards = fields.Char()
# OTHER
notes = fields.Text()

# REFERENCE INFORMATION
refinfo_id = fields.One2many('drs_product_views.refinfo',
'drs_product_code', string="Reference Info")


class refinfo(models.Model):
_name = 'drs_product_views.refinfo'

drs_product_code = fields.Many2one('product.template',
ondelete='cascade', string="Product")

file = fields.Char()
link = fields.Char()
type = fields.Char()
appliedVariationProduct = fields.Char()
applicableRegion = fields.Char()
description = fields.Text()


아바타
취소
베스트 답변

let's say you want to select 2 fields from table1 and 2 fields from table 2 . 
Then  the sql would be : 

Select d.supplier, d.product_name_eng, r.file, r.link from product_template as d inner join drs_product_views_refinfo as r on r.drs_product_code = d.id;

아바타
취소
관련 게시물 답글 화면 활동
2
7월 24
2620
1
6월 24
5092
1
10월 23
10781
1
10월 23
98
1
8월 23
2193