コード例 #1
0
ファイル: party.py プロジェクト: chunjiekuaile/tryton4.6
class PartyCreditLimitAmount(ModelSQL, CompanyValueMixin):
    "Party Credit Limit Amount"
    __name__ = 'party.party.credit_limit_amount'
    party = fields.Many2One(
        'party.party', "Party", ondelete='CASCADE', select=True)
    credit_limit_amount = fields.Numeric(
        "Credit Limit Amount", digits=(16, Eval('credit_limit_digits', 2)),
        depends=['credit_limit_digits'])
    credit_limit_digits = fields.Function(fields.Integer('Currency Digits'),
        'on_change_with_credit_limit_digits')

    @classmethod
    def __register__(cls, module_name):
        TableHandler = backend.get('TableHandler')
        exist = TableHandler.table_exist(cls._table)

        super(PartyCreditLimitAmount, cls).__register__(module_name)

        if not exist:
            cls._migrate_property([], [], [])

    @classmethod
    def _migrate_property(cls, field_names, value_names, fields):
        field_names.append('credit_limit_amount')
        value_names.append('credit_limit_amount')
        fields.append('company')
        migrate_property(
            'party.party', field_names, cls, value_names,
            parent='party', fields=fields)

    @fields.depends('company')
    def on_change_with_credit_limit_digits(self, name=None):
        if self.company:
            return self.company.currency.digits
コード例 #2
0
class DocumentPaymentLine(ModelSQL, ModelView):
    "Documents Payment Line"
    _name='ekd.document.line.payment'
    _description=__doc__

    doc_payment = fields.Many2One('ekd.document', 'Document Payment', ondelete="CASCADE")
    doc_base = fields.Many2One('ekd.document.head.request', 'Document Base')
    amount_payment = fields.Numeric('Amount Payment', digits=(16,2))
    line_request = fields.Many2One('ekd.document.line.request', 'Line Request of money')
    line_ref = fields.Reference(selection='get_line_ref',  string='Ref.')
    type_transaction = fields.Selection([
                    ('income_cash','Income in Cash'),
                    ('expense_cash','Expense in Cash'),
                    ('return_cash','Return in Cash'),
                    ('income_bank','Income in Bank'),
                    ('expense_bank','Expense in Bank'),
                    ('return_bank','Return in Bank')
                    ], 'Type Transaction')
    state = fields.Selection([
                    ('deleted','Deleted'),
                    ('done','Done'),
                    ('payment','Payment'),
                    ('wait_bank','Waiting Confirm Bank')
            ], 'State')

    def get_line_ref(self):
        dictions_obj = self.pool.get('ir.dictions')
        res = []
        diction_ids = dictions_obj.search([
                            ('model', '=', 'ekd.document.line.payment'),
                            ('pole', '=', 'line_ref'),
                            ])
        for diction in dictions_obj.browse(diction_ids):
            res.append([diction.key, diction.value])
        return res
コード例 #3
0
class MagentoTax(ModelSQL, ModelView):
    "Magento Tax"
    __name__ = "sale.channel.magento.tax"

    # TODO: Add Domain
    channel = fields.Many2One(
        "sale.channel", "Channel", required=True, select=True
    )
    tax_percent = fields.Numeric(
        "Tax Percent", digits=(16, 4), required=True, select=True
    )
    taxes = fields.Many2Many(
        "sale.channel.magento.tax.tax_rel", "channel_tax", "tax", "Taxes"
    )

    @classmethod
    def __setup__(cls):
        super(MagentoTax, cls).__setup__()

        cls._error_messages.update({
            'unique_tax_percent_per_channel':
            "Tax percent must be unique per channel"
        })
        cls._sql_constraints += [
            ('unique_tax_percent', 'UNIQUE(channel, tax_percent)',
             'unique_tax_percent_per_channel')
        ]
コード例 #4
0
class Line:
    __name__ = 'account.move.line'
    amount_residual = fields.Function(fields.Numeric('Amount Residual',
        digits=(16, 2)), 'get_amount_residual')

    def get_amount_residual(self, name):
        Invoice = Pool().get('account.invoice')

        res = Decimal('0.0')
        if self.reconciliation or \
        not self.account.kind in ('payable', 'receivable'):
            return res

        move_line_total = self.debit - self.credit

        invoices = Invoice.search([
            ('move', '=', self.move.id),
        ])
        if invoices:
            invoice = invoices[0]
            for payment_line in invoice.payment_lines:
                if payment_line.id == self.id:
                    continue
                move_line_total += payment_line.debit - payment_line.credit
            res = move_line_total
        return res
コード例 #5
0
class Rate(ModelSQL, ModelView):
    'Rate'
    __name__ = 'currency.currency.rate'
    _rec_name = 'date'
    date = fields.Date('Date', required=True, select=True)
    rate = fields.Numeric('Rate', digits=(12, 6), required=1)
    currency = fields.Many2One('currency.currency', 'Currency',
            ondelete='CASCADE',)

    @classmethod
    def __setup__(cls):
        super(Rate, cls).__setup__()
        cls._sql_constraints = [
            ('date_currency_uniq', 'UNIQUE(date, currency)',
                'A currency can only have one rate by date.'),
            ('check_currency_rate', 'CHECK(rate >= 0)',
                'The currency rate must greater than or equal to 0'),
            ]
        cls._order.insert(0, ('date', 'DESC'))

    @staticmethod
    def default_date():
        Date = Pool().get('ir.date')
        return Date.today()

    @classmethod
    def check_xml_record(self, records, values):
        return True
コード例 #6
0
class LoginsToApp(ModelSQL, ModelView):
    #docstring for AssessmentImage
    'Registrations to mobile App'

    # Internal class name. Always used as a reference inside Tryton
    # default: '<module_name>.<class_name>' on Tryton
    # becomes '<module_name>_<class_name>' in the database
    __name__ = 'iversta.logins-to-app'

    # ———————————————- One2Many Many2One fields ——————————————————————————

    # ———————————————————— Plain fields ————————————————————————————
    login = fields.Char('Login', help='User login')
    full_name = fields.Char('Full name', help='A full name of a user')
    token_issued = fields.Char('New token issued',
                               help='A new token issued for a new login')
    token_used = fields.Char('Token used', help='Current token used to login')
    user_id = fields.Numeric('Tryton ID in Tryton', help='DB id in Tryton DB')
    login_result = fields.Selection([('S', 'Sucessful'), ('U', 'Failed')],
                                    'Login Result',
                                    help='Result of login attempt')
    app_ver = fields.Char(
        'Mobile App ver',
        readonly=True,
        help='Version of mobile app that used for inspection')
    device_id = fields.Char('Mobile Device id',
                            readonly=True,
                            help='Device that used for inspection')

    @staticmethod
    def default_login_result():
        return 'U'
コード例 #7
0
class StockShipmentInvoiceReport(ModelSQL, ModelView):
    """StockShipmentInvoiceReport"""
    __name__ = "hrp_inventory_report.stock_shipment_invoice_report"

    number = fields.Function(fields.Char('number', select=True),
                             'get_data')  # 序号
    party = fields.Many2One('party.party', 'party', select=True)  # 特定供应商
    order = fields.Char('order', select=True)  # 入库单号
    actual_payment = fields.Function(
        fields.Numeric('actual_payment', digits=(16, 2), readonly=True),
        'get_quantity')  # 实付金额
    invoice_number = fields.Function(
        fields.Char('invoice_number', select=True), 'get_invoice_number')

    @staticmethod
    def table_query():
        pass

    def get_data(self, name):
        pass

    def get_quantity(self, name):
        pass

    def get_invoice_number(self, name):
        pass
コード例 #8
0
class Inventory(metaclass=PoolMeta):
    __name__ = 'stock.inventory'

    total_cost = fields.Function(
        fields.Numeric('Total Cost', digits=price_digits),
            'get_total_cost')

    @fields.depends('lines')
    def on_change_lines(self):
        self.total_cost = self.get_total_cost()

    def get_total_cost(self, name=None):
        result = Decimal('0.0')
        for line in self.lines:
            if line.total_cost:
                result += line.total_cost
        return result

    @classmethod
    def complete_lines(cls, inventories, fill=True):
        super(Inventory, cls).complete_lines(inventories, fill)
        cls.set_cost_price(inventories)

    @classmethod
    def set_cost_price(cls, inventories):
        for inventory in inventories:
            for line in inventory.lines:
                line.cost_price = line.product.template.cost_price
                line.save()
            inventory.save()
コード例 #9
0
class GiftCardPrice(ModelSQL, ModelView):
    "Gift Card Price"
    __name__ = 'product.product.gift_card.price'
    _rec_name = 'price'

    product = fields.Many2One("product.product",
                              "Product",
                              required=True,
                              select=True)

    price = fields.Numeric("Price", required=True)

    @classmethod
    def __setup__(cls):
        super(GiftCardPrice, cls).__setup__()

        cls._error_messages.update(
            {'negative_amount': 'Price can not be negative'})

    @classmethod
    def validate(cls, prices):
        """
        Validate product price for gift card
        """
        super(GiftCardPrice, cls).validate(prices)

        for price in prices:
            price.check_price()

    def check_price(self):
        """
        Price can not be negative
        """
        if self.price < 0:
            self.raise_user_error("negative_amount")
コード例 #10
0
ファイル: currency.py プロジェクト: elat333/gw_tryton_docker
class Rate(ModelSQL, ModelView):
    'Rate'
    __name__ = 'currency.currency.rate'
    date = fields.Date('Date', required=True, select=True,
        help="From when the rate applies.")
    rate = fields.Numeric('Rate', digits=(12, 6), required=1,
        help="The floating exchange rate used to convert the currency.")
    currency = fields.Many2One('currency.currency', 'Currency',
            ondelete='CASCADE',
        help="The currency on which the rate applies.")

    @classmethod
    def __setup__(cls):
        super(Rate, cls).__setup__()
        t = cls.__table__()
        cls._sql_constraints = [
            ('date_currency_uniq', Unique(t, t.date, t.currency),
                'A currency can only have one rate by date.'),
            ('check_currency_rate', Check(t, t.rate >= 0),
                'The currency rate must greater than or equal to 0'),
            ]
        cls._order.insert(0, ('date', 'DESC'))

    @staticmethod
    def default_date():
        Date = Pool().get('ir.date')
        return Date.today()

    @classmethod
    def check_xml_record(cls, records, values):
        return True

    def get_rec_name(self, name):
        return str(self.date)
コード例 #11
0
ファイル: account.py プロジェクト: nicoe/analytic_account
class AccountDistribution(ModelView, ModelSQL):
    "Analytic Account Distribution"
    __name__ = 'analytic_account.account.distribution'
    parent = fields.Many2One('analytic_account.account',
                             "Parent",
                             required=True,
                             select=True)
    root = fields.Function(fields.Many2One('analytic_account.account', "Root"),
                           'on_change_with_root')
    account = fields.Many2One('analytic_account.account',
                              "Account",
                              required=True,
                              domain=[
                                  ('root', '=', Eval('root', -1)),
                              ],
                              depends=['root'])
    ratio = fields.Numeric("Ratio",
                           required=True,
                           domain=[
                               ('ratio', '>=', 0),
                               ('ratio', '<=', 1),
                           ])

    @classmethod
    def __setup__(cls):
        super(AccountDistribution, cls).__setup__()
        cls._order.insert(0, ('ratio', 'DESC'))

    @fields.depends('parent', '_parent_parent.root')
    def on_change_with_root(self, name=None):
        if self.parent:
            return self.parent.root.id
コード例 #12
0
class Exemplary(ModelSQL, ModelView):
    'Exemplary'
    __name__ = 'library.book.exemplary'
    _rec_name = 'identifier'

    book = fields.Many2One('library.book',
                           'Book',
                           ondelete='CASCADE',
                           required=True)
    identifier = fields.Char('Identifier', required=True)
    acquisition_date = fields.Date('Acquisition Date')
    acquisition_price = fields.Numeric('Acquisition Price',
                                       digits=(16, 2),
                                       domain=[
                                           'OR',
                                           ('acquisition_price', '=', None),
                                           ('acquisition_price', '>', 0)
                                       ])

    @classmethod
    def __setup__(cls):
        super().__setup__()
        t = cls.__table__()
        cls._sql_constraints += [
            ('identifier_uniq', Unique(t, t.identifier),
             'The identifier must be unique!'),
        ]

    @classmethod
    def default_acquisition_date(cls):
        return datetime.date.today()

    def get_rec_name(self, name):
        return '%s: %s' % (self.book.rec_name, self.identifier)
コード例 #13
0
class TestPaymentTermViewResult(ModelView):
    'Test Payment Term'
    __name__ = 'account.invoice.payment_term.test.result'
    date = fields.Date('Date', readonly=True)
    amount = fields.Numeric('Amount', readonly=True,
        digits=(16, Eval('currency_digits', 2)), depends=['currency_digits'])
    currency_digits = fields.Integer('Currency Digits')
コード例 #14
0
ファイル: test_model.py プロジェクト: mbehrle/trytond-babi
class TestBabiModel(ModelSQL, ModelView):
    'Test BABI Model'
    __name__ = 'babi.test'

    date = fields.Date('Date')
    category = fields.Char('Category')
    amount = fields.Numeric('Amount')
コード例 #15
0
ファイル: product.py プロジェクト: nicoe/product
class ProductListPrice(ModelSQL, CompanyValueMixin):
    "Product List Price"
    __name__ = 'product.list_price'
    template = fields.Many2One('product.template',
                               "Template",
                               ondelete='CASCADE',
                               select=True)
    list_price = fields.Numeric("List Price", digits=price_digits)

    @classmethod
    def __register__(cls, module_name):
        TableHandler = backend.get('TableHandler')
        exist = TableHandler.table_exist(cls._table)

        super(ProductListPrice, cls).__register__(module_name)

        if not exist:
            cls._migrate_property([], [], [])

    @classmethod
    def _migrate_property(cls, field_names, value_names, fields):
        field_names.append('list_price')
        value_names.append('list_price')
        fields.append('company')
        migrate_property('product.template',
                         field_names,
                         cls,
                         value_names,
                         parent='template',
                         fields=fields)
コード例 #16
0
class EmployeeCostPrice(ModelSQL, ModelView):
    'Employee Cost Price'
    __name__ = 'company.employee_cost_price'
    date = fields.Date('Date', required=True, select=True)
    cost_price = fields.Numeric('Cost Price',
                                digits=price_digits,
                                required=True,
                                help="Hourly cost price")
    employee = fields.Many2One('company.employee', 'Employee')

    @classmethod
    def __register__(cls, module_name):
        TableHandler = backend.get('TableHandler')
        super(EmployeeCostPrice, cls).__register__(module_name)
        table = TableHandler(cls, module_name)

        # Migration from 2.8 drop date_cost_price_uniq
        table.drop_constraint('date_cost_price_uniq')

    @classmethod
    def __setup__(cls):
        super(EmployeeCostPrice, cls).__setup__()
        t = cls.__table__()
        cls._sql_constraints = [
            ('employee_date_cost_price_uniq',
             Unique(t, t.employee, t.date, t.cost_price),
             'A employee can only have one cost price by date.'),
        ]
        cls._order.insert(0, ('date', 'DESC'))

    @staticmethod
    def default_cost_price():
        return Decimal(0)

    @staticmethod
    def default_date():
        Date = Pool().get('ir.date')
        return Date.today()

    def get_rec_name(self, name):
        return str(self.date)

    @classmethod
    def delete(cls, prices):
        Employee = Pool().get('company.employee')
        super(EmployeeCostPrice, cls).delete(prices)
        Employee._cost_prices_cache.clear()

    @classmethod
    def create(cls, vlist):
        Employee = Pool().get('company.employee')
        prices = super(EmployeeCostPrice, cls).create(vlist)
        Employee._cost_prices_cache.clear()
        return prices

    @classmethod
    def write(cls, *args):
        Employee = Pool().get('company.employee')
        super(EmployeeCostPrice, cls).write(*args)
        Employee._cost_prices_cache.clear()
コード例 #17
0
ファイル: party.py プロジェクト: ioanp/account_invoice_ar
class Party(metaclass=PoolMeta):
    __name__ = 'party.party'

    pyafipws_fce = fields.Boolean('MiPyme FCE',
                                  states={'readonly': ~Eval('active', True)},
                                  depends=['active'])
    pyafipws_fce_amount = fields.Numeric(
        'MiPyme FCE Amount',
        digits=(16, Eval('pyafipws_fce_amount_digits', 2)),
        states={
            'readonly': Or(~Eval('pyafipws_fce', False),
                           ~Eval('active', True)),
        },
        depends=['active', 'pyafipws_fce_amount_digits', 'pyafipws_fce'])
    pyafipws_fce_amount_digits = fields.Function(
        fields.Integer('Currency Digits'), 'get_pyafipws_fce_amount_digits')

    @staticmethod
    def default_pyafipws_fce_amount():
        return Decimal('0')

    def get_pyafipws_fce_amount_digits(self, name):
        pool = Pool()
        Company = pool.get('company.company')
        company_id = Transaction().context.get('company')
        if company_id:
            company = Company(company_id)
            return company.currency.digits
コード例 #18
0
class TestApply(ModelView):
    """Test Apply"""

    __name__ = 'hrp_internal_delivery.test_apply'
    _rec_name = 'number'

    product = fields.Many2One("product.product", "Product", required=True)  # 产品
    product_name = fields.Char('product_name', select=True, readonly=True)  # 产品
    code = fields.Char('code', select=True, readonly=True)  # 编码
    drug_specifications = fields.Char('drug_specifications', select=True, readonly=True)  # 规格
    company = fields.Many2One('product.uom', 'company', select=True, readonly=True)  # 单位
    odd_numbers = fields.Char('odd_numbers', select=True, readonly=True)  # 建议请领数量
    a_charge = fields.Char('a_charge', select=True, readonly=True)  # 件装量
    stock_level = fields.Char('stock_level', select=True, readonly=True)  # 现有库存量
    outpatient_7days = fields.Char('Outpatient_7days', select=True, readonly=True)  # 7日量
    proposal = fields.Float('proposal', select=True, states=STATES
                            , depends=['is_direct_sending'])  # 请领数量
    is_direct_sending = fields.Boolean('Is_direct_sending', select=True, readonly=True)  # 是否直送
    is_collar = fields.Boolean('is_collar', select=True)  # 是否请领
    party = fields.Many2One('party.party', 'Party', select=True)  # 供应商
    unit_price = fields.Numeric('unit_price', digits=(16, 4))  # 价格

    parent = fields.Many2One('hrp_internal_delivery.internal_apply', 'parent', select=True)

    @staticmethod
    def default_is_collar():
        return False
コード例 #19
0
class Deduccion(ModelSQL, ModelView):
    'Deduccion'
    __name__ = 'rrhh.pa.208.deduccion'
    name = fields.Char('Nombre', required=True)
    description = fields.Text('Descripcion')
    tipo = fields.Selection([
        ('porcentaje', 'Porcentaje'),
        ('fijo', 'Monto Fijo'),
    ],
                            'Tipo',
                            required=True)
    valor = fields.Numeric('Valor',
                           required=True,
                           digits=(16, Eval('valor_digits', 4)),
                           depends=['valor_digits'])
    valor_digits = fields.Function(fields.Integer('Valor Digits'),
                                   'get_valor_digits')
    orden = fields.Integer('Orden')
    ley = fields.Boolean('De Ley')
    active = fields.Boolean('Active')

    @staticmethod
    def default_active():
        return True

    @staticmethod
    def default_valor_digits():
        return 4

    def get_valor_digits(self, name=None):
        return 4
コード例 #20
0
class Hora(ModelSQL, ModelView):
    'Hora'
    __name__ = 'rrhh.pa.208.hora'
    name = fields.Char('Nombre', required=True)
    description = fields.Text('Descripcion')
    tipo = fields.Selection([
        ('normal', 'Normal'),
        ('sobretiempo', 'Sobretiempo'),
        ('descuento', 'Descuento'),
    ],
                            'Tipo',
                            required=True)
    recargo = fields.Numeric('% Recargo',
                             digits=(16, Eval('currency_digits', 2)),
                             states={
                                 'invisible':
                                 Not(Equal(Eval('tipo'), 'sobretiempo')),
                             },
                             depends=['currency_digits', 'tipo'])
    currency_digits = fields.Function(fields.Integer('Currency Digits'),
                                      'get_currency_digits')
    orden = fields.Integer('Orden')
    active = fields.Boolean('Active')

    @staticmethod
    def default_active():
        return True

    @staticmethod
    def default_currency_digits():
        return _get_currency_digits()

    def get_currency_digits(self, name=None):
        return _get_currency_digits()
コード例 #21
0
ファイル: health_surgery.py プロジェクト: mdn57/health
class SurgerySupply(ModelSQL, ModelView):
    'Supplies related to the surgery'
    __name__ = 'gnuhealth.surgery_supply'

    name = fields.Many2One('gnuhealth.surgery', 'Surgery')
    qty = fields.Numeric('Qty',
                         required=True,
                         help="Initial required quantity")
    supply = fields.Many2One('product.product',
                             'Supply',
                             required=True,
                             domain=[('is_medical_supply', '=', True)],
                             help="Supply to be used in this surgery")

    notes = fields.Char('Notes')
    qty_used = fields.Numeric('Used', required=True, help="Actual amount used")
コード例 #22
0
class ExportData(ModelSQL):
    "Export Data"
    __name__ = 'test.export_data'
    boolean = fields.Boolean('Boolean')
    integer = fields.Integer('Integer')
    float = fields.Float('Float')
    numeric = fields.Numeric('Numeric')
    char = fields.Char('Char')
    text = fields.Text('Text')
    date = fields.Date('Date')
    datetime = fields.DateTime('DateTime')
    timedelta = fields.TimeDelta('TimeDelta')
    selection = fields.Selection([
        (None, ''),
        ('select1', 'Select 1'),
        ('select2', 'Select 2'),
    ], 'Selection')
    many2one = fields.Many2One('test.export_data.target', 'Many2One')
    many2many = fields.Many2Many('test.export_data.relation', 'many2many',
                                 'target', 'Many2Many')
    one2many = fields.One2Many('test.export_data.target', 'one2many',
                               'One2Many')
    reference = fields.Reference('Reference', [
        (None, ''),
        ('test.export_data.target', 'Target'),
    ])
コード例 #23
0
ファイル: product.py プロジェクト: chunjiekuaile/tryton4.6
class ProductCostHistory(ModelSQL, ModelView):
    'History of Product Cost'
    __name__ = 'product.product.cost_history'
    product = fields.Many2One('product.product', "Product")
    date = fields.DateTime('Date')
    cost_price = fields.Numeric('Cost Price')

    @classmethod
    def __setup__(cls):
        super(ProductCostHistory, cls).__setup__()
        cls._order.insert(0, ('date', 'DESC'))

    @classmethod
    def table_query(cls):
        pool = Pool()
        ProductCostPrice = pool.get('product.cost_price')
        history = ProductCostPrice.__table_history__()
        return history.select(Max(Column(history, '__id')).as_('id'),
                              Max(history.create_uid).as_('create_uid'),
                              Max(history.create_date).as_('create_date'),
                              Max(history.write_uid).as_('write_uid'),
                              Max(history.write_date).as_('write_date'),
                              Coalesce(history.write_date,
                                       history.create_date).as_('date'),
                              history.product.as_('product'),
                              history.cost_price.as_('cost_price'),
                              group_by=(history.id,
                                        Coalesce(history.write_date,
                                                 history.create_date),
                                        history.product, history.cost_price))

    def get_rec_name(self, name):
        return str(self.date)
コード例 #24
0
class Vehiculo(ModelView, ModelSQL):
    'Vehiculo'
    __name__ = 'oci.vehiculo'
    _order = 'name'

    active = fields.Boolean('Active')
    name = fields.Char('Pantente', required=True)
    km = fields.Integer('Kilometros')
    monto = fields.Function(fields.Numeric('Monto Total'), 'get_monto')
    monto_mensual = fields.Function(fields.Numeric('Monto Mensual'),
                                    'get_monto_mensual')
    modelo = fields.Char('Modelo', required=True)
    marca = fields.Char('Marca', required=True)
    bonos = fields.One2Many('oci.bono', 'name', 'Bonos', readonly=True)

    def get_monto(self, name):
        monto = 0
        for bono in self.bonos:
            monto += bono.monto
        return monto

    def get_monto_mensual(self, name):
        monto = 0
        Date = Pool().get('ir.date')
        today = Date.today()
        today2 = today.replace(day=1)
        bonos = Bono.search([('fecha', '>', today2)])
        for bono in bonos:
            monto = bono.monto
        return monto

    def get_combustible(self, fecha1, fecha2):
        bonos = Bono.search([('fecha', '>=', fecha1), ('fecha', '<=', fecha2),
                             ('name', '=', self.id)])
        return bonos

    def get_monto_entre_fechas(self, fecha1, fecha2):
        bonos = Bono.search([('fecha', '>=', fecha1), ('fecha', '<=', fecha2),
                             ('name', '=', self.id)])
        monto = 0
        for bono in bonos:
            monto += bono.monto
        return monto

    @staticmethod
    def default_active():
        return True
コード例 #25
0
class RrhhCv(ModelSQL, ModelView):
    'Curriculum Vitae'
    __name__ = 'rrhh.cv'

    estado_cv = fields.Selection([
        ('CITADO', 'Citado'),
        ('ANULADO', 'Anulado'),
        ('PENDIENTE', 'Pendiente'),        
        (None, ''),        
        ], 'Estado CV', sort=False, required=True)
    nombre = fields.Char('Apellido y Nombre',40)    
    photo1 = fields.Binary('Foto', states = STATES)
    fecha_presen = fields.Date('Fecha de Presentacion')
    fecha_nac = fields.Date('Fecha Nac.')
    cuil = fields.Char('Cuil',13)
    telefono = fields.Char('Telefono',30)
    celular = fields.Char('Celular',20)    
     
    direccion = fields.Char('Calle',20)
    altura = fields.Char('Altura',10)
    piso = fields.Char('Piso',5)
    dto = fields.Char('Dto.',5)
    entrecalle = fields.Char('Entre Calle',20)
    localidad = fields.Char('Localidad',20)
    
    ccosto = fields.Many2One('gnuhealth.hospital.building', 'Edificio')
    categoria = fields.Many2One('rrhh.categoria', 'Categoria')    
    convenio = fields.Selection([
        ('SI', 'Si'),
        ('NO', 'No'),
        ], 'Convenio', sort=False, required=True)
    sueldo = fields.Numeric('Sueldo', digits=(10,2))
    tliqui = fields.Selection([
        ('M', 'Mensual'),
        ('Q', 'Quincena'),
        ], 'Tipo Liquidacion', sort=False, required=True)
    tip_tur = fields.Selection([
        ('Dia' ,'Dia'),('Tarde', 'Tarde'),('Noche', 'Noche'),('Mixto', 'Mixto')], 
        'Turno', sort=False, required=False)
    entrada = fields.Time('Hor.Entrada')
    salida = fields.Time('Hor.Salida')
    observaciones = fields.Text('Observaciones')
    evaluacion = fields.Text('Evaluacion')
    otros = fields.Text('Otros')
    cv_photo1 = fields.Binary('Imagen1', states = STATES)
    cv_photo2 = fields.Binary('Imagen2', states = STATES)
    cv_photo3 = fields.Binary('Imagen3', states = STATES)
    email = fields.Char('E-Mail',40)
    #~ --------------- Calculo de edad del empleado  ----------------    
    edad_emple = fields.Function(fields.Char('Edad de Postulante',7, 
        on_change_with=['date_nac']),"on_change_with_date_agecv")

    def on_change_with_date_agecv(self,name=None):
        import datetime
        fecha_1=datetime.date.today().year        
        fecha_2= self.date_nac.year
        diff =  fecha_1 - fecha_2 
        years = str(diff)
        return years + ' años'
コード例 #26
0
class Origin(origin_mixin(_states, _depends), ModelSQL, ModelView):
    "Account Statement Origin"
    __name__ = 'account.statement.origin'
    _rec_name = 'number'

    lines = fields.One2Many(
        'account.statement.line',
        'origin',
        "Lines",
        states={
            'readonly':
            ((Eval('statement_id', -1) < 0)
             | ~Eval('statement_state').in_(['draft', 'validated'])),
        },
        domain=[
            ('statement', '=', Eval('statement')),
            ('date', '=', Eval('date')),
        ],
        depends=['statement', 'date', 'statement_id'])
    statement_id = fields.Function(fields.Integer("Statement ID"),
                                   'on_change_with_statement_id')
    pending_amount = fields.Function(fields.Numeric(
        "Pending Amount",
        digits=(16, Eval('_parent_statement', {}).get('currency_digits', 2))),
                                     'on_change_with_pending_amount',
                                     searcher='search_pending_amount')
    informations = fields.Dict('account.statement.origin.information',
                               "Informations",
                               readonly=True)

    @fields.depends('statement')
    def on_change_with_statement_id(self, name=None):
        if self.statement:
            return self.statement.id
        return -1

    @fields.depends('lines', 'amount')
    def on_change_with_pending_amount(self, name=None):
        lines_amount = sum(
            getattr(l, 'amount') or Decimal(0) for l in self.lines)
        return (self.amount or Decimal(0)) - lines_amount

    @classmethod
    def search_pending_amount(cls, name, clause):
        pool = Pool()
        Line = pool.get('account.statement.line')
        table = cls.__table__()
        line = Line.__table__()

        _, operator, value = clause
        Operator = fields.SQL_OPERATORS[operator]

        query = (table.join(
            line, 'LEFT', condition=line.origin == table.id).select(
                table.id,
                having=Operator(table.amount - Coalesce(Sum(line.amount), 0),
                                value),
                group_by=table.id))
        return [('id', 'in', query)]
コード例 #27
0
ファイル: expense.py プロジェクト: iehoshia/training_iesa
class ExpenseMoveReference(ModelView, ModelSQL):
    'Expense Move Reference'
    __name__ = 'account.iesa.expense.move.line'

    expense = fields.Many2One('account.iesa.expense', 'Expense')
    party = fields.Many2One('party.party', 'Party')
    description = fields.Char('Description')
    amount = fields.Numeric('Amount')
コード例 #28
0
class Configuration:
    __name__ = 'production.configuration'
    supply_period = fields.Property(fields.Numeric('Supply Period',
            digits=(16, 0), help='In number of days', required=True))

    @staticmethod
    def default_supply_period():
        return Decimal(0)
コード例 #29
0
class Employee(metaclass=PoolMeta):
    __name__ = 'company.employee'
    cost_price = fields.Function(
        fields.Numeric('Cost Price',
                       digits=price_digits,
                       help="Hourly cost price for this Employee."),
        'get_cost_price')
    cost_prices = fields.One2Many('company.employee_cost_price',
                                  'employee',
                                  'Cost Prices',
                                  help="List of hourly cost price over time.")
    _cost_prices_cache = Cache('company_employee.cost_prices')

    def get_cost_price(self, name):
        '''
        Return the cost price at the date given in the context or the
        current date
        '''
        ctx_date = Transaction().context.get('date', None)
        return self.compute_cost_price(ctx_date)

    def get_employee_costs(self):
        "Return a sorted list by date of start date and cost_price"
        pool = Pool()
        CostPrice = pool.get('company.employee_cost_price')
        # Get from cache employee costs or fetch them from the db
        employee_costs = self._cost_prices_cache.get(self.id)
        if employee_costs is None:
            cost_prices = CostPrice.search([
                ('employee', '=', self.id),
            ],
                                           order=[('date', 'ASC')])

            employee_costs = []
            for cost_price in cost_prices:
                employee_costs.append((cost_price.date, cost_price.cost_price))
            self._cost_prices_cache.set(self.id, employee_costs)
        return employee_costs

    def compute_cost_price(self, date=None):
        "Return the cost price at the given date"
        pool = Pool()
        Date = pool.get('ir.date')

        employee_costs = self.get_employee_costs()

        if date is None:
            with Transaction().set_context(company=self.company.id):
                date = Date.today()
        # compute the cost price for the given date
        cost = 0
        if employee_costs and date >= employee_costs[0][0]:
            for edate, ecost in employee_costs:
                if date >= edate:
                    cost = ecost
                else:
                    break
        return cost
コード例 #30
0
ファイル: account.py プロジェクト: iehoshia/training_iesa
class Type(ModelSQL, ModelView):
    'Account Type'
    __name__ = 'account.account.type'

    level = fields.Function(fields.Numeric('Level',digits=(2,0)),
        '_get_level')
    custom_amount = fields.Function(fields.Numeric('Custom Amount',
        digits=(2,0)), '_get_custom_amount')
    type_display_balance = fields.Selection([('debit','Debit'),
        ('credit','Credit')],
        'Type')

    def _get_level(self, parent=None): 
        level = 0
        if self.parent:
            level = self.parent.level + 1
        return  level

    def _get_childs_by_order(self, res=None):
        '''Returns the records of all the children computed recursively, and sorted by sequence. Ready for the printing'''
        
        Account = Pool().get('account.account.type')
        
        if res is None: 
            res = []

        childs = Account.search([('parent', '=', self.id)], order=[('sequence','ASC')])
        
        if len(childs)>=1:
            for child in childs:
                res.append(Account(child.id))
                child._get_childs_by_order(res=res)
        return res 

    def _get_custom_amount(self, name):
        amount = 0
        if self.type_display_balance == 'credit':
            amount  = - self.amount
        else:
            amount  = self.amount
        return amount

    @staticmethod
    def default_type_display_balance():
        return 'debit'