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

skip the section and note while creating a serial number in order line

S'inscrire

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

Cette question a été signalée
sequenceserial_numbernoteorder.linesection
2 Réponses
5826 Vues
Avatar
Bharath Singh

I need to skip the section and note while creating a serial number in orderline, i made many modification,still its considering the section and notes as a line item, And its creating a serial number for section and notes.

My Python code :

from odoo import api, fields, models


class SaleOrder(models.Model):
_inherit = 'sale.order'

@api.multi
@api.depends('order_line')
def _compute_maxim_line_sequence(self):

for sale in self:
for line in sale.order_line:
if line.name:
sale.maxim_line_sequence = (
maxim(sale.mapped('order_line.sequence') or [0]) + 1)

maxim_line_sequence = fields.Integer(
string='Maxim sequence in lines',
compute='_compute_maxim_line_sequence',
store=True
)

@api.multi
def _reset_sequence(self):
for rec in self:
current_sequence = 1
for line in rec.order_line:
if line.name:
line.sequence = current_sequence
current_sequence += 1

@api.multi
def write(self, line_values):
res = super(SaleOrder, self).write(line_values)
self._reset_sequence()
return res

@api.multi
def copy(self, default=None):
return super(SaleOrder,
self.with_context(keep_line_sequence=True)).copy(default)


class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'

# re-defines the field to change the default
sequence = fields.Integer(
help="Gives the sequence of this line when displaying the sale order.",
default=9999,
# related='x_seq_handle',
string="Sequence"
)

# displays sequence on the order line
sequence2 = fields.Integer(
help="Shows the sequence of this line in the sale order.",
related='sequence',
string="Line Number",
readonly=True,
store=True
)

@api.model
def create(self, values):
line = super(SaleOrderLine, self).create(values)
# We do not reset the sequence if we are copying a complete sale order
if self.env.context.get('keep_line_sequence'):
line.order_id._reset_sequence()
return line



here i can't able to restrict to create serial number to only order line contains product it.

can you please help me to do this.

0
Avatar
Ignorer
Iñaki

Hi Bharath,

I tried to follow your example but in this code (taken from module set_sequence_number) it does not work:

@api.depends('order_id.order_line', 'order_id.order_line.product_id')
def _sequence_ref(self):
for line in self:
no = 0
line.sequence_ref = no
for l in line.order_id.order_line:
no += 1
l.sequence_ref = no

I wrote the line "if not line.display_type:" in all the places but I do not get it to work. I also didn't get for this other code:

@api.depends('sequence', 'move_id')
def _compute_number(self):
for s in self:
s.index = 0
for
invoice in self.mapped('move_id'):
index = 1
if
invoice.invoice_line_ids:
for line in invoice.invoice_line_ids:
line.index = index
index += 1

I would be happy if you can show me where should the if not condition goes. I am using Odoo14.

Thank you.

Avatar
Mohamed Salah
Meilleure réponse

did you find solution please?

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

Hi,

If you need to exclude the sections and notes, you can add the condition like this:-  if not line.display_type , if the line is section or notes, the value will be set in this field.


You can see the field in the sale.order.line model:

display_type = fields.Selection([
('line_section', "Section"),
('line_note', "Note")], default=False, help="Technical field for UX purpose.")


Thanks

0
Avatar
Ignorer
Bharath Singh
Auteur

yeah already i tried this too, once again i tried this, still section are considered for serial number.

Niyas Raphy (Walnut Software Solutions)

can you show me the code of how you set sequence number, will be fine if you can add that as a comment here, in the questions there seems a lot of code

Bharath Singh
Auteur

@api.multi

@api.depends('order_line')

def _compute_max_line_sequence(self):

for sale in self:

for line in sale.order_line:

if not line.display_type:

sale.max_line_sequence = (

max(sale.mapped('order_line.sequence') or [0]) + 1)

max_line_sequence = fields.Integer(

string='Max sequence in lines',

compute='_compute_max_line_sequence',

store=True

)

@api.multi

def _reset_sequence(self):

for rec in self:

current_sequence = 1

for line in rec.order_line:

if not line.display_type:

line.sequence = current_sequence

current_sequence += 1

i include the if not condition in these function

Bharath Singh
Auteur

Hi @Niyas Raphy, did you find any issue in below code.

Niyas Raphy (Walnut Software Solutions)

what is the difference between these two functions

Bharath Singh
Auteur

first function is for generating a serial number

second is used for resetting the serial number sequence for usecase scenarios.

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 does the sequence work with handle widget? Résolu
widget sequence note section odoo12
Avatar
Avatar
1
avr. 19
21667
How is the account.move.line name not shown in columns?
note section
Avatar
0
janv. 25
2249
increment sale order line sequence by 10 Résolu
sequence increment order.line
Avatar
Avatar
1
janv. 24
14071
SO new section
sale sequence sale.order.line section V12
Avatar
0
sept. 20
4215
Disable auto-assign of Serial Numbers to Sales Order Operations
serial_number
Avatar
Avatar
Avatar
3
juin 25
2624
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