下面是一些在Odoo中使用`active_id`的常见用法: 1.在Python代码中使用`active_id`: ```python class MyClass(models.TransientModel): _name = 'my.module.wizard' def my_function(self): active_id = self.env.context.get('active_id') record = self.env['my.module'].browse(active_id) #现在你...
active_id:带有表单活跃记录或表中第一条记录的 ID active_ids:带有一个列表中活跃记录的列表(如果是表单则只有一个元素) active_domain:如果在表单视图中触发了该操作 本例中,active_ids中保存任务列表中所选记录的 ID,可使用这些 ID 作为向导task_ids字段的默认值,相关代码如下(izard/checkout_mass_message....
company_id和company_ids上下文值自Odoo 13可在记录规则运算中使用,此前的版本使用的user.company_id.id不推荐再使用。例如,此前常用的['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]现在应写为[('company_id', 'in', company_ids)]。 对多字段的搜...
id : 所以,它可以为footnotes, unfolding,提供参考,同时如果有动作, active_id 也需要在这里定义. name : 需要显示的名称 type : 行的类型. 这里定义鼠标点击时,对此行的动作。(行所支持的类型,包含:account_id, line, tax_id, unreconciled_aml,bank_statement_id, partner_id, move_line_id, too_many,...
active=fields.Boolean(default=True, string=u'是否归档') 8.Integer: 整型 sequence =fields.Integer(string=u'排序', default=10) 9.Binary: 存储为二进制文件 files=fields.Binary(u'文件',filters='*.xlsx', required=True) 10.Float: 浮点型 amount = fields.Float(string=u'总计') 11.Monetary: 与...
如果一个视图通过id请求,如果它的mode不是primary,将匹配离它最近的mode为primary的父级 视图解析 解析为请求/匹配的primary视图生成最终的arch: 如果视图有父级,而父级被完全解析,然后当前视图继承的规范才会被应用 如果视图没有父级,它的arch会按原样使用 ...
name="res_model">rating.rating</field> <field name="view_mode">kanban,pivot,graph</field> <field name="domain">[('res_model', '=', 'your.model'), ('res_id', '=', active_id), ('consumed', '=', True)]</field> </record> <record id="your_model_view_form_inhe...
if self.context.get('active_model') == 'res.partner': return self.context.get('active_id', False) 1. 2. 3. 向导和代码复用 步骤2,我们可以移除for循环。并假设len(self)为1,我们可添加self.ensure_one()方法。 def add_book_rents(self): ...
在上一个视图中点击链接或按钮打开表单时,一个active_id键会被加入上下文,它带有原表单我们所在位置记录的 id。以列表视图为例,active_ids上下文键中包含上一个列表中所选择的记录 id 列表。 在客户端中,上下文可用于使用default_或default_search_前缀在目录视图上设置默认值或启动默认过滤器。举例如下: ...
div><group><field name="tag_ids" context="{'default_category_id': active_id}"><tree string="Tags" editable="bottom"><field name="sequence" widget="handle"/><field name="name"/><field name="color" widget="color_picker"/></tree></field></group></sheet></field></record> 练习-...