class EducationClassDivisionHistory(models.Model):
    _name = 'education.class.history'
    _description = "Student Class history"
    _rec_name = 'class_id'

    academic_year_id = fields.Many2one('education.academic.year', string='Academic Year',
                                       help="Select the Academic Year")
    class_id = fields.Many2one('education.class.division', string='Class',
                               help="Select the class")
    level=fields.Many2one('education.class',string='level',related='class_id.class_id',store=True) #related='class_id.class_id'
    section=fields.Many2one('education.class.section',string='section',related='class_id.section_id') #
    from_date=fields.Date('From')
    till_date=fields.Date('Till')
    student_id = fields.Many2one('education.student', string='Students')
    roll_no=fields.Integer('Roll No',required=True)
    compulsory_subjects=fields.Many2many('education.syllabus','education_syllabus_class_history_rel',
                                         'compulsory_subjects','compulsory_for',string='Compulsory')
    selective_subjects=fields.Many2many('education.syllabus','education_syllabus_class_history_1_rel',
                                        'selective_subjects','selective_for',string='Selective')
    optional_subjects=fields.Many2many('education.syllabus','education_syllabus_class_history_optional_rel',
                                        'optional_subjects','optional_for',string='Optional')
    # selective_subjects=fields.Many2many('education.syllabus','selective_for',string='Selective')
    # optional_subjects=fields.Many2many('education.syllabus','optional_for',string='Optional')
    _sql_constraints = [
        ('student_class_history', 'unique(academic_year_id,student_id)', "Student mustbe Unique for a year"),
        ('student_class_history', 'unique(academic_year_id,class_id,roll_no)', "Roll no must be qnique for Class"),
    ]
示例#2
0
class VATReport(models.TransientModel):
    _name = "report_vat_report"
    _inherit = 'account_financial_report_abstract'
    """ Here, we just define class fields.
    For methods, go more bottom at this file.

    The class hierarchy is :
    * VATReport
    ** VATReportTaxTags
    *** VATReportTax
    """

    # Filters fields, used for data computation
    company_id = fields.Many2one(comodel_name='res.company')
    date_from = fields.Date()
    date_to = fields.Date()
    based_on = fields.Selection([('taxtags', 'Tax Tags'),
                                 ('taxgroups', 'Tax Groups')],
                                string='Based On',
                                required=True,
                                default='taxtags')
    tax_detail = fields.Boolean('Tax Detail')

    # Data fields, used to browse report data
    taxtags_ids = fields.One2many(comodel_name='report_vat_report_taxtag',
                                  inverse_name='report_id')
示例#3
0
class EducationAcademicMonth(models.Model):
    _name = 'education.academic.month'
    _description = 'Academic month'
    _rec_name = 'month_code'
    name = fields.Char("Month")
    years = fields.Integer('Year')
    months = fields.Many2one('education.month',
                             string='Name',
                             required=True,
                             help='Name of the Month')
    month_code = fields.Char('Month')
    start_date = fields.Date(string='Start date')
    end_date = fields.Date(string='End date')
    active = fields.Boolean(
        'Active',
        default=True,
        help=
        "If unchecked, it will allow you to hide the Academic Year without removing it."
    )

    @api.depends('months')
    def calculate_details(self):
        for rec in self:
            rec.end_date = date(rec.years, rec.months.id,
                                monthrange(rec.years, rec.months.id)[1])
            rec.start_date = date(rec.years, rec.months.id, 1)
            rec.month_code = rec.months.code + " " + str(rec.years)
class AgedPartnerBalanceReportMoveLine(models.TransientModel):
    _name = 'report_aged_partner_balance_move_line'
    _inherit = 'account_financial_report_abstract'

    report_partner_id = fields.Many2one(
        comodel_name='report_aged_partner_balance_partner',
        ondelete='cascade',
        index=True)

    # Data fields, used to keep link with real object
    move_line_id = fields.Many2one('account.move.line')

    # Data fields, used for report display
    date = fields.Date()
    date_due = fields.Date()
    entry = fields.Char()
    journal = fields.Char()
    account = fields.Char()
    partner = fields.Char()
    label = fields.Char()

    amount_residual = fields.Float(digits=(16, 2))
    current = fields.Float(digits=(16, 2))
    age_30_days = fields.Float(digits=(16, 2))
    age_60_days = fields.Float(digits=(16, 2))
    age_90_days = fields.Float(digits=(16, 2))
    age_120_days = fields.Float(digits=(16, 2))
    older = fields.Float(digits=(16, 2))
示例#5
0
class PayslipLinesContributionRegister(models.TransientModel):
    _name = 'payslip.lines.contribution.register'
    _description = 'Payslip Lines by Contribution Registers'

    date_from = fields.Date(string='Date From',
                            required=True,
                            default=datetime.now().strftime('%Y-%m-01'))
    date_to = fields.Date(
        string='Date To',
        required=True,
        default=str(datetime.now() +
                    relativedelta.relativedelta(months=+1, day=1, days=-1))
        [:10])

    @api.multi
    def print_report(self):
        active_ids = self.env.context.get('active_ids', [])
        datas = {
            'ids': active_ids,
            'model': 'hr.contribution.register',
            'form': self.read()[0]
        }
        return self.env.ref(
            'hr_payroll.action_contribution_register').report_action(
                [], data=datas)
示例#6
0
class OpenItemsReportMoveLine(models.TransientModel):

    _name = 'report_open_items_move_line'
    _inherit = 'account_financial_report_abstract'

    report_partner_id = fields.Many2one(
        comodel_name='report_open_items_partner',
        ondelete='cascade',
        index=True)

    # Data fields, used to keep link with real object
    move_line_id = fields.Many2one('account.move.line')

    # Data fields, used for report display
    date = fields.Date()
    date_due = fields.Date()
    entry = fields.Char()
    journal = fields.Char()
    account = fields.Char()
    partner = fields.Char()
    label = fields.Char()
    amount_total_due = fields.Float(digits=(16, 2))
    amount_residual = fields.Float(digits=(16, 2))
    currency_id = fields.Many2one('res.currency')
    amount_total_due_currency = fields.Float(digits=(16, 2))
    amount_residual_currency = fields.Float(digits=(16, 2))
示例#7
0
class AccountPeriod(models.Model):
    _name = "account.period"
    _description = "Account period"
    _order = "date_start, special desc"

    name = fields.Char('Period Name', required=True)
    code = fields.Char('Code', size=12)
    special = fields.Boolean('Opening/Closing Period',
                             help="These periods can overlap.")
    date_start = fields.Date('Start of Period',
                             required=True,
                             states={'done': [('readonly', True)]})
    date_stop = fields.Date('End of Period',
                            required=True,
                            states={'done': [('readonly', True)]})
    fiscalyear_id = fields.Many2one('account.fiscalyear',
                                    'Fiscal Year',
                                    required=True,
                                    states={'done': [('readonly', True)]},
                                    index=True)
    state = fields.Selection(
        [('draft', 'Open'), ('done', 'Closed')],
        'Status',
        readonly=True,
        copy=False,
        default='draft',
        help=
        'When monthly periods are created. The status is \'Draft\'. At the end of monthly period it is in \'Done\' status.'
    )
    company_id = fields.Many2one('res.company',
                                 related='fiscalyear_id.company_id',
                                 string='Company',
                                 store=True,
                                 readonly=True)
class EducationAcademicYearEvaluation(models.Model):
    _name = 'education.academic_year.evaluation'
    _description = 'Evaluations for an academic year'
    _order = 'academic_year_id,sequence'

    name = fields.Char(string='Name', required=True)
    sequence = fields.Integer()
    academic_year_id = fields.Many2one(comodel_name='education.academic_year',
                                       string='Academic Year',
                                       ondelete='cascade',
                                       required=True)
    date_start = fields.Date(string='Date Start', required=True)
    date_end = fields.Date(string='Date End', required=True)

    @api.constrains('academic_year_id', 'date_start', 'date_end')
    def _check_dates(self):
        for record in self:
            if not record.date_end > record.date_start:
                raise ValidationError(_('End date must be after start date.'))
            min_date_start = record.academic_year_id.date_start
            max_date_end = record.academic_year_id.date_end
            check_date_start = (
                (min_date_start and min_date_start > record.date_start)
                or (max_date_end and record.date_start > max_date_end))
            check_date_end = (
                (min_date_start and min_date_start > record.date_end)
                or (max_date_end and record.date_end > max_date_end))
            if check_date_start or check_date_end:
                raise ValidationError(
                    _('Evaluation dates must be between academic year dates.'))

    _sql_constraints = [
        ('name_unique', 'unique(name, academic_year_id)',
         'Evaluation name must be unique!'),
    ]
示例#9
0
class StudentAttendance(models.TransientModel):
    _name = "student.attendance"
    _description = "Student Attendance"

    from_date = fields.Date('From Date',
                            required=True,
                            default=lambda self: fields.Date.today())
    to_date = fields.Date('To Date',
                          required=True,
                          default=lambda self: fields.Date.today())

    @api.constrains('from_date', 'to_date')
    def check_dates(self):
        for record in self:
            from_date = fields.Date.from_string(record.from_date)
            to_date = fields.Date.from_string(record.to_date)
            if to_date < from_date:
                raise ValidationError(
                    _("To Date cannot be set before From Date."))

    def print_report(self):
        data = self.read(['from_date', 'to_date'])[0]
        data.update({'student_id': self.env.context.get('active_id', False)})

        return self.env.ref(
            'openeagleedu_attendance.action_report_student_attendance') \
            .report_action(self, data=data)
示例#10
0
class AccountFiscalYear(models.Model):
    _name = 'account.fiscal.year'
    _description = 'Fiscal Year'

    name = fields.Char(string='Name', required=True)
    date_from = fields.Date(string='Start Date',
                            required=True,
                            help='Start Date, included in the fiscal year.')
    date_to = fields.Date(string='End Date',
                          required=True,
                          help='Ending Date, included in the fiscal year.')
    company_id = fields.Many2one('res.company',
                                 string='Company',
                                 required=True,
                                 default=lambda self: self.env.user.company_id)

    @api.constrains('date_from', 'date_to', 'company_id')
    def _check_dates(self):
        '''
        Check interleaving between fiscal years.
        There are 3 cases to consider:

        s1   s2   e1   e2
        (    [----)----]

        s2   s1   e2   e1
        [----(----]    )

        s1   s2   e2   e1
        (    [----]    )
        '''
        for fy in self:
            # Starting date must be prior to the ending date
            date_from = fy.date_from
            date_to = fy.date_to
            if date_to < date_from:
                raise ValidationError(
                    _('The ending date must not be prior to the starting date.'
                      ))

            domain = [
                ('id', '!=', fy.id),
                ('company_id', '=', fy.company_id.id),
                '|',
                '|',
                '&',
                ('date_from', '<=', fy.date_from),
                ('date_to', '>=', fy.date_from),
                '&',
                ('date_from', '<=', fy.date_to),
                ('date_to', '>=', fy.date_to),
                '&',
                ('date_from', '<=', fy.date_from),
                ('date_to', '>=', fy.date_to),
            ]

            if self.search_count(domain) > 0:
                raise ValidationError(
                    _('You can not have an overlap between two fiscal years, please correct the start and/or end dates of your fiscal years.'
                      ))
class AccountCommonReport(models.TransientModel):
    _name = "account.common.report"
    _description = "Account Common Report"

    company_id = fields.Many2one('res.company',
                                 string='Company',
                                 required=True,
                                 default=lambda self: self.env.company)
    journal_ids = fields.Many2many(
        'account.journal',
        string='Journals',
        required=True,
        default=lambda self: self.env['account.journal'].search([(
            'company_id', '=', self.company_id.id)]))
    date_from = fields.Date(string='Start Date')
    date_to = fields.Date(string='End Date')
    target_move = fields.Selection([
        ('posted', 'All Posted Entries'),
        ('all', 'All Entries'),
    ],
                                   string='Target Moves',
                                   required=True,
                                   default='posted')

    @api.onchange('company_id')
    def _onchange_company_id(self):
        if self.company_id:
            self.journal_ids = self.env['account.journal'].search([
                ('company_id', '=', self.company_id.id)
            ])
        else:
            self.journal_ids = self.env['account.journal'].search([])

    def _build_contexts(self, data):
        result = {}
        result['journal_ids'] = 'journal_ids' in data['form'] and data['form'][
            'journal_ids'] or False
        result['state'] = 'target_move' in data['form'] and data['form'][
            'target_move'] or ''
        result['date_from'] = data['form']['date_from'] or False
        result['date_to'] = data['form']['date_to'] or False
        result['strict_range'] = True if result['date_from'] else False
        result['company_id'] = data['form']['company_id'][0] or False
        return result

    def _print_report(self, data):
        raise NotImplementedError()

    def check_report(self):
        self.ensure_one()
        data = {}
        data['ids'] = self.env.context.get('active_ids', [])
        data['model'] = self.env.context.get('active_model', 'ir.ui.menu')
        data['form'] = self.read([
            'date_from', 'date_to', 'journal_ids', 'target_move', 'company_id'
        ])[0]
        used_context = self._build_contexts(data)
        data['form']['used_context'] = dict(used_context,
                                            lang=get_lang(self.env).code)
        return self.with_context(discard_logo_check=True)._print_report(data)
示例#12
0
class EagleeduExam(models.Model):
    _name = 'eagleedu.exam'
    _description = 'Education Exam'

    name = fields.Char(string='Name of Exam', default='New')
    _rec_name = "exam_type"

    generated_name = fields.Char(string='Gen Name', default='New')
    class_id = fields.Many2one('education.class', string='Class')
    division_id = fields.Many2one('education.class.division',
                                  string='Division')
    exam_type = fields.Many2one('education.exam.type',
                                string='Type',
                                required=True)
    # school_class_division_wise = fields.Selection([('school', 'School'), ('class', 'Class'), ('division', 'Division')],
    #                                               related='exam_type.school_class_division_wise',
    #                                               string='School/Class/Division Wise')
    # total_working_days=fields.Integer("Total Working Days")
    # class_division_hider = fields.Char(string='Class Division Hider')
    start_date = fields.Date(string='Start Date', required=True)
    end_date = fields.Date(string='End Date', required=True)
    # subject_line = fields.One2many('education.subject.line', 'exam_id', string='Subjects')
    state = fields.Selection([('draft', 'Draft'), ('ongoing', 'On Going'),
                              ('close', 'Closed'), ('cancel', 'Canceled')],
                             default='draft')
    # academic_year = fields.Many2one('eagleedu.academic.year', string='Academic Year',
    #                                  related='division_id.academic_year_id', store=True)
    company_id = fields.Many2one(
        'res.company',
        string='Company',
        default=lambda self: self.env['res.company']._company_default_get())
示例#13
0
class FleetVehicleAssignationLog(models.Model):
    _name = "fleet.vehicle.assignation.log"
    _description = "Drivers history on a vehicle"
    _order = "create_date desc, date_start desc"

    vehicle_id = fields.Many2one('fleet.vehicle', string="Vehicle", required=True)
    driver_id = fields.Many2one('res.partner', string="Driver", required=True)
    date_start = fields.Date(string="Start Date")
    date_end = fields.Date(string="End Date")
示例#14
0
class ResPartnerPermission(models.Model):
    _name = 'res.partner.permission'
    _inherit = ['portal.mixin', 'mail.thread', 'mail.activity.mixin']
    _description = 'Contact Permission'
    _rec_name = 'partner_id'

    partner_id = fields.Many2one(comodel_name='res.partner',
                                 string='Student',
                                 required=True,
                                 domain=[('educational_category', 'in',
                                          ('student', 'other'))])
    allowed_signer_ids = fields.Many2many(
        comodel_name='res.partner',
        string='Allowed Signers',
        compute='_compute_allowed_signer_ids',
        store=True)
    signer_id = fields.Many2one(comodel_name='res.partner',
                                string='Signed by',
                                domain="[('id', 'in', allowed_signer_ids)]")
    type_id = fields.Many2one(comodel_name='res.partner.permission.type',
                              string='Type',
                              required=True)
    type_description = fields.Text(string='Type Description',
                                   related='type_id.description',
                                   store=True)
    description = fields.Text(string='Description')
    state = fields.Selection(selection=[('yes', 'Yes'), ('no', 'No'),
                                        ('pending', 'Pending')],
                             string='State',
                             default='pending',
                             required=True)
    start_date = fields.Date(string='Start Date')
    end_date = fields.Date(string='End Date')
    attachment_doc = fields.Binary(string='Attached Document')

    @api.depends('partner_id', 'partner_id.child2_ids',
                 'partner_id.child2_ids.relation',
                 'partner_id.child2_ids.responsible_id')
    def _compute_allowed_signer_ids(self):
        for record in self:
            record.allowed_signer_ids = (
                record.partner_id.child2_ids.filtered(lambda l: l.relation in (
                    'progenitor', 'guardian')).mapped('responsible_id'))

    def button_sign(self):
        self.ensure_one()
        self.write({
            'state': 'yes',
            'signer_id': self.env.user.partner_id.id,
        })

    def button_deny(self):
        self.ensure_one()
        self.write({
            'state': 'no',
            'signer_id': self.env.user.partner_id.id,
        })
示例#15
0
class ResourceCalendarAttendance(models.Model):
    _name = "resource.calendar.attendance"
    _description = "Work Detail"
    _order = 'week_type, dayofweek, hour_from'

    name = fields.Char(required=True)
    dayofweek = fields.Selection([('0', 'Monday'), ('1', 'Tuesday'),
                                  ('2', 'Wednesday'), ('3', 'Thursday'),
                                  ('4', 'Friday'), ('5', 'Saturday'),
                                  ('6', 'Sunday')],
                                 'Day of Week',
                                 required=True,
                                 index=True,
                                 default='0')
    date_from = fields.Date(string='Starting Date')
    date_to = fields.Date(string='End Date')
    hour_from = fields.Float(
        string='Work from',
        required=True,
        index=True,
        help="Start and End time of working.\n"
        "A specific value of 24:00 is interpreted as 23:59:59.999999.")
    hour_to = fields.Float(string='Work to', required=True)
    calendar_id = fields.Many2one("resource.calendar",
                                  string="Resource's Calendar",
                                  required=True,
                                  ondelete='cascade')
    day_period = fields.Selection([('morning', 'Morning'),
                                   ('afternoon', 'Afternoon')],
                                  required=True,
                                  default='morning')
    resource_id = fields.Many2one('resource.resource', 'Resource')
    week_type = fields.Selection([('1', 'Odd week'), ('0', 'Even week')],
                                 'Week Even/Odd',
                                 default=False)
    two_weeks_calendar = fields.Boolean(
        "Calendar in 2 weeks mode", related='calendar_id.two_weeks_calendar')
    display_type = fields.Selection([('line_section', "Section")],
                                    default=False,
                                    help="Technical field for UX purpose.")
    sequence = fields.Integer(
        default=10,
        help=
        "Gives the sequence of this line when displaying the resource calendar."
    )

    @api.onchange('hour_from', 'hour_to')
    def _onchange_hours(self):
        # avoid negative or after midnight
        self.hour_from = min(self.hour_from, 23.99)
        self.hour_from = max(self.hour_from, 0.0)
        self.hour_to = min(self.hour_to, 23.99)
        self.hour_to = max(self.hour_to, 0.0)

        # avoid wrong order
        self.hour_to = max(self.hour_to, self.hour_from)
示例#16
0
class TrialBalanceReport(models.TransientModel):
    """ Here, we just define class fields.
    For methods, go more bottom at this file.

    The class hierarchy is :
    * TrialBalanceReport
    *** TrialBalanceReportAccount
    **** TrialBalanceReportPartner
            If "show_partner_details" is selected
    """

    _name = 'report_trial_balance'
    _inherit = 'account_financial_report_abstract'

    # Filters fields, used for data computation
    date_from = fields.Date()
    date_to = fields.Date()
    fy_start_date = fields.Date()
    only_posted_moves = fields.Boolean()
    hide_account_at_0 = fields.Boolean()
    foreign_currency = fields.Boolean()
    company_id = fields.Many2one(comodel_name='res.company')
    filter_account_ids = fields.Many2many(comodel_name='account.account')
    filter_partner_ids = fields.Many2many(comodel_name='res.partner')
    filter_journal_ids = fields.Many2many(comodel_name='account.journal')
    show_partner_details = fields.Boolean()
    hierarchy_on = fields.Selection(
        [('computed', 'Computed Accounts'),
         ('relation', 'Child Accounts'),
         ('none', 'No hierarchy')],
        string='Hierarchy On',
        required=True,
        default='computed',
        help="""Computed Accounts: Use when the account group have codes
        that represent prefixes of the actual accounts.\n
        Child Accounts: Use when your account groups are hierarchical.\n
        No hierarchy: Use to display just the accounts, without any grouping.
        """,
    )
    limit_hierarchy_level = fields.Boolean('Limit hierarchy levels')
    show_hierarchy_level = fields.Integer('Hierarchy Levels to display',
                                          default=1)
    hide_parent_hierarchy_level = fields.Boolean(
        'Do not display parent levels', default=False)
    # General Ledger Report Data fields,
    # used as base for compute the data reports
    general_ledger_id = fields.Many2one(
        comodel_name='report_general_ledger'
    )

    # Data fields, used to browse report data
    account_ids = fields.One2many(
        comodel_name='report_trial_balance_account',
        inverse_name='report_id'
    )
class CrossoveredBudget(models.Model):
    _name = "crossovered.budget"
    _description = "Budget"
    _inherit = ['mail.thread']

    name = fields.Char('Budget Name',
                       required=True,
                       states={'done': [('readonly', True)]})
    user_id = fields.Many2one('res.users',
                              'Responsible',
                              default=lambda self: self.env.user,
                              oldname='creating_user_id')
    date_from = fields.Date('Start Date',
                            required=True,
                            states={'done': [('readonly', True)]})
    date_to = fields.Date('End Date',
                          required=True,
                          states={'done': [('readonly', True)]})
    state = fields.Selection([('draft', 'Draft'), ('cancel', 'Cancelled'),
                              ('confirm', 'Confirmed'),
                              ('validate', 'Validated'), ('done', 'Done')],
                             'Status',
                             default='draft',
                             index=True,
                             required=True,
                             readonly=True,
                             copy=False,
                             track_visibility='always')
    crossovered_budget_line = fields.One2many(
        'crossovered.budget.lines',
        'crossovered_budget_id',
        'Budget Lines',
        states={'done': [('readonly', True)]},
        copy=True)
    company_id = fields.Many2one('res.company',
                                 'Company',
                                 required=True,
                                 default=lambda self: self.env['res.company'].
                                 _company_default_get('account.budget.post'))

    def action_budget_confirm(self):
        self.write({'state': 'confirm'})

    def action_budget_draft(self):
        self.write({'state': 'draft'})

    def action_budget_validate(self):
        self.write({'state': 'validate'})

    def action_budget_cancel(self):
        self.write({'state': 'cancel'})

    def action_budget_done(self):
        self.write({'state': 'done'})
示例#18
0
class CrmPartnerReportAssign(models.Model):
    """ CRM Lead Report """
    _name = "crm.partner.report.assign"
    _auto = False
    _description = "CRM Partnership Analysis"

    partner_id = fields.Many2one('res.partner', 'Partner', required=False, readonly=True)
    grade_id = fields.Many2one('res.partner.grade', 'Grade', readonly=True)
    activation = fields.Many2one('res.partner.activation', 'Activation', index=True)
    user_id = fields.Many2one('res.users', 'User', readonly=True)
    date_review = fields.Date('Latest Partner Review')
    date_partnership = fields.Date('Partnership Date')
    country_id = fields.Many2one('res.country', 'Country', readonly=True)
    team_id = fields.Many2one('crm.team', 'Sales Team', oldname='section_id', readonly=True)
    nbr_opportunities = fields.Integer('# of Opportunity', readonly=True, oldname='opp')
    turnover = fields.Float('Turnover', readonly=True)
    date = fields.Date('Invoice Account Date', readonly=True)

    _depends = {
        'account.invoice.report': ['date', 'partner_id', 'price_total', 'state', 'type'],
        'crm.lead': ['partner_assigned_id'],
        'res.partner': ['activation', 'country_id', 'date_partnership', 'date_review',
                        'grade_id', 'parent_id', 'team_id', 'user_id'],
    }

    @api.model_cr
    def init(self):
        """
            CRM Lead Report
            @param cr: the current row, from the database cursor
        """
        tools.drop_view_if_exists(self._cr, 'crm_partner_report_assign')
        self._cr.execute("""
            CREATE OR REPLACE VIEW crm_partner_report_assign AS (
                SELECT
                    coalesce(i.id, p.id - 1000000000) as id,
                    p.id as partner_id,
                    (SELECT country_id FROM res_partner a WHERE a.parent_id=p.id AND country_id is not null limit 1) as country_id,
                    p.grade_id,
                    p.activation,
                    p.date_review,
                    p.date_partnership,
                    p.user_id,
                    p.team_id,
                    (SELECT count(id) FROM crm_lead WHERE partner_assigned_id=p.id) AS nbr_opportunities,
                    i.price_total as turnover,
                    i.date
                FROM
                    res_partner p
                    left join account_invoice_report i
                        on (i.partner_id=p.id and i.type in ('out_invoice','out_refund') and i.state in ('open','in_payment','paid'))
            )""")
示例#19
0
class ContractLineWizard(models.TransientModel):

    _name = 'contract.line.wizard'
    _description = 'Contract Line Wizard'

    date_start = fields.Date(string='Date Start')
    date_end = fields.Date(string='Date End')
    recurring_next_date = fields.Date(string='Next Invoice Date')
    is_auto_renew = fields.Boolean(string="Auto Renew", default=False)
    manual_renew_needed = fields.Boolean(
        string="Manual renew needed",
        default=False,
        help="This flag is used to make a difference between a definitive stop"
        "and temporary one for which a user is not able to plan a"
        "successor in advance",
    )
    contract_line_id = fields.Many2one(
        comodel_name="contract.line",
        string="Contract Line",
        required=True,
        index=True,
    )

    @api.multi
    def stop(self):
        for wizard in self:
            wizard.contract_line_id.stop(
                wizard.date_end, manual_renew_needed=wizard.manual_renew_needed
            )
        return True

    @api.multi
    def plan_successor(self):
        for wizard in self:
            wizard.contract_line_id.plan_successor(
                wizard.date_start, wizard.date_end, wizard.is_auto_renew
            )
        return True

    @api.multi
    def stop_plan_successor(self):
        for wizard in self:
            wizard.contract_line_id.stop_plan_successor(
                wizard.date_start, wizard.date_end, wizard.is_auto_renew
            )
        return True

    @api.multi
    def uncancel(self):
        for wizard in self:
            wizard.contract_line_id.uncancel(wizard.recurring_next_date)
        return True
示例#20
0
class ProductMargin(models.TransientModel):
    _name = 'product.margin'
    _description = 'Product Margin'

    from_date = fields.Date('From', default=time.strftime('%Y-01-01'))
    to_date = fields.Date('To', default=time.strftime('%Y-12-31'))
    invoice_state = fields.Selection([
        ('paid', 'Paid'),
        ('open_paid', 'Open and Paid'),
        ('draft_open_paid', 'Draft, Open and Paid'),
    ], 'Invoice State', index=True, required=True, default="open_paid")

    @api.multi
    def action_open_window(self):
        self.ensure_one()
        context = dict(self.env.context or {})

        def ref(module, xml_id):
            proxy = self.env['ir.model.data']
            return proxy.get_object_reference(module, xml_id)

        model, search_view_id = ref('product', 'product_search_form_view')
        model, graph_view_id = ref('product_margin', 'view_product_margin_graph')
        model, form_view_id = ref('product_margin', 'view_product_margin_form')
        model, tree_view_id = ref('product_margin', 'view_product_margin_tree')

        context.update(invoice_state=self.invoice_state)

        if self.from_date:
            context.update(date_from=self.from_date)

        if self.to_date:
            context.update(date_to=self.to_date)

        views = [
            (tree_view_id, 'tree'),
            (form_view_id, 'form'),
            (graph_view_id, 'graph')
        ]
        return {
            'name': _('Product Margins'),
            'context': context,
            'view_type': 'form',
            "view_mode": 'tree,form,graph',
            'res_model': 'product.product',
            'type': 'ir.actions.act_window',
            'views': views,
            'view_id': False,
            'search_view_id': search_view_id,
        }
class ResPartnerPermissionCreate(models.TransientModel):
    _name = 'res.partner.permission.create'
    _description = 'Wizard to create permission from students'

    student_ids = fields.Many2many(comodel_name='res.partner',
                                   string='Students')
    type_id = fields.Many2one(comodel_name='res.partner.permission.type',
                              string='Type',
                              required=True)
    description = fields.Text(string='Description')
    start_date = fields.Date(string='Start Date')
    end_date = fields.Date(string='End Date')

    @api.model
    def default_get(self, fields_list):
        res = super(ResPartnerPermissionCreate, self).default_get(fields_list)
        context = self.env.context
        active_ids = context.get('active_ids')
        students = self.env['res.partner']
        if context.get('active_model') == 'res.partner' and active_ids:
            students = students.browse(active_ids).filtered(
                lambda p: p.educational_category in ['student', 'other'])
        res.update({
            'student_ids': [(6, 0, students.ids)],
        })
        return res

    @api.multi
    def create_permissions(self):
        permissions = permission_model = self.env['res.partner.permission']
        for student in self.student_ids:
            permissions |= permission_model.create({
                'partner_id':
                student.id,
                'type_id':
                self.type_id.id,
                'start_date':
                self.start_date,
                'end_date':
                self.end_date,
                'description':
                self.description or '',
            })
        action = self.env.ref(
            'contacts_school_permission.action_res_partner_permission')
        action_dict = action.read()[0] if action else {}
        domain = expression.AND([[('id', 'in', permissions.ids)],
                                 safe_eval(action.domain or '[]')])
        action_dict.update({'domain': domain})
        return action_dict
示例#22
0
class discount_history(models.Model):

    _name = 'discount.history'
    
    sr_no = fields.Integer('Sr. No.')
    discount_category_id = fields.Many2one('discount.category','Discount Category')
    discount_category_code = fields.Char(related='discount_category_id.code')
    action_type = fields.Selection([('applied','Applied' ),('removed','Removed')],'Action')
    action_date = fields.Date("Action Date")
    applied_by = fields.Many2one('res.users', 'Applied By')
    applicable_from_date = fields.Date('Applicable From Date')
    academic_year_id = fields.Many2one('batch', 'Academic Year')
    is_applicable = fields.Boolean('Is Applicable')
    partner_id = fields.Many2one('res.partner',string="Student")
示例#23
0
class HrSalaryEmployeeBymonth(models.TransientModel):

    _name = 'hr.salary.employee.month'
    _description = 'Hr Salary Employee By Month Report'

    def _get_default_category(self):
        return self.env['hr.salary.rule.category'].search(
            [('code', '=', 'NET')], limit=1)

    def _get_default_start_date(self):
        year = fields.Date.from_string(fields.Date.today()).strftime('%Y')
        return '{}-01-01'.format(year)

    def _get_default_end_date(self):
        date = fields.Date.from_string(fields.Date.today())
        return date.strftime('%Y') + '-' + date.strftime(
            '%m') + '-' + date.strftime('%d')

    start_date = fields.Date(string='Start Date',
                             required=True,
                             default=_get_default_start_date)
    end_date = fields.Date(string='End Date',
                           required=True,
                           default=_get_default_end_date)
    employee_ids = fields.Many2many('hr.employee',
                                    'payroll_year_rel',
                                    'payroll_year_id',
                                    'employee_id',
                                    string='Employees',
                                    required=True)
    category_id = fields.Many2one('hr.salary.rule.category',
                                  string='Category',
                                  required=True,
                                  default=_get_default_category)

    @api.multi
    def print_report(self):
        """
         To get the date and print the report
         @return: return report
        """
        self.ensure_one()
        data = {'ids': self.env.context.get('active_ids', [])}
        res = self.read()
        res = res and res[0] or {}
        data.update({'form': res})
        return self.env.ref(
            'l10n_in_hr_payroll.action_report_hrsalarybymonth').report_action(
                self, data=data)
示例#24
0
class HrPayslipRun(models.Model):
    _name = 'hr.payslip.run'
    _description = 'Payslip Batches'

    name = fields.Char(required=True,
                       readonly=True,
                       states={'draft': [('readonly', False)]})
    slip_ids = fields.One2many('hr.payslip',
                               'payslip_run_id',
                               string='Payslips',
                               readonly=True,
                               states={'draft': [('readonly', False)]})
    state = fields.Selection([
        ('draft', 'Draft'),
        ('close', 'Close'),
    ],
                             string='Status',
                             index=True,
                             readonly=True,
                             copy=False,
                             default='draft')
    date_start = fields.Date(string='Date From',
                             required=True,
                             readonly=True,
                             states={'draft': [('readonly', False)]},
                             default=lambda self: fields.Date.to_string(
                                 date.today().replace(day=1)))
    date_end = fields.Date(string='Date To',
                           required=True,
                           readonly=True,
                           states={'draft': [('readonly', False)]},
                           default=lambda self: fields.Date.to_string(
                               (datetime.now() + relativedelta(
                                   months=+1, day=1, days=-1)).date()))
    credit_note = fields.Boolean(
        string='Credit Note',
        readonly=True,
        states={'draft': [('readonly', False)]},
        help=
        "If its checked, indicates that all payslips generated from here are refund payslips."
    )

    @api.multi
    def draft_payslip_run(self):
        return self.write({'state': 'draft'})

    @api.multi
    def close_payslip_run(self):
        return self.write({'state': 'close'})
示例#25
0
class ResPartner(models.Model):
    _inherit = "res.partner"

    partner_weight = fields.Integer(
        'Level Weight',
        default=0,
        tracking=True,
        help=
        "This should be a numerical value greater than 0 which will decide the contention for this partner to take this lead/opportunity."
    )
    grade_id = fields.Many2one('res.partner.grade',
                               'Partner Level',
                               tracking=True)
    grade_sequence = fields.Integer(related='grade_id.sequence',
                                    readonly=True,
                                    store=True)
    activation = fields.Many2one('res.partner.activation',
                                 'Activation',
                                 index=True,
                                 tracking=True)
    date_partnership = fields.Date('Partnership Date')
    date_review = fields.Date('Latest Partner Review')
    date_review_next = fields.Date('Next Partner Review')
    # customer implementation
    assigned_partner_id = fields.Many2one(
        'res.partner',
        'Implemented by',
    )
    implemented_partner_ids = fields.One2many(
        'res.partner',
        'assigned_partner_id',
        string='Implementation References',
    )
    implemented_count = fields.Integer(
        compute='_compute_implemented_partner_count', store=True)

    @api.depends('implemented_partner_ids',
                 'implemented_partner_ids.website_published',
                 'implemented_partner_ids.active')
    def _compute_implemented_partner_count(self):
        for partner in self:
            partner.implemented_count = len(
                partner.implemented_partner_ids.filtered('website_published'))

    @api.onchange('grade_id')
    def _onchange_grade_id(self):
        grade = self.grade_id
        self.partner_weight = grade.partner_weight if grade else 0
示例#26
0
class HolidaysSummaryDept(models.TransientModel):

    _name = 'hr.holidays.summary.dept'
    _description = 'HR Leaves Summary Report By Department'

    date_from = fields.Date(string='From',
                            required=True,
                            default=lambda *a: time.strftime('%Y-%m-01'))
    depts = fields.Many2many('hr.department',
                             'summary_dept_rel',
                             'sum_id',
                             'dept_id',
                             string='Department(s)')
    holiday_type = fields.Selection([('Approved', 'Approved'),
                                     ('Confirmed', 'Confirmed'),
                                     ('both', 'Both Approved and Confirmed')],
                                    string='Leave Type',
                                    required=True,
                                    default='Approved')

    @api.multi
    def print_report(self):
        self.ensure_one()
        [data] = self.read()
        if not data.get('depts'):
            raise UserError(_('You have to select at least one department.'))
        departments = self.env['hr.department'].browse(data['depts'])
        datas = {'ids': [], 'model': 'hr.department', 'form': data}
        return self.env.ref(
            'hr_holidays.action_report_holidayssummary').with_context(
                from_transient_model=True).report_action(departments,
                                                         data=datas)
示例#27
0
class account_move_line_inherit(models.Model):
    _inherit = "account.move.line"

    # ref = fields.Char('move_id', 'ref', string='Reference', store=True)
    # move_id = fields.Many2one('account.move', 'Journal Entry', ondelete="cascade", help="The move of this entry line.", select=2, required=True, auto_join=True)
    # debit = fields.Float('Debit', digits_compute=dp.get_precision('Account'))
    # credit = fields.Float('Credit', digits_compute=dp.get_precision('Account'))
    # amount_currency = fields.Float('Amount Currency', help="The amount expressed in an optional other currency.")
    date_maturity = fields.Date(
        'Due date',
        select=True,
        help=
        "This field is used for payable and receivable journal entries. You can put the limit date for the payment of this line."
    )
    reconcile_id = fields.Many2one('account.move.reconcile',
                                   'Reconcile',
                                   readonly=True,
                                   ondelete='set null',
                                   select=2,
                                   copy=False)
    state = fields.Selection([('draft', 'Unbalanced'), ('valid', 'Balanced')],
                             'Status',
                             readonly=True,
                             copy=False)
    statement_id = fields.Many2one(
        'account.bank.statement',
        'Statement',
        help="The bank statement used for bank reconciliation",
        select=1,
        copy=False)
class ActivityStatementWizard(models.TransientModel):
    """Activity Statement wizard."""

    _inherit = 'statement.common.wizard'
    _name = 'activity.statement.wizard'
    _description = 'Activity Statement Wizard'

    @api.model
    def _get_date_start(self):
        return (fields.Date.context_today(self).replace(day=1) -
                relativedelta(days=1)).replace(day=1)

    date_start = fields.Date(required=True, default=_get_date_start)

    @api.onchange('aging_type')
    def onchange_aging_type(self):
        super().onchange_aging_type()
        if self.aging_type == 'months':
            self.date_start = self.date_end.replace(day=1)
        else:
            self.date_start = self.date_end - relativedelta(days=30)

    def _export(self):
        """Export to PDF."""
        data = self._prepare_statement()
        return self.env.ref('partner_statement'
                            '.action_print_activity_statement').report_action(
                                self, data=data)

    def _prepare_statement(self):
        res = super()._prepare_statement()
        res.update({'date_start': self.date_start})
        return res
示例#29
0
class test_model(models.Model):
    _name = 'test_converter.test_model'
    _description = 'Test Converter Model'

    char = fields.Char()
    integer = fields.Integer()
    float = fields.Float()
    numeric = fields.Float(digits=(16, 2))
    many2one = fields.Many2one('test_converter.test_model.sub',
                               group_expand='_gbf_m2o')
    binary = fields.Binary(attachment=False)
    date = fields.Date()
    datetime = fields.Datetime()
    selection_str = fields.Selection(
        [
            ('A', u"Qu'il n'est pas arrivé à Toronto"),
            ('B', u"Qu'il était supposé arriver à Toronto"),
            ('C', u"Qu'est-ce qu'il fout ce maudit pancake, tabernacle ?"),
            ('D', u"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()

    # `base` module does not contains any model that implement the functionality
    # `group_expand`; test this feature here...

    @api.model
    def _gbf_m2o(self, subs, domain, order):
        sub_ids = subs._search([], order=order, access_rights_uid=SUPERUSER_ID)
        return subs.browse(sub_ids)
class EagleeduInstructor(models.Model):
    _name = 'eagleedu.instructor'
    # _inherit = ['mail.thread']
    _description = 'All Teachers Details'

    @api.model
    def create(self, vals):
        """Over riding the create method to assign
        the sequence for newly creating records"""
        vals['instructor_id'] = self.env['ir.sequence'].next_by_code(
            'eagleedu.instructor')
        res = super(EagleeduInstructor, self).create(vals)
        return res

    name = fields.Char(string="Instructor Name", required=True)
    instructor_id = fields.Char(string="Instructor ID No.", readonly=True)
    ins_father_name = fields.Char(string="Father Name")
    ins_mother_name = fields.Char(string="Mother Name")
    ins_mobile_no = fields.Char(string="Mobile no.")
    ins_email = fields.Char(string="Email Address")
    ins_present_address = fields.Char(string="Present Address")
    ins_permanent_address = fields.Char(string="Permanent Address")
    ins_image = fields.Binary(string="Instructor Image")
    ins_gender = fields.Selection([('male', 'Male'), ('female', 'Female'),
                                   ('other', 'Other')],
                                  string='Gender',
                                  required=False,
                                  track_visibility='onchange',
                                  help="Your Gender is")
    ins_date_of_birth = fields.Date(string="Date Of birth",
                                    help="Enter your DOB")