Skip to content
Snippets Groups Projects

11.0

Merged Felipe Carlini requested to merge 11.0 into 11.0-stage
1 file
+ 24
22
Compare changes
  • Side-by-side
  • Inline
+ 24
22
@@ -73,33 +73,35 @@ class PurchaseOrder(models.Model):
res = super(PurchaseOrder, self).create(values)
return res
@api.constrains('mo_uom')
def mo_uom_validate(self):
@api.constrains('economic_level')
def economic_level_validate(self):
for rec in self:
mo_uom = rec.mo_uom
if len(mo_uom) == 0:
continue
if len(mo_uom) == 6 and mo_uom.isdigit() and int(mo_uom[0:2]) <= 12:
rec.mo_uom = mo_uom[0:2] + '/' + mo_uom[2:]
continue
if len(mo_uom) == 7 and (mo_uom[0:2] + mo_uom[3:]).isdigit() and int(mo_uom[0:2]) <= 12 and \
mo_uom[2] == '/':
continue
raise ValidationError(_('Check the format of the %s field it must be MM/YYYY') % 'MO UOM')
if rec.is_opened and rec.economic_level:
economic_level = rec.economic_level
if len(economic_level) == 0:
continue
if len(economic_level) == 6 and economic_level.isdigit() and int(economic_level[0:2]) <= 12:
rec.economic_level = economic_level[0:2] + '/' + economic_level[2:]
continue
if len(economic_level) == 7 and (economic_level[0:2] + economic_level[3:]).isdigit() and int(economic_level[0:2]) <= 12 and \
economic_level[2] == '/':
continue
raise ValidationError(_('Check the format of the %s field it must be MM/YYYY') % 'economic level')
@api.constrains('effectiveness')
def effectiveness_validate(self):
for rec in self:
effectiveness = rec.effectiveness
if len(effectiveness) == 0:
continue
if len(effectiveness) == 6 and effectiveness.isdigit() and int(effectiveness[0:2]) <= 12:
rec.effectiveness = effectiveness[0:2] + '/' + effectiveness[2:]
continue
if len(effectiveness) == 7 and (effectiveness[0:2] + effectiveness[3:]).isdigit() and \
int(effectiveness[0:2]) <= 12 and effectiveness[2] == '/':
continue
raise ValidationError(_('Check the format of the %s field it must be MM/YYYY') % (_('effectiveness')))
if rec.is_opened and rec.effectiveness:
effectiveness = rec.effectiveness
if len(effectiveness) == 0:
continue
if len(effectiveness) == 6 and effectiveness.isdigit() and int(effectiveness[0:2]) <= 12:
rec.effectiveness = effectiveness[0:2] + '/' + effectiveness[2:]
continue
if len(effectiveness) == 7 and (effectiveness[0:2] + effectiveness[3:]).isdigit() and \
int(effectiveness[0:2]) <= 12 and effectiveness[2] == '/':
continue
raise ValidationError(_('Check the format of the %s field it must be MM/YYYY') % (_('effectiveness')))
class ProcurementGroup(models.Model):
_inherit = "procurement.group"
Loading