[ADD] create project_funders
to track funds on tasks
Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
This commit is contained in:
committed by
Stéphan Sainléger
parent
c4ef88d3d4
commit
1f8baa73d1
2
project_funders/models/__init__.py
Normal file
2
project_funders/models/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from . import project_funders
|
||||
from . import project_task
|
16
project_funders/models/project_funders.py
Normal file
16
project_funders/models/project_funders.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from odoo import _, api, fields, models
|
||||
|
||||
|
||||
class ProjectFunders(models.Model):
|
||||
_name = "project.funder"
|
||||
_description = "Funder and amount for tasks"
|
||||
|
||||
name = fields.Char(compute="_compute_name", string="Name")
|
||||
partner_id = fields.Many2one("res.partner", string="Funder", required=True)
|
||||
amount = fields.Float("Untaxed Amount", required=True)
|
||||
task_id = fields.Many2one("project.task", string="Task")
|
||||
|
||||
@api.depends("partner_id", "amount")
|
||||
def _compute_name(self):
|
||||
for record in self:
|
||||
record.name = "%s (%s)" % (record.partner_id.name, record.amount)
|
13
project_funders/models/project_task.py
Normal file
13
project_funders/models/project_task.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from odoo import _, api, fields, models
|
||||
|
||||
|
||||
class ProjectTask(models.Model):
|
||||
_inherit = "project.task"
|
||||
|
||||
funder_ids = fields.One2many("project.funder", "task_id", string="funder")
|
||||
amount_total = fields.Float(compute="_compute_amount_total", string="Amount Total")
|
||||
|
||||
@api.depends("funder_ids")
|
||||
def _compute_amount_total(self):
|
||||
for record in self:
|
||||
record.amount_total = sum(record.funder_ids.mapped("amount"))
|
Reference in New Issue
Block a user