Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
7 ตอบกลับ
11364 มุมมอง

Hello,

I want to update odoo default rule (portal rule), but the update seems never works

So, the rule I want to update is:

.....

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

    <field name="name">Portal Sales Orders Line</field>

    <field name="model_id" ref="sale.model_sale_order_line"/>

    <field name="domain_force">[('order_id.message_follower_ids','child_of',[user.commercial_partner_id.id])]</field>

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

</record>

....


and in my custom module:

<data noupdate="0">

     <record id="portal_sale.portal_sale_order_line_rule" model="ir.rule">

         <field name="domain_force">['|',

             ('order_id.partner_id','child_of',[user.commercial_partner_id.id]),

             ('order_id.message_follower_ids','child_of',[user.commercial_partner_id.id])

        ]</field>

    </record>

<data>


On default rules, it's defined as <data noupdate="1">

That modification works when install the custom modules on a new db, but it's doesn't works when updating existing db.  


 Thank you

 

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Try to use record attribute

forcecreate="True"

for example:

<record forcecreate=True id="portal_sale.portal_sale_order_line_rule" model="ir.rule">


Example:

 <record forcecreate="True" model="ir.rule" id="sale.sale_order_comp_rule">
    <field name="name">Sales Order multi-company TEST</field>
    <field name="model_id" ref="sale.model_sale_order"/>
    <field name="global" eval="True"/>
    <field name="domain_force">['|',('company_id','=','TEST'),('company_id','child_of',[user.company_id.id])]</field>
</record>



อวตาร
ละทิ้ง
ผู้เขียน

Hi Zbik, thanks for the answer :) I've also tried that attribute, nothing happen. I've delete those rules and then updating the modules (both module, portal_sale and my custom module), the update re-create those rules, but the modification does nothing (I mean, there is no impact of the modification expected)

Answer updated. Example works without any problem in my system.

ผู้เขียน

hi Zbik, with your example, is it works when you change the 'domain_force' value and then update odoo server?

In example domain_force is changed (see string 'TEST'). Yes, this works when I update my custom module. Your 'depends' are set correctly?

ผู้เขียน คำตอบที่ดีที่สุด

I think, I found the solution (someone already posted the same problem)

https://www.odoo.com/forum/help-1/question/how-can-i-update-a-record-stored-with-the-attribute-noupdate-1-78133


Thank you zbik for your answer :)

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

The first answer in this web page works well for me:

https://stackoverflow.com/questions/38995280/in-odoo-how-to-force-overwriting-of-a-record-rule-which-is-defined-in-a-base-mod

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
พ.ค. 24
30868
1
ม.ค. 23
2526
3
ส.ค. 20
5115
0
ก.พ. 18
2669
0
เม.ย. 16
4344