Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SqliteError insert into PrintTemplate (address, created, createdBy, date, header, height, isCustom, logo, `... #863

Open
struanmccallum opened this issue Feb 29, 2024 · 5 comments

Comments

@struanmccallum
Copy link

struanmccallum commented Feb 29, 2024

Steps to reproduce:

  1. Open Frappe Books from App drawer in MacOS
  2. Attempt to load the most recent .db file
  3. Results in error pop-up:
image

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%0A

Steps%20to%20Reproduce

%0AAdd%20steps%20to%20reproduce%20the%20error...%0A%0A

Info

%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%27scionmyth@gmail.com%27,%20NULL,%20%27Header%27,%2029.7,%200,%20NULL,%20%272024-02-29T02:08:59.089Z%27,%20%27scionmyth@gmail.com%27,%20%27Basic%20-%20Sales%20Invoice%27,%20%27%0A%20%20%0A%20%20%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%7B%7B%20print.companyName%20%7D%7D%0A%20%20%20%20%20%20%0A%20%20%20%20%0A%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%20%20
%7B%7B%20print.email%20%7D%7D
%0A%20%20%20%20%20%20%7B%7B%20print.phone%20%7D%7D%0A%20%20%20%20%0A%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%20%20%7B%7B%20print.links.address.addressDisplay%20%7D%7D%0A%20%20%20%20%20%20GSTIN:%20%7B%7B%20print.gstin%20%7D%7D%0A%20%20%20%20%0A%20%20%0A%0A%20%20%0A%20%20%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%20%20%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%0A%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%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%0A%20%20%0A%0A%20%20%0A%20%20%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%20%20%7B%7B%20t%60Item%60%20%7D%7D%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%7B%7B%20t%60HSN/SAC%60%20%7D%7D%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%7B%7B%20t%60Quantity%60%20%7D%7D%0A%20%20%20%20%20%20%7B%7B%20t%60Rate%60%20%7D%7D%0A%20%20%20%20%20%20%7B%7B%20t%60Amount%60%20%7D%7D%0A%20%20%20%20%0A%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%20%20%7B%7B%20row.item%20%7D%7D%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%7B%7B%20row.hsnCode%20%7D%7D%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%7B%7B%20row.quantity%20%7D%7D%0A%20%20%20%20%20%20%7B%7B%20row.rate%20%7D%7D%0A%20%20%20%20%20%20%7B%7B%20row.amount%20%7D%7D%0A%20%20%20%20%0A%20%20%0A%0A%20%20%0A%20%20%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%7B%7B%20t%60Notes%60%20%7D%7D%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%7B%7B%20doc.terms%20%7D%7D

%0A%20%20%20%20%0A%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20

%7B%7B%20t%60Subtotal%60%20%7D%7D

%0A%20%20%20%20%20%20%20%20

%7B%7B%20doc.netTotal%20%7D%7D

%0A%20%20%20%20%20%20%0A%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20

%7B%7B%20t%60Discount%60%20%7D%7D

%0A%20%20%20%20%20%20%20%20

%7B%7B%20doc.totalDiscount%20%7D%7D

%0A%20%20%20%20%20%20%0A%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20

%7B%7B%20tax.account%20%7D%7D

%0A%20%20%20%20%20%20%20%20

%7B%7B%20tax.amount%20%7D%7D

%0A%20%20%20%20%20%20%0A%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20

%7B%7B%20t%60Discount%60%20%7D%7D

%0A%20%20%20%20%20%20%20%20

%7B%7B%20doc.totalDiscount%20%7D%7D

%0A%20%20%20%20%20%20%0A%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20

%7B%7B%20t%60Grand%20Total%60%20%7D%7D

%0A%20%20%20%20%20%20%20%20

%7B%7B%20doc.grandTotal%20%7D%7D

%0A%20%20%20%20%20%20%0A%20%20%20%20%0A%20%20%0A%27,%20%27SalesInvoice%27,%2021)%20-%20NOT%20NULL%20constraint%20failed:%20PrintTemplate.date_%0A%0A**Stack**:%0A%60%60%60%0ASqliteError:%20insert%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%27scionmyth@gmail.com%27,%20NULL,%20%27Header%27,%2029.7,%200,%20NULL,%20%272024-02-29T02:08:59.089Z%27,%20%27scionmyth@gmail.com%27,%20%27Basic%20-%20Sales%20Invoice%27,%20%27%0A%20%20%0A%20%20%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%7B%7B%20print.companyName%20%7D%7D%0A%20%20%20%20%20%20%0A%20%20%20%20%0A%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%20%20
%7B%7B%20print.email%20%7D%7D
%0A%20%20%20%20%20%20%7B%7B%20print.phone%20%7D%7D%0A%20%20%20%20%0A%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%20%20%7B%7B%20print.links.address.addressDisplay%20%7D%7D%0A%20%20%20%20%20%20GSTIN:%20%7B%7B%20print.gstin%20%7D%7D%0A%20%20%20%20%0A%20%20%0A%0A%20%20%0A%20%20%0A%20%20%20%20%0A%20%20%20%20%0A%20%20%20%20%20%20
@struanmccallum
Copy link
Author

I should mention it was working fine in the previous version(s).

@Isaac-GC
Copy link
Collaborator

Isaac-GC commented Mar 4, 2024

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 }}
    
  

  
  
    
    
      

@Isaac-GC
Copy link
Collaborator

Isaac-GC commented Mar 4, 2024

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
image

Let me know what you find out!

@struanmccallum
Copy link
Author

struanmccallum commented Mar 4, 2024

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

@Isaac-GC
Copy link
Collaborator

Isaac-GC commented Mar 4, 2024

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)
image

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:

  1. Use DB Browser to load the database (this is the easiest way)
  2. 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
  3. Open up Frappe Books and navigate to Customize Forms
  4. Delete the "Print Template" entry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants