Currently, the Backorder created takes the next Delivery Order number. But I want it to be numbered as the created Delivery Order number plus a "-1" behind (Same as OpenERP(Odoo) V7.
E.g. I'm validating the Delivery Order number D000903, and there's a backorder that need to be created. Once I click Create Backorder, I want the backorder number to be D000903-1, instead of the next delivery order number D000904.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
you can override the default behavior by implementing a custom method. Here's an example of how you can achieve this:
from odoo import models, fields, api
class StockPicking(models.Model):
_inherit = 'stock.picking'
@api.model
def create_backorder(self):
"""Override create_backorder method to customize backorder numbering"""
res = super(StockPicking, self).create_backorder()
# Get the original delivery order
original_order = self.env['stock.picking'].browse(res['res_id'])
# Get the original delivery order number
original_order_number = original_order.name
# Split the number to extract the prefix and suffix
prefix, suffix = original_order_number.rsplit('-', 1) if '-' in original_order_number else (original_order_number, '')
# Increment the suffix by 1
new_suffix = int(suffix) + 1
# Create the new backorder number
backorder_number = f'{prefix}-{new_suffix}' if suffix else f'{original_order_number}-{new_suffix}'
# Update the backorder with the new number
backorder = self.env['stock.picking'].browse(res['context']['active_id'])
backorder.name = backorder_number
return res
In this code, we override the create_backorder method in the stock.picking model. We retrieve the original delivery order number and split it into the prefix and suffix parts. We increment the suffix by 1 and create the new backorder number by combining the prefix and the incremented suffix. Finally, we update the backorder record with the new number.
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
2
thg 12 24
|
5692 | ||
|
0
thg 6 22
|
2126 | ||
|
2
thg 3 22
|
3663 | ||
|
1
thg 2 22
|
2425 | ||
|
2
thg 3 21
|
3617 |