22.03.26
This commit is contained in:
@@ -537,7 +537,7 @@ class AssayImporter:
|
||||
pool = Pool()
|
||||
self.AssayLine = pool.get('assay.line')
|
||||
self.Element = pool.get('assay.element')
|
||||
self.Uom = pool.get('product.uom')
|
||||
self.Unit = pool.get('assay.unit')
|
||||
|
||||
# -----------------------------
|
||||
# PUBLIC ENTRYPOINT
|
||||
@@ -599,7 +599,7 @@ class AssayImporter:
|
||||
line.assay = assay
|
||||
line.element = self._get_or_create_element(item.get('element'))
|
||||
line.value = self._safe_float(item.get('value'))
|
||||
line.unit = self._get_uom(item.get('unit'))
|
||||
line.unit = self._get_unit(item.get('unit'))
|
||||
line.category = category
|
||||
|
||||
line.method = item.get('method')
|
||||
@@ -624,13 +624,13 @@ class AssayImporter:
|
||||
element.save()
|
||||
return element
|
||||
|
||||
def _get_uom(self, unit_name):
|
||||
def _get_unit(self, unit_name):
|
||||
if not unit_name:
|
||||
return None
|
||||
|
||||
uoms = self.Uom.search([('symbol', '=', unit_name)])
|
||||
if uoms:
|
||||
return uoms[0]
|
||||
units = self.Unit.search([('symbol', '=', unit_name)])
|
||||
if units:
|
||||
return units[0]
|
||||
|
||||
return None # ou lever une erreur selon ton besoin
|
||||
|
||||
@@ -660,7 +660,19 @@ class AssayImporter:
|
||||
return 'umpire'
|
||||
|
||||
return 'provisional'
|
||||
|
||||
|
||||
class AssayUnit(ModelSQL, ModelView):
|
||||
'Assay Unit'
|
||||
__name__ = 'assay.unit'
|
||||
|
||||
name = fields.Char('Name') # Percent, g/t, ppm
|
||||
symbol = fields.Char('Symbol') # %, g/t, ppm
|
||||
dimension = fields.Selection([
|
||||
('mass_fraction', 'Mass Fraction'),
|
||||
('grade', 'Grade'),
|
||||
('trace', 'Trace'),
|
||||
])
|
||||
|
||||
class Assay(ModelSQL, ModelView):
|
||||
"Assay"
|
||||
__name__ = 'assay.assay'
|
||||
@@ -701,7 +713,7 @@ class AssayLine(ModelSQL, ModelView):
|
||||
|
||||
value = fields.Float("Value")
|
||||
|
||||
unit = fields.Many2One('product.uom', "Unit")
|
||||
unit = fields.Many2One('assay.unit', "Unit")
|
||||
|
||||
category = fields.Selection([
|
||||
('assay', 'Assay'),
|
||||
|
||||
Reference in New Issue
Block a user