嗨,我是Odoo的新手,现在我有2个型号,如下所示:
class HumanResource(models.Model):
_name = 'hr.employee'
_inherit = 'hr.employee'
test = fields.Char('test')
# Profiling Details
food_ids = fields.One2many(
'hr.employee.food',
'food_id',
string='Food Cost'
)
class HrFood(models.Model):
_name = "hr.employee.food"
_description = "Employee Food"
# food_id = fields.Many2one('hr.employee', 'Food', default={'food_id': lambda self, cr, uid, context: context.get('food_id')})
food_id = fields.Many2one('hr.employee', string='Employee Name')
# foodtype = ?to?
food_name = fields.Char(
string='Food Name',
help='Please Enter the Food Name'
)
food_category = fields.Selection(
[('breakfast', 'Breakfast'),
('lunch', 'Lunch'),
('teatime', 'Tea Time'),
('dinner', 'Dinner'),
('supper', 'Supper')],
string='Category',
)
food_cost = fields.Float(
string='Food Amount',
digits=(5, 2)
)
然后我有查看文件:
<odoo>
<record id="view_form_hr_employee_food" model="ir.ui.view">
<field name="name">Create Food Cost</field>
<field name="model">hr.employee.food</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="food_id" />
<separator string="Reference" />
<field name="food_category" />
<field name="food_name" />
<field name="food_cost" />
</group>
</sheet>
</form>
</field>
</record>
</odoo>
我正在尝试覆盖由HrFood类自动生成的模式弹出框。
视图文件是我尝试过的,我也确实将视图添加到了清单 .py
这是界面,食品费用是一个单身字段enter image description here
这是我要覆盖enter image description here
的弹出模式框那我错过了什么? 请帮助我解决我的问题,我是Odoo的newbee。我的Odoo版本是Odoo 11,谢谢。
答案 0 :(得分:1)
有两个选项。
<field name="food_ids" context="{'form_view_ref': 'my_module.my_second_food_form_view'}" />
<field name="food_ids">
<form>
<!-- your form view here -->
</form>
<tree editable="bottom"> <!-- if you don't want it editable just delete the attribute -->
<!-- your tree view here -->
</tree>
</field>