Skip to Content
Menu
This question has been flagged
3 Replies
1382 Views
class Missions(models.Model):

_name = 'mission.mission'
_description = 'mission.mission'

_rec_name = 'mission_id'

project_ids = fields.Many2one('project.project', string='Projet')
mission_id = fields.Many2one('missname.missname', String='Mission')
miss_id = fields.Integer(string='I_mission')
version = fields.Selection([('pro', 'Provisoire'), ('Déf', 'Définitif')])
Délais_jrs = fields.Float(string='Délai en jours', compute='_compute_delai_mois')
Délais_mois = fields.Integer(string='Délai en mois')
ordre_arre = fields.Date(string='Ordre d arrét')
ordre_repr = fields.Date(string='Ordre de reprise')
Délai_restants = fields.Float(string='Délai Restant en mois', compute='_compute_delais_restant')
Délai_écoulée = fields.Float(string='Délai écoulé en mois', compute='_compute_delais_ecoule')
date_debut = fields.Date(string='Date de la mission')
nbr_mission = fields.Float(string='nombre de mission', compute='_delais_mission')


def _delais_mission(self):
for k in self:

if k.ordre_arre and k.ordre_repr:
date_1 = datetime.strptime(k.ordre_arre, '%Y-%m-%d')
date_2 = datetime.strptime(k.ordre_repr, '%Y-%m-%d')
k.nbr_mission = ((date_2 - date_1).days) / 30
print(k.nbr_mission)




class Delais(models.Model):

_name = 'delais.delais'
_descritpion = 'delais.delais'

_rec_name = 'project_ids'

project_ids = fields.Many2one('project.project', string='Projet')
delai_arr_mois = fields.Float(string='Délais D arrét en mois', compute='_delai_mission')
@api.multi
def _delai_mission(self):
#domaine = ['project_ids', '=', self.project_ids]
dict = self.env['mission.mission'].search_read([['project_ids', '=', self.project_ids], ['nbr_mission']])

print(dict)
somme = 0
for key in dict:
print(key['nbr_mission'])
somme = somme + key['nbr_mission']
print(f'la somme est : {somme}')
self.delai_arr_mois = somme

help please !!
Avatar
Discard
Best Answer

Hello,

you have to use for loop whenever you have to iterate detail.detail records, currently you got multiple details.

Avatar
Discard
Author

I want to iterate in model mission.mission

you got multiple delais.delais(8, 7) records. for that you have to use for loop when delais records are fetched.

Best Answer

It looks like you may have forgotten an @api.multi tag at the top of that function.

Avatar
Discard
Author

it montionned

Author

i montionned it

Related Posts Replies Views Activity
2
Jul 24
942
1
Jun 24
3564
1
Oct 23
8590
1
Oct 23
97
1
Aug 23
2192