Can not write the value in the field of the child table with frappe.db.sql

I am trying to write a value to a field in a child table when I save a document.

class reg_inc (Document):
def validate (self):
sql_zapros = “update tabtest_child_table set sec_data = ‘uuu’ where name = ‘c805b51a68’;”
frappe.db.sql (sql_zapros)
frappe.db.commit ()

nothing is saved.

If I do the same operation for another arbitrary doctype (not child), everything works.

if I make the same request through the console for child doctype, everything works too.

What is the problem with child doctypes?

Привет Дмитрий,

Try to check your SQL database if there are changes. Changes made through frappe.db.sql won’t immediately show because of the cache you may want to refresh your browser.

If you have the child doctype as table on a parent doctype, try accessing the properties of the child doctypes directly.



thanks for the answer ,
I checked in the database through the console, nothing changes.

Please clarify about
“try accessing the properties of the child doctypes directly”

How to do this, is there any special API for this?
In your example there is
validate_c_form_on_cancel function
with checking attributes c_form_applicable and c_form_no.
What are these attributes, where you can read about them?


That is just an example.

Example, if you have a DocType with a table field, items. You can access its properties.

class RegInc(Document):
    def validate(self):
        self.items[0].item_name = 'Test' # accessing the item_name