1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
# |
3
|
|
|
# This file is part of SENAITE.CORE |
4
|
|
|
# |
5
|
|
|
# Copyright 2018 by it's authors. |
6
|
|
|
# Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst. |
7
|
|
|
|
8
|
|
|
from AccessControl import ClassSecurityInfo |
9
|
|
|
from bika.lims import bikaMessageFactory as _ |
10
|
|
|
from bika.lims.browser.fields.remarksfield import RemarksField |
11
|
|
|
from bika.lims.browser.widgets import RemarksWidget |
12
|
|
|
from bika.lims.config import PRICELIST_TYPES |
13
|
|
|
from bika.lims.config import PROJECTNAME |
14
|
|
|
from bika.lims.content.bikaschema import BikaSchema |
15
|
|
|
from bika.lims.interfaces import IDeactivable |
16
|
|
|
from bika.lims.interfaces import IPricelist |
17
|
|
|
from DateTime import DateTime |
18
|
|
|
from Products.Archetypes.public import BaseFolder |
19
|
|
|
from Products.Archetypes.public import BooleanField |
20
|
|
|
from Products.Archetypes.public import BooleanWidget |
21
|
|
|
from Products.Archetypes.public import DecimalWidget |
22
|
|
|
from Products.Archetypes.public import FixedPointField |
23
|
|
|
from Products.Archetypes.public import Schema |
24
|
|
|
from Products.Archetypes.public import SelectionWidget |
25
|
|
|
from Products.Archetypes.public import StringField |
26
|
|
|
from Products.Archetypes.public import registerType |
27
|
|
|
from zope.interface import implements |
28
|
|
|
|
29
|
|
|
|
30
|
|
|
schema = BikaSchema.copy() + Schema(( |
31
|
|
|
|
32
|
|
|
StringField( |
33
|
|
|
"Type", |
34
|
|
|
required=1, |
35
|
|
|
vocabulary=PRICELIST_TYPES, |
36
|
|
|
widget=SelectionWidget( |
37
|
|
|
format="select", |
38
|
|
|
label=_("Pricelist for"), |
39
|
|
|
), |
40
|
|
|
), |
41
|
|
|
|
42
|
|
|
BooleanField( |
43
|
|
|
"BulkDiscount", |
44
|
|
|
default=False, |
45
|
|
|
widget=SelectionWidget( |
46
|
|
|
label=_("Bulk discount applies"), |
47
|
|
|
), |
48
|
|
|
), |
49
|
|
|
|
50
|
|
|
FixedPointField( |
51
|
|
|
"BulkPrice", |
52
|
|
|
widget=DecimalWidget( |
53
|
|
|
label=_("Discount %"), |
54
|
|
|
description=_("Enter discount percentage value"), |
55
|
|
|
), |
56
|
|
|
), |
57
|
|
|
|
58
|
|
|
BooleanField( |
59
|
|
|
"Descriptions", |
60
|
|
|
default=False, |
61
|
|
|
widget=BooleanWidget( |
62
|
|
|
label=_("Include descriptions"), |
63
|
|
|
description=_("Select if the descriptions should be included"), |
64
|
|
|
), |
65
|
|
|
), |
66
|
|
|
|
67
|
|
|
RemarksField( |
68
|
|
|
"Remarks", |
69
|
|
|
searchable=True, |
70
|
|
|
widget=RemarksWidget( |
71
|
|
|
label=_("Remarks"), |
72
|
|
|
), |
73
|
|
|
)), |
74
|
|
|
) |
75
|
|
|
|
76
|
|
|
Field = schema["title"] |
77
|
|
|
Field.required = 1 |
78
|
|
|
Field.widget.visible = True |
79
|
|
|
|
80
|
|
|
Field = schema["effectiveDate"] |
81
|
|
|
Field.schemata = "default" |
82
|
|
|
# If no date is selected the item will be publishedimmediately. |
83
|
|
|
Field.required = 0 |
84
|
|
|
Field.widget.visible = True |
85
|
|
|
|
86
|
|
|
Field = schema["expirationDate"] |
87
|
|
|
Field.schemata = "default" |
88
|
|
|
# If no date is chosen, it will never expire. |
89
|
|
|
Field.required = 0 |
90
|
|
|
Field.widget.visible = True |
91
|
|
|
|
92
|
|
|
|
93
|
|
|
class Pricelist(BaseFolder): |
94
|
|
|
"""Pricelist content |
95
|
|
|
""" |
96
|
|
|
implements(IPricelist, IDeactivable) |
97
|
|
|
|
98
|
|
|
security = ClassSecurityInfo() |
99
|
|
|
displayContentsTab = False |
100
|
|
|
schema = schema |
|
|
|
|
101
|
|
|
_at_rename_after_creation = True |
102
|
|
|
|
103
|
|
|
def _renameAfterCreation(self, check_auto_id=False): |
104
|
|
|
from bika.lims.idserver import renameAfterCreation |
105
|
|
|
renameAfterCreation(self) |
106
|
|
|
|
107
|
|
|
@security.public |
108
|
|
|
def current_date(self): |
109
|
|
|
""" return current date """ |
110
|
|
|
return DateTime() |
111
|
|
|
|
112
|
|
|
|
113
|
|
|
registerType(Pricelist, PROJECTNAME) |
114
|
|
|
|