Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
5 Trả lời
22293 Lượt xem

Hello, 


Currenty sales order date is automatically set as today's date.

Where to change it so that we can update it manually?

Thanks in advance

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hello, you've probably solved this already, but I see that when searching anything for this issue, your question pops out first. Just to make things clear, I've sorted this out completely easily:

When you apply any changes to the PY files, you have to restart your server for the changes to take place. The comment (#) of line 783, does make the order date to become the same as quotation's date, when you confirm the order, but it doesn't make the field editable. 

To make the field editable, in the same sale.py file, you have to add 'sale': [('readonly'False)] and the date field becomes editable. Here is what i've done:

Line 155:     date_order = fields.Datetime(string='Order Date'required=Truereadonly=Trueindex=Truestates={'draft': [('readonly'False)], 'sent': [('readonly'False)], 'sale': [('readonly'False)]}, copy=Falsedefault=fields.Datetime.now, help="Creation date of draft/sent orders,\nConfirmation date of confirmed orders.")

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

In order to edit the order, you need to change the readonly attribute of order_date field.

Create a custom module,and inherit sale.order model.Then give the code as shown below.


class SaleOrder(models.Model):
    _inherit = 'sale.order'
CUSTOM_FIELD_STATES = {
    state: [('readonly', False)]
    for state in {'sale', 'done', 'cancel'}
}
    date_order = fields.Datetime(
        string="Order Date",
        states=CUSTOM_FIELD_STATES,
        copy=False, required=True,
        help="Creation date of draft/sent orders,\nConfirmation date of "
             "confirmed orders.")


Hope it helps


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

did you resolve this one?

I also want to manually update the Sale Order confirmation date.

I already tried to comment out the line 783# 'date_order': fields.Datetime.now()
but it is not working. It still auto fill the order date and can not be changed any more 

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

as I am not a technical personal, I am not sure about your reply and don't know where to apply the change.

Could you please be more specific? thanks in advance

 
Ảnh đại diện
Huỷ bỏ

you cannot achieve this by editing in the front end, either you have to make changes directly in the odoo source code(which is not a good way) or you have to create a custom module and inherit the method action_confirm in the sale.order model

Tác giả

Ok so I would like to do it from the odoo source code, any chance you can help me?

Câu trả lời hay nhất

Yeah i have the same problem, I have commented the line et it still gives me today's date and time.

how do you restart the server ?

Thanks

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 4 22
2530
2
thg 4 21
7764
1
thg 7 16
4551
1
thg 3 15
3851
0
thg 1 25
1364