Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

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

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
sequenceserial_numbernoteorder.linesection
2 Besvarelser
5824 Visninger
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
Kassér
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
Bedste svar

did you find solution please?

0
Avatar
Kassér
Avatar
Niyas Raphy (Walnut Software Solutions)
Bedste svar

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
Kassér
Bharath Singh
Forfatter

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
Forfatter

@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
Forfatter

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
Forfatter

first function is for generating a serial number

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

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Tilmeld dig
Related Posts Besvarelser Visninger Aktivitet
How does the sequence work with handle widget? Løst
widget sequence note section odoo12
Avatar
Avatar
1
apr. 19
21656
How is the account.move.line name not shown in columns?
note section
Avatar
0
jan. 25
2243
increment sale order line sequence by 10 Løst
sequence increment order.line
Avatar
Avatar
1
jan. 24
14069
SO new section
sale sequence sale.order.line section V12
Avatar
0
sep. 20
4212
Disable auto-assign of Serial Numbers to Sales Order Operations
serial_number
Avatar
Avatar
Avatar
3
jun. 25
2613
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة 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 er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

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