Merge branch 'master-recurring-fatemi' into 'master'

[IMP]:Changed error msg and updated Recurring Source

See merge request flectra-hq/flectra!127
This commit is contained in:
Parthiv Patel 2018-08-07 09:05:56 +00:00
commit ed24f4624c

View File

@ -84,7 +84,7 @@ class Recurring(models.Model):
record.doc_source.partner_id != record.partner_id: record.doc_source.partner_id != record.partner_id:
raise ValidationError(_( raise ValidationError(_(
'Error! Source Document should be related to partner %s' % 'Error! Source Document should be related to partner %s' %
record.partner_id.name)) record.doc_source.partner_id.name))
name = fields.Char(string='Name') name = fields.Char(string='Name')
active = fields.Boolean( active = fields.Boolean(
@ -172,8 +172,8 @@ class Recurring(models.Model):
'interval_type': recurring.interval_type, 'interval_type': recurring.interval_type,
'numbercall': recurring.exec_init, 'numbercall': recurring.exec_init,
'nextcall': recurring.date_init, 'nextcall': recurring.date_init,
'model_id': self.env['ir.model'].search([('model', '=', 'model_id': self.env['ir.model'].search(
model)]).id, [('model', '=', model)]).id,
'priority': 6, 'priority': 6,
'user_id': recurring.user_id.id, 'user_id': recurring.user_id.id,
'state': 'code', 'state': 'code',
@ -184,11 +184,12 @@ class Recurring(models.Model):
@api.multi @api.multi
def set_recurring_id(self): def set_recurring_id(self):
if self.doc_source and 'recurring_id' \ if self.doc_source and 'recurring_id' and 'rec_source_id' in \
in self.env[self.doc_source._name]._fields: self.env[self.doc_source._name]._fields:
rec_id = self.env[self.doc_source._name].browse(self.doc_source.id) rec_id = self.env[self.doc_source._name].browse(self.doc_source.id)
if not rec_id.recurring_id: if not rec_id.recurring_id and not rec_id.rec_source_id:
rec_id.recurring_id = self.id rec_id.recurring_id = self.id
rec_id.rec_source_id = self.doc_source.id
else: else:
raise ValidationError( raise ValidationError(
_('Document is already recurring')) _('Document is already recurring'))