Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Validations
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Épicerie
    • Quincaillerie
    • Magasin de jouets
    Restauration & Hôtellerie
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brasserie
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Commerce
    • Bricoleur
    • Matériel informatique & support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Parcourir toutes les industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenir partenaire
    • Services pour partenaires
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Comptabilité
  • Inventaire
  • PoS
  • Projet
  • MRP
All apps
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

loan request

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
odoo12.0
1 Répondre
4131 Vues
Avatar
jenan soliman

Hello

I am working  on loan limitation, the function must do the following:

if the employee requests a loan less than the limitation, a new limitation must be calculated by subtracting the loan amount.

if an employee requests another loan, the limitation must equal the new limitation - the sum of the loan amount.

here's my code:



limit = fields.Float('limitation',compute='_check_contract_limitation')
@api.onchange('loan_amount', 'employee_id','limit')
def _check_contract_limitation(self):
for rec in self:
#hr_contract = self.env['hr.contract'].search([('employee_id.name', '=', self.employee_id.name)], limit=1)
if not rec.employee_id.contract_id:
raise ValidationError("you dont have contract record.")
elif rec.employee_id.contract_id:
rec.limit = rec.employee_id.contract_id.wage
# rec.a = hr_contract.date_start
if rec.employee_id.contract_id.date_start:
fmt = '%Y-%m-%d'
d1 = rec.employee_id.contract_id.date_start
d2 = datetime.datetime.now().date()
r = relativedelta.relativedelta(d2, d1)
contract_time = r.years
rec.a = contract_time
if contract_time == None:
raise ValidationError("check contract duration.")
else:
if contract_time >= 5:

rec.limit = rec.employee_id.contract_id.wage * 5 - rec.loan_amount
if rec.loan_amount > rec.limit:
rec.loan_amount = False
raise
ValidationError("please correct loan amount is greater than limitaion.")
return

elif
contract_time >= 0 and contract_time < 5:
rec.limit = rec.employee_id.contract_id.wage * contract_time - rec.loan_amount
if rec.loan_amount > rec.limit:
rec.loan_amount = False
raise
ValidationError("please correct loan amount is greater than limitaion.")
return





0
Avatar
Ignorer
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Meilleure réponse

Hi,

You can try this code:

import datetime
from dateutil.relativedelta
import relativedelta

limit = fields.Float('Limitation', compute='_check_contract_limitation')

@api.onchange('loan_amount', 'employee_id')
def _check_contract_limitation(self):
for
rec in self:
   
if not rec.employee_id.contract_id:
        raise ValidationError(
"You don't have a contract record.")
   
   
contract = rec.employee_id.contract_id
   
if not contract.date_start:
        raise ValidationError(
"Contract start date is missing.")
   
   
contract_start_date = datetime.datetime.strptime(contract.date_start, '%Y-%m-%d').date()
   
today = datetime.datetime.now().date()
   
contract_duration = relativedelta(today, contract_start_date).years

   
if contract_duration is None:
        raise ValidationError(
"Check contract duration.")
   
   
if contract_duration >= 5:
       
rec.limit = contract.wage * 5 - rec.loan_amount
    elif
0 <= contract_duration < 5:
       
rec.limit = contract.wage * contract_duration - rec.loan_amount
   
   
if rec.loan_amount > rec.limit:
       
rec.loan_amount = False
        raise ValidationError(
"Please correct the loan amount; it is greater than the limitation.")


Hope it helps

0
Avatar
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Expected singleton: hr.emp.travel.location(62, 63)
odoo12.0
Avatar
Avatar
Avatar
2
oct. 25
2183
How to write Record Rule with domain based on the company_dependent Fields Résolu
odoo12.0
Avatar
Avatar
Avatar
3
oct. 23
11182
sum Colum of based on id
odoo12.0
Avatar
Avatar
1
mai 23
3125
How to make pagination that has a table in qweb
odoo12.0
Avatar
Avatar
2
avr. 23
3917
Inherit Element form kanban View Résolu
odoo12.0
Avatar
Avatar
1
mars 23
3058
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenir partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now