关于基于父域ODOO 13的儿童领域的更改
我有一个项目预算模型(project.budget)。每个项目预算都有许多行,这意味着我有一个模型(project.budget.line)。我已经在发票模型(account.move)中添加了许多2ONE字段:buckit_ID此字段是指项目预算模型,我还为发票线模型(account.move.line)添加了一个许多2ONE字段,该字段是:buffict_line字段是指项目预算线模型。当我使用帐户移动中的预算ID选择预算ID时,我想要的是,使用“变更”中的预算线,这意味着仅返回属于项目预算的线路,但是这里什么都没有发生的是我的代码:
class CustomAccountingMove(models.Model):
_inherit = 'account.move'
budget_id = fields.Many2one('project.budget', string='Project Bugdet')
@api.onchange('budget_id')
def onchange_budget_id(self):
for rec in self:
return {'domain': {'invoice_line_ids.budget_line': [
('id',
'in',
rec.mapped('budget_id.budget_line_ids.id')
)]
}
}
class CustomAccountingMoveline(models.Model):
_inherit = 'account.move.line'
budget_line = fields.Many2one('project.budget.line', string='Budget Line')
I have a project budget model(project.budget). each project budget has many lines, meaning I have a model (project.budget.line). I have added a many2one field to the invoice model(account.move): budget_id this field refers to the project budget model, and I also added a many2one field to the invoice lines model (account.move.line) which is: budget_line this field refers to the project budget line model. what I want when I select a budget using budget id in the account move filter the budget line in the account move line using on change meaning returning only the lines that belong to the project budget, but nothing is happening here is my code:
class CustomAccountingMove(models.Model):
_inherit = 'account.move'
budget_id = fields.Many2one('project.budget', string='Project Bugdet')
@api.onchange('budget_id')
def onchange_budget_id(self):
for rec in self:
return {'domain': {'invoice_line_ids.budget_line': [
('id',
'in',
rec.mapped('budget_id.budget_line_ids.id')
)]
}
}
class CustomAccountingMoveline(models.Model):
_inherit = 'account.move.line'
budget_line = fields.Many2one('project.budget.line', string='Budget Line')
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在视图中设置域并使用
parent
以获取bucced_id
:forgik_id_id
在左侧是buceb> bucced_light_line_ids中使用的倒数名称
You can set the domain in view and use
parent
to get thebudget_id
:budget_id
on the left is the inverse name used inbudget_line_ids