gpt4 book ai didi

python - Odoo 9 模块至 V10

转载 作者:行者123 更新时间:2023-12-01 03:19:08 24 4
gpt4 key购买 nike

我有一个可以在 V9 中运行的版本 9 模块。我试图将其安装在 V10 中并收到错误。创建安全组时出现此错误。我还尝试从维护者工具迁移到 V10。

>    Replace openerp imports to odoo.
>
> Rename __openerp__.py to __manifest__.py
>
> Replace select = True by index = TrueReplace string selectors in XML by name (if possible) or other attribute selector or even another
> equivalent path/reference. For example, change <group string="x"
> position="after"> by <group name="x" position="after">Remove <data>
> and </data> in xml files if noupdate="0"
>
> Replace the <openerp>/</openerp> tags in xml files by <odoo>/</odoo>.
>
> Don't use @api.one with @api.onchange or it will crash.
>
> ...

错误如下

File "/home/jason/git/odoo10/odoo/addons/base/ir/ir_model.py", line 1028, in xmlid_lookup
raise ValueError('External ID not found in the system: %s' % xmlid)
ParseError: "<type 'exceptions.ValueError'>: "External ID not found in the system: base.group_sale_salesman_all_leads" while evaluating
"[(4,ref('base.group_user')), (4,ref('account.group_account_invoice')), (4,ref('stock.group_stock_user')), (4,ref('base.group_sale_salesman_all_leads'))]"" while parsing /home/jason/git/customaddons/layby_order/security/layby_security.xml:5, near
<record id="group_layby_user" model="res.groups">
<field name="name">Layby User</field>
<field name="category_id" ref="base.module_category_sales_management"/>
<field name="comment">This is applicable for Layby User.</field>
<field name="implied_ids" eval="[(4,ref('base.group_user')), (4,ref('account.group_account_invoice')), (4,ref('stock.group_stock_user')), (4,ref('base.group_sale_salesman_all_leads'))]"/>
</record>

layby_security.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<record id="group_layby_user" model="res.groups">
<field name="name">Layby User</field>
<field name="category_id" ref="base.module_category_sales_management"/>
<field name="comment">This is applicable for Layby User.</field>
<field name="implied_ids" eval="[(4,ref('base.group_user')),
(4,ref('account.group_account_invoice')),
(4,ref('stock.group_stock_user')),
(4,ref('base.group_sale_salesman_all_leads'))]"/>
</record>

</data>
</openerp>

ir.model.access.csv

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_layby_order,layby.order,model_layby_order,group_layby_user,1,1,1,0
access_layby_order_line,layby.order.line,model_layby_order_line,group_layby_user,1,1,1,1

如果我停止服务器并再次启动它,然后尝试安装,我得到的第一个错误是

    File "/home/jason/git/customaddons/layby_order/layby.py", line 147
date_order = fields.Date.context_today(self)
SyntaxError: invalid syntax

之后,如果我安装,我会收到解析错误“外部 ID 未找到”。我想我得到这个的原因是因为安装在第 147 行停止 date_order = fields.Date.context_today(self) 但我不知道为什么。

已更新

仍然停在147号线

date_order = fields.Date.context_today(self))

更改为 sales_team.group_sale_salesman_all_leads

原来的错误消失了,但现在得到了

raise Exception(_('Module loading %s failed: file %s could not be processed:\n %s') % (module, fname, warning_msg))
Exception: Module loading layby_order failed: file layby_order/security/ir.model.access.csv could not be processed:
No matching record found for external id 'model_layby_order' in field 'Object'
Missing required value for the field 'Object' (model_id)
No matching record found for external id 'model_layby_order_line' in field 'Object'
Missing required value for the field 'Object' (model_id)

最佳答案

OCA 的将模块从 v9 迁移到 v10 的指南基本上足够了,只是它没有提到以前以 base 为前缀的几个安全组。已被移动/模块化到各自的模块,例如 base.group_hr_user正如您在案例中所看到的,base.group_sale_salesman_all_leads .

要解决您的第一个问题,请更改您的引用号 base.group_sale_salesman_all_leadssales_team.group_sale_salesman_all_leadslayby_security.xml :

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<record id="group_layby_user" model="res.groups">
<field name="name">Layby User</field>
<field name="category_id" ref="base.module_category_sales_management"/>
<field name="comment">This is applicable for Layby User</field>
<field name="implied_ids" eval="[(4,ref('base.group_user')),
(4,ref('account.group_account_invoice')),
(4,ref('stock.group_stock_user')),
(4,ref('sales_team.group_sale_salesman_all_leads'))]"/>
</record>

</data>
</openerp>

对于您的第二期,如果 date_order是您要添加到类中的字段,请执行以下操作:

date_order = fields.Date(default=fields.Date.context_today)

否则,如果您实际上声明的是变量而不是新字段,则您的语法看起来没问题,并且 Odoo 10 仍在使用 fields.Date.context_today() .

您可以look it up on github .

<小时/>

编辑:(问题更新后)

该错误可能是因为您在 res.groups 中缺少模型声明。记录。

您可以尝试添加 <field name="model_id" ref="model_layby_order"/>在layby_security.xml 中?

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<record id="group_layby_user" model="res.groups">
<field name="name">Layby User</field>
<field name="model_id" ref="model_layby_order"/>
<field name="category_id" ref="base.module_category_sales_management"/>
<field name="comment">This is applicable for Layby User</field>
<field name="implied_ids" eval="[(4,ref('base.group_user')),
(4,ref('account.group_account_invoice')),
(4,ref('stock.group_stock_user')),
(4,ref('sales_team.group_sale_salesman_all_leads'))]"/>
</record>

</data>
</openerp>

关于python - Odoo 9 模块至 V10,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42124597/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com