This question has been flagged
1 Reply
7900 Views

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()


Avatar
Discard
Best Answer

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;

Avatar
Discard