Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2 Vastaukset
7616 Näkymät

Below code doesn't Work:

py:

is_other_attachment = fields.Boolean(string='Other Attachment',default=False)​
other_attachment = fields.Many2many(comodel_name="ir.attachment",
relation="m2m_ir_attachment_rel",
column1="m2m_id",
column2="attachment_id",
string="Other Attachment")


xml:

<field name="is_other_attachment"/>
<field name="other_attachment" widget="many2many_binary" attrs="{'required':[('is_other_attachment', '=', True)]}"/>
Avatar
Hylkää
Paras vastaus

Hello Yezeed,

If you are wanna use specific condition on ir.attachment object my suggestion is use @api.constrains for that field.

Like here we set mandatory to add attachment based on state,

@api.one
@api.constrains('other_attachment', 'state')
def check_ir_attachment(self):
    for rec in self:
        if rec.state == 'confirm':
            raise ValidationError("Please upload document for this record to move to '%s' stage." % rec.state)

This can help you a lot.(Y)

Thank you.

Hiren Dangar. 

Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
4
jouluk. 22
4512
4
maalisk. 21
10731
2
marrask. 21
7556
1
huhtik. 20
6806
2
tammik. 20
4891