Skip to Content
Menu
This question has been flagged
1 Reply
1078 Views

Hi,all:

      As we know in 'Project' module we have 'partner_id' as customer(related to res.partner),then I add a new field in res.partner called 'created_time',then when create a project I should check customer's created_time,if our customer  is not created for more than three months,this project is not supposed to be created,so how should I use res.partner's created_time in project module?

    Thanks for your help.                         


Avatar
Discard
Best Answer

Hi,

You can add a related field in your model to get the create date of the partner, 


partner_id = fields.Many2one('res.partner', string='Customer', required=True,
domain=[('customer', '=', True)], track_visibility='onchange')
partner_create_date = fields.Datetime(string='Create Date', related='partner_id.create_date')


Then you can  compare the create data and return the warning accordingly. Check this to see how to add constrains for a field in the model: How To Add Constrains For A Field


Thanks

Avatar
Discard