我在制造商的产品表格中创建了一个标签。它有manufacturer_name和manufacturer_partno字段以及其他一些字段。每个产品都有多个制造商(一对多关系)。我想在添加供应商表格中获得manufacturer_partno的下拉列表,它们是相同的产品(相同的产品ID)。我只是想知道这是怎么可能的。如果可以,请帮帮我。
// This is the product class extension
class product_template(osv.osv):
_inherit = "product.template"
_columns = {
'mrpproduct_partnumber': fields.char("Part Number", size=30, required=True),
'mrpproduct_description': fields.text("Description", required=True),
'mrpmanufacturers_ids': fields.one2many('mrpproduct.manufacturer','mrpproduct_id',string="Manufacturers"),
'mrprohs_compliant': fields.boolean('RoHS Compliant'),
'mrprequires_inspection': fields.boolean('Requires Inspection'),
'mrpperishable': fields.boolean('Perishable'),
'mrpperishabledate': fields.date('Perishable Date'),
'mrpwashable': fields.boolean('Washable'),
'mrphazardous': fields.boolean('Hazardous Material'),
'mrphazardouspdf': fields.binary('MSDF PDF'),
'mrpmsllevel_id': fields.many2one('mrp.msllevel','MSL Level'),
'mrppackagingsize_id': fields.many2one('mrp.packagingsize','Packaging Size'),
'mrpprocesstype_id': fields.many2one('mrp.processtype','Process Type'),
}
_order="mrpproduct_partnumber asc"
// This is the manufacturer
class mrpproduct_manufacturer(osv.osv):
_name = "mrpproduct.manufacturer"
_columns = {
'mrpmanufacturer_id': fields.many2one('mrp.manufacturers','Manufacturers'),
'mrpmanufacturer_pno': fields.char("Manufacturer Part Number", size=30, required=True),
'mrpmanufacturer_preference': fields.selection([('1','1'),('2','2'),('3','3'),('4','4'),('5','5'),('6','6'),('7','7'),('8','8'),('9','9'),], string="Priority"),
'mrpdatasheet': fields.binary('Data Sheet'),
'mrpproduct_id': fields.many2one('product.template','Manufacturer'),
}
_order="mrpmanufacturer_preference desc"