Exemplo n.º 1
0
from netforce import database
from netforce import ipc
import os
from netforce import access
from decimal import *
import decimal

_cache = {}


def _clear_cache():
    pid = os.getpid()
    print("currency _clear_cache pid=%s" % pid)
    _cache.clear()

ipc.set_signal_handler("clear_currency_cache", _clear_cache)


class Currency(Model):
    _name = "currency"
    _string = "Currency"
    _key = ["name"]
    _name_field = "code"
    _audit_log = True
    _fields = {
        "name": fields.Char("Name", required=True, search=True),
        "code": fields.Char("Code", required=True, search=True),
        "sign": fields.Char("Sign", required=True),
        "iso_number": fields.Char("ISO Number"),
        "rates": fields.One2Many("currency.rate", "currency_id", "Rate History"),
        "sell_rate": fields.Decimal("Current Sell Rate", scale=6, function="get_current_rate", function_multi=True),
Exemplo n.º 2
0
from netforce import database
from netforce import ipc
import os
from netforce import access
from decimal import *
import decimal

_cache = {}


def _clear_cache():
    pid = os.getpid()
    print("currency _clear_cache pid=%s" % pid)
    _cache.clear()

ipc.set_signal_handler("clear_currency_cache", _clear_cache)


class Currency(Model):
    _name = "currency"
    _string = "Currency"
    _key = ["name"]
    _name_field = "code"
    _audit_log = True
    _fields = {
        "name": fields.Char("Name", required=True, search=True),
        "code": fields.Char("Code", required=True, search=True),
        "sign": fields.Char("Sign", required=True),
        "iso_number": fields.Char("ISO Number"),
        "rates": fields.One2Many("currency.rate", "currency_id", "Rate History"),
        "sell_rate": fields.Decimal("Current Sell Rate", scale=6, function="get_current_rate", function_multi=True),
Exemplo n.º 3
0
from netforce.model import Model, fields, get_model
from netforce import ipc
from netforce.locale import get_active_locale
from netforce.database import get_active_db
import os

_block_cache = {}


def _clear_cache():
    print("clear block cache (pid=%s)" % os.getpid())
    _block_cache.clear()


ipc.set_signal_handler("clear_block_cache", _clear_cache)


class Block(Model):
    _name = "cms.block"
    _string = "Block"
    _fields = {
        "name":
        fields.Char("Name", required=True, search=True),
        "related_id":
        fields.Reference([["cms.page", "Page"], ["cms.blog.post", "Post"]],
                         "Related To"),
        "html":
        fields.Text("HTML", search=True, translate=True),
        "comments":
        fields.One2Many("message", "related_id", "Comments"),
Exemplo n.º 4
0
from netforce.model import Model, fields
import time
import os
from netforce import ipc
from netforce import database

_cache = {}


def _clear_cache():
    pid = os.getpid()
    print("uom _clear_cache pid=%s" % pid)
    _cache.clear()


ipc.set_signal_handler("clear_uom_cache", _clear_cache)


class Uom(Model):
    _name = "uom"
    _string = "Unit of Measure"
    _key = ["name"]
    _fields = {
        "name": fields.Char("Name", required=True, search=True),
        "type": fields.Selection(
            [
                ["unit", "Unit"],
                ["time", "Time"],
                ["length", "Length"],
                ["weight", "Weight"],
                ["volume", "Volume"],
Exemplo n.º 5
0
from netforce.database import get_connection, get_active_db
import os
import csv
from netforce import static
from netforce.locale import get_active_locale
from netforce import ipc

_cache = {}


def _clear_cache():
    pid = os.getpid()
    print("translation _clear_cache pid=%s" % pid)
    _cache.clear()

ipc.set_signal_handler("clear_translation_cache", _clear_cache)


class Translation(Model):
    _name = "translation"
    _string = "Translation"
    _key = ["lang_id", "original"]
    _fields = {
        "lang_id": fields.Many2One("language", "Language", required=True, search=True),
        "original": fields.Char("Original String", required=True, search=True),
        "translation": fields.Char("Translation", search=True),
        "comments": fields.One2Many("message", "related_id", "Comments"),
    }
    _order = "lang_id,original"

    def change_lang(self, context={}):
Exemplo n.º 6
0
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
# OR OTHER DEALINGS IN THE SOFTWARE.

from netforce.model import Model, fields
from netforce import ipc
import os
import netforce


def _clear_cache():
    print("clear template cache pid=%s" % os.getpid())
    netforce.template.clear_template_cache()


ipc.set_signal_handler("clear_template_cache", _clear_cache)


class Template(Model):
    _name = "template"
    _string = "Template"
    _key = ["name", "theme_id"]
    _fields = {
        "name": fields.Char("Name", required=True, search=True),
        "template": fields.Text("Template"),
        "theme_id": fields.Many2One("theme", "Theme"),
        "module_id": fields.Many2One("module", "Module"),
    }
    _order = "name"

    def create(self, vals, **kw):
Exemplo n.º 7
0
from netforce.model import Model, fields
import time
import os
from netforce import ipc
from netforce import database

_cache = {}


def _clear_cache():
    pid = os.getpid()
    print("uom _clear_cache pid=%s" % pid)
    _cache.clear()


ipc.set_signal_handler("clear_uom_cache", _clear_cache)


class Uom(Model):
    _name = "uom"
    _string = "Unit of Measure"
    _key = ["name"]
    _fields = {
        "name":
        fields.Char("Name", required=True, search=True),
        "type":
        fields.Selection(
            [["unit", "Unit"], ["time", "Time"], ["length", "Length"],
             ["weight", "Weight"], ["volume", "Volume"], ["other", "Other"]],
            "Type",
            required=True,
Exemplo n.º 8
0
# OR OTHER DEALINGS IN THE SOFTWARE.

from netforce.model import Model, fields, get_model
from netforce import ipc
from netforce.locale import get_active_locale
from netforce.database import get_active_db
import os

_block_cache = {}


def _clear_cache():
    print("clear block cache (pid=%s)" % os.getpid())
    _block_cache.clear()

ipc.set_signal_handler("clear_block_cache", _clear_cache)


class Block(Model):
    _name = "cms.block"
    _string = "Block"
    _fields = {
        "name": fields.Char("Name", required=True, search=True),
        "related_id": fields.Reference([["cms.page", "Page"], ["cms.blog.post", "Post"]], "Related To"),
        "html": fields.Text("HTML", search=True, translate=True),
        "comments": fields.One2Many("message", "related_id", "Comments"),
    }
    _order = "name"

    def get_block(self, name, page_id=None, post_id=None, context={}):
        # print("get_block",name,page_id,post_id)