Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

from builtins import object 

from lino.api import dd 

from lino import mixins 

from django.utils.translation import ugettext_lazy as _ 

 

 

class Categories(dd.ChoiceList): 

    verbose_name = _("Category") 

    verbose_name_plural = _("Categories") 

 

Categories.add_item("01", _("Hardware"), 'hardware') 

Categories.add_item("02", _("Service"), 'service') 

Categories.add_item("03", _("Accessories"), 'accessories') 

Categories.add_item("04", _("Software"), 'software') 

 

 

class Product(mixins.BabelNamed): 

 

    price = dd.PriceField(_("Price"), blank=True, null=True) 

 

    category = Categories.field(blank=True, null=True) 

 

    class Meta(object): 

        verbose_name = 'Product' 

        verbose_name_plural = 'Products' 

 

 

class Products(dd.Table): 

    model = Product 

    sort_order = ['name'] 

    column_names = "name category price *" 

    auto_fit_column_widths = True 

 

    detail_layout = """ 

    id price category 

    name 

    """ 

 

    insert_layout = dd.FormLayout(""" 

    name 

    category price 

    """, window_size=(40, 'auto'))