예제 #1
0
파일: workflow.py 프로젝트: LiberTang0/5
class wkf_transition(osv.osv):
    _table = "wkf_transition"
    _name = "workflow.transition"
    _rec_name = 'signal'
    _columns = {
        'trigger_model': fields.char('Trigger Object'),
        'trigger_expr_id': fields.char('Trigger Expression'),
        'sequence': fields.integer('Sequence'),
        'signal': fields.char('Signal (Button Name)',
                              help="When the operation of transition comes from a button pressed in the client form, "\
                              "signal tests the name of the pressed button. If signal is NULL, no button is necessary to validate this transition."),
        'group_id': fields.many2one('res.groups', 'Group Required',
                                   help="The group that a user must have to be authorized to validate this transition."),
        'condition': fields.char('Condition', required=True,
                                 help="Expression to be satisfied if we want the transition done."),
        'act_from': fields.many2one('workflow.activity', 'Source Activity', required=True, select=True, ondelete='cascade',
                                    help="Source activity. When this activity is over, the condition is tested to determine if we can start the ACT_TO activity."),
        'act_to': fields.many2one('workflow.activity', 'Destination Activity', required=True, select=True, ondelete='cascade',
                                  help="The destination activity."),
        'wkf_id': fields.related('act_from','wkf_id', type='many2one', relation='workflow', string='Workflow', select=True),
    }
    _defaults = {
        'condition': lambda *a: 'True',
        'sequence': 10,
    }

    _order = 'sequence,id'

    def name_get(self, cr, uid, ids, context=None):
        return [(line.id, (line.act_from.name) + '+' +
                 (line.act_to.name)) if line.signal == False else
                (line.id, line.signal)
                for line in self.browse(cr, uid, ids, context=context)]

    def name_search(self,
                    cr,
                    user,
                    name,
                    args=None,
                    operator='ilike',
                    context=None,
                    limit=100):
        if args is None:
            args = []
        if name:
            ids = self.search(cr,
                              user,
                              [
                                  '|', ('act_from', operator, name),
                                  ('act_to', operator, name)
                              ] + args,
                              limit=limit)
            return self.name_get(cr, user, ids, context=context)
        return super(wkf_transition, self).name_search(cr,
                                                       user,
                                                       name,
                                                       args=args,
                                                       operator=operator,
                                                       context=context,
                                                       limit=limit)
예제 #2
0
class account_invoice_report(osv.osv):
    _inherit = "account.invoice.report"
    _columns = {
        'cost_center_id':
        fields.many2one('account.cost.center',
                        string="Centro de costos",
                        readonly=True),
        'account_analytic_id':
        fields.many2one('account.analytic.account',
                        string="Cuenta analitica",
                        readonly=True)
    }

    def _select(self):
        return super(account_invoice_report, self)._select(
        ) + ", sub.cost_center_id as cost_center_id, sub.account_analytic_id as account_analytic_id"

    def _sub_select(self):
        return super(account_invoice_report, self)._sub_select(
        ) + ", ail.cost_center_id as cost_center_id, ail.account_analytic_id as account_analytic_id"

    def _group_by(self):
        return super(
            account_invoice_report,
            self)._group_by() + ", ail.cost_center_id, ail.account_analytic_id"
예제 #3
0
파일: resource.py 프로젝트: ecoreos/hz
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)
예제 #4
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)
예제 #5
0
class MailComposeMessage(osv.TransientModel):
    """Add concept of mass mailing campaign to the mail.compose.message wizard
    """
    _inherit = 'mail.compose.message'

    _columns = {
        'mass_mailing_campaign_id': fields.many2one(
            'mail.mass_mailing.campaign', 'Mass Mailing Campaign'
        ),
        'mass_mailing_id': fields.many2one(
            'mail.mass_mailing', 'Mass Mailing', ondelete='cascade'
        ),
        'mass_mailing_name': fields.char('Mass Mailing'),
        'mailing_list_ids': fields.many2many(
            'mail.mass_mailing.list', string='Mailing List'
        ),
    }

    def get_mail_values(self, cr, uid, ids, res_ids, context=None):
        """ Override method that generated the mail content by creating the
        mail.mail.statistics values in the o2m of mail_mail, when doing pure
        email mass mailing. """
        res = super(MailComposeMessage, self).get_mail_values(cr, uid, ids, res_ids, context=context)
        # TDE: arg was wiards, not ids - but new API -> multi with ensure_one
        wizard = self.browse(cr, uid, ids[0], context=context)
        # use only for allowed models in mass mailing
        if wizard.composition_mode == 'mass_mail' and \
                (wizard.mass_mailing_name or wizard.mass_mailing_id) and \
                wizard.model in [item[0] for item in self.pool['mail.mass_mailing']._get_mailing_model(cr, uid, context=context)]:
            mass_mailing = wizard.mass_mailing_id
            if not mass_mailing:
                reply_to_mode = wizard.no_auto_thread and 'email' or 'thread'
                reply_to = wizard.no_auto_thread and wizard.reply_to or False
                mass_mailing_id = self.pool['mail.mass_mailing'].create(
                    cr, uid, {
                        'mass_mailing_campaign_id': wizard.mass_mailing_campaign_id and wizard.mass_mailing_campaign_id.id or False,
                        'name': wizard.mass_mailing_name,
                        'template_id': wizard.template_id and wizard.template_id.id or False,
                        'state': 'done',
                        'reply_to_mode': reply_to_mode,
                        'reply_to': reply_to,
                        'sent_date': fields.datetime.now(),
                        'body_html': wizard.body,
                        'mailing_model': wizard.model,
                        'mailing_domain': wizard.active_domain,
                    }, context=context)
                mass_mailing = self.pool['mail.mass_mailing'].browse(cr, uid, mass_mailing_id, context=context)
            for res_id in res_ids:
                res[res_id].update({
                    'mailing_id':  mass_mailing.id,
                    'statistics_ids': [(0, 0, {
                        'model': wizard.model,
                        'res_id': res_id,
                        'mass_mailing_id': mass_mailing.id,
                    })],
                    # email-mode: keep original message for routing
                    'notification': mass_mailing.reply_to_mode == 'thread',
                    'auto_delete': not mass_mailing.keep_archives,
                })
        return res
예제 #6
0
파일: stock_account.py 프로젝트: ecoreos/hz
class stock_location(osv.osv):
    _inherit = "stock.location"

    _columns = {
        'valuation_in_account_id':
        fields.many2one(
            'account.account',
            'Stock Valuation Account (Incoming)',
            domain=[('internal_type', '=', 'other'),
                    ('deprecated', '=', False)],
            help=
            "Used for real-time inventory valuation. When set on a virtual location (non internal type), "
            "this account will be used to hold the value of products being moved from an internal location "
            "into this location, instead of the generic Stock Output Account set on the product. "
            "This has no effect for internal locations."),
        'valuation_out_account_id':
        fields.many2one(
            'account.account',
            'Stock Valuation Account (Outgoing)',
            domain=[('internal_type', '=', 'other'),
                    ('deprecated', '=', False)],
            help=
            "Used for real-time inventory valuation. When set on a virtual location (non internal type), "
            "this account will be used to hold the value of products being moved out of this location "
            "and into an internal location, instead of the generic Stock Output Account set on the product. "
            "This has no effect for internal locations."),
    }
예제 #7
0
class PaymentMethod(osv.Model):
    _name = 'payment.method'
    _order = 'partner_id'

    _columns = {
        'name': fields.char('Name', help='Name of the payment method'),
        'partner_id': fields.many2one('res.partner', 'Partner', required=True),
        'acquirer_id': fields.many2one('payment.acquirer', 'Acquirer Account', required=True),
        'acquirer_ref': fields.char('Acquirer Ref.', required=True),
        'active': fields.boolean('Active'),
        'payment_ids': fields.one2many('payment.transaction', 'payment_method_id', 'Payment Transactions'),
    }

    _defaults = {
        'active': True
    }

    def create(self, cr, uid, values, context=None):
        # call custom create method if defined (i.e. ogone_create for ogone)
        if values.get('acquirer_id'):
            acquirer = self.pool['payment.acquirer'].browse(cr, uid, values.get('acquirer_id'), context=context)

            # custom create
            custom_method_name = '%s_create' % acquirer.provider
            if hasattr(self, custom_method_name):
                values.update(getattr(self, custom_method_name)(cr, uid, values, context=context))

        return super(PaymentMethod, self).create(cr, uid, values, context=context)
예제 #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),
    }
예제 #9
0
파일: workflow.py 프로젝트: LiberTang0/5
class wkf_triggers(osv.osv):
    _table = "wkf_triggers"
    _name = "workflow.triggers"
    _log_access = False
    _columns = {
        'res_id':
        fields.integer('Resource ID', size=128),
        'model':
        fields.char('Object'),
        'instance_id':
        fields.many2one('workflow.instance',
                        'Destination Instance',
                        ondelete="cascade"),
        'workitem_id':
        fields.many2one('workflow.workitem',
                        'Workitem',
                        required=True,
                        ondelete="cascade"),
    }

    def _auto_init(self, cr, context=None):
        super(wkf_triggers, self)._auto_init(cr, context)
        cr.execute(
            'SELECT indexname FROM pg_indexes WHERE indexname = \'wkf_triggers_res_id_model_index\''
        )
        if not cr.fetchone():
            cr.execute(
                'CREATE INDEX wkf_triggers_res_id_model_index ON wkf_triggers (res_id, model)'
            )
예제 #10
0
파일: workflow.py 프로젝트: LiberTang0/5
class wkf_workitem(osv.osv):
    _table = "wkf_workitem"
    _name = "workflow.workitem"
    _log_access = False
    _rec_name = 'state'
    _columns = {
        'act_id':
        fields.many2one('workflow.activity',
                        'Activity',
                        required=True,
                        ondelete="cascade",
                        select=True),
        'wkf_id':
        fields.related('act_id',
                       'wkf_id',
                       type='many2one',
                       relation='workflow',
                       string='Workflow'),
        'subflow_id':
        fields.many2one('workflow.instance',
                        'Subflow',
                        ondelete="set null",
                        select=True),
        'inst_id':
        fields.many2one('workflow.instance',
                        'Instance',
                        required=True,
                        ondelete="cascade",
                        select=True),
        'state':
        fields.char('Status', select=True),
    }
예제 #11
0
class sale_order_line(osv.osv):
    _inherit = 'sale.order.line'
    _columns = {
        'event_id': fields.many2one(
            'event.event', 'Event',
            help="Choose an event and it will automatically create a registration for this event."),
        'event_ticket_id': fields.many2one(
            'event.event.ticket', 'Event Ticket',
            help="Choose an event ticket and it will automatically create a registration for this event ticket."),
        # those 2 fields are used for dynamic domains and filled by onchange
        # TDE: really necessary ? ...
        'event_type_id': fields.related('product_id', 'event_type_id', type='many2one', relation="event.type", string="Event Type"),
        'event_ok': fields.related('product_id', 'event_ok', string='event_ok', type='boolean'),
    }

    def _prepare_order_line_invoice_line(self, cr, uid, line, account_id=False, context=None):
        res = super(sale_order_line, self)._prepare_order_line_invoice_line(cr, uid, line, account_id=account_id, context=context)
        if line.event_id:
            event = self.pool['event.event'].read(cr, uid, line.event_id.id, ['name'], context=context)
            res['name'] = '%s: %s' % (res.get('name', ''), event['name'])
        return res

    @api.onchange('product_id')
    def product_id_change_event(self):
        if self.product_id.event_ok:
            values = dict(event_type_id=self.product_id.event_type_id.id,
                          event_ok=self.product_id.event_ok)
        else:
            values = dict(event_type_id=False, event_ok=False)
        self.update(values)

    @api.multi
    def _update_registrations(self, confirm=True, registration_data=None):
        """ Create or update registrations linked to a sale order line. A sale
        order line has a product_uom_qty attribute that will be the number of
        registrations linked to this line. This method update existing registrations
        and create new one for missing one. """
        Registration = self.env['event.registration']
        registrations = Registration.search([('sale_order_line_id', 'in', self.ids)])
        for so_line in [l for l in self if l.event_id]:
            existing_registrations = registrations.filtered(lambda self: self.sale_order_line_id.id == so_line.id)
            if confirm:
                existing_registrations.filtered(lambda self: self.state != 'open').confirm_registration()
            else:
                existing_registrations.filtered(lambda self: self.state == 'cancel').do_draft()

            for count in range(int(so_line.product_uom_qty) - len(existing_registrations)):
                registration = {}
                if registration_data:
                    registration = registration_data.pop()
                # TDE CHECK: auto confirmation
                registration['sale_order_line_id'] = so_line
                self.env['event.registration'].with_context(registration_force_draft=True).create(
                    Registration._prepare_attendee_values(registration))
        return True

    def onchange_event_ticket_id(self, cr, uid, ids, event_ticket_id=False, context=None):
        price = event_ticket_id and self.pool["event.event.ticket"].browse(cr, uid, event_ticket_id, context=context).price or False
        return {'value': {'price_unit': price}}
예제 #12
0
class hr_contract(osv.osv):

    _inherit = 'hr.contract'
    _description = 'Employee Contract'
    _columns = {
        'analytic_account_id':
        fields.many2one('account.analytic.account', 'Analytic Account'),
        'journal_id':
        fields.many2one('account.journal', 'Salary Journal'),
    }
예제 #13
0
class lead_test(osv.Model):
    _name = "base.action.rule.lead.test"
    _description = "Action Rule Test"

    _columns = {
        'name':
        fields.char('Subject', required=True, select=1),
        'user_id':
        fields.many2one('res.users', 'Responsible'),
        'state':
        fields.selection(AVAILABLE_STATES, string="Status", readonly=True),
        'active':
        fields.boolean('Active', required=False),
        'partner_id':
        fields.many2one('res.partner', 'Partner', ondelete='set null'),
        'date_action_last':
        fields.datetime('Last Action', readonly=1),
        'line_ids':
        fields.one2many('base.action.rule.line.test', 'lead_id'),
    }

    _defaults = {
        'state': 'draft',
        'active': True,
    }

    customer = ecore.fields.Boolean(related='partner_id.customer',
                                    readonly=True,
                                    store=True)

    @api.cr_uid_ids_context
    def message_post(self,
                     cr,
                     uid,
                     thread_id,
                     body='',
                     subject=None,
                     message_type='notification',
                     subtype=None,
                     parent_id=False,
                     attachments=None,
                     context=None,
                     **kwargs):
        pass

    def message_subscribe(self,
                          cr,
                          uid,
                          ids,
                          partner_ids=None,
                          channel_ids=None,
                          subtype_ids=None,
                          force=True,
                          context=None):
        pass
예제 #14
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',
    }
예제 #15
0
파일: pos_report.py 프로젝트: LiberTang0/5
class report_transaction_pos(osv.osv):
    _name = "report.transaction.pos"
    _description = "transaction for the pos"
    _auto = False
    _columns = {
        'date_create': fields.char('Date', size=16, readonly=True),
        'journal_id': fields.many2one('account.journal', 'Sales Journal', readonly=True),
        'jl_id': fields.many2one('account.journal', 'Cash Journals', readonly=True),
        'user_id': fields.many2one('res.users', 'User', readonly=True),
        'no_trans': fields.float('Number of Transaction', readonly=True),
        'amount': fields.float('Amount', readonly=True),
        'invoice_id': fields.float('Nbr Invoice', readonly=True),
        'invoice_am': fields.float('Invoice Amount', readonly=True),
        'product_nb': fields.float('Product Nb.', readonly=True),
        'disc': fields.float('Disc.', readonly=True),
    }

    def init(self, cr):
        tools.drop_view_if_exists(cr, 'report_transaction_pos')
        cr.execute("""
            create or replace view report_transaction_pos as (
               select
                    min(absl.id) as id,
                    count(absl.id) as no_trans,
                    sum(absl.amount) as amount,
                    sum((100.0-line.discount) * line.price_unit * line.qty / 100.0) as disc,
                    to_char(date_trunc('day',absl.create_date),'YYYY-MM-DD')::text as date_create,
                    po.user_id as user_id,
                    po.sale_journal as journal_id,
                    abs.journal_id as jl_id,
                    count(po.invoice_id) as invoice_id,
                    count(p.id) as product_nb
                from
                    account_bank_statement_line as absl,
                    account_bank_statement as abs,
                    product_product as p,
                    pos_order_line as line,
                    pos_order as po
                where
                    absl.pos_statement_id = po.id and
                    line.order_id=po.id and
                    line.product_id=p.id and
                    absl.statement_id=abs.id

                group by
                    po.user_id,po.sale_journal, abs.journal_id,
                    to_char(date_trunc('day',absl.create_date),'YYYY-MM-DD')::text
                )
        """)
예제 #16
0
파일: resource.py 프로젝트: ecoreos/hz
class resource_calendar_leaves(osv.osv):
    _name = "resource.calendar.leaves"
    _description = "Leave Detail"
    _columns = {
        'name':
        fields.char("Name"),
        'company_id':
        fields.related('calendar_id',
                       'company_id',
                       type='many2one',
                       relation='res.company',
                       string="Company",
                       store=True,
                       readonly=True),
        'calendar_id':
        fields.many2one("resource.calendar", "Working Time"),
        'date_from':
        fields.datetime('Start Date', required=True),
        'date_to':
        fields.datetime('End Date', required=True),
        'resource_id':
        fields.many2one(
            "resource.resource",
            "Resource",
            help=
            "If empty, this is a generic holiday for the company. If a resource is set, the holiday/leave is only for this resource"
        ),
    }

    def check_dates(self, cr, uid, ids, context=None):
        for leave in self.browse(cr, uid, ids, context=context):
            if leave.date_from and leave.date_to and leave.date_from > leave.date_to:
                return False
        return True

    _constraints = [
        (check_dates,
         'Error! leave start-date must be lower then leave end-date.',
         ['date_from', 'date_to'])
    ]

    def onchange_resource(self, cr, uid, ids, resource, context=None):
        result = {}
        if resource:
            resource_pool = self.pool.get('resource.resource')
            result['calendar_id'] = resource_pool.browse(
                cr, uid, resource, context=context).calendar_id.id
            return {'value': result}
        return {'value': {'calendar_id': []}}
예제 #17
0
class calendar_contacts(osv.osv):
    _name = 'calendar.contacts'

    _columns = {
        'user_id':
        fields.many2one('res.users', 'Me'),
        'partner_id':
        fields.many2one('res.partner', 'Employee', required=True, domain=[]),
        'active':
        fields.boolean('active'),
    }
    _defaults = {
        'user_id': lambda self, cr, uid, ctx: uid,
        'active': True,
    }
예제 #18
0
파일: procurement.py 프로젝트: LiberTang0/5
class procurement_rule(osv.osv):
    '''
    A rule describe what a procurement should do; produce, buy, move, ...
    '''
    _name = 'procurement.rule'
    _description = "Procurement Rule"
    _order = "name"

    def _get_action(self, cr, uid, context=None):
        return []

    _columns = {
        'name':
        fields.char(
            'Name',
            required=True,
            translate=True,
            help=
            "This field will fill the packing origin and the name of its moves"
        ),
        'active':
        fields.boolean(
            'Active',
            help=
            "If unchecked, it will allow you to hide the rule without removing it."
        ),
        'group_propagation_option':
        fields.selection([('none', 'Leave Empty'), ('propagate', 'Propagate'),
                          ('fixed', 'Fixed')],
                         string="Propagation of Procurement Group"),
        'group_id':
        fields.many2one('procurement.group', 'Fixed Procurement Group'),
        'action':
        fields.selection(selection=lambda s, cr, uid, context=None: s.
                         _get_action(cr, uid, context=context),
                         string='Action',
                         required=True),
        'sequence':
        fields.integer('Sequence'),
        'company_id':
        fields.many2one('res.company', 'Company'),
    }

    _defaults = {
        'group_propagation_option': 'propagate',
        'sequence': 20,
        'active': True,
    }
예제 #19
0
class stock_move(osv.osv):
    _inherit = 'stock.move'
    _columns = {
        'purchase_line_id':
        fields.many2one('purchase.order.line',
                        'Purchase Order Line',
                        ondelete='set null',
                        select=True,
                        readonly=True),
    }

    def get_price_unit(self, cr, uid, move, context=None):
        """ Returns the unit price to store on the quant """
        if move.purchase_line_id:
            return move.price_unit
        return super(stock_move, self).get_price_unit(cr,
                                                      uid,
                                                      move,
                                                      context=context)

    def copy(self, cr, uid, id, default=None, context=None):
        default = default or {}
        context = context or {}
        if not default.get('split_from'):
            #we don't want to propagate the link to the purchase order line except in case of move split
            default['purchase_line_id'] = False
        return super(stock_move, self).copy(cr, uid, id, default, context)
예제 #20
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"),
    }
예제 #21
0
파일: mrp_report.py 프로젝트: LiberTang0/5
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')
            )""")
예제 #22
0
class res_users(osv.osv):
    _inherit = 'res.users'
    _columns = {
        'pos_security_pin':
        fields.char(
            'Security PIN',
            size=32,
            help=
            'A Security PIN used to protect sensible functionality in the Point of Sale'
        ),
        'pos_config':
        fields.many2one('pos.config',
                        'Default Point of Sale',
                        domain=[('state', '=', 'active')]),
    }

    def _check_pin(self, cr, uid, ids, context=None):
        for user in self.browse(cr, uid, ids, context=context):
            if user.pos_security_pin and not user.pos_security_pin.isdigit():
                return False
        return True

    _constraints = [
        (_check_pin, "Security PIN can only contain digits",
         ['pos_security_pin']),
    ]
예제 #23
0
파일: models.py 프로젝트: ecoreos/hz
class One2ManyChild(orm.Model):
    _name = 'export.one2many.child'
    # FIXME: orm.py:1161, fix to name_get on m2o field
    _rec_name = 'value'

    _columns = {
        'parent_id': fields.many2one('export.one2many'),
        'str': fields.char('unknown', size=None),
        'value': fields.integer(),
    }

    def name_get(self, cr, uid, ids, context=None):
        return [(record.id, "%s:%s" % (self._name, record.value))
                for record in self.browse(cr, uid, ids, context=context)]

    def name_search(self,
                    cr,
                    user,
                    name='',
                    args=None,
                    operator='ilike',
                    context=None,
                    limit=100):
        if isinstance(name, basestring) and name.split(':')[0] == self._name:
            ids = self.search(cr, user,
                              [['value', operator,
                                int(name.split(':')[1])]])
            return self.name_get(cr, user, ids, context=context)
        else:
            return []
예제 #24
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'
예제 #25
0
class hr_holidays_remaining_leaves_user(osv.osv):
    _name = "hr.holidays.remaining.leaves.user"
    _description = "Total holidays by type"
    _auto = False
    _columns = {
        'name': fields.char('Employee'),
        'no_of_leaves': fields.integer('Remaining leaves'),
        'user_id': fields.many2one('res.users', 'User'),
        'leave_type': fields.char('Leave Type'),
        }

    def init(self, cr):
        tools.drop_view_if_exists(cr, 'hr_holidays_remaining_leaves_user')
        cr.execute("""
            CREATE or REPLACE view hr_holidays_remaining_leaves_user as (
                 SELECT
                    min(hrs.id) as id,
                    rr.name as name,
                    sum(hrs.number_of_days) as no_of_leaves,
                    rr.user_id as user_id,
                    hhs.name as leave_type
                FROM
                    hr_holidays as hrs, hr_employee as hre,
                    resource_resource as rr,hr_holidays_status as hhs
                WHERE
                    hrs.employee_id = hre.id and
                    hre.resource_id =  rr.id and
                    hhs.id = hrs.holiday_status_id
                GROUP BY
                    rr.name,rr.user_id,hhs.name
            )
        """)
예제 #26
0
파일: resource.py 프로젝트: ecoreos/hz
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'}
예제 #27
0
파일: test_models.py 프로젝트: LiberTang0/5
class o2m_child(orm.Model):
    _name = name('o2m.child')

    _columns = {
        'parent_id': fields.many2one(name('o2m')),
        'value': fields.integer()
    }
예제 #28
0
파일: pos_report.py 프로젝트: LiberTang0/5
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

                )
        """)
예제 #29
0
class product_template(osv.osv):
    _name = "product.template"
    _inherit = "product.template"
    _columns = {
        'intrastat_id': fields.many2one('report.intrastat.code',
                                        'Intrastat code'),
    }
예제 #30
0
class crm_claim_category(osv.Model):
    _name = "crm.claim.category"
    _description = "Category of claim"
    _columns = {
        'name': fields.char('Name', required=True, translate=True),
        'team_id': fields.many2one('crm.team', 'Sales Team'),
    }
예제 #31
0
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")),
    # related: specialization of fields.function, should work the same way
    # TODO: reference
]

for name, field in models:
    class NewModel(orm.Model):
        _name = 'export.%s' % name
        _columns = {
            'const': fields.integer(),
            'value': field,
        }
        _defaults = {