products : defining the things you sell and buy

The lino_xl.lib.products plugin adds functionality for managing "products".

A tested document

This is a tested document. The following instructions are used for initialization:

>>> from lino import startup
>>> startup('lino_book.projects.apc.settings.doctests')
>>> from lino.api.doctest import *

Overview

A product is something you can sell or buy. The lino_xl.lib.sales plugins injects a sales_price field to the product model.

Products can be grouped into categories, and every product must be of a given product type.

The difference between the category and the type of a product is that end-users can edit the former while the latter are to be provided by the application developer.

Products

class lino_xl.lib.products.Product

Django model to represent a product.

description

The description of this product.

This is a BabelField, so there will be one field for every language defined in lino.core.site.Site.languages.

product_type

The type of this product.

This field may not be blank and must be an item of ProductTypes.

The default value is set by the actor used for creating the product. Some product actors don't have a default product type, in that case the default value is ProductTypes.default.

cat

The category of this product.

This is a pointer to ProductCat, but the selection list is limited to thos categories having the same product_type.

delivery_unit

Pointer to DeliveryUnits

vat_class

The VAT class. Injected by lino_xl.lib.vat. If that plugin is not installed, vat_class is a dummy field.

class lino_xl.lib.products.Products
>>> rt.show(products.Products)
==== ================================================================ ================================================================ ================================================================ ================= ===============
 ID   Bezeichnung                                                      Bezeichnung (fr)                                                 Bezeichnung (en)                                                 Kategorie         Verkaufspreis
---- ---------------------------------------------------------------- ---------------------------------------------------------------- ---------------------------------------------------------------- ----------------- ---------------
 9    Bildbearbeitung und Unterhalt Website                            Traitement d'images et maintenance site existant                 Image processing and website content maintenance                 Website-Hosting   25,00
 6    EDV Konsultierung & Unterhaltsarbeiten                           ICT Consultation & maintenance                                   IT consultation & maintenance                                    Website-Hosting   30,00
 8    Programmierung                                                   Programmation                                                    Programming                                                      Website-Hosting   40,00
 7    Server software installation, configuration and administration   Server software installation, configuration and administration   Server software installation, configuration and administration   Website-Hosting   35,00
 2    Stuhl aus Holz                                                   Chaise en bois                                                   Wooden chair                                                     Möbel             99,99
 4    Stuhl aus Metall                                                 Chaise en métal                                                  Metal chair                                                      Möbel             79,99
 1    Tisch aus Holz                                                   Table en bois                                                    Wooden table                                                     Möbel             199,99
 3    Tisch aus Metall                                                 Table en métal                                                   Metal table                                                      Möbel             129,99
 5    Website-Hosting 1MB/Monat                                        Hébergement 1MB/mois                                             Website hosting 1MB/month                                        Website-Hosting   3,99
                                                                                                                                                                                                                           **643,95**
==== ================================================================ ================================================================ ================================================================ ================= ===============

Product categories

Product categories can be used to group products into "categories". Categories can be edited by the user via Configure ‣ Products ‣ Categories or Configure ‣ Sales ‣ Categories.

>>> show_menu_path(products.ProductCats)
Konfigurierung --> Verkauf --> Produktkategorien
class lino_xl.lib.products.ProductCat

Django model to represent a product category.

product_type

The product type to apply to products of this category.

>>> rt.show(products.ProductCats)
==== ================= =============================== ================== ============== =============
 ID   Bezeichnung       Bezeichnung (fr)                Bezeichnung (en)   Product type   description
---- ----------------- ------------------------------- ------------------ -------------- -------------
 1    Möbel             Meubles                         Furniture          Produkte
 2    Website-Hosting   Hébergement de sites Internet   Website Hosting    Produkte
==== ================= =============================== ================== ============== =============

Product types

Products can be differentiated by their "type". Types cannot be edited by the user. But every product type can have a layout on its own. Every product type has its own menu entry.

class lino_xl.lib.products.ProductType
text

The verbose name of this product type.

This string is used for the menu entries in Configure ‣ Products.

table_name

The name of the table to use for displaying a list of products with this type.

class lino_xl.lib.products.ProductTypes

The list of product types.

It should contain at least one item whose name is default.

For each item of this list the plugin adds one menu entry to the Configure menu.

default

The product type to be set on new products when they are created in an actor that doesn't have a default product type.

>>> rt.show(products.ProductTypes)
====== ========= ========== ===================
 Wert   name      Text       Table name
------ --------- ---------- -------------------
 100    default   Produkte   products.Products
====== ========= ========== ===================
class lino_xl.lib.products.DeliveryUnits

The list of possible delivery units of a product.

>>> rt.show(products.DeliveryUnits)
====== ======= =======
 Wert   name    Text
------ ------- -------
 10     hour    Hour
 20     piece   Piece
 30     kg      Kg
====== ======= =======

Price rules

Price rules can be used to define which products are available for a given partner, and to find a default product for a given context.

class lino_xl.lib.products.PriceFactors

A choicelist of "price factors".

This list is empty by default. Applications can define their specific price factors. Every price factor causes a field to be injected to the lino_xl.lib.contats.Partner model.

>>> rt.show(products.PriceFactors)
Keine Daten anzuzeigen
class lino_xl.lib.products.PriceRules

The list of price rules.

>>> rt.show(products.PriceRules)
Keine Daten anzuzeigen