Replace m2o to selection field

This commit is contained in:
Raimon Esteve 2022-05-03 11:28:21 +02:00
parent 6642fa1233
commit 87a8e4f0f5
1 changed files with 10 additions and 1 deletions

View File

@ -13,7 +13,7 @@ class WineAgingHistory(ModelSQL, ModelView):
readonly=True)
product = fields.Many2One('product.product', "Product", required=True,
readonly=True)
material = fields.Many2One('stock.location.material', "Material",
material = fields.Selection('get_materials', "Material",
readonly=True)
date_start = fields.Date("Date Start", required=True, readonly=True)
date_end = fields.Date("Date End", readonly=True,
@ -27,6 +27,15 @@ class WineAgingHistory(ModelSQL, ModelView):
duration = fields.Function(fields.Integer("Duration"),
'get_duration')
@classmethod
def get_materials(field_name):
pool = Pool()
LocationMaterial = pool.get('stock.location.material')
materials = [(None, "")]
for material in LocationMaterial.search([]):
materials.append((material.name, material.name))
return materials
@classmethod
def get_duration(cls, records, name):
res = dict((x.id, None) for x in records)