Skip to Content
Menu
This question has been flagged
3 Replies
2633 Views
I did a task module

class task(models.Model):
_inherit = "project.task"

def _default_task_accounting_type_id(self):
domain = [('name', '=', 'Développement')]
return self.env['account.analytic.tag'].search(domain, limit=1)

task_accounting_type = fields.Many2one('account.analytic.tag', default=_default_task_accounting_type_id)

I want to have a different domain depending of task related project based on project name.
Something like:

def _default_task_accounting_type_id(self):
        if self.project_id.???? == 'Marketing':
            domain = [('name', '=', 'Développement')]
         else:
    domain = [('name', '=', 'Développement')]
return self.env['account.analytic.tag'].search(domain, limit=1)

How could I get the project name related to a task in my function?
Avatar
Discard
Author

Hi hassan,

self.project_id.name does not work:

_logger.warning(str(type(self.project_id.name)))

--> gives <class 'bool'>

Do I miss something?

.models.models: <class 'bool'>

Author

By the way I use odoo 13, and type(self.project_id)) is <class 'odoo.api.project.project'>

Best Answer
self.project_id.name
Avatar
Discard
Related Posts Replies Views Activity
1
Jun 23
1698
1
Nov 22
1765
2
Jun 20
2215
2
Jul 18
5784
4
Jul 18
6693