Skip to content

Commit

Permalink
[IMP] budget_activity: add required_activity in lines
Browse files Browse the repository at this point in the history
  • Loading branch information
Saran440 committed Sep 24, 2024
1 parent 3ba9b4a commit 1383094
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 7 additions & 0 deletions budget_activity/models/base_budget_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ def _domain_activity(self):
class BudgetDoclineMixin(models.AbstractModel):
_inherit = "budget.docline.mixin"

required_activity = fields.Boolean(compute="_compute_required_activity", store=True)

@api.depends("company_id.budget_control_key")
def _compute_required_activity(self):
for rec in self:
rec.required_activity = rec.company_id.budget_control_key == "activity_id"

def _update_budget_commitment(self, budget_vals, analytic, reverse=False):
budget_vals = super()._update_budget_commitment(
budget_vals, analytic, reverse=reverse
Expand Down
6 changes: 4 additions & 2 deletions budget_activity_purchase/views/purchase_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@
expr="//field[@name='order_line']/tree//field[@name='product_id']"
position="after"
>
<field name="required_activity" invisible="1" />
<field
name="activity_id"
attrs="{'required': [('analytic_distribution', '!=', False)]}"
attrs="{'required': [('required_activity', '!=', False)]}"
groups="analytic.group_analytic_accounting"
/>
</xpath>
<xpath
expr="//field[@name='order_line']/form//field[@name='product_id']"
position="after"
>
<field name="required_activity" invisible="1" />
<field
name="activity_id"
attrs="{'required': [('analytic_distribution', '!=', False)]}"
attrs="{'required': [('required_activity', '!=', False)]}"
groups="analytic.group_analytic_accounting"
/>
</xpath>
Expand Down

0 comments on commit 1383094

Please sign in to comment.