main #7
@@ -537,7 +537,7 @@ class AssayImporter:
|
|||||||
pool = Pool()
|
pool = Pool()
|
||||||
self.AssayLine = pool.get('assay.line')
|
self.AssayLine = pool.get('assay.line')
|
||||||
self.Element = pool.get('assay.element')
|
self.Element = pool.get('assay.element')
|
||||||
self.Uom = pool.get('product.uom')
|
self.Unit = pool.get('assay.unit')
|
||||||
|
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
# PUBLIC ENTRYPOINT
|
# PUBLIC ENTRYPOINT
|
||||||
@@ -599,7 +599,7 @@ class AssayImporter:
|
|||||||
line.assay = assay
|
line.assay = assay
|
||||||
line.element = self._get_or_create_element(item.get('element'))
|
line.element = self._get_or_create_element(item.get('element'))
|
||||||
line.value = self._safe_float(item.get('value'))
|
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.category = category
|
||||||
|
|
||||||
line.method = item.get('method')
|
line.method = item.get('method')
|
||||||
@@ -624,13 +624,13 @@ class AssayImporter:
|
|||||||
element.save()
|
element.save()
|
||||||
return element
|
return element
|
||||||
|
|
||||||
def _get_uom(self, unit_name):
|
def _get_unit(self, unit_name):
|
||||||
if not unit_name:
|
if not unit_name:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
uoms = self.Uom.search([('symbol', '=', unit_name)])
|
units = self.Unit.search([('symbol', '=', unit_name)])
|
||||||
if uoms:
|
if units:
|
||||||
return uoms[0]
|
return units[0]
|
||||||
|
|
||||||
return None # ou lever une erreur selon ton besoin
|
return None # ou lever une erreur selon ton besoin
|
||||||
|
|
||||||
@@ -661,6 +661,18 @@ class AssayImporter:
|
|||||||
|
|
||||||
return 'provisional'
|
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):
|
class Assay(ModelSQL, ModelView):
|
||||||
"Assay"
|
"Assay"
|
||||||
__name__ = 'assay.assay'
|
__name__ = 'assay.assay'
|
||||||
@@ -701,7 +713,7 @@ class AssayLine(ModelSQL, ModelView):
|
|||||||
|
|
||||||
value = fields.Float("Value")
|
value = fields.Float("Value")
|
||||||
|
|
||||||
unit = fields.Many2One('product.uom', "Unit")
|
unit = fields.Many2One('assay.unit', "Unit")
|
||||||
|
|
||||||
category = fields.Selection([
|
category = fields.Selection([
|
||||||
('assay', 'Assay'),
|
('assay', 'Assay'),
|
||||||
|
|||||||
Reference in New Issue
Block a user