我正在尝试为"每日交易"创建一个模块。获得ValueError
value = d[key] = self.method(*args, **kwargs) File "/home/odoo/odoo-dev/odoo/odoo/addons/base/ir/ir_model.py", line 1028, in xmlid_lookup raise ValueError('External ID not found in the system: %s' % xmlid) ParseError: "External ID not found in the system: daily_transaction.action_daily_transaction" while parsing /home/odoo/odoo-dev/custom-addons/daily_transaction/daily_transaction_view.xml:11, near <menuitem action="action_daily_transaction" id="menu_action_daily_transaction" parent="menu_daily_transaction_root" sequence="20"/>
我的文件结构:(一个是Bold是我的文件名)
__初始化__。PY
from import daily_transaction
__清单__。PY
{
'name':'Daily Transaction Manager',
'version':'1.0',
'description':'**********************This app will keep the record of all the tansactions happening*********',
'author':'Test',
'data':['daily_transaction_view.xml'],
'installable':True,
'auto_install':False,
}
daily_transaction.py
from . import fields,osv
class daily_transaction(osv.osv):
_name = 'daily.transaction'
_description = 'Daily Transaction'
_columns = {
'subject': fields.char('Subject', size=128, required = True),
'data' : fields.data('Date', required = True),
'note': fields.text('Notes'),
'amount': fields.float('Amount', required = True),
'type' : fields.selection([
('transport','Transport'),
('household','Household'),
('personal','Personal'),
],
'Type', required = True),
}
daily_transaction_view.xml
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- Main Menu Related Info -->
<menuitem name="Daily Transaction" id="base.daily_transaction_root" sequence="60"/>
<!-- Sub Menu Related Info -->
<menuitem id="menu_daily_transaction_root" name="Daily Transaction" parent="base.daily_transaction_root" sequence="1" />
<!-- Action Menu Related Info -->
<menuitem action="action_daily_transaction" id="menu_action_daily_transaction" parent="menu_daily_transaction_root" sequence="20"/>
<!--Daily Transaction List View-->
<record id="view_daily_transaction_tree" model="ir.ui.view"> <!-- here id is the external id for this tree view which must be unique and will be used for accessing this record -->
<field name="name">daily.transaction.tree</field> <!-- this will be our name of record in ir.ui.view -->
<field name="model">daily.transaction</field> <!-- this will map out tree view with our daily transaction model -->
<field name="arch" type="xml">
<!-- this will be our title of list/tree view -->
<tree string="Daily Transaction">
<!-- these will automatically map table headers for our list view, so we’ll select out column names of our model here -->
<field name="name"/>
<field name="date"/>
<field name="type"/>
<field name="amount"/>
</tree>
</field>
</record>
<!--Daily Transaction Form View-->
<record id="view_daily_transaction_form" model="ir.ui.view">
<field name="name">daily.transaction.form.view</field>
<field name="model">daily.transaction</field>
<field name="arch" type="xml">
<!-- this will be our title of list/tree view -->
<form string="Daily Transaction" version="7.0">
<group>
<field name="name"/>
<field name="date"/>
<field name="type"/>
<field name="amount"/>
<field name="note"/>
</group>
</form>
</field>
</record>
<record id="action_daily_transaction" model="ir.actions.act_window">
<field name="name">Daily Transaction</field> <!-- name of action -->
<field name="res_model">daily.transaction</field> <!-- this action will be mapped to model specified -->
<field name="view_type">form</field>
<field name="view_mode">tree,form</field> <!-- these are type of view our module will show for our daily transaction mode -->
<field name="search_view_id" eval="False"/> <!-- here we specify id of our search view -->
<field name="context">{}</field>
<field name="help">Create new daily transaction.</field> <!-- help text for our model -->
</record>
</data>
</odoo
答案 0 :(得分:5)
它提供此错误是因为您在创建之前使用了操作,因此首先您必须定义操作然后才能使用它。
所以你应该尝试如下:
<record id="action_daily_transaction" model="ir.actions.act_window">
<field name="name">Daily Transaction</field> <!-- name of action -->
<field name="res_model">daily.transaction</field> <!-- this action will be mapped to model specified -->
<field name="view_type">form</field>
<field name="view_mode">tree,form</field> <!-- these are type of view our module will show for our daily transaction mode -->
<field name="search_view_id" eval="False"/> <!-- here we specify id of our search view -->
<field name="context">{}</field>
<field name="help">Create new daily transaction.</field> <!-- help text for our model -->
</record>
<menuitem action="action_daily_transaction" id="menu_action_daily_transaction"
parent="menu_daily_transaction_root" sequence="20"/>