Я хочу скрыть кнопку редактирования при оплате состояния счета, как на изображении ниже.
И я унаследовал invoice_form и добавил соответствующий атрибут.
<record id="invoice_form_inherit" model="ir.ui.view">
<field name="name">invoice.form.inherit</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<xpath expt='//form[@string="Invoice"]' possition='attributes'>
<!-- Frist intent : nothing happened -->
<attribute name="edit" attrs="{'invisible:[('state','=','paid')]'}"/>
<!-- Second intent : edit, always hide -->
<attribute name="edit" attrs="{'invisible:[('state','=','paid')]'}">false</field>
<!-- Thirds intent : edit, never hide -->
<attribute name="edit" attrs="{'invisible:[('state','=','paid')]'}">true</field>
</field>
Пожалуйста, помогите мне, что не так? Спасибо!!
ИЗМЕНИТЬ
Следуя рекомендациям @Sathiyan, я создал файл /security/invoice_security.xml
и добавил в свой __opnenerp__.py
, внутри я добавил следующие строки:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record id="rule_no_edit_invoice_paid" model="ir.rule">
<field name="name">rule.no.edit.invoice.paid</field>
<field name="model_id" ref="account.model_account_invoice"/>
<field name="group" eval="[(4,ref('account.group_account_invoice'))]"/>
<field name="domain_force">[('state','=','paid')]</field>
<field eval="1" name="perm_read"/>
<!--
<field eval="0" name="perm_create"/>
<field eval="0" name="perm_write"/>
<field eval="0" name="perm_unlink"/>
-->
</record>
</data>
</openerp>
Когда я поставил noupdate="1"
, я создал новую базу данных и установил ее туда, но ничего не произошло! Вы можете сказать мне, что я делаю не так? пожалуйста.