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

When create a new user it invoke my override write method in a new model

S'inscrire

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

Cette question a été signalée
writeres.useroverride
6360 Vues
Avatar
PuentesDSoftware

I create a new model and override its write method, but when I create a new user, my override write is called.

Why happend that?


My class:


class Movimiento(models.Model):

_name = 'gestion_autos.movimiento'

name = fields.Char(string='Nombre')

product_id = fields.Many2one('product.template', string='Producto', required=True)

fecha = fields.Date(string='Fecha', default=fields.Date.today)

price_unit = fields.Float(string='Precio por unidad', required=True, default='1.0')

amount = fields.Float(string='Cantidad', required=True, default='1.0')

price_total = fields.Float(compute='_compute_price_total', string='Precio total',

store=True)

taxi_id = fields.Many2one('gestion_autos.taxi', string='Taxi',

required=True)

credito = fields.Boolean(default=False, string='Credito')

@api.depends('price_unit', 'amount')

def _compute_price_total(self):

for record in self:

if record.price_unit < 0.0:

record.price_unit = 0.0

if record.amount < 0.0:

record.amount = 0.0

record.price_total = record.price_unit * record.amount


class Gasto(Movimiento):

_name = 'gestion_autos.gasto'

partner_id = fields.Many2one('res.partner', string="Proveedor", required=True)

pago_ids = fields.One2many('gestion_autos.pagogasto', 'gasto_id', string="Pago")

@api.onchange('product_id')

def _onchange_product_id(self):

self.price_unit = self.product_id.standard_price

@api.model

def create(self, vals):

_logger.error("gasto - create - self : %r", self)

_logger.error("gasto - create - vals : %r", vals)

gasto_id = super(Gasto, self).create(vals)

if vals.get('credito') == False:

gasto_id.update_pay()

return gasto_id

@api.multi

def write(self, vals):

_logger.error("gasto - write - self : %r", self)

_logger.error("gasto - write - vals : %r", vals)

res = super(Gasto, self).write(vals)

if not res:

return res

pagos = self.env['gestion_autos.pagogasto'].search([('gasto_id.id', 'in', self.ids)])

pagos.unlink()

if vals.get('credito') == False:

self.update_pay()

return True

@api.one

def update_pay(self):

pagogasto_obj = self.env['gestion_autos.pagogasto']

res = pagogasto_obj.create({

'fecha':self.fecha,

'price':self.price_total,

'partner_id':self.partner_id.id,

'gasto_id':self.id,

'referencia':"Fac - %s - %s" % (self.fecha, self.partner_id.name)

})

return True



Output when create a new user:


2015-04-03 23:19:13,210 18132 ERROR newdb openerp.addons.gestion_autos.models.contabilidad: gasto - write - self : gestion_autos.gasto()

2015-04-03 23:19:13,210 18132 ERROR newdb openerp.addons.gestion_autos.models.contabilidad: gasto - write - vals : {'partner_id': 6}

2015-04-03 23:19:13,212 18132 ERROR newdb openerp.addons.gestion_autos.models.contabilidad: gasto - write - self : gestion_autos.gasto()

2015-04-03 23:19:13,212 18132 ERROR newdb openerp.addons.gestion_autos.models.contabilidad: gasto - write - vals : {'partner_id': False}


Please some explanation to that

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é
If field is selected on of the other 6 fields should be selected to
write override
Avatar
Avatar
1
sept. 18
4282
"Write" called twice on update, once on creation, and "Create" never called?
write override
Avatar
1
mars 15
7006
how can i override _login and check_credentials method of res_user in odoo
login res.user override
Avatar
Avatar
1
juin 17
10800
Override write method in product
product write method override
Avatar
1
févr. 21
6540
odoo[13]:When I override the write method at that time it is goes in loop how to stop the loop ?
write override writeMethod Odoo13.0
Avatar
Avatar
1
avr. 20
9195
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