Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
1057 Widoki

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.

Awatar
Odrzuć
Autor

Thanks Ray

Najlepsza odpowiedź

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'

Awatar
Odrzuć
Autor

Thanks Nikhil

Najlepsza odpowiedź

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.

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
kwi 25
619
0
kwi 25
594
2
mar 25
941
0
lut 25
868
1
lut 25
1123