Esempio n. 1
0
class hr_contract_be(osv.osv):
    _inherit = 'hr.contract'

    _columns = {
        'travel_reimbursement_amount':
        fields.float('Reimbursement of travel expenses',
                     digits_compute=dp.get_precision('Payroll')),
        'car_company_amount':
        fields.float('Company car employer',
                     digits_compute=dp.get_precision('Payroll')),
        'car_employee_deduction':
        fields.float('Company Car Deduction for Worker',
                     digits_compute=dp.get_precision('Payroll')),
        'misc_onss_deduction':
        fields.float('Miscellaneous exempt ONSS ',
                     digits_compute=dp.get_precision('Payroll')),
        'meal_voucher_amount':
        fields.float('Check Value Meal ',
                     digits_compute=dp.get_precision('Payroll')),
        'meal_voucher_employee_deduction':
        fields.float('Check Value Meal - by worker ',
                     digits_compute=dp.get_precision('Payroll')),
        'insurance_employee_deduction':
        fields.float('Insurance Group - by worker ',
                     digits_compute=dp.get_precision('Payroll')),
        'misc_advantage_amount':
        fields.float('Benefits of various nature ',
                     digits_compute=dp.get_precision('Payroll')),
        'additional_net_amount':
        fields.float('Net supplements',
                     digits_compute=dp.get_precision('Payroll')),
        'retained_net_amount':
        fields.float('Net retained ',
                     digits_compute=dp.get_precision('Payroll')),
    }
Esempio n. 2
0
class res_partner(osv.osv):
    _inherit = "res.partner"

    _columns = {
        'partner_latitude': fields.float('Geo Latitude', digits=(16, 5)),
        'partner_longitude': fields.float('Geo Longitude', digits=(16, 5)),
        'date_localization': fields.date('Geo Localization Date'),
    }

    def geo_localize(self, cr, uid, ids, context=None):
        # Don't pass context to browse()! We need country names in english below
        for partner in self.browse(cr, uid, ids):
            if not partner:
                continue
            result = geo_find(geo_query_address(street=partner.street,
                                                zip=partner.zip,
                                                city=partner.city,
                                                state=partner.state_id.name,
                                                country=partner.country_id.name))
            if result:
                self.write(cr, uid, [partner.id], {
                    'partner_latitude': result[0],
                    'partner_longitude': result[1],
                    'date_localization': fields.date.context_today(self, cr, uid, context=context)
                }, context=context)
        return True
Esempio n. 3
0
class report_workcenter_load(osv.osv):
    _name = "report.workcenter.load"
    _description = "Work Center Load"
    _auto = False
    _log_access = False
    _columns = {
        'name':
        fields.char('Week', required=True),
        'workcenter_id':
        fields.many2one('mrp.workcenter', 'Work Center', required=True),
        'cycle':
        fields.float('Number of Cycles'),
        'hour':
        fields.float('Number of Hours'),
    }

    def init(self, cr):
        cr.execute("""
            create or replace view report_workcenter_load as (
                SELECT
                    min(wl.id) as id,
                    to_char(p.date_planned,'YYYY:mm:dd') as name,
                    SUM(wl.hour) AS hour,
                    SUM(wl.cycle) AS cycle,
                    wl.workcenter_id as workcenter_id
                FROM
                    mrp_production_workcenter_line wl
                    LEFT JOIN mrp_production p
                        ON p.id = wl.production_id
                GROUP BY
                    wl.workcenter_id,
                    to_char(p.date_planned,'YYYY:mm:dd')
            )""")
Esempio n. 4
0
class report_sales_by_user_pos_month(osv.osv):
    _name = "report.sales.by.user.pos.month"
    _description = "Sales by user monthly"
    _auto = False
    _columns = {
        'date_order': fields.date('Order Date',required=True, select=True),
        'amount': fields.float('Total', readonly=True, select=True),
        'qty': fields.float('Quantity', readonly=True, select=True),
        'user_id': fields.many2one('res.users', 'User', readonly=True, select=True),
    }

    def init(self, cr):
        tools.drop_view_if_exists(cr, 'report_sales_by_user_pos_month')
        cr.execute("""
            create or replace view report_sales_by_user_pos_month as (
                select
                    min(po.id) as id,
                    to_char(date_trunc('month',po.date_order),'YYYY-MM-DD')::text as date_order,
                    po.user_id as user_id,
                    sum(pol.qty)as qty,
                    sum((pol.price_unit * pol.qty * (1 - (pol.discount) / 100.0))) as amount
                from
                    pos_order as po,pos_order_line as pol,product_product as pp,product_template as pt
                where
                    pt.id=pp.product_tmpl_id and pp.id=pol.product_id and po.id = pol.order_id
               group by
                    to_char(date_trunc('month',po.date_order),'YYYY-MM-DD')::text,
                    po.user_id

                )
        """)
Esempio n. 5
0
class resource_calendar_attendance(osv.osv):
    _name = "resource.calendar.attendance"
    _description = "Work Detail"

    _columns = {
        'name':
        fields.char("Name", required=True),
        'dayofweek':
        fields.selection([('0', 'Monday'),
                          ('1', 'Tuesday'), ('2', 'Wednesday'),
                          ('3', 'Thursday'), ('4', 'Friday'),
                          ('5', 'Saturday'), ('6', 'Sunday')],
                         'Day of Week',
                         required=True,
                         select=True),
        'date_from':
        fields.date('Starting Date'),
        'date_to':
        fields.date('End Date'),
        'hour_from':
        fields.float('Work from',
                     required=True,
                     help="Start and End time of working.",
                     select=True),
        'hour_to':
        fields.float("Work to", required=True),
        'calendar_id':
        fields.many2one("resource.calendar",
                        "Resource's Calendar",
                        required=True),
    }

    _order = 'dayofweek, hour_from'

    _defaults = {'dayofweek': '0'}
Esempio n. 6
0
class account_tax(osv.osv):
    """ Add fields used to define some brazilian taxes """
    _inherit = 'account.tax'

    _columns = {
        'tax_discount':
        fields.boolean('Discount this Tax in Prince',
                       help="Mark it for (ICMS, PIS e etc.)."),
        'base_reduction':
        fields.float('Redution',
                     required=True,
                     digits=0,
                     help="Um percentual decimal em % entre 0-1."),
        'amount_mva':
        fields.float('MVA Percent',
                     required=True,
                     digits=0,
                     help="Um percentual decimal em % entre 0-1."),
        'amount_type':
        fields.selection([('group', 'Group of Taxes'), ('fixed', 'Fixed'),
                          ('percent', 'Percentage of Price'),
                          ('division', 'Percentage of Price Tax Included')],
                         string="Tax Computation",
                         required=True)
    }
    _defaults = TAX_DEFAULTS
Esempio n. 7
0
class DecimalPrecisionTestModel(orm.Model):
    _name = 'decimal.precision.test'

    _columns = {
        'float': fields.float(),
        'float_2': fields.float(digits=(16, 2)),
        'float_4': fields.float(digits=(16, 4)),
    }
Esempio n. 8
0
class purchase_requisition_line(osv.osv):
    _name = "purchase.requisition.line"
    _description = "Purchase Requisition Line"
    _rec_name = 'product_id'

    _columns = {
        'product_id': fields.many2one('product.product', 'Product', domain=[('purchase_ok', '=', True)]),
        'product_uom_id': fields.many2one('product.uom', 'Product Unit of Measure'),
        'product_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product Unit of Measure')),
        'requisition_id': fields.many2one('purchase.requisition', 'Call for Tenders', ondelete='cascade'),
        'company_id': fields.related('requisition_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True),
        'account_analytic_id': fields.many2one('account.analytic.account', 'Analytic Account',),
        'schedule_date': fields.date('Scheduled Date'),
    }

    def onchange_product_id(self, cr, uid, ids, product_id, product_uom_id, parent_analytic_account, analytic_account, parent_date, date, context=None):
        """ Changes UoM and name if product_id changes.
        @param name: Name of the field
        @param product_id: Changed product_id
        @return:  Dictionary of changed values
        """
        value = {'product_uom_id': ''}
        if product_id:
            prod = self.pool.get('product.product').browse(cr, uid, product_id, context=context)
            value = {'product_uom_id': prod.uom_id.id, 'product_qty': 1.0}
        if not analytic_account:
            value.update({'account_analytic_id': parent_analytic_account})
        if not date:
            value.update({'schedule_date': parent_date})
        return {'value': value}

    _defaults = {
        'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'purchase.requisition.line', context=c),
    }
Esempio n. 9
0
class resource_resource(osv.osv):
    _name = "resource.resource"
    _description = "Resource Detail"
    _columns = {
        'name':
        fields.char("Name", required=True),
        'code':
        fields.char('Code', size=16, copy=False),
        'active':
        fields.boolean(
            'Active',
            track_visibility='onchange',
            help=
            "If the active field is set to False, it will allow you to hide the resource record without removing it."
        ),
        'company_id':
        fields.many2one('res.company', 'Company'),
        'resource_type':
        fields.selection([('user', 'Human'), ('material', 'Material')],
                         'Resource Type',
                         required=True),
        'user_id':
        fields.many2one(
            'res.users',
            'User',
            help='Related user name for the resource to manage its access.'),
        'time_efficiency':
        fields.float(
            'Efficiency Factor',
            size=8,
            required=True,
            help=
            "This field depict the efficiency of the resource to complete tasks. e.g  resource put alone on a phase of 5 days with 5 tasks assigned to him, will show a load of 100% for this phase by default, but if we put a efficiency of 200%, then his load will only be 50%."
        ),
        'calendar_id':
        fields.many2one("resource.calendar",
                        "Working Time",
                        help="Define the schedule of resource"),
    }

    _defaults = {
        'resource_type':
        'user',
        'time_efficiency':
        1,
        'active':
        True,
        'company_id':
        lambda self, cr, uid, context: self.pool.get('res.company').
        _company_default_get(cr, uid, 'resource.resource', context=context)
    }

    def copy(self, cr, uid, id, default=None, context=None):
        if default is None:
            default = {}
        if not default.get('name', False):
            default.update(name=_('%s (copy)') %
                           (self.browse(cr, uid, id, context=context).name))
        return super(resource_resource, self).copy(cr, uid, id, default,
                                                   context)
Esempio n. 10
0
class stock_reportcustomer_model(osv.osv):
    _inherit = ['mail.thread', 'ir.needaction_mixin']
    _name = 'stock.reportcustomer.model'
    _description = 'Formulario de las Factuas del Cliente'
    _columns = {
        'name':
        fields.many2one('res.partner', 'Cliente'),
        'date':
        fields.date('Fecha Inicio', required=False),
        'date_end':
        fields.date('Fecha Fin', required=False),
        'reportcustomer_lines':
        fields.one2many('stock.reportcustomer.model.line', 'reportcustomer_id',
                        ' Detalle de los Productos'),
        'reportcustomer_invoice_lines':
        fields.one2many('stock.reportcustomer.invoices.line',
                        'reportcustomer_id', ' Detalle de los Productos'),
        'total_invoices':
        fields.float(
            'Monto Total Facturacion',
            digits=(14, 2),
        )
    }
    _defaults = {}
    _order = 'id desc'
Esempio n. 11
0
class pos_discount(osv.osv_memory):
    _name = 'pos.discount'
    _description = 'Add a Global Discount'
    _columns = {
        'discount': fields.float('Discount (%)', required=True, digits=(16,2)),
    }
    _defaults = {
        'discount': 5,
    }

    def apply_discount(self, cr, uid, ids, context=None):
        """
         To give the discount of  product and check the.

         @param self: The object pointer.
         @param cr: A database cursor
         @param uid: ID of the user currently logged in
         @param context: A standard dictionary
         @return : nothing
        """
        order_ref = self.pool.get('pos.order')
        order_line_ref = self.pool.get('pos.order.line')
        if context is None:
            context = {}
        this = self.browse(cr, uid, ids[0], context=context)
        record_id = context and context.get('active_id', False)
        if isinstance(record_id, (int, long)):
            record_id = [record_id]
        for order in order_ref.browse(cr, uid, record_id, context=context):
            order_line_ref.write(cr, uid, [x.id for x in order.lines], {'discount':this.discount}, context=context)
        return {}
Esempio n. 12
0
class res_currency_rate(osv.osv):
    _name = "res.currency.rate"
    _description = "Currency Rate"

    _columns = {
        'name': fields.datetime('Date', required=True, select=True),
        'rate': fields.float('Rate', digits=(12, 6), help='The rate of the currency to the currency of rate 1'),
        'currency_id': fields.many2one('res.currency', 'Currency', readonly=True),
        'company_id': fields.many2one('res.company', 'Company')
    }
    _defaults = {
        'name': lambda *a: time.strftime('%Y-%m-%d 00:00:00'),
    }
    _order = "name desc"

    def name_search(self, cr, user, name, args=None, operator='ilike', context=None, limit=80):
        if operator in ['=', '!=']:
            try:
                date_format = '%Y-%m-%d'
                if context.get('lang'):
                    lang_obj = self.pool['res.lang']
                    lang_ids = lang_obj.search(cr, user, [('code', '=', context['lang'])], context=context)
                    if lang_ids:
                        date_format = lang_obj.browse(cr, user, lang_ids[0], context=context).date_format
                name = time.strftime('%Y-%m-%d', time.strptime(name, date_format))
            except ValueError:
                try:
                    args.append(('rate', operator, float(name)))
                except ValueError:
                    return []
                name = ''
                operator = 'ilike'
        return super(res_currency_rate, self).name_search(cr, user, name, args=args, operator=operator, context=context, limit=limit)
Esempio n. 13
0
class account_journal(osv.osv):
    _inherit = 'account.journal'
    _columns = {
        'journal_user': fields.boolean('Active in Point of Sale', help="Check this box if this journal define a payment method that can be used in a point of sale."),

        'amount_authorized_diff' : fields.float('Amount Authorized Difference', help="This field depicts the maximum difference allowed between the ending balance and the theoretical cash when closing a session, for non-POS managers. If this maximum is reached, the user will have an error message at the closing of his session saying that he needs to contact his manager."),
    }
Esempio n. 14
0
class res_company(osv.osv):
    _inherit = 'res.company'

    _columns = {
        'plafond_secu':
        fields.float('Plafond de la Securite Sociale',
                     digits_compute=dp.get_precision('Payroll')),
        'nombre_employes':
        fields.integer('Nombre d\'employes'),
        'cotisation_prevoyance':
        fields.float('Cotisation Patronale Prevoyance',
                     digits_compute=dp.get_precision('Payroll')),
        'org_ss':
        fields.char('Organisme de securite sociale'),
        'conv_coll':
        fields.char('Convention collective'),
    }
Esempio n. 15
0
class test_converter(orm.Model):
    _name = 'web_editor.converter.test'

    # disable translation export for those brilliant field labels and values
    _translate = False

    _columns = {
        'char':
        fields.char(),
        'integer':
        fields.integer(),
        'float':
        fields.float(),
        'numeric':
        fields.float(digits=(16, 2)),
        'many2one':
        fields.many2one('web_editor.converter.test.sub'),
        'binary':
        fields.binary(),
        'date':
        fields.date(),
        'datetime':
        fields.datetime(),
        'selection':
        fields.selection([
            (1, "réponse A"),
            (2, "réponse B"),
            (3, "réponse C"),
            (4, "réponse D"),
        ]),
        'selection_str':
        fields.selection(
            [
                ('A', "Qu'il n'est pas arrivé à Toronto"),
                ('B', "Qu'il était supposé arriver à Toronto"),
                ('C', "Qu'est-ce qu'il fout ce maudit pancake, tabernacle ?"),
                ('D', "La réponse D"),
            ],
            string=
            u"Lorsqu'un pancake prend l'avion à destination de Toronto et "
            u"qu'il fait une escale technique à St Claude, on dit:"),
        'html':
        fields.html(),
        'text':
        fields.text(),
    }
Esempio n. 16
0
class stock_reportcustomer_model_line(osv.osv):
    _name = 'stock.reportcustomer.model.line'
    _description = 'Detalle Ventas del Producto'
    _rec_name = 'product_id'
    _columns = {
        'product_id':
        fields.many2one('product.product', 'Producto', required=False),
        'qty':
        fields.float('Cantidad', digits=(14, 4), required=False),
        'amount_total':
        fields.float('Total Ventas', digits=(14, 4), required=False),
        'uom_id':
        fields.many2one('product.uom', 'Unidad de Medida', required=False),
        'reportcustomer_id':
        fields.many2one('stock.reportcustomer.model', 'ID Ref'),
    }

    _defaults = {}
Esempio n. 17
0
class stock_valuation_adjustment_lines(osv.osv):
    _name = 'stock.valuation.adjustment.lines'
    _description = 'Stock Valuation Adjustment Lines'

    def _amount_final(self, cr, uid, ids, name, args, context=None):
        result = {}
        for line in self.browse(cr, uid, ids, context=context):
            result[line.id] = {
                'former_cost_per_unit': 0.0,
                'final_cost': 0.0,
            }
            result[line.id]['former_cost_per_unit'] = (line.former_cost / line.quantity if line.quantity else 1.0)
            result[line.id]['final_cost'] = (line.former_cost + line.additional_landed_cost)
        return result

    def _get_name(self, cr, uid, ids, name, arg, context=None):
        res = {}
        for line in self.browse(cr, uid, ids, context=context):
            res[line.id] = line.product_id.code or line.product_id.name or ''
            if line.cost_line_id:
                res[line.id] += ' - ' + line.cost_line_id.name
        return res

    _columns = {
        'name': fields.function(_get_name, type='char', string='Description', store=True),
        'cost_id': fields.many2one('stock.landed.cost', 'Landed Cost', required=True, ondelete='cascade'),
        'cost_line_id': fields.many2one('stock.landed.cost.lines', 'Cost Line', readonly=True),
        'move_id': fields.many2one('stock.move', 'Stock Move', readonly=True),
        'product_id': fields.many2one('product.product', 'Product', required=True),
        'quantity': fields.float('Quantity', digits_compute=dp.get_precision('Product Unit of Measure'), required=True),
        'weight': fields.float('Weight', digits_compute=dp.get_precision('Product Unit of Measure')),
        'volume': fields.float('Volume', digits_compute=dp.get_precision('Product Unit of Measure')),
        'former_cost': fields.float('Former Cost', digits_compute=dp.get_precision('Product Price')),
        'former_cost_per_unit': fields.function(_amount_final, multi='cost', string='Former Cost(Per Unit)', type='float', store=True, digits=0),
        'additional_landed_cost': fields.float('Additional Landed Cost', digits_compute=dp.get_precision('Product Price')),
        'final_cost': fields.function(_amount_final, multi='cost', string='Final Cost', type='float', store=True, digits=0),
    }

    _defaults = {
        'quantity': 1.0,
        'weight': 1.0,
        'volume': 1.0,
    }
Esempio n. 18
0
class company(osv.osv):
    _inherit = 'res.company'
    _columns = {
        'manufacturing_lead':
        fields.float('Manufacturing Lead Time',
                     required=True,
                     help="Security days for each manufacturing operation."),
    }
    _defaults = {
        'manufacturing_lead': lambda *a: 1.0,
    }
Esempio n. 19
0
class pos_config(osv.osv):
    _inherit = 'pos.config' 
    _columns = {
        'iface_discount': fields.boolean('Order Discounts', help='Allow the cashier to give discounts on the whole order.'),
        'discount_pc': fields.float('Discount Percentage', help='The default discount percentage'),
        'discount_product_id': fields.many2one('product.product','Discount Product', help='The product used to model the discount'),
    }
    _defaults = {
        'iface_discount': True,
        'discount_pc': 10,
    }
Esempio n. 20
0
class hr_contract(osv.osv):
    """
    Employee contract allows to add different values in fields.
    Fields are used in salary rule computation.
    """

    _inherit = 'hr.contract'
    _description = 'HR Contract'

    _columns = {
        'tds':
        fields.float('TDS',
                     digits_compute=dp.get_precision('Payroll'),
                     help="Amount for Tax Deduction at Source"),
        'driver_salay':
        fields.boolean(
            'Driver Salary',
            help="Check this box if you provide allowance for driver"),
        'medical_insurance':
        fields.float(
            'Medical Insurance',
            digits_compute=dp.get_precision('Payroll'),
            help="Deduction towards company provided medical insurance"),
        'voluntary_provident_fund':
        fields.float(
            'Voluntary Provident Fund (%)',
            digits_compute=dp.get_precision('Payroll'),
            help=
            "VPF is a safe option wherein you can contribute more than the PF ceiling of 12% that has been mandated by the government and VPF computed as percentage(%)"
        ),
        'house_rent_allowance_metro_nonmetro':
        fields.float(
            'House Rent Allowance (%)',
            digits_compute=dp.get_precision('Payroll'),
            help=
            "HRA is an allowance given by the employer to the employee for taking care of his rental or accommodation expenses for metro city it is 50% and for non metro 40%. \nHRA computed as percentage(%)"
        ),
        'supplementary_allowance':
        fields.float('Supplementary Allowance',
                     digits_compute=dp.get_precision('Payroll')),
    }
Esempio n. 21
0
class mrp_repair_fee(osv.osv, ProductChangeMixin):
    _name = 'mrp.repair.fee'
    _description = 'Repair Fees Line'

    def _amount_line(self, cr, uid, ids, field_name, arg, context=None):
        """ Calculates amount.
        @param field_name: Name of field.
        @param arg: Argument
        @return: Dictionary of values.
        """
        res = {}
        tax_obj = self.pool.get('account.tax')
        cur_obj = self.pool.get('res.currency')
        for line in self.browse(cr, uid, ids, context=context):
            if line.to_invoice:
                cur = line.repair_id.pricelist_id.currency_id
                taxes = tax_obj.compute_all(cr, uid, line.tax_id, line.price_unit, cur.id, line.product_uom_qty, line.product_id.id, line.repair_id.partner_id.id)
                res[line.id] = taxes['total_included']
            else:
                res[line.id] = 0
        return res

    _columns = {
        'repair_id': fields.many2one('mrp.repair', 'Repair Order Reference', required=True, ondelete='cascade', select=True),
        'name': fields.char('Description', select=True, required=True),
        'product_id': fields.many2one('product.product', 'Product'),
        'product_uom_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product Unit of Measure'), required=True),
        'price_unit': fields.float('Unit Price', required=True),
        'product_uom': fields.many2one('product.uom', 'Product Unit of Measure', required=True),
        'price_subtotal': fields.function(_amount_line, string='Subtotal', digits=0),
        'tax_id': fields.many2many('account.tax', 'repair_fee_line_tax', 'repair_fee_line_id', 'tax_id', 'Taxes'),
        'invoice_line_id': fields.many2one('account.invoice.line', 'Invoice Line', readonly=True, copy=False),
        'to_invoice': fields.boolean('To Invoice'),
        'invoiced': fields.boolean('Invoiced', readonly=True, copy=False),
    }

    _defaults = {
        'to_invoice': lambda *a: True,
    }
Esempio n. 22
0
class membership_invoice(osv.osv_memory):
    """Membership Invoice"""

    _name = "membership.invoice"
    _description = "Membership Invoice"
    _columns = {
        'product_id': fields.many2one('product.product','Membership', required=True),
        'member_price': fields.float('Member Price', digits_compute= dp.get_precision('Product Price'), required=True),
    }
    def onchange_product(self, cr, uid, ids, product_id=False):
        """This function returns value of  product's member price based on product id.
        """
        if not product_id:
            return {'value': {'member_price': False}}
        return {'value': {'member_price': self.pool.get('product.product').price_get(cr, uid, [product_id])[product_id]}}

    def membership_invoice(self, cr, uid, ids, context=None):
        mod_obj = self.pool.get('ir.model.data')
        partner_obj = self.pool.get('res.partner')
        datas = {}
        if context is None:
            context = {}
        data = self.browse(cr, uid, ids, context=context)
        if data:
            data = data[0]
            datas = {
                'membership_product_id': data.product_id.id,
                'amount': data.member_price
            }
        invoice_list = partner_obj.create_membership_invoice(cr, uid, context.get('active_ids', []), datas=datas, context=context)

        try:
            search_view_id = mod_obj.get_object_reference(cr, uid, 'account', 'view_account_invoice_filter')[1]
        except ValueError:
            search_view_id = False
        try:
            form_view_id = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_form')[1]
        except ValueError:
            form_view_id = False

        return  {
            'domain': [('id', 'in', invoice_list)],
            'name': 'Membership Invoices',
            'view_type': 'form',
            'view_mode': 'tree,form',
            'res_model': 'account.invoice',
            'type': 'ir.actions.act_window',
            'views': [(False, 'tree'), (form_view_id, 'form')],
            'search_view_id': search_view_id,
        }
Esempio n. 23
0
class res_company(osv.osv):
    _inherit = 'res.company'
    _columns = {
        'timesheet_range': fields.selection(
            [('day','Day'),('week','Week'),('month','Month')], 'Timesheet range',
            help="Periodicity on which you validate your timesheets."),
        'timesheet_max_difference': fields.float('Timesheet allowed difference(Hours)',
            help="Allowed difference in hours between the sign in/out and the timesheet " \
                 "computation for one sheet. Set this to 0 if you do not want any control."),
    }
    _defaults = {
        'timesheet_range': lambda *args: 'week',
        'timesheet_max_difference': lambda *args: 0.0
    }
Esempio n. 24
0
class payroll_advice_line(osv.osv):
    '''
    Bank Advice Lines
    '''
    def onchange_employee_id(self,
                             cr,
                             uid,
                             ids,
                             employee_id=False,
                             context=None):
        res = {}
        hr_obj = self.pool.get('hr.employee')
        if not employee_id:
            return {'value': res}
        employee = hr_obj.browse(cr, uid, [employee_id], context=context)[0]
        res.update({
            'name': employee.bank_account_id.acc_number,
            'ifsc_code': employee.bank_account_id.bank_bic or ''
        })
        return {'value': res}

    _name = 'hr.payroll.advice.line'
    _description = 'Bank Advice Lines'
    _columns = {
        'advice_id':
        fields.many2one('hr.payroll.advice', 'Bank Advice'),
        'name':
        fields.char('Bank Account No.', size=25, required=True),
        'ifsc_code':
        fields.char('IFSC Code', size=16),
        'employee_id':
        fields.many2one('hr.employee', 'Employee', required=True),
        'bysal':
        fields.float('By Salary', digits_compute=dp.get_precision('Payroll')),
        'debit_credit':
        fields.char('C/D', size=3, required=False),
        'company_id':
        fields.related('advice_id',
                       'company_id',
                       type='many2one',
                       required=False,
                       relation='res.company',
                       string='Company',
                       store=True),
        'ifsc':
        fields.related('advice_id', 'neft', type='boolean', string='IFSC'),
    }
    _defaults = {
        'debit_credit': 'C',
    }
Esempio n. 25
0
class WebsiteTwitterTweet(osv.osv):
    _name = "website.twitter.tweet"
    _description = "Twitter Tweets"
    _columns = {
        'website_id': fields.many2one('website', string="Website"),
        'screen_name': fields.char("Screen Name"),
        'tweet': fields.text('Tweets'),

        # Twitter IDs are 64-bit unsigned ints, so we need to store them in
        # unlimited precision NUMERIC columns, which can be done with a
        # float field. Used digits=(0,0) to indicate unlimited.
        # Using VARCHAR would work too but would have sorting problems.
        'tweet_id': fields.float("Tweet ID", digits=(0, 0)),  # Twitter
    }
Esempio n. 26
0
class mrp_product_produce_line(osv.osv_memory):
    _name = "mrp.product.produce.line"
    _description = "Product Produce Consume lines"

    _columns = {
        'product_id':
        fields.many2one('product.product', string='Product'),
        'product_qty':
        fields.float(
            'Quantity (in default UoM)',
            digits_compute=dp.get_precision('Product Unit of Measure')),
        'lot_id':
        fields.many2one('stock.production.lot', string='Lot'),
        'produce_id':
        fields.many2one('mrp.product.produce', string="Produce"),
    }
Esempio n. 27
0
class crm_team(osv.Model):
    _name = "crm.team"
    _inherit = ['mail.thread', 'ir.needaction_mixin']
    _description = "Sales Team"
    _order = "name"
    _period_number = 5

    def _get_default_team_id(self, cr, uid, context=None, user_id=None):
        if context is None:
            context = {}
        if user_id is None:
            user_id = uid
        team_id = context.get('default_team_id')
        if not team_id:
            team_ids = self.search(cr, uid, ['|', ('user_id', '=', user_id), ('member_ids', 'in', user_id)], limit=1, context=context)
            team_id = team_ids[0] if team_ids else False
        if not team_id:
            team_id = self.pool['ir.model.data'].xmlid_to_res_id(cr, uid, 'sales_team.team_sales_department')
        return team_id

    _columns = {
        'name': fields.char('Sales Team', size=64, required=True, translate=True),
        'code': fields.char('Code', size=8),
        'active': fields.boolean('Active', help="If the active field is set to "\
                        "false, it will allow you to hide the sales team without removing it."),
        'company_id': fields.many2one('res.company', 'Company'),
        'user_id': fields.many2one('res.users', 'Team Leader'),
        'member_ids': fields.one2many('res.users', 'sale_team_id', 'Team Members'),
        'reply_to': fields.char('Reply-To', size=64, help="The email address put in the 'Reply-To' of all emails sent by eCore about cases in this sales team"),
        'working_hours': fields.float('Working Hours', digits=(16, 2)),
        'color': fields.integer('Color Index'),
    }

    _defaults = {
        'active': 1,
        'company_id': lambda self, cr, uid, context: self.pool.get('res.company')._company_default_get(cr, uid, 'crm.team', context=context),
    }

    _sql_constraints = [
        ('code_uniq', 'unique (code)', 'The code of the sales team must be unique !')
    ]

    def create(self, cr, uid, values, context=None):
        if context is None:
            context = {}
        context['mail_create_nosubscribe'] = True
        return super(crm_team, self).create(cr, uid, values, context=context)
Esempio n. 28
0
class bid_line_qty(osv.osv_memory):
    _name = "bid.line.qty"
    _description = "Change Bid line quantity"
    _columns = {
        'qty':
        fields.float(
            'Quantity',
            digits_compute=dp.get_precision('Product Unit of Measure'),
            required=True),
    }

    def change_qty(self, cr, uid, ids, context=None):
        active_ids = context and context.get('active_ids', [])
        data = self.browse(cr, uid, ids, context=context)[0]
        self.pool.get('purchase.order.line').write(
            cr, uid, active_ids, {'quantity_tendered': data.qty})
        return {'type': 'ir.actions.act_window_close'}
Esempio n. 29
0
class stock_return_picking_line(osv.osv_memory):
    _name = "stock.return.picking.line"
    _rec_name = 'product_id'

    _columns = {
        'product_id':
        fields.many2one('product.product', string="Product", required=True),
        'quantity':
        fields.float(
            "Quantity",
            digits_compute=dp.get_precision('Product Unit of Measure'),
            required=True),
        'wizard_id':
        fields.many2one('stock.return.picking', string="Wizard"),
        'move_id':
        fields.many2one('stock.move', "Move"),
    }
Esempio n. 30
0
class sale_order_line(osv.osv):
    _inherit = "sale.order.line"

    @api.multi
    @api.onchange('product_id', 'product_uom')
    def product_id_change_margin(self):
        for line in self:
            if line.order_id.pricelist_id:
                frm_cur = self.env.user.company_id.currency_id
                to_cur = line.order_id.pricelist_id.currency_id
                purchase_price = line.product_id.standard_price
                if line.product_uom != line.product_id.uom_id:
                    purchase_price = self.env['product.uom']._compute_price(
                        line.product_id.uom_id.id,
                        purchase_price,
                        to_uom_id=line.product_uom.id)
                ctx = self.env.context.copy()
                ctx['date'] = line.order_id.date_order
                price = frm_cur.with_context(ctx).compute(purchase_price,
                                                          to_cur,
                                                          round=False)
                line.purchase_price = price

    def _product_margin(self, cr, uid, ids, field_name, arg, context=None):
        cur_obj = self.pool.get('res.currency')
        res = {}
        for line in self.browse(cr, uid, ids, context=context):
            cur = line.order_id.pricelist_id.currency_id
            res[line.id] = 0
            if line.product_id:
                tmp_margin = line.price_subtotal - (
                    (line.purchase_price or line.product_id.standard_price) *
                    line.product_uom_qty)
                res[line.id] = cur_obj.round(cr, uid, cur, tmp_margin)
        return res

    _columns = {
        'margin':
        fields.function(_product_margin,
                        string='Margin',
                        digits_compute=dp.get_precision('Product Price'),
                        store=True),
        'purchase_price':
        fields.float('Cost', digits_compute=dp.get_precision('Product Price'))
    }
Esempio n. 31
0
def selection_fn(obj, cr, uid, context=None):
    return list(enumerate(["Corge", "Grault", "Wheee", "Moog"]))

def function_fn(model, cr, uid, ids, field_name, arg, context):
    return dict((id, 3) for id in ids)

def function_fn_write(model, cr, uid, id, field_name, field_value, fnct_inv_arg, context):
    """ just so CreatorCase.export can be used
    """
    pass

models = [
    ('boolean', fields.boolean()),
    ('integer', fields.integer()),
    ('float', fields.float()),
    ('decimal', fields.float(digits=(16, 3))),
    ('string.bounded', fields.char('unknown', size=16)),
    ('string.required', fields.char('unknown', size=None, required=True)),
    ('string', fields.char('unknown', size=None)),
    ('date', fields.date()),
    ('datetime', fields.datetime()),
    ('text', fields.text()),
    ('selection', fields.selection([(1, "Foo"), (2, "Bar"), (3, "Qux"), (4, '')])),
    # here use size=-1 to store the values as integers instead of strings
    ('selection.function', fields.selection(selection_fn, size=-1)),
    # just relate to an integer
    ('many2one', fields.many2one('export.integer')),
    ('one2many', fields.one2many('export.one2many.child', 'parent_id')),
    ('many2many', fields.many2many('export.many2many.other')),
    ('function', fields.function(function_fn, fnct_inv=function_fn_write, type="integer")),