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
    • Intelligence artificielle
    • 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
    • Supermarché
    • 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
    • Homme à tout faire
    • 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
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

Onchange y self.env.company not work

S'inscrire

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

Cette question a été signalée
invoicemexicoodoo16features
2 Réponses
2751 Vues
Avatar
Manuel Garcia

Hello, I have a problem with the onchange event that is not working completely in multi-company. The instruction self.env.company is not returning the current company. Can you help me identify what could be failing, if there is any solution or if it is an Odoo bug that needs to be fixed. The problem had not arisen until multiple companies with different RFCs began to be used. The restriction validates that the mx_customer_rfc field is the same as the company’s. So the problem is that self.env.company always returns the same company regardless of whether the user is moving from company to company. What I identified is that outside of onchange it does work, it is even the classic way to assign the default company (default=lambda self:self.env.company).


@api.constrains('mx_customer_rfc')
def _check_customer_rfc(self):
for record in self:
if record.mx_customer_rfc and record.mx_customer_rfc != self.env.company.vat and (record.move_type == 'in_invoice' or record.move_type == 'in_refund' or record.move_type == 'in_receipt'):
raise ValidationError('El RFC del receptor (%s) no corresponde con el RFC de %s (%s)' %
(record.mx_customer_rfc, self.env.company.name, self.env.company.vat))



0
Avatar
Ignorer
Manuel Garcia
Auteur

@Niyas Raphy
Hi,
Yes, it’s correct, you have multi-company mode enabled and several companies selected in the company switcher, that is, in the menu bar, and you understand that self.env.company will return the first selected company. However, when using @api.constrains for some strange reason it no longer works, it always returns the same company regardless of whether you are switching between companies from the menu bar.

Thanks

Avatar
Manuel Garcia
Auteur Meilleure réponse

@Niyas Raphy

Hi,
Yes, it’s correct, you have multi-company mode enabled and several companies selected in the company switcher, that is, in the menu bar, and you understand that self.env.company will return the first selected company. However, when using @api.constrains for some strange reason it no longer works, it always returns the same company regardless of whether you are switching between companies from the menu bar.

Thanks


0
Avatar
Ignorer
Avatar
Niyas Raphy (Walnut Software Solutions)
Meilleure réponse

Hi,
If you have multi company enabled and multiple companies selected in the company switched, ie, in the menu bar, self.env.company will return the first select company .

And this will return the selected company properly, can you confirm that are you looking for the same or you are looking for the company selected in the record ?

If you need to check with company set in the record, use self.company_id instead of self.env.company

Thanks

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é
Add bank account number under company details of a invoice - Odoo 16 Community Edition Résolu
invoice odoo16features
Avatar
Avatar
1
mars 24
1476
How to place a foreach loop inside a <td> in a QWEB Report Résolu
invoice odoo16features
Avatar
Avatar
1
juil. 23
4887
How to place a foreach loop inside a <td> in a QWEB Report
invoice odoo16features
Avatar
0
juil. 23
25
Link Invoice and Sale order In Odoo 16.4
invoice sales.order odoo16features
Avatar
Avatar
1
déc. 24
4109
Odoo 16. Report same report has two different faces.
invoice reports odoo16features
Avatar
Avatar
1
déc. 23
3845
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 Svenska ภาษาไทย 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