我需要你的帮助我是python初学者,我在odoo中开发了一个基本模型我想开发2个函数来帮助我计算" montant" / 26的划分并放入导致" montant journalier" 第二个函数必须计算列的总和" montant"并将结果放入" total" 如果你可以帮助我将感激我真的需要它 这是我的观点和我的.py和.xml
python文件
RUN
xml文件
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import datetime
import math
from datetime import date
from openerp.osv import osv, fields, orm
class obj_ghb(osv.osv):
_name = 'obj.ghb'
_description = 'objet ghb'
def onchange_montant( self, cr, uid, ids,montant, context = {} ):
data={}
if montant:
data['montantjournalier']= montant/26 or False
return {'value': data}
def get_total_days( self, cr, uid, ids,days_tota,arg, context = None ):
diff_day={}
for record in self.browse(cr, uid, ids, context=context):
s_date = datetime.datetime.strptime(record.datedebut, "%Y-%m-%d").date()
e_date =datetime.datetime.strptime(record.datefin, "%Y-%m-%d").date()
diff_day[record.id] =(e_date-s_date).days
return diff_day
_columns = {
'nomprojet': fields.char('Nom du projet'),
'responsable': fields.char('Responsable GHB'),
'client': fields.char('Client'),
'contactclient': fields.char('Contact du client'),
'datedebut': fields.date('Date de debut'),
'datefin': fields.date('Date de fin'),
'nombredejour': fields.function(get_total_days, type = "integer", method=True,store = True, string = "Jours travaillés"),
'obj_ghb_parent': fields.one2many('loyer', 'loyer_obj_ghb'),
'obj_ghb_id': fields.one2many('assurance', 'assurance_obj_ghb'),
'obj_ghb_parenttt': fields.one2many('salaire', 'salaire_obj_ghb'),
'obj_ghb_parentttt': fields.one2many('autres', 'autres_obj_ghb'),
'total': fields.char('Total'),
'totall': fields.char('Totall'),
'totalll': fields.char('Totalll'),
'totallll': fields.char('Totallll'),
}
class loyer(osv.osv):
_name='loyer'
_columns = {
'nom': fields.char('Nom'),
'montant': fields.float('Montant'),
'montantjournalier': fields.float('Montant journalier') ,
'loyer_obj_ghb': fields.many2one('obj.ghb'),
}
class assurance(osv.osv):
_name='assurance'
_columns = {
'name': fields.char('Nom'),
'mount': fields.char('Montant'),
'dailymount': fields.char('Montant journalier') ,
'assurance_obj_ghb': fields.many2one('obj.ghb'),
}
class salaire(osv.osv):
_name='salaire'
_columns = {
'nommm': fields.char('Nom'),
'montanttt': fields.char('Montant'),
'montantjournalierrr': fields.char('Montant journalier') ,
'salaire_obj_ghb': fields.many2one('obj.ghb'),
}
class autres(osv.osv):
_name='autres'
_columns = {
'nommmm': fields.char('Nom'),
'montantttt': fields.char('Montant'),
'montantjournalierrrr': fields.char('Montant journalier') ,
'autres_obj_ghb': fields.many2one('obj.ghb'),
}