Hello, I am trying to obtain the value of a date that appears in the chat record, I am trying to save it in a calculated field of type date, but I have not been able to find a way to obtain it, I am trying to do this in the stock.picking model and the specific date is a status of a transfer, for example "confirmed", I appreciate any help or guidance.
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ờ
Hi,
To obtain the value of a date associated with a
specific status in a stock.picking record and save it in a calculated
field of type date, you can achieve this using Odoo's computed fields
and searching through the stock.picking records based on their status.
Here's a general outline of how you can implement this:
Define a computed field in the stock.picking model to store the desired date value.
Use
the @api.depends decorator to specify the dependencies for the computed
field. In this case, it will depend on the status of the picking.
Implement
the logic inside the computed field method to search for records with
the desired status and retrieve the associated date value.
Here's an example implementation:from odoo import models, fields, api
class StockPicking(models.Model):
_inherit = 'stock.picking'
# Define a computed field to store the desired date value
status_date = fields.Date(string='Status Date', compute='_compute_status_date', store=True)
@api.depends('state')
def _compute_status_date(self):
for picking in self:
# You can customize this logic based on your specific requirements
if picking.state == 'confirmed':
# Search for related moves, for example
move = self.env['stock.move'].search([('picking_id', '=', picking.id)], limit=1)
if move:
picking.status_date = move.date # Assign the date value to the computed field
else:
picking.status_date = False # No move found, set the field value to False
else:
picking.status_date = False # Set the field value to False if the status is not 'confirmed'
Hope it helps
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 | |
---|---|---|---|---|
|
1
thg 4 24
|
3256 | ||
|
2
thg 2 24
|
3496 | ||
ODOO Studio Calculate
Đã xử lý
|
|
1
thg 10 18
|
4865 | |
|
3
thg 2 24
|
2898 | ||
|
3
thg 1 24
|
2367 |