跳至內容
選單
此問題已被標幟
1 回覆
320 瀏覽次數

Hy i have this error when I want to install this module odoo_rental_sales

Erreur lors de l'importation du module 'odoo_rental_sales'. while parsing /tmp/tmpodmobodx/odoo_rental_sales/security/rental_order_contract_security.xml:5, somewhere inside <record id="rental_order_contract_rule_company" model="ir.rule"> <field name="name">Rental Order Contract Multi-Company</field> <field name="model_id" ref="model_rental_order_contract"/> <field name="domain_force">[('company_id', 'in', company_ids)]</field> </record>

thx for your help

頭像
捨棄
作者

I m running odoo on runtipi. the code seems different


最佳答案

The error indicates an issue with the security rule in rental_order_contract_security.xml . Specifically, the problem is with this line:

xml

Copy Edit

< field name = "domain_force" > [('company_id', 'in', company_ids)] </ field >

Possible Causes & Solutions:

1. company_ids is Undefined

Odoo does not recognize company_ids in the domain. Try replacing it with the correct Odoo environment variable:

Fix: Replace:

xml

Copy Edit

< field name = "domain_force" > [('company_id', 'in', company_ids)] </ field >

With:

xml

Copy Edit

< field name = "domain_force" > [('company_id', '=', user.company_id.id)] </ field >

Or, if multi-company is needed:

xml

Copy Edit

< field name = "domain_force" > [('company_id', 'in', user.company_ids.ids)] </ field >

2. Incorrect Model Reference ( model_rental_order_contract )

Ensure that model_rental_order_contract is correctly defined in ir.model . To check this, go to Odoo shell:

python

Copy Edit

env[ 'ir.model' ].search([( 'model' , '=' , 'rental.order.contract' )])

If this returns an empty list, the model is missing or not properly defined.

3. Security Rule Placement Issue

Check if the security rule is loaded at the correct stage. If the model is defined in another module, ensure that the dependency is included in __manifest__.py :

python

Copy Edit

'depends' : [ 'base' , 'sale' , 'your_module_name' ],

4. Restart and Upgrade

After fixing the XML file, restart Odoo and update the module:

sh

Copy Edit

sudo service odoo restart odoo -u odoo_rental_sales

頭像
捨棄