"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!"
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Contabilitate
- Inventar
- PoS
- Project
- MRP
Această întrebare a fost marcată
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.
yes you are also right brother.
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
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
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
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
Hi Sir, i have modified the answer please check
ok ill check and reply
@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.
code is not working
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
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
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!
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 ?
Done thank you
sequence number not prefect its mismatch
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
this is +1 number in when we confirm sale order and then after we validate it another +1 so 1 number is mismatching
Can you share me a video , i might be able to troubleshot for you ?
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
when we click confirm sale order it will create sequence in backend we want to fixed this then this functionality will work perfectly
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
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
are you sure you changes in write method ? what about create method ?
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
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
Ok at least i try, thank you anyway
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!
Înscrie-teRelated Posts | Răspunsuri | Vizualizări | Activitate | |
---|---|---|---|---|
|
1
mar. 24
|
2173 | ||
|
2
aug. 23
|
2232 | ||
|
2
mai 23
|
2437 | ||
|
1
apr. 23
|
2606 | ||
|
0
iun. 22
|
1486 |