コンテンツへスキップ
メニュー
この質問にフラグが付けられました

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?

アバター
破棄
最善の回答

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.

アバター
破棄
関連投稿 返信 ビュー 活動
0
8月 25
553
2
2月 25
53
0
10月 23
1634
2
12月 19
5519
0
3月 15
4848