Odoo 9模块到V10

时间:2017-02-08 22:10:52

标签: python python-2.7 openerp odoo-10

我有一个适用于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

之后,如果我安装,我得到Parse错误外部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)

1 个答案:

答案 0 :(得分:2)

OCA将模块从v9迁移到v10的指南大多已经足够了,除了它没有提到曾经被var loadJS = function(url, implementationCode){//url, url_Next //url is URL of external file, implementationCode is the code //to be called from the file, location is the location to //insert the <script> element var scriptTag = document.createElement('script');//will add scriptTag_Next scriptTag.type = 'text/javascript'; scriptTag.setAttribute('nonce','22os9h3sdfa'); scriptTag.src = url; scriptTag.onload = implementationCode;//Will It be work? -> scriptTag.onload = scriptTag_Next = implementationCode; scriptTag.onreadystatechange = implementationCode;//like as above scriptTag_Next.onreadystatechange ?? document.body.appendChild(scriptTag); }; var yourCodeToBeCalled = function(){ console.log('okay'); } loadJS('js/jquery-3_1_1.min.js', yourCodeToBeCalled);//My my suggestion loadJS('js/jquery-3_1_1.min.js', 'js/test.js' yourCodeToBeCalled) 作为前缀的几个安全组已被移动/模块化到它们各自的模块,例如{ {1}}正如您在案例中看到的那样base

要解决您的第一个问题,请在base.group_hr_user中将您的参考base.group_sale_salesman_all_leads更改为base.group_sale_salesman_all_leads

sales_team.group_sale_salesman_all_leads

对于您的第二个问题,如果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('sales_team.group_sale_salesman_all_leads'))]"/>
    </record>

</data>
</openerp>

否则,如果您实际上声明了一个变量而不是一个新字段,那么您的语法看起来没问题,Odoo 10仍在使用date_order

你可以look it up on github

编辑:(问题更新后)

错误可能是因为您遗漏了date_order = fields.Date(default=fields.Date.context_today) 记录中的模型声明。

您可以尝试在layby_security.xml中添加fields.Date.context_today()吗?

res.groups