Beispiel #1
0
    def projects_list(self):
        user_bank_id = None
        if not http.request.env.user.sudo(http.request.env.user). \
                user_has_groups(
                    'bestja_project_hierarchy.managers_level0,bestja_project_hierarchy.managers_level1'
                ):
            user_organization = http.request.env['organization'].sudo().search([
                ('level', '=', 2),
                '|',  # noqa
                    ('coordinator', '=', http.request.env.user.id),
                    ('projects.manager', '=', http.request.env.user.id)
            ])
            if not user_organization:
                return exceptions.Forbidden()
            user_bank_id = user_organization.parent.id

        projects = http.request.env['bestja.project'].sudo().search([
            ('organization_level', '=', 0),
            ('use_detailed_reports', '=', True),
            ('date_start', '<=', Date.today()),
        ], order='date_start desc')

        return http.request.render('bestja_detailed_reports.projects_list', {
            'projects': projects,
            'user_bank_id': user_bank_id,
        })
Beispiel #2
0
    def projects_list(self):
        user_bank_id = None
        if not http.request.env.user.sudo(http.request.env.user). \
                user_has_groups(
                    'bestja_project_hierarchy.managers_level0,bestja_project_hierarchy.managers_level1'
                ):
            user_organization = http.request.env['organization'].sudo().search(
                [
                    ('level', '=', 2),
                    '|',  # noqa
                    ('coordinator', '=', http.request.env.user.id),
                    ('projects.manager', '=', http.request.env.user.id)
                ])
            if not user_organization:
                return exceptions.Forbidden()
            user_bank_id = user_organization.parent.id

        projects = http.request.env['bestja.project'].sudo().search(
            [
                ('organization_level', '=', 0),
                ('use_detailed_reports', '=', True),
                ('date_start', '<=', Date.today()),
            ],
            order='date_start desc')

        return http.request.render('bestja_detailed_reports.projects_list', {
            'projects': projects,
            'user_bank_id': user_bank_id,
        })
Beispiel #3
0
 def _compute_age(self):
     today = fDate.from_string(fDate.today())
     self._check_release_date()
     for perizia in self.filtered('fine_operazioni'):
         delta = fDate.from_string(
             perizia.fine_operazioni) - fDate.from_string(
                 perizia.inizio_operazioni)
         # delta = fDate.from_string(days)
         perizia.giorni_consegna = delta.days
Beispiel #4
0
 def _search_age_days(self, operator, value):
     today = fDate.from_string(fDate.today())
     value_days = td(days=value)
     value_date = fDate.to_string(today - value_days)
     print '>>>>>>>>>', [('birthday', operator, value_date)]
     return [('birthday', operator, value_date)]
Beispiel #5
0
 def _inverse_age_days(self):
     today = fDate.from_string(fDate.today())
     for person in self.filtered('birthday'):
         d = td(days=person.age_days)
         person.birthday = fDate.to_string(today - d)
Beispiel #6
0
 def _compute_age_days(self):
     today = fDate.from_string(fDate.today())
     for person in self.filtered('birthday'):
         delta = (today - fDate.from_string(person.birthday))
         person.age_days = delta.days
Beispiel #7
0
 def _search_age(operator, value):
     today = fDate.from_string(fDate.today())
     value_days = td(days=value)
     value_date = fDate.to_string(today - value_days)
     return [('date_release', operator, value_date)]
Beispiel #8
0
 def _inverse_age(self):
     today = fDate.from_string(fDate.today())
     for book in self.filtered('date_release'):
         d = td(days=book.age_days) - today
         book.date_release = fDate.to_string(d)
Beispiel #9
0
 def _compute_age(self):
     today = fDate.from_string(fDate.today())
     for book in self.filtered('date_release'):
         delta = (fDate.from_string(book.date_release) - today)
         book.age_days = delta.days
Beispiel #10
0
		compute_sudo=False,
		)

	publisher_city = fields.Char(
		'Publisher City',
		related='publisher_id.city')


	_sql_constraints = [
		('name_uniq',
		'UNIQUE (name)',
		'Book title must be unique.')
		]

def _inverse_age(self): today =
	fDate.from_string(fDate.today())
	for book in self.filtered('date_release'):
	d = td(days=book.age_days) - today
	book.date_release = fDate.to_string(d)

def _search_age(self, operator, value):
	today = fDate.from_string(fDate.today())
	value_days = td(days=value)
	value_date = fDate.to_string(today - value_days)
	return [('date_release', operator, value_date)]


@api.model
	def _referencable_models(self):
	models = self.env['res.request.link'].search([])
	return [(x.object, x.name) for x in models]
Beispiel #11
0
 def _check_date_release(self):
     for r in self:
         if r.date_release > dt.today():
             raise models.ValidationError('Release date cannot be in future.')
 def _search_age(self, operator, value):
     today = fDate.from_string(fDate.today())
     value_days = td(days=value)
     value_date = fDate.to_string(today - value_days)
     return [('date_release', operator, value_date)]
 def _inverse_age(self):
     today = fDate.from_string(fDate.today())
     for book in self.filtered('date_release'):
         d = td(days=book.age_days) - today
         book.date_release = fDate.to_string(d)
 def _compute_age(self):
     today = fDate.from_string(fDate.today())
     for book in self.filtered('date_release'):
         delta = (fDate.from_string(book.date_release) - today)
         book.age_days = delta.days
Beispiel #15
0
    def attendance_per_location(self, date=None, location=None):
        if not date:
            date = Date.today()

        dt_from = datetime.datetime.strptime("%s 00:00:00" % date, DEFAULT_SERVER_DATETIME_FORMAT) - datetime.timedelta(
                hours=8)
        dt_to = datetime.datetime.strptime("%s 23:59:59" % date, DEFAULT_SERVER_DATETIME_FORMAT) - datetime.timedelta(
                hours=8)

        if not location:
            location = "1"

        Attendance = request.env["hr.attendance"].sudo()
        Employee = request.env["hr.employee"].sudo()
        values = {}

        domain = []
        if date:
            domain.append(("name", ">=", Datetime.to_string(dt_from)))
            domain.append(("name", "<=", Datetime.to_string(dt_to)))

        # if location:
        #     domain.append(("location", "=", location))

        all_employees = Employee.search([])

        emp_attendances_values = []
        for emp in all_employees:
            attendance = dict()
            attendance["name"] = emp.name
            attendance["dep"] = emp.department_id.name

            records = Attendance.search(domain + [("employee_id", "=", emp.id)],
                                        order="name")
            if records and records[-1].location:
                latest_rec = records[-1]
                attendance["state"] = "打卡"

                dt = UTC_Datetime_To_TW_TZ(latest_rec.name)
                date_part = dt.strftime(DEFAULT_SERVER_DATE_FORMAT)
                time_part = dt.strftime(DEFAULT_SERVER_TIME_FORMAT)
                attendance["date"] = date_part
                attendance["time"] = time_part
                attendance["location"] = latest_rec.location
            else:
                attendance["state"] = "未打卡"
                attendance["date"] = None
                attendance["time"] = None
                attendance["location"] = None

            leave_time = emp.get_holiday_on(date)
            attendance["leave"] = string.join(leave_time.keys(), ",") if leave_time else None

            emp_attendances_values.append(attendance)

        # attendance_grouped_by_location = itertools.groupby(emp_attendances_values, key=lambda a: a["location"])
        attendances = defaultdict(lambda: list())
        for attendance in emp_attendances_values:
            attendances[attendance["location"]].append(attendance)  # or _("not attended")

        print_time = UTC_Datetime_To_TW_TZ(Datetime.now())
        values["print_time"] = Datetime.to_string(print_time)

        values["date"] = date
        values["location"] = location
        values["emp_attendances"] = attendances
        keys = sorted(attendances.keys())
        if None in keys:
            keys.remove(None)
            keys.append(None)
        values["attendance_keys"] = keys
        values["action_count"] = len(filter(lambda a: a.get("date", None), emp_attendances_values))
        values["un_action_count"] = len(filter(lambda a: not a.get("date", None), emp_attendances_values))

        return request.render("hr_sf.attendance_per_location", values)