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

Load custom model and add a field to pos.order.line in Point of Sale

S'inscrire

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

Cette question a été signalée
modelspoint_of_saleOdoo12.0
2 Réponses
8300 Vues
Avatar
Paulo Matos

Dear all

I am trying to add a new custom field to the "pos.order.line" for use with Point of Sale application in Odoo 12.

This new field is dependable on a new model I have created for use with products.

I added this field to the model and I need it to be automatically filled on every pos order line for every product.

It is something like the "taxes", were user selects a product and Odoo automatically set the tax information on pos order line.

For a better understanding I will try to reproduce the steps I have accomplished so far.

1. New model: for this example I will call it "Type".

This model will be filled with "several" types and added to every product I have.

class Types(models.Model):
_name = 'types'
_description = 'Sample Types Model'
code = fields.Char('Code', required=True)
name = fields.Char('Description', required=True)

2. As stated, this "types" will be added to every product I have, so, I have added a new field to "products.template" model:

class ProductTemplate(models.Model): 
_inherit = "product.template"
types_id = fields.Many2one('types', string='Product specific type')

3. Since I need this value to be shown on every pos order line, I added the field to the "pos.order.line" model using the same approach:

class PosOrderLine(models.Model):
_inherit = "pos.order.line"
types_id = fields.Many2one('types', string='Product specific type'

PS: I could use another approach by "working" with "product_id" field on the "pos.order.line", but I need to keep track of the "type" used on every product line even if user changes the "type" on the product and using this approach I will keep track the "type" used on the pos order no matter if the type was changed on the product.


4. Here the problem starts.

I need to load the new model and the new field added to "product.template" and write the default "type" for every product on the "pos.order.line", when the order is confirmed.

I am trying to load the "types" model and the new "types_id" field on product.template using the following code:

var pos_model = require('point_of_sale.models');

pos_model.load_fields("types", "code", "name");
pos_model.load_fields("product.template", "types_id");

Is the code above correct?

5. Now, I need to override the method that manages the pos.order.lines, in order to automatically load the "type" field when a product is added to the basket and write it to database for every product lines included on the order.

Can anyone help me please?

Thank you very much

Best regards

PM


0
Avatar
Ignorer
Avatar
Paulo Matos
Auteur Meilleure réponse

I have solved my problem with the help of Kenly on another forum.

Just had to declare the "types_id" field on "pos.order.line" like:

class PosOrderLine(models.Model):
_inherit = "pos.order.line"
types_id = fields.Many2one(related='product_id.product_tmpl_id.types_id',
string='Product specific type', store=True)

Thank you all


0
Avatar
Ignorer
Avatar
ayoub
Meilleure réponse

Hello,please i want to change the form for a many2one field.I want to show another kanban view.

can you help me ?

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é
Studying ODOO Point of sale source code v12.0
point_of_sale Point Of Sale odoo12.0 Odoo12.0
Avatar
Avatar
Avatar
2
avr. 21
7844
Odoo 12: Help on JavaScript function for Point of Sale
javascript function point_of_sale Odoo12.0
Avatar
0
avr. 20
3070
add model to point of sale
javascript models self point_of_sale
Avatar
0
avr. 15
4146
Configuring Advanced Rights to Hide 'Cost' on POS Screen for Employees
point_of_sale
Avatar
Avatar
1
juil. 25
2764
can i use restaurant features without having floor or tables in pos? Résolu
point_of_sale
Avatar
Avatar
Avatar
Avatar
Avatar
4
août 25
4202
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