def generate_descriptions(self):
        self.ensure_one()
        child = self.child_id
        if not child:
            raise exceptions.Warning(
                'ObjectError',
                _('No valid child id given !'))
        case_study = child.case_study_ids[0]

        self.write({
            'desc_fr': Child_description_fr.gen_fr_translation(
                child, case_study),
            'desc_de': Child_description_de.gen_de_translation(
                child, case_study),
            'desc_en': Child_description_en.gen_en_translation(
                child, case_study),
            'desc_it': Child_description_it.gen_it_translation(
                child, case_study),
        })

        return {
            'name': _('Descriptions generation'),
            'type': 'ir.actions.act_window',
            'res_model': self._name,
            'view_mode': 'form',
            'view_type': 'form',
            'target': 'new',
        }
    def generate_descriptions(self, cr, uid, ids, context=None):
        child_obj = self.pool.get('compassion.child')
        child = child_obj.browse(cr, uid, context.get('child_id'), context)
        if not child:
            raise orm.except_orm('ObjectError', _('No valid child id given !'))
        if isinstance(child, list):
            child = child[0]
        case_study = child.case_study_ids[-1]
        self.write(cr, uid, ids, {
            'state': 'descriptions',
            'desc_fr': Child_description_fr.gen_fr_translation(
                cr, uid, child, case_study, context),
            'desc_de': Child_description_de.gen_de_translation(
                cr, uid, child, case_study, context),
            'desc_en': Child_description_en.gen_en_translation(
                cr, uid, child, case_study, context),
            'desc_it': Child_description_it.gen_it_translation(
                cr, uid, child, case_study, context),
            }, context)

        return {
            'name': _('Descriptions generation'),
            'type': 'ir.actions.act_window',
            'res_model': self._name,
            'view_mode': 'form',
            'view_type': 'form',
            'res_id': ids[0],
            'context': context,
            'target': 'new',
            }
    def generate_descriptions(self, cr, uid, ids, context=None):
        wizard = self.browse(cr, uid, ids[0], context)
        child = wizard.child_id
        if not child:
            raise orm.except_orm('ObjectError', _('No valid child id given !'))
        case_study = child.case_study_ids[0]

        self.write(cr, uid, ids, {
            'desc_fr': Child_description_fr.gen_fr_translation(
                cr, uid, child, case_study, context),
            'desc_de': Child_description_de.gen_de_translation(
                cr, uid, child, case_study, context),
            'desc_en': Child_description_en.gen_en_translation(
                cr, uid, child, case_study, context),
            'desc_it': Child_description_it.gen_it_translation(
                cr, uid, child, case_study, context),
        }, context)

        return {
            'name': _('Descriptions generation'),
            'type': 'ir.actions.act_window',
            'res_model': self._name,
            'view_mode': 'auto_description_form',
            'view_type': 'form',
            'context': context,
            'target': 'new',
        }
 def _get_desc(self, lang):
     child = self.env['compassion.child'].browse(
         self.env.context.get('child_id'))
     case_study = child.case_study_ids[0]
     res = False
     if lang == 'fr':
         res = Child_description_fr.gen_fr_translation(
             child, case_study)
     elif lang == 'de':
         res = Child_description_de.gen_de_translation(
             child, case_study)
     elif lang == 'it':
         res = Child_description_it.gen_it_translation(
             child, case_study)
     elif lang == 'en':
         res = Child_description_en.gen_en_translation(
             child, case_study)
     return res + '\n\n'     # Fix for displaying the textfield
 def _get_desc(self, cr, uid, lang, context):
     child = self.pool.get('compassion.child').browse(
         cr, uid, context.get('child_id'), context)
     case_study = child.case_study_ids[0]
     res = False
     if lang == 'fr':
         res = Child_description_fr.gen_fr_translation(
             cr, uid, child, case_study, context)
     elif lang == 'de':
         res = Child_description_de.gen_de_translation(
             cr, uid, child, case_study, context)
     elif lang == 'it':
         res = Child_description_it.gen_it_translation(
             cr, uid, child, case_study, context)
     elif lang == 'en':
         res = Child_description_en.gen_en_translation(
             cr, uid, child, case_study, context)
     return res + '\n\n'     # Fix for displaying the textfield
    def generate_descriptions(self, cr, uid, ids, context=None):
        child_obj = self.pool.get('compassion.child')
        child = child_obj.browse(cr, uid, context.get('child_id'), context)
        if not child:
            raise orm.except_orm('ObjectError', _('No valid child id given !'))
        if isinstance(child, list):
            child = child[0]
        case_study = child.case_study_ids[-1]
        self.write(
            cr, uid, ids, {
                'state':
                'descriptions',
                'desc_fr':
                Child_description_fr.gen_fr_translation(
                    cr, uid, child, case_study, context),
                'desc_de':
                Child_description_de.gen_de_translation(
                    cr, uid, child, case_study, context),
                'desc_en':
                Child_description_en.gen_en_translation(
                    cr, uid, child, case_study, context),
                'desc_it':
                Child_description_it.gen_it_translation(
                    cr, uid, child, case_study, context),
            }, context)

        return {
            'name': _('Descriptions generation'),
            'type': 'ir.actions.act_window',
            'res_model': self._name,
            'view_mode': 'form',
            'view_type': 'form',
            'res_id': ids[0],
            'context': context,
            'target': 'new',
        }