books
books copied to clipboard
SqliteError insert into `PrintTemplate` (`address`, `created`, `createdBy`, `date`, `header`, `height`, `isCustom`, `logo`, `...
Steps to reproduce:
- Open Frappe Books from App drawer in MacOS
- Attempt to load the most recent .db file
- Results in error pop-up:
Environmental settings:
- MacOS Sonoma 14.3.1 Stable release running on 2020 MacBook Air M1 (more than 50% storage available)
- Microsoft Edge 122 latest stable release
- Frappe Books Version 0.21.2 (0.21.2)
Not sure if this is helpful - here is the body of the 'Report' that was generated after clicking 'Report'. GitHub rejected the full string URL as it was too long just FYI (and ANY help appreciated):
Description
%0AAdd%20some%20description...%0A%0ASteps%20to%20Reproduce
%0AAdd%20steps%20to%20reproduce%20the%20error...%0A%0AInfo
%0A%0A**Error**:%20_DatabaseError:%20SqliteError%0Ainsert%20into%20%60PrintTemplate%60%20(%60address%60,%20%60created%60,%20%60createdBy%60,%20%60date%60,%20%60header%60,%20%60height%60,%20%60isCustom%60,%20%60logo%60,%20%60modified%60,%20%60modifiedBy%60,%20%60name%60,%20%60template%60,%20%60type%60,%20%60width%60)%20values%20(NULL,%20%272024-02-29T02:08:59.089Z%27,%20%[email protected]%27,%20NULL,%20%27Header%27,%2029.7,%200,%20NULL,%20%272024-02-29T02:08:59.089Z%27,%20%[email protected]%27,%20%27Basic%20-%20Sales%20Invoice%27,%20%27%7B%7B%20doc.name%20%7D%7D
%0A%20%20%20%20%20%20%7B%7B%20doc.date%20%7D%7D
%0A%20%20%20%20%7B%7B%20doc.party%20%7D%7D
%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%7B%7B%20doc.links.party.links.address.addressDisplay%20%7D%7D%0A%20%20%20%20%20%20
%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20GSTIN:%20%7B%7B%20doc.partyGSTIN%20%7D%7D%0A%20%20%20%20%20%20
%0A%20%20%20%20
I should mention it was working fine in the previous version(s).
I copied the above and url decoded it to make it a little easier to read (using https://gchq.github.io/CyberChef/#recipe=URL_Decode()):
Add some description...
Steps to Reproduce
Add steps to reproduce the error...
Info
**Error**: _DatabaseError: SqliteError
insert into `PrintTemplate` (`address`, `created`, `createdBy`, `date`, `header`, `height`, `isCustom`, `logo`, `modified`, `modifiedBy`, `name`, `template`, `type`, `width`) values (NULL, '2024-02-29T02:08:59.089Z', '<censored>@gmail.com', NULL, 'Header', 29.7, 0, NULL, '2024-02-29T02:08:59.089Z', '<censored>@gmail.com', 'Basic - Sales Invoice', '
{{ print.companyName }}
{{ print.email }}
{{ print.phone }}
{{ print.links.address.addressDisplay }}
GSTIN: {{ print.gstin }}
{{ doc.name }}
{{ doc.date }}
{{ doc.party }}
{{ doc.links.party.links.address.addressDisplay }}
GSTIN: {{ doc.partyGSTIN }}
{{ t`Item` }}
{{ t`HSN/SAC` }}
{{ t`Quantity` }}
{{ t`Rate` }}
{{ t`Amount` }}
{{ row.item }}
{{ row.hsnCode }}
{{ row.quantity }}
{{ row.rate }}
{{ row.amount }}
{{ t`Notes` }}
{{ doc.terms }}
{{ t`Subtotal` }}
{{ doc.netTotal }}
{{ t`Discount` }}
{{ doc.totalDiscount }}
{{ tax.account }}
{{ tax.amount }}
{{ t`Discount` }}
{{ doc.totalDiscount }}
{{ t`Grand Total` }}
{{ doc.grandTotal }}
', 'SalesInvoice', 21) - NOT NULL constraint failed: PrintTemplate.date_
**Stack**:
```
SqliteError: insert into `PrintTemplate` (`address`, `created`, `createdBy`, `date`, `header`, `height`, `isCustom`, `logo`, `modified`, `modifiedBy`, `name`, `template`, `type`, `width`) values (NULL, '2024-02-29T02:08:59.089Z', '<censored>@gmail.com', NULL, 'Header', 29.7, 0, NULL, '2024-02-29T02:08:59.089Z', '<censored>@gmail.com', 'Basic - Sales Invoice', '
{{ print.companyName }}
{{ print.email }}
{{ print.phone }}
{{ print.links.address.addressDisplay }}
GSTIN: {{ print.gstin }}
It looks like it is injecting a NULL date when updating the PrintTemplate --> From what I can see, its perhaps updates between frappe books versions and a db patch that didn't get applied.
If possible, can I have you build/provide a sample DB that is having the error occur please?
If you're not comfortable with sharing the DB, you can download DB Browser for Sqlite (or some other DB manager) and check in the SalesInvoice
table to see if this column is blank
Let me know what you find out!
struan-books.db.zip Hi Isaac - I've uploaded the DB in a ZIP file - the contents are not super important but it would be handy to be able to access them without having to revert to an older version of FB.
Just FYI I opened the DB in the DB Browser and I discovered that this column is NOT blank. Is it something else?
Cheers StruanM
You shouldn't need to revert to an older version of Frappe Books.
The issue lies in somewhere in the Custom Fields set in the Customize Form's 'PrintTemplate' Entry. As you added 4 new custom fields (header
, date
, address
, logo
), the database set these values as the same as the actual column name (i.e. Header for header
)
Not sure if this the intended way that its supposed to behave, but I'm pretty sure its not especially as when I replace the Date
with an actual date (i.e. 2024-01-01T00:00:00.000Z
), the database loads as it should. I'll have to look into the issue deeper, but for now there a couple workarounds that I recommend:
-
If you don't absolutely need the Customize Form 'PrintTemplate' entry in there. The options you had listed (
header
,date
,address
,logo
) are available in the default print templates and you shouldn't need to have custom items for that. -
If you do need the Customize Form 'PrintTemplate', just ignore steps 3 and 4 of the fix below
FIX:
- Use DB Browser to load the database (this is the easiest way)
- Open up the "PrintTemplate" Table, and update the Date to some arbitrary Date (i.e. copy from the "created" or "modified" column) -> Make sure to hit "Write Changes" after you did this
- Open up Frappe Books and navigate to Customize Forms
- Delete the "Print Template" entry