Skip to content

Commit

Permalink
[IMP] public_budget: crear partidas presupuestarias cuando hay modifi…
Browse files Browse the repository at this point in the history
…caciones

Si hay una modificación en alguna partida de un presupuesto y esa partida no existe en la solapa de detalle entonces creamos la partida en la solapa de detalle
Task: 29028
  • Loading branch information
pablohmontenegro committed Jan 31, 2023
1 parent d66a597 commit 71a764c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions public_budget/models/budget.py
Expand Up @@ -332,3 +332,21 @@ def action_to_open_definitive_lines(self):
'context': {'search_default_budget_id': self.id},

}

def create_new_details_from_modif(self):
modification = self.mapped("budget_modification_ids.budget_modification_detail_ids.budget_position_id.id")
details = self.mapped("budget_detail_ids.budget_position_id.id")
new_detail_to_create = set(modification) - set(details)
if not new_detail_to_create:
return

self.write({'budget_detail_ids': [
(0, 0, {'budget_position_id': item, 'initial_amount': 0.0})
for item in new_detail_to_create
]})

def write(self, values):
res = super().write(values)
if 'budget_modification_ids' in values:
self.create_new_details_from_modif()
return res

0 comments on commit 71a764c

Please sign in to comment.