Odoo Help

2

1
2 Answers
1
Avatar

Muhammad Anees Saudi Arabia

--Muhammad Anees--

7218
| 7 3 9
Riyadh, Saudi Arabia
--Muhammad Anees--

Odoo, Dynamics AX and Web Developer.

Muhammad Anees Saudi Arabia
7/23/19, 6:13 AM

Here I got it working..

class HrLeave(models.Model):
    _inherit = 'hr.leave'
 @api.multi
def action_confirm(self): record = super(HrLeave, self).action_confirm() if self.message_main_attachment_id.id is False and self.holiday_status_id.time_type == 'full_day_training': raise ValidationError("Please attach document for leave type: %s" % self.holiday_status_id.name) return record ​

Can we use record to get fields like record['message_main_attachment_id.id'] or record['name']?

But with self it ok.

1 Comment
Subramanyam.V India
7/23/19, 8:24 AM

Technically the same is answered below

1
Avatar

paulo Japan

--paulo--

6909
| 6 2 5
Japan
--paulo--

Odoo developer

paulo Japan
7/23/19, 5:33 AM

Hi,

   You can raise an exception if an attachment field is not set while validating,try the code below

if not attachment_field:
raise exceptions.UserError(_("Please add attachment"))

     you can override the create method or any other method and check this     

Ask a Question
Writer
Keep Informed
1 follower(s)
About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now