Giter Site home page Giter Site logo

django-oscar-invoices's Introduction

django-oscar-invoices

Quickstart

Installation

$ pip install django-oscar-invoices

Setup

  1. Add oscar_invoices to the INSTALLED_APPS variable of your project's settings.py.
  2. Sync the database using python manage.py migrate.
  3. Create instances of LegalEntity and LegalEntityAddress.
  4. Integrate InvoiceCreator in your checkout process.

By default, we generate only HTML invoice document and allow user to decide how to generate PDF documents. You can integrate python-pdfkit, WeasyPrint, xhtml2pdf, reportlab or another library of your choice.

Since documents contains sensitive data, we store them out of the media folder and do not provide public access via URL. For this purpose, we use custom storage class oscar_invoices.storages.DocumentsStorage, invoice documents placed into the nested folder settings.OSCAR_INVOICES_UPLOAD_FOLDER and available for the admin users via dashboard order list.

You can find more information in documentation.

Sandbox

Sandbox environment set up to automatically create invoices on checkout. But for this, instances of LegalEntity and LegalEntityAddress must be created (from admin site) before order placement.

django-oscar-invoices's People

Contributors

jaroel avatar jayvdb avatar phedoreanu avatar samitnuk avatar specialunderwear avatar viggo-devries avatar woutdp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-oscar-invoices's Issues

Potential race-conditions -> Duplicated Invoice Numbers ???

Think there is a potential problem: Invoices with the same numbers could be generated.

oscar_invoices.utils.InvoiceCreator does this:

    def generate_invoice_number(self, **kwargs):
        Invoice = self.get_invoice_model()
        pk = Invoice.get_last_pk() + 1
        return '%06d' % pk

last pk +1 doesn't guarantee that duplicate invoice numbers will not be created when a next invoice is generated before the previous one is saved.

Solution could be to lock the table. Or else: Create a new Invoice instance first and then use the pk from the created instance, isn't it?

execution error

ImportError: cannot import name 'OSCAR_MAIN_TEMPLATE_DIR' from 'oscar' (C:\justin\environments\venv3.7\lib\site-packages\oscar_init_.py)

key error when adding new invoice

I was able to create my legal entity and address in the admin app. Not sure if thats intended, but i did not find anything in /dashboard.

From there I tried adding the invoice directly in django admin app and i get...


Django Version: 1.11.15
Python Version: 3.4.9
Installed Applications:
['ar_django',
 'artificial_reason',
 'oscar_invoices',
 'cms',
 'menus',
 'sekizai',
 'filer',
 'easy_thumbnails',
 'mptt',
 'djangocms_text_ckeditor',
 'djangocms_admin_style',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.sites',
 'allauth',
 'allauth.account',
 'allauth.socialaccount',
 'allauth.socialaccount.providers.google',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.flatpages',
 'compressor',
 'widget_tweaks',
 'oscar',

// REMOVED EXTRANEOUS JUNK ...

File "/virtualenv/lib/python3.4/site-packages/django/utils/encoding.py" in force_text
  76.                     s = six.text_type(s)

File "/virtualenv/lib/python3.4/site-packages/oscar_invoices/abstract_models.py" in __str__
  105.             'Invoice %(invoice_number)s') % {'number': self.number}

File "/virtualenv/lib/python3.4/site-packages/django/utils/functional.py" in __mod__
  162.                 return six.text_type(self) % rhs

Exception Type: KeyError at /admin/oscar_invoices/invoice/add/
Exception Value: 'invoice_number'

not possible to use own OSCAR_INVOICES_INVOICE_MODEL

The django orm will create migrations if i try to use a own model via OSCAR_INVOICES_INVOICE_MODEL
e.g.:

Migrations for 'oscar_invoices':
  /usr/local/lib/python3.6/site-packages/oscar_invoices/migrations/0003_auto_20190312_1322.py
    - Remove field legal_entity from invoice
    - Remove field order from invoice
    - Delete model Invoice

Use get_class for oscar_invoice.utils.InvoiceCreator

Currently overriding oscar_invoice.utils.InvoiceCreator is non trivial because it is not loaded with get_class. The only way to make this possible is to add one more namespace to the application. Let's say we add a namespace called 'poepie' making the folder structure like this:

oscar_invoices/poepie/utils.py

that would allow using get_class like this:

InvoiceCreator = get_class("poepie.utils", "Invoice_creator", "oscar_invoices")

You can not use get_class with only 2 namespace levels, you CAN however use get_model (it is implemented completely different).

Please suggest the 3rd namespace name and I will create a PR.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.