跳至内容
菜单
此问题已终结

If we face the support from the client to update the Quotation Date in the  sale module, when the fields was in readonly, is there any options in odoo to do that without the DB access and SSH access, only with the admin username and password.

Is it possible in odoo ? if it's there  any options means, let me know the proper way to update the data.

形象
丢弃
编写者

Thanks Ray

最佳答案

1. Use Odoo's Debug Mode

Enable Developer Mode:


Go to your Odoo instance.

Add ?debug=1 to the URL or use the developer tools from the settings menu.

Modify Field Properties Temporarily:


Navigate to the form where the field is readonly.

Use the developer tools to locate the field (Inspect Field option).

Temporarily remove the readonly attribute in the view by duplicating the view and editing it via the "Edit View: Form" menu.

Example:


Locate the XML snippet in the view:

xml

Copy code

<field name="quotation_date" readonly="1"/>

Remove readonly="1" or set it conditionally:

xml

Copy code

<field name="quotation_date" attrs="{'readonly': [('state', '=', 'done')]}"/>

Save and Reload:


After saving the view, reload the form. The field will now be editable.


2. Use Automated Actions

If modifying the field directly is not an option, you can use an automated action to update the field value programmatically.


Steps:

Go to Settings > Technical > Automated Actions.


Create a New Automated Action:


Model: Select the model you want to update (eg, sale.order).

Trigger: Choose On Update or On Time-Based Conditions.

Action: Add Python code to update the field.

Example:


python

Copy code

if record.id == your_record_id:

    record.quotation_date = '2023-12-01'

形象
丢弃
编写者

Thanks Nikhil

最佳答案

The Quotation date is only readonly once the Quotation has been confirmed into a Sales Order.

Assuming you want to update the Order Date (date_order) of a Sales Order (which is updated to the Date the Quotation was confirmed) you can do this in a Server Action.

Activate Developer Mode


Create a Server Action


sale_order = env['sale.order'].search([('name','=','S00019')])

if sale_order:
    sale_order['date_order'] = '2024-12-01'


Using Server Action as the model allows you to see the RUN button so you can execute the code. 


 - this approach can bypass business logic​, so only do it if you know what the impact of your changes will be (and test first in a duplicate database) and only do this on simple fields - you can't back date transactions impacting inventory or accounting transactions for example.

形象
丢弃
相关帖文 回复 查看 活动
1
4月 25
307
0
4月 25
222
2
3月 25
558
0
2月 25
492
1
2月 25
653