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
    Food & Hospitality
    • 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
    • Brewery
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Trades
    • Bricoleur
    • Matériel informatique et 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
    Browse all 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
    • Devenez partenaire
    • Services for Partners
    • 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

Data from fields get lost after pressin button

S'inscrire

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

Cette question a été signalée
fieldsvaluesTransientModelodoo16features
1 Répondre
2579 Vues
Avatar
Agustin Cortes

Hello,

i porting/developing a module (working un V8).

It have a wizard , from the wizard we jump to a editable tree view with results and the option to confirm the operation.


I create the model (transient) en when clicking in the button (confirm the action) the data in the form get lost, all the fields cames empty

Here is my code:


the XML:


product.prices_update_wizard_result
product.prices_update_wizard_result











product.prices_update_wizard_result_detail.tree
product.prices_update_wizard_result_detail








and the py file:

class prices_update_wizard_result_detail(models.TransientModel):
_name = 'product.prices_update_wizard_result_detail'
_description = "details results"

result_id = fields.Many2one(
'product.prices_update_wizard_result', 'Result')
product_tmpl_id = fields.Many2one(
'product.template', 'Product Template',
readonly=True)
old_price = fields.Float(
'Old Price',
readonly=True)
new_price = fields.Float(
'New Price',
required=True
)


class prices_update_wizard_result(models.TransientModel):
_name = 'product.prices_update_wizard_result'
_description = "results"

@api.model
def default_get(self, fields_list):
res=super(prices_update_wizard_result,self).default_get(fields_list)
ret = []
price_discount = self._context.get('price_discount', 0.0)
price_surcharge = self._context.get('price_surcharge', 0.0)
price_round = self._context.get('price_round', 0.0)
product_tmpl_ids = self._context.get('product_tmpl_ids', [])
price_type = self._context.get('price_type', False)
for product_tmpl in self.env['product.template'].browse(
product_tmpl_ids):
if price_type == 'list_price':
old_price = product_tmpl.list_price
elif price_type == 'standard_price':
old_price = product_tmpl.standard_price
else:
raise UserError(_('Price type "%s" is not implemented') % (price_type))
vals = {
'product_tmpl_id': product_tmpl.id,
'old_price': old_price,
'new_price': self.env[
'product.prices_update_wizard'].calc_new_price(
old_price, price_discount,
price_surcharge, price_round),
}
ret.append([0,0,vals])
res.update({'detail_ids':ret})
return res


detail_ids = fields.One2many(
'product.prices_update_wizard_result_detail',
'result_id',
string='Products Detail',
store=False,
)

def confirm(self):
products_vals = []
price_type = self._context.get('price_type', False)
for line in self.detail_ids: #self.detail_ids comes empty
vals = {
'product_tmpl': line.product_tmpl_id,
'new_price': line.new_price,
}
products_vals.append(vals)
return self.env['product.prices_update_wizard'].update_prices(
products_vals, price_type)

if i change to models.Model works, but, if i perform a inline editiong, don't get stored in the self.detail_ids

Try with force_save but not solved at all


Any idea of any posible solution?

0
Avatar
Ignorer
Agustin Cortes
Auteur

cant post xml code
here it goes

<record id="view_prices_update_wizard_result_form" model="ir.ui.view">
<field name="name">product.prices_update_wizard_result</field>
<field name="model">product.prices_update_wizard_result</field>
<field name="arch" type="xml">
<form string="Products">
<header>
<button name="confirm" string="Confirm" type="object" class="oe_highlight" />
</header>
<field name="detail_ids" force_save = "1"/>
</form>
</field>
</record>

<record id="view_prices_update_wizard_result_detail_tree" model="ir.ui.view">
<field name="name">product.prices_update_wizard_result_detail.tree</field>
<field name="model">product.prices_update_wizard_result_detail</field>
<field name="arch" type="xml">
<tree string="Products" create="false" editable="top">
<field name="product_tmpl_id" force_save = "1"/>
<field name="old_price" force_save = "1"/>
<field name="new_price" force_save = "1"/>
</tree>
</field>
</record>

Avatar
Agustin Cortes
Auteur Meilleure réponse

Ok, i solved with a workarraound, not the ideal solution.

Basicaly, i create a temp variable in the first class, and update that value with api.onchage

when you press the button, i use that variable instead of the one from the view.
Not ideal, but working fine

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é
how to populate a new field in odoo on old records
development fields odoo16features
Avatar
Avatar
1
août 25
3736
Put 3 fields with their respective labels on a single line, odoo 16
fields label odoo16features
Avatar
Avatar
Avatar
2
janv. 24
4513
many2one field is not saving
fields many2one odoo16features
Avatar
Avatar
1
août 23
3641
fields.Html() can not editable when it on the tree-view.
fields Html odoo16features
Avatar
Avatar
1
mai 23
3554
inherit and add fields odoo16
fields res.partner odoo16features
Avatar
Avatar
Avatar
Avatar
3
avr. 23
5939
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
  • Devenez 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