コード例 #1
0
ファイル: action.py プロジェクト: katrid/orun
class ServerAction(Action):
    sequence = models.IntegerField(default=5)
    model = models.ForeignKey('content.type', null=False)
    code = models.TextField(label=_('Python Code'))
    actions = models.ManyToManyField('self')
    target_model = models.ForeignKey('content.type')
    target_field = models.ForeignKey('content.field')
    lines = models.OneToManyField('ui.action.server.line')

    class Meta:
        name = 'ui.action.server'
コード例 #2
0
ファイル: bank.py プロジェクト: katrid/orun
class BankStatement(models.Model):
    name = models.CharField(verbose_name='Reference', states={'open': {'readonly': False}}, copy=False, readonly=True)
    reference = models.CharField(verbose_name='External Reference', states={'confirm': {'readonly': False}}, copy=False, readonly=True)
    date = models.DateField(null=False, states={'confirm': {'readonly': True}})
    date_done = models.DateTimeField(verbose_name=_('Closed On'))
    balance_start = models.MonetaryField(verbose_name=_('Starting Balance'), states={'confirm': {'readonly': True}})
    balance_end_real = models.MonetaryField('Ending Balance', states={'confirm': [('readonly', True)]})
    accounting_date = models.DateField(verbose_name="Accounting Date", help_text="If set, the accounting entries created during the bank statement reconciliation process will be created at this date.\n"
                                                                 "This is useful if the accounting period in which the entries should normally be booked is already closed.",
                                  states={'open': [('readonly', False)]}, readonly=True)
    state = models.ChoiceField([('open', 'New'), ('confirm', 'Validated')], verbose_name='Status', null=False, readonly=True, copy=False, default='open')
    currency = models.ForeignKey('res.currency', compute='_compute_currency', verbose_name="Currency")
    journal = models.ForeignKey('account.journal', verbose_name='Journal', null=False, states={'confirm': [('readonly', True)]}, default=_default_journal)
    journal_type = models.ChoiceField(proxy='journal.type', help_text="Technical field used for usability purposes")
    company = models.ForeignKey(
        'res.company', proxy='journal.company', verbose_name='Company', store=True, readonly=True,
        default=lambda self: self.env.company
    )

    total_entry_encoding = models.MonetaryField('Transactions Subtotal', compute='_end_balance', store=True, help_text="Total of transaction lines.")
    balance_end = models.MonetaryField('Computed Balance', compute='_end_balance', store=True, help_text='Balance as calculated based on Opening Balance and transaction lines')
    difference = models.MonetaryField(compute='_end_balance', store=True, help_text="Difference between the computed ending balance and the specified ending balance.")

    lines = models.OneToManyField('account.bank.statement.line', 'statement', verbose_name='Statement lines', states={'confirm': [('readonly', True)]}, copy=True)
    move_lines = models.OneToManyField('account.move.line', 'statement', verbose_name='Entry lines', states={'confirm': [('readonly', True)]})
    move_line_count = models.IntegerField(compute="_get_move_line_count")

    all_lines_reconciled = models.BooleanField(compute='_check_lines_reconciled')
    user = models.ForeignKey('res.users', verbose_name='Responsible', required=False, default=lambda self: self.env.user)
    cashbox_start = models.ForeignKey('account.bank.statement.cashbox', verbose_name="Starting Cashbox")
    cashbox_end = models.ForeignKey('account.bank.statement.cashbox', verbose_name="Ending Cashbox")
    is_difference_zero = models.BooleanField(compute='_is_difference_zero', verbose_name='Is zero', help_text="Check if difference is zero.")

    class Meta:
        name = 'account.bank.statement'
        verbose_name = _('Bank Statement')
コード例 #3
0
class ProductionLot(models.Model):
    name = models.CharField(
        100,
        label=_('Lot/Serial'),
        null=False,
        help_text=_('Unique Lot/Serial Number'),
        default=lambda self: self.env['ir.sequence'].next_by_code(
            'stock.lot.serial'),
    )
    ref = models.CharField(
        100,
        label=_('Internal Reference'),
        help_text=
        _("Internal reference number in case it differs from the manufacturer's lot/serial number"
          ))
    product = models.ForeignKey('product.product',
                                label=_('Product'),
                                null=False,
                                check_company=True,
                                filter=lambda self: self.domain_product_id())
    product_uom = models.ForeignKey('uom.uom',
                                    label=_('Unit of Measure'),
                                    related='product.uom',
                                    stored=True)
    quants = models.OneToManyField('stock.quant', readonly=True)
    product_qty = models.DecimalField(label=_('Quantity'),
                                      getter='get_product_qty')
    description = models.HtmlField(label=_('Description'))
    display_complete = models.BooleanField(getter='get_display_complete')
    company = models.ForeignKey('res.company',
                                label=_('Company'),
                                null=False,
                                stored=True,
                                db_index=True)

    class Meta:
        name = 'stock.production.lot'
        verbose_name = 'Lot/Serial'
コード例 #4
0
ファイル: bank.py プロジェクト: katrid/orun
class AccountBankStatementLine(models.Model):

    name = models.CharField(verbose_name='Label', null=False)
    date = models.DateField(null=False, default=lambda self: self._context.get('date', models.DateField.context_today(self)))
    amount = models.MonetaryField(currency_field='journal_currency')
    journal_currency = models.ForeignKey(
        'res.currency', verbose_name="Journal's Currency", proxy='statement.currency',
        help_text='Utility field to express amount currency', readonly=True
    )
    partner = models.ForeignKey('res.partner', verbose_name='Partner')
    account_number = models.CharField(verbose_name='Bank Account Number', help_text="Technical field used to store the bank account number before its creation, upon the line's processing")
    bank_account = models.ForeignKey('res.partner.bank', verbose_name='Bank Account', help_text="Bank account that was used in this transaction.")
    account = models.ForeignKey('account.account', verbose_name='Counterpart Account', domain=[('deprecated', '=', False)],
                                 help_text="This technical field can be used at the statement line creation/import time in order to avoid the reconciliation"
                                      " process on it later on. The statement line will simply create a counterpart on this account")
    statement = models.ForeignKey('account.bank.statement', verbose_name='Statement', index=True, null=False, on_delete=models.CASCADE)
    journal = models.ForeignKey('account.journal', proxy='statement.journal', verbose_name='Journal', store=True, readonly=True)
    partner_name = models.CharField(help_text="This field is used to record the third party name when importing bank statement in electronic format,"
                                    " when the partner doesn't exist yet in the database (or cannot be found).")
    ref = models.CharField(verbose_name='Reference')
    note = models.TextField(verbose_name='Notes')
    transaction_type = models.CharField(verbose_name='Transaction Type')
    sequence = models.IntegerField(index=True, help_text="Gives the sequence order when displaying a list of bank statement lines.", default=1)
    company = models.ForeignKey('res.company', proxy='statement.company', verbose_name='Company', store=True, readonly=True)
    journal_entrys = models.OneToManyField('account.move.line', 'statement_line', 'Journal Items', copy=False, readonly=True)
    amount_currency = models.MonetaryField(help_text="The amount expressed in an optional other currency if it is a multi-currency entry.")
    currency = models.ForeignKey('res.currency', verbose_name='Currency', help_text="The optional other currency if it is a multi-currency entry.")
    state = models.ChoiceField(proxy='statement.state', verbose_name='Status', readonly=True)
    move_name = models.CharField(
        verbose_name='Journal Entry Name', readonly=True,
        default=False, copy=False,
        help_text="Technical field holding the number given to the journal entry, automatically set when the statement line is reconciled then stored to set the same number again if the line is cancelled, set to draft and re-processed again."
    )
    
    class Meta:
        name = 'account.bank.statement.line'
        description = _('Bank Statement Line')
        ordering = ('-statement_id', 'date', 'sequence', '-id')
コード例 #5
0
ファイル: models.py プロジェクト: katrid/orun
class Team(models.Model):
    name = models.CharField(100, verbose_name=_('Name'))
    active = models.BooleanField(verbose_name=_('Active'), default=True)
    company = models.ForeignKey('res.company')
    # currency = models.ForeignKey('res.currency')
    user = models.ForeignKey('auth.user', verbose_name=_('Team Leader'))
    members = models.OneToManyField('auth.user', 'sale_team')
    favorite_users = models.ManyToManyField('auth.user')
    color = models.IntegerField()
    team_type = models.ChoiceField(
        (
            ('sales', _('Sales')),
            ('website', _('Website')),
        ),
        default='sales',
        null=False,
        verbose_name=_('Team Type'),
    )

    class Meta:
        name = 'sales.team'
        verbose_name = _('Sales Team')
        verbose_name_plural = _('Sales Teams')
コード例 #6
0
class Event(mail.models.Comments):
    name = models.CharField(verbose_name=_('Meeting Subject'), null=True, widget_attrs={'done': [('readonly', True)]})
    status = models.ChoiceField(
        (('draft', _('Unconfirmed')), ('open', _('Confirmed'))), readonly=True, default='draft'
    )

    # is_attendee = models.BooleanField('Attendee', compute='_compute_attendee')
    # attendee_status = models.ChoiceField(Attendee.STATE_SELECTION, verbose_name='Attendee Status', compute='_compute_attendee')
    # display_time = models.CharField('Event Time', compute='_compute_display_time')
    # display_start = models.CharField('Date', compute='_compute_display_start', store=True)
    start = models.DateTimeField(
        verbose_name=_('Start'), null=False,
        help_text="Start date of an event, without time for full days events"
    )
    stop = models.DateTimeField(
        verbose_name=_('Stop'), null=False,
        help_text="Stop date of an event, without time for full days events"
    )

    all_day = models.BooleanField(verbose_name=_('All Day'), states={'done': [('readonly', True)]}, default=False)
    start_date = models.DateField('Start Date', compute='_compute_dates', inverse='_inverse_dates', store=True,
                                  states={'done': [('readonly', True)]}, track_visibility='onchange')
    start_datetime = models.DateTimeField(
        verbose_name=_('Start DateTime'), compute='_compute_dates', inverse='_inverse_dates',
        store=True, states={'done': {'readonly': True}},
        track_visibility='onchange'
    )
    end_date = models.DateField(
        verbose_name=_('End Date'), compute='_compute_dates', inverse='_inverse_dates', store=True,
        states={'done': [('readonly', True)]}, track_visibility='onchange'
    )
    end_datetime = models.DateTimeField(
        verbose_name=_('End Datetime'), compute='_compute_dates', inverse='_inverse_dates', store=True,
        states={'done': [('readonly', True)]},
        track_visibility='onchange'
    )
    duration = models.FloatField(verbose_name=_('Duration'), states={'done': [('readonly', True)]})
    description = models.TextField(verbose_name=_('Description'), states={'done': [('readonly', True)]})
    privacy = models.ChoiceField(
        [('public', 'Everyone'), ('private', 'Only me'), ('confidential', 'Only internal users')],
        verbose_name=_('Privacy'),
        default='public', states={'done': [('readonly', True)]},
    )
    location = models.CharField(
        'Location', states={'done': [('readonly', True)]}, track_visibility='onchange',
        help_text="Location of Event"
    )
    show_as = models.ChoiceField(
        (('free', _('Free')), ('busy', _('Busy'))), verbose_name=_('Show Time as'),
        states={'done': [('readonly', True)]}, default='busy'
    )

    # linked document
    object_id = models.BigIntegerField('Object ID')
    model = models.ForeignKey('ir.model', verbose_name=_('Document Model'), ondelete=models.CASCADE)
    model_name = models.CharField('Document Model Name', related='model.name', readonly=True, store=True)
    activities = models.OneToManyField('mail.activity', 'calendar_event_id', verbose_name='Activities')

    # redifine message_ids to remove autojoin to avoid search to crash in get_recurrent_ids
    # message_ids = models.OneToManyField()

    recurrent_rule = models.CharField(
        verbose_name=_('Recurrent Rule'), compute='_compute_recurrent_rule', inverse='_inverse_recurrent_rule',
        store=True
    )
    recurrent_rule_type = models.ChoiceField(
        (
            ('daily', _('Day(s)')),
            ('weekly', _('Week(s)')),
            ('monthly', _('Month(s)')),
            ('yearly', _('Year(s)')),
        ), verbose_name=_('Recurrence'), states={'done': [('readonly', True)]},
        help_text="Let the event automatically repeat at that interval"
    )
    recurrency = models.BooleanField('Recurrent', help_text="Recurrent Meeting")
    recurrent_id = models.BigIntegerField('Recurrent ID')
    recurrent_id_date = models.DateTimeField('Recurrent ID date')
    end_type = models.ChoiceField(
        (
            ('count', 'Number of repetitions'),
            ('end_date', 'End date')
        ), verbose_name=_('Recurrence Termination'), default='count'
    )
    interval = models.IntegerField(
        verbose_name='Repeat Every', default=1,
        help_text="Repeat every (Days/Week/Month/Year)"
    )
    count = models.IntegerField(verbose_name='Repeat', help_text="Repeat x times", default=1)
    mo = models.BooleanField(verbose_name=_('Mon'))
    tu = models.BooleanField(verbose_name=_('Tue'))
    we = models.BooleanField(verbose_name=_('Wed'))
    th = models.BooleanField(verbose_name=_('Thu'))
    fr = models.BooleanField(verbose_name=_('Fri'))
    sa = models.BooleanField(verbose_name=_('Sat'))
    su = models.BooleanField(verbose_name=_('Sun'))
    month_by = models.ChoiceField([
        ('date', 'Date of month'),
        ('day', 'Day of month')
    ], verbose_name=_('Option'), default='date')
    day = models.IntegerField('Date of month', default=1)
    week_list = models.ChoiceField(
        (
            ('MO', 'Monday'),
            ('TU', 'Tuesday'),
            ('WE', 'Wednesday'),
            ('TH', 'Thursday'),
            ('FR', 'Friday'),
            ('SA', 'Saturday'),
            ('SU', 'Sunday')
        ), verbose_name=_('Weekday')
    )
    by_day = models.ChoiceField(
        (
            ('1', _('First')),
            ('2', _('Second')),
            ('3', _('Third')),
            ('4', _('Fourth')),
            ('5', _('Fifth')),
            ('-1', _('Last')),
        ), verbose_name=_('By day')
    )
    final_date = models.DateField('Repeat Until')
    user_id = models.ForeignKey('res.users', 'Owner', states={'done': [('readonly', True)]},
                                default=lambda self: self.env.user)
    partner_id = models.ForeignKey(
        'res.partner', verbose_name='Responsible', related='user_id.partner_id', readonly=True
    )
    active = models.BooleanField(
        verbose_name=_('Active'), default=True,
        help_text="If the active field is set to false, it will allow you to hide the event alarm information without removing it."
    )
    event_types = models.ManyToManyField('calendar.event.type', verbose_name=_('Tags'))
    attendee = models.OneToManyField(
        'calendar.attendee', 'event', verbose_name=_('Participant'), ondelete=models.CASCADE
    )
    partners = models.OneToManyField(
        'res.partner', 'calendar_event_res_partner_rel', verbose_name='Attendees',
        states={'done': [('readonly', True)]}, default=_default_partners
    )
    alarms = models.ManyToManyField(
        'calendar.alarm', 'calendar_alarm_calendar_event_rel', verbose_name='Reminders',
        ondelete="restrict", copy=False
    )
    is_highlighted = models.BooleanField(compute='_compute_is_highlighted', verbose_name='Is the Event Highlighted')

    class Meta:
        name = 'calendar.event'
        verbose_name = "Event"
コード例 #7
0
ファイル: action.py プロジェクト: katrid/orun
class WindowAction(Action):
    VIEW_MODE = (
        ('form', 'Form'),
        ('list', 'List'),
        ('card', 'Card'),
        ('search', 'Search'),
        ('calendar', 'Calendar'),
    )
    view = models.ForeignKey('ui.view', label=_('View'))
    domain = models.TextField(label=_('Domain'))
    context = models.TextField(label=_('Context'))
    model = models.CharField(128, null=False, label=_('Model'))
    object_id = models.BigIntegerField(label=_('Object ID'))
    #content_object = GenericForeignKey()
    view_mode = models.CharField(128, default='list,form', label=_('View Mode'))
    target = models.CharField(16, label=_('Target'), choices=(
        ('current', 'Current Window'),
        ('new', 'New Window'),
    ))
    limit = models.IntegerField(default=100, label=_('Limit'))
    auto_search = models.BooleanField(default=True, label=_('Auto Search'))
    # views = models.TextField(getter='_get_views', editable=False, serializable=True)
    view_list = models.OneToManyField('ui.action.window.view')
    view_type = models.SelectionField(VIEW_MODE, default='form')

    class Meta:
        name = 'ui.action.window'
        field_groups = {
            'list_fields': ['name', 'action_type', 'usage', 'view', 'model', 'view_mode', 'limit', 'auto_search']
        }

    def _get_views(self):
        modes = self.view_mode.split(',')
        views = self.view_list.all()
        modes = {mode: None for mode in modes}
        if self.view_id:
            modes[self.view_type] = self.view_id
        for v in views:
            modes[v.view_mode] = v.view_id
        if 'search' not in modes:
            modes['search'] = None
        return modes

    @classmethod
    def from_model(cls, model):
        if isinstance(model, models.Model):
            model = model._meta.name
        return cls.objects.filter(model=model).first()

    def _get_info(self, context):
        info = super()._get_info(context)
        # Send action information as katrid.js protocol
        modes = info['viewModes'] = info.pop('view_mode').split(',')
        # info['viewMode'] = info.pop('view_type')
        info['viewMode'] = modes[0]
        model = apps[self.model]
        info['fields'] = model.admin_get_fields_info()
        info['caption'] = info.pop('name')
        view_id = self.view_id
        views_info = info['viewsInfo'] = {}
        # check if there's a specified view
        if view_id:
            views_info[self.view.view_type] = model._admin_get_view_info(
                view_type=self.view_type, view=view_id, toolbar=True
            )
        views_info.update({
            k: model._admin_get_view_info(view_type=k, view=None, toolbar=True) for k in modes if k not in views_info
        })
        info['viewsInfo']['search'] = model._admin_get_view_info(view_type='search')
        return info
コード例 #8
0
ファイル: bank.py プロジェクト: katrid/orun
class BankStatementCashWizard(models.Model):
    cashbox_lines = models.OneToManyField('account.cashbox.line', verbose_name=_('Cashbox Lines'))

    class Meta:
        name = 'account.bank.statement.cashbox'