Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată

Is there a way to block the edition of quality checks once they have been filled?


We use quality controls using both spreadsheets and worksheets. 

We would like to block them after the information has been filled, to avoid any type of changes.

Is there a way to do this?

Imagine profil
Abandonează
Cel mai bun răspuns

Hi,

By default in Odoo Quality, a quality.check record stays editable even after it has a result (Pass/Fail) or worksheet data. Odoo doesn’t automatically lock them. 

3 ways:

1. Security Group:

You can create a record rule that prevents write access on quality.check once certain conditions are met.

Example condition: only allow editing if quality_state = 'none' (not yet processed).

<record id="rule_quality_check_no_edit_done" model="ir.rule">

    <field name="name">No edit on done quality checks</field>

    <field name="model_id" ref="quality_control.model_quality_check"/>

    <field name="groups" eval="[(4, ref('quality_control.group_quality_user'))]"/>

    <field name="domain_force">[('quality_state', '!=', 'none')]</field>

    <field name="perm_read" eval="True"/>

    <field name="perm_write" eval="False"/>

    <field name="perm_create" eval="True"/>

    <field name="perm_unlink" eval="False"/>

</record>


Or

2. Python Code

Override the write method in a custom module, and raise an error if someone tries to edit a filled check:

from odoo import models, exceptions, _


class QualityCheck(models.Model):

    _inherit = "quality.check"


    def write(self, vals):

        for rec in self:

            if rec.quality_state != 'none':  # already processed

                raise exceptions.UserError(

                    _("You cannot modify a quality check once it has been filled.")

                )

        return super().write(vals)


Or

3. View Customization

You can make the form view read-only once filled by using a domain in Readonly:

<field name="quality_state" readonly="quality_state != 'none'"/>



Hope it helps.

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
0
aug. 25
551
2
feb. 25
53
0
oct. 23
1633
2
dec. 19
5516
0
mar. 15
4848