activity modifications 3
This commit is contained in:
parent
9eeb4caeb4
commit
56038744e5
|
|
@ -178,6 +178,19 @@ class PaProgram(models.Model):
|
|||
|
||||
active = fields.Boolean(string='Program Status', default=True)
|
||||
|
||||
# @api.constrains('name')
|
||||
# def _create_program_account(self):
|
||||
# for rec in self:
|
||||
# if not rec.name:
|
||||
# continue
|
||||
# # check if analytic account already exists
|
||||
# analytic = self.env["account.analytic.account"].search([("name", "=", rec.name)], limit=1)
|
||||
# if not analytic:
|
||||
# self.env["account.analytic.account"].create({
|
||||
# "name": rec.name,
|
||||
# })
|
||||
|
||||
|
||||
@api.constrains('payment_type', 'sponsor_id')
|
||||
def _check_sponsor_if_paid(self):
|
||||
for record in self:
|
||||
|
|
@ -224,6 +237,28 @@ class PaProgramActivity(models.Model):
|
|||
estimated_budget = fields.Float("Estimated Budget")
|
||||
active = fields.Boolean("Active", default=True)
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
res = super().create(vals) # ✅ fix
|
||||
if not res.analytic_account_id:
|
||||
account = self.env['account.analytic.account'].create({
|
||||
'name': res.name,
|
||||
'active': True,
|
||||
})
|
||||
res.analytic_account_id = account.id
|
||||
return res
|
||||
|
||||
def write(self, vals):
|
||||
res = super().write(vals) # ✅ same correction here
|
||||
for record in self:
|
||||
if not record.analytic_account_id:
|
||||
account = self.env['account.analytic.account'].create({
|
||||
'name': record.name,
|
||||
'active': True,
|
||||
})
|
||||
record.analytic_account_id = account.id
|
||||
return res
|
||||
|
||||
|
||||
class PaProgramMedad(models.Model):
|
||||
_name = 'pa.program.medad'
|
||||
|
|
@ -243,6 +278,28 @@ class PaProgramMedad(models.Model):
|
|||
estimated_budget = fields.Float("Estimated Budget")
|
||||
active = fields.Boolean("Active", default=True)
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
res = super().create(vals) # ✅ fix
|
||||
if not res.analytic_account_id:
|
||||
account = self.env['account.analytic.account'].create({
|
||||
'name': res.name,
|
||||
'active': True,
|
||||
})
|
||||
res.analytic_account_id = account.id
|
||||
return res
|
||||
|
||||
def write(self, vals):
|
||||
res = super().write(vals) # ✅ same correction here
|
||||
for record in self:
|
||||
if not record.analytic_account_id:
|
||||
account = self.env['account.analytic.account'].create({
|
||||
'name': record.name,
|
||||
'active': True,
|
||||
})
|
||||
record.analytic_account_id = account.id
|
||||
return res
|
||||
|
||||
|
||||
# Example family/beneficiary for demo: you should replace with your actual model
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue