跳至内容
菜单
此问题已终结
1 回复
9300 查看

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
2424
1
6月 24
4941
1
10月 23
10585
1
10月 23
98
1
8月 23
2193