Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More

products : defining the things you sell and buy

The lino_xl.lib.products plugin adds functionality for managing “products”.

Side note: Code snippets (lines starting with >>>) in this document get tested as part of our development workflow. The following initialization snippet tells you which demo project is being used in this document.

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

Overview

product

Something you can trade (e.g. sell, buy, rent) in an item of a trade voucher. Mostly a name and a price. It can be material (a good) or immaterial (a service). Database model: Product.

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

product category

A group of products that fit together.

See Product categories.

product type

A name for the nature or type of a set of products.

Used for example to differentiate between “Services” and “Goods”.

The detail layout of a product can vary depending on its type, but not depending on its category.

Every application has its specific list of product types. This list can be locally modified by the server administrator.

Rule of thumb: product categories can get edited by end users while product types are hard-coded by the application developer.

price factor

A property of a partner that may influence the price of certain products.

The list of price factors is meant to be defined by the application developer. Changing it locally would also require changes in the some layouts. Changes to this list may require a database migration because every price factor causes a field to be injected to the lino_xl.lib.contacts.Partner model.

price rules

A set of rules that specify which product to use for a given price selector and a given set of price factors.

price selector

A database object used to specify “what is being sold” in price rules.

In Lino Voga and Lino Presto we use the calendar entry type as price selector, in Lino Noi the lino_xl.lib.working.SessionType.

Dependencies

The lino_xl.lib.trading plugins injects a sales_price field to the product model.

Products

class lino_xl.lib.products.Product

Django model to represent a product.

name

A one-line designation for this product.

body

The long 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.

category

The category of this product.

This is a pointer to Category. The selection list is limited to those 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.

body_short_preview

See lino.modlib.memo.Previewable.body_short_preview.

body_full_preview

See lino.modlib.memo.Previewable.body_full_preview.

barcode_svg

A htmlbox showing the barcode of this product.

get_ruled_price(self, partner, selector)

Return the product to use for this partner and this selector according to the price rules.

class lino_xl.lib.products.Products

Base class for all tables of 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
 10   Book                                                             Book                                                             Book                                                             Sonstige          29,90
 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
 11   Stamp                                                            Stamp                                                            Stamp                                                            Sonstige          1,40
 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
                                                                                                                                                                                                                           **675,25**
==== ================================================================ ================================================================ ================================================================ ================= ===============

Product categories

The list of available product categories of a site can be modified by end users with appropriate permission via Configure ‣ Products ‣ Categories or Configure ‣ Sales ‣ Categories.

>>> show_menu_path(products.Categories, language="en")
Configure --> Sales --> Product Categories
>>> rt.show(products.Categories, language="en")
==== ======== ================= =============================== ================== ==============
 ID   Parent   Designation       Designation (fr)                Designation (en)   Product type
---- -------- ----------------- ------------------------------- ------------------ --------------
 1             Möbel             Meubles                         Furniture          Products
 2             Website-Hosting   Hébergement de sites Internet   Website Hosting    Products
 3             Sonstige          Autre                           Other              Products
==== ======== ================= =============================== ================== ==============
class lino_xl.lib.products.Category

Django model used to represent a product category.

product_type

The product type to apply to products of this category.

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    Stunden
 20     piece   Stück
 30     kg      Kg
 40     box     Dosen
====== ======= =========

Price rules

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

class lino_xl.lib.products.PriceFactors

The choicelist of price factors.

This list is empty by default. See Lino Tera or Lino Presto for examples of applications that use price factors.

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

The sequence number of this rule. Lino loops over price rules in this order and returns the first one that applies.

product

The product to use for getting the price when this rule applies.

selector

Either None or an additional selector for this price rule.

When given, this must be an instance of lino_xl.lib.products.Plugin.price_selector.

Every price rule also has one automatic field for each price factor.

class lino_xl.lib.products.PriceRules

The list of price rules.

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

Plugin settings

products.barcodes_driver

Which barcode driver to use on this site.

Default is None. Allowed values: “ean13”, “ean8”.

This plugin requires the python-barcode Python package when products.barcodes_driver is not None.