Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Customizing Sequence Code Generation and Delivery Slip Behavior in stock.picking Module

Subscribe

Get notified when there's activity on this post

This question has been flagged
communitystock_pickingv15
3 Replies
4930 Views
Avatar
Kabir Khan

"I'm looking for guidance on customizing the behavior of the stock.picking module in my ERP system. Currently, when confirming a quotation, it creates a sale order along with a delivery slip, which generates a sequence code immediately. However, I want to delay the generation of the delivery slip number until the stock.picking state is 'done'. Essentially, The behavior of the sale invoice process where the sequence code isn't generated until the invoice is done. Additionally, I want the stock.picking state to remain as 'draft' until the delivery is done. Can anyone provide insights or steps on how to achieve this customization effectively? Any advice, code snippets, or pointers to relevant documentation would be highly appreciated. Thank you!"

0
Avatar
Discard
Avatar
Jaideep
Best Answer

Why not create a new field "Delivery Challan" with sequence number that is updated when the picking state is done?

Update the required reports with the new field and make the current field invisible in the views.

1
Avatar
Discard
Kabir Khan
Author

yes you are also right brother.

Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi,

You can modify the sequence of stock.picking from the UI itself, for that go toInventory -> Configuration -> Operation Types


Open any operation type, You can see the sequence prefix from it


 Go to the internal link of the Reference sequences to make changes for more


Hope it helps

0
Avatar
Discard
Kabir Khan
Author

dear brother i just wanted to dont want create delivery challan number untill the ​

if stock_picking.state == 'done':

when i click quotation confirm it will create sale order and also create stock picking transfer with challan number but i wish its creating challan or delivery on state == done when i click to validate the stock picking transfer challan generate
otherwise stock pick transfer is dont want to such he creating delivery challan number

hope you understand :)

i just wanted to not forced to create delivery challan on creating sale order i inherit the method but didnt get it will creating automatically delivery challan number

Avatar
Dương Nguyễn
Best Answer

I check the code , if you do like this , you will need to do 2 think

1. Remove the sql constrain for unique name


2. Add these code

@api.model

def create(self, vals):

​res = super().create(vals)

​for r in res:

​ ​if r.name != '/' and r.state != 'done':

​ ​ ​r.name = '/'

​return res


 

def write(self, vals):

​res = super().write(vals)

​for r in self:

​ ​if r.name == '/' and r.state == 'done':

​ ​ ​picking_type = r.picking_type_id

​ ​ ​if picking_type.sequence_id.number_next_actual > 0:

​ ​ ​ ​picking_type.sequence_id.number_next_actual -= 1

​ ​ ​r.name = picking_type.sequence_id.next_by_id()

return res
overall, i suggest that you shouldn't do this because this is quite strange behavior unless you have something specific thing why you doing like this

0
Avatar
Discard
Kabir Khan
Author

dear brother i just wanted to dont want create delivery challan number untill the ​
if r.state == 'done':

when i click quotation confirm it will create sale order and also create stock picking transfer with challan number but i wish its creating challan or delivery on state == done when i click to validate the stock picking transfer challan generate
otherwise stock pick transfer is dont want to such he creating delivery challan number

hope you understand :)

i just wanted to not forced to create delivery challan on creating sale order i inherit the method but didnt get it will creating automatically delivery challan number

Dương Nguyễn

Hi Sir, i have modified the answer please check

Kabir Khan
Author

ok ill check and reply

Kabir Khan
Author

@Dương Nguyễn beacause the delivery challan was not in sequence the delivery order is not proper date wise with seqence code like

deliverychallan001 this is delivery expected time 20 March
deliverychallan002 this is delivery expected time 02 March

in delivery chllan the sequence not maintain
deliverychallan002
deliverychallan001
is show like this will export this and send data to GOVT TAX india then the entry delivery challan number not sync proper sequence wise.

Kabir Khan
Author

code is not working

Dương Nguyễn

really, i test i work fine, is this the flow that you want
Confirm Sale Order -> The system will create a delivery picking and the picking name will stay '/' until you validate it right

Kabir Khan
Author

can you share me full code of file? how many module you inherit i added this in new custom file but it will generate
automatically

class CustomStockPicking(models.Model):
_inherit = 'stock.picking'

@api.model
def create(self, vals):
res = super(CustomStockPicking, self).create(vals)
for r in res:
if r.name != '/' and r.state != 'done':
r.name = '/'
return res

def write(self, vals):
res = super(CustomStockPicking, self).write(vals)
for r in self:
if r.name == '/' and r.state == 'done':
picking_type = r.picking_type_id
r.name = picking_type.sequence_id.next_by_id()
return res

Kabir Khan
Author

name = fields.Char('Reference', default='/', copy=False, readonly=True)

i update this and also upgrade module but still is show

Reference must be unique per company!

Kabir Khan
Author

its working but when add more then one...
Reference must be unique per company!

i update the code and remove index but not working should i change too in pgadmin ?

Kabir Khan
Author

Done thank you

Kabir Khan
Author

sequence number not prefect its mismatch

Dương Nguyễn

I don't understand, how you want it to match ? The logic behind it is like if you have picking 001, 002 already the next one will always be 003 you can't change that

Kabir Khan
Author

this is +1 number in when we confirm sale order and then after we validate it another +1 so 1 number is mismatching

Dương Nguyễn

Can you share me a video , i might be able to troubleshot for you ?

Kabir Khan
Author

when i confirm the quotation in ir.sequence module where we to fetch next number its add automatically so sequence did not maintain its a gape 1 in every delivery challan

Kabir Khan
Author

when we click confirm sale order it will create sequence in backend we want to fixed this then this functionality will work perfectly

Kabir Khan
Author

my question only is this we don't want to also create sequence number if delivery challan not generated.

your answer is work but sequence is not maintain its increment 2 times ir.sequence table next number...

hope you understand

Dương Nguyễn

Oh i found the bug, because in the original create method, odoo already increase it so in the ovveride i give i increase it to. So here is the modify code
def write(self, vals):
res = super().write(vals)
for r in self:
if r.name == '/' and r.state == 'done':
picking_type = r.picking_type_id
if picking_type.sequence_id.number_next_actual > 0:
picking_type.sequence_id.number_next_actual -= 1
r.name = picking_type.sequence_id.next_by_id()
return res

Kabir Khan
Author

are you sure you changes in write method ? what about create method ?

Dương Nguyễn

i test and it work but i am not sure whether this create more bug or not because your use case is strange you know,
Good Luck sir

Kabir Khan
Author

not working mismatch sequence number

whole code
--------------------

from odoo import api, fields, models

class CustomStockPicking(models.Model):
_inherit = 'stock.picking'

name = fields.Char('Reference', default='/', copy=False, readonly=True)
_sql_constraints = [
('name_uniq', 'unique(company_id)', 'Reference must be unique per company!'),
]

@api.model
def create(self, vals):
res = super(CustomStockPicking, self).create(vals)
for r in res:
if r.name != '/' and r.state != 'done':
r.name = '/'
return res

def write(self, vals):
res = super(CustomStockPicking, self).write(vals)
for r in self:
picking_type = None # Initialize picking_type with a default value
if r.name == '/' and r.state == 'done':
picking_type = r.picking_type_id
if picking_type.sequence_id.number_next_actual > 0:
picking_type.sequence_id.number_next_actual -= 1
r.name = picking_type.sequence_id.next_by_id()
return res

Dương Nguyễn

Ok at least i try, thank you anyway

Kabir Khan
Author

still gape 1 to 2 you can check both side via confirming order and direct create transfer still issue in sequence number :(

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

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

Sign up
Related Posts Replies Views Activity
inherit stock.picking
community stock_picking sale.order v15
Avatar
Avatar
1
Mar 24
3654
How to call another models onchange function in my custom model, when we call that , i want to work the fucntion
community v15
Avatar
Avatar
Avatar
2
Aug 23
3238
500: Internal Server Error in odoo Community 15 Solved
community v15
Avatar
Avatar
Avatar
2
May 23
3371
Can i call another models onchange function from my custom model?
community v15
Avatar
Avatar
1
Apr 23
3590
odoo ocr
community v15
Avatar
0
Jun 22
2441
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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