1

我有一个适用于 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 错误 External ID not found。我在想我得到这个的原因是因为安装在第 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)
4

1 回答 1

2

baseOCA 将模块从 v9 迁移到 v10 的指南基本上就足够了,除了它没有提到过去base.group_hr_userbase.group_sale_salesman_all_leads.

要解决您的第一个问题,请将您的 ref 更改base.group_sale_salesman_all_leadssales_team.group_sale_salesman_all_leadsin 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>

对于您的第二个问题,如果date_order是您要添加到班级的字段,请改为执行以下操作:

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

否则,如果您实际上是在声明一个变量而不是一个新字段,那么您的语法看起来还可以,并且 Odoo 10 仍在使用fields.Date.context_today().

你可以在 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>
于 2017-02-08T22:39:39.920 回答