关于基于父域ODOO 13的儿童领域的更改

发布于 2025-02-13 03:27:01 字数 892 浏览 0 评论 0原文

我有一个项目预算模型(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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

っ〆星空下的拥抱 2025-02-20 03:27:01

您可以在视图中设置域并使用parent以获取bucced_id

<field name="budget_line" domain="[('budget_id', '=', parent.budget_id)]"/>

forgik_id_id在左侧是buceb> bucced_light_line_ids中使用的倒数名称

You can set the domain in view and use parent to get the budget_id:

<field name="budget_line" domain="[('budget_id', '=', parent.budget_id)]"/>

budget_id on the left is the inverse name used in budget_line_ids

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文