Exemple #1
0
    def action_breeding_list(self):
        ctx = {
            'default_work_order_id': self.id,
        }

        model_name = 'berdikari.breeding.input'
        model = self.env[model_name]
        if len(self.line_breed_ids) == 1:
            rec = model.search([('work_order_id', '=', self.id)], limit=1)
            res_id = False
            if rec:
                res_id = rec.id

            action = Util.jek_open_form(
                self, model_name=model_name, id=res_id, ctx=ctx
            )
        else:
            domain = [('work_order_id','=',self.id)]
            action = Util.jek_redirect_to_model(
                title='Breeding', model_name=model_name, ctx=ctx, domain=domain
            )

            action = self.env.ref('berdikari.breeding_input_list_action').read()[0]
            action['domain'] = domain

        return action
Exemple #2
0
    def send(self, auto_commit=False, raise_exception=False):
        for rec in self:
            subject = rec.subject

            if subject == 'Password reset':
                super(MailMail, self).send()
            else:
                row_custom = Util.get_setup(self)
                white_list_email = row_custom.white_list_email
                list_white_list_email = [one.login for one in white_list_email]

                email_list = []
                if rec.email_to:
                    email_list.append(rec.email_to)
                for partner in rec.recipient_ids:
                    email_list.append(partner.email)

                for email in email_list:
                    if email in list_white_list_email:
                        _logger.info('##################Send Email : %s ', email)
                        super(MailMail, self).send()
                    else:
                        _logger.info('##################Blocked Email : %s ', email)
                        # Memastikan tidak ada yang outstanding
                        self.cancel()
                        return False
Exemple #3
0
    def action_create_paklaring(self):
        termination_date = self.termination_date
        if not termination_date:
            raise ValidationError(_('Tgl Keluar harus diisi dulu, sebelum membuat Paklaring'))

        model_paklaring = self.env['berdikari.hr.employee.paklaring']
        setup = self.env['jekdoo.setup'].get_setup()
        dept_head_hr_id = setup.dept_head_hr_id
        if dept_head_hr_id:
            my_user = dept_head_hr_id.user_id
            my_employee = dept_head_hr_id
            my_job = my_employee.job_id
        else:
            raise ValidationError(_('Please Set Dept Head HR'))
        # my_user = self.env.user
        # my_employee = my_user.employee_id
        # my_job = my_employee.job_id
        import datetime
        vals = {
            'employee_id': self.id,
            'nomor_pegawai': self.barcode,
            'employee_last_position': self.job_id,
            'employee_address': self.address,
            'created_date': datetime.datetime.today(),
            'user_id': my_employee.id,
            'user_job_id': my_job.id if my_job else False,
        }
        if self.paklaring_id.id:
            paklaring = model_paklaring.write(vals)
        else:
            paklaring = model_paklaring.create(vals)
            self.paklaring_id = paklaring.id

        return Util.jek_pop1('Done')
Exemple #4
0
 def action_cash_advance(self):
     ctx = {
         'default_partner_id': self.id,
     }
     model_name = 'account.invoice'
     domain = [('partner_id', '=', self.id)]
     return Util.jek_redirect_to_model(model_name, 'Employee Cash Advance', ctx, domain=domain)
Exemple #5
0
    def action_validate(self):
        for rec in self:
            for one in rec.stock_scrap_ids:
                result = one.action_validate()
                if type(result) is not bool:
                    # {'name': 'Insufficient Quantity', 'view_type': 'form', 'view_mode': 'form',
                    #  'res_model': 'stock.warn.insufficient.qty.scrap', 'view_id': 1121, 'type': 'ir.actions.act_window',
                    #  'context': {'default_product_id': 176, 'default_location_id': 45, 'default_scrap_id': 14},
                    #  'target': 'new'}

                    name = result.get('name')

                    context = result.get('context')
                    default_product_id = context.get('default_product_id')
                    default_location_id = context.get('default_location_id')

                    product = self.env['product.product'].browse(
                        default_product_id)
                    location_id = self.env['stock.location'].browse(
                        default_location_id)

                    product_uom_id = one.product_uom_id

                    available_qty = 0
                    stock_quant = self.env['stock.quant'].search(
                        [('product_id', '=', default_product_id),
                         ('location_id', '=', default_location_id),
                         ('product_uom_id', '=', product_uom_id.id)],
                        limit=1)
                    other_stock = ''
                    if stock_quant:
                        available_qty = stock_quant.quantity
                    else:
                        stock_quant_ids = self.env['stock.quant'].search([
                            ('product_id', '=', default_product_id),
                            ('product_uom_id', '=', product_uom_id.id),
                            ('location_id.usage', '=', 'internal'),
                        ])
                        if stock_quant_ids:
                            other_stock += '\n---------------------------------------------------------------------'
                            for one_stock in stock_quant_ids:
                                other_stock += '\n Location: {} / {} {}'.format(
                                    one_stock.location_id.display_name,
                                    one_stock.quantity,
                                    one_stock.product_uom_id.display_name,
                                )

                    pesan = _('{}: {} at {}, Available Stock: {} {}'.format(
                        name, product.display_name, location_id.display_name,
                        available_qty, other_stock))
                    return Util.jek_pop1(pesan, name)
                    # return result

            rec.name = self.env['ir.sequence'].next_by_code(
                'berdikari.stock.scrap.header')
            rec.state = 'done'
        return True
Exemple #6
0
    def action_rfq_list(self):
        ctx = {
            'search_default_purchase_request_id': self.name,
        }
        domain = [('purchase_request_id', '=', self.id)]

        return Util.jek_redirect_to_model('purchase.order',
                                          'RFQ by PR Number',
                                          ctx,
                                          domain=domain)
Exemple #7
0
    def action_hatcher_input(self):
        ctx = {
            'default_work_order_id': self.id,
        }

        model_name = 'berdikari.fms.grading.hatcher'
        res_id = False
        action = Util.jek_open_form(
            self, model_name=model_name, id=res_id, ctx=ctx
        )
        return action
Exemple #8
0
    def action_write_off_input(self):
        ctx = {
            'default_asset_id': self.id,
        }

        model_name = 'berdikari.asset.write.off'
        res_id = False
        action = Util.jek_open_form(self,
                                    model_name=model_name,
                                    id=res_id,
                                    ctx=ctx)
        return action
Exemple #9
0
    def action_hatcher_list(self):
        ctx = {
            'default_work_order_id': self.id,
        }

        model_name = 'berdikari.fms.grading.hatcher'
        model = self.env[model_name]
        if len(self.line_breed_ids) == 1:
            rec = model.search([('work_order_id', '=', self.id)], limit=1)
            res_id = False
            if rec:
                res_id = rec.id

            action = Util.jek_open_form(
                self, model_name=model_name, id=res_id, ctx=ctx
            )
        else:
            action = Util.jek_redirect_to_model(
                title='Hatcher', model_name=model_name, ctx=ctx, domain=[('work_order_id','=',self.id)]
            )
        return action
Exemple #10
0
 def action_leave_carry_over(self):
     model_leave_carry_over = self.env['berdikari.leave.carry.over']
     today = datetime.now()
     leave_period_year = today.year + 1
     check_date = date(today.year, today.month, today.day)
     leave_period_date = date(leave_period_year, 1, 1)
     ctx = {
         'default_employee_id': self.id,
         'default_leave_to_carry_over_period': str(leave_period_year) if check_date == leave_period_date else str((today.year - 1)),
     }
     model_name = 'berdikari.leave.carry.over'
     domain = [('employee_id', '=', self.id)]
     return Util.jek_redirect_to_model(model_name, 'Leave Carry Over', ctx, domain=domain)
Exemple #11
0
    def action_create_rfq(self):
        ctx = {
            'default_purchase_request_id': self.id,
        }

        model_name = 'purchase.order'

        res_id = False
        action = Util.jek_open_form(self,
                                    model_name=model_name,
                                    id=res_id,
                                    ctx=ctx)
        return action
Exemple #12
0
    def action_work_order_list(self):
        ctx = {
            'default_flock_id': self.id,
        }

        model_name = 'berdikari.work.order'
        model = self.env[model_name]
        if len(self.work_order_ids) == 1:
            rec = model.search([('flock_id', '=', self.id)], limit=1)
            res_id = False
            if rec:
                res_id = rec.id

            action = Util.jek_open_form(self,
                                        model_name=model_name,
                                        id=res_id,
                                        ctx=ctx)
        else:
            action = Util.jek_redirect_to_model(title='Work Order',
                                                model_name=model_name,
                                                ctx=ctx,
                                                domain=[('flock_id', '=',
                                                         self.id)])
        return action
Exemple #13
0
    def action_write_off_input(self):
        ctx = {
            'default_asset_id': self.asset_id.id,
            'default_asset_qty': self.qty,
            'default_aquire_value': self.asset_id.value,
            'default_write_off_value': self.asset_id.value,
            'default_asset_used_id': self.id,
        }

        model_name = 'berdikari.asset.write.off'
        res_id = False
        action = Util.jek_open_form(self,
                                    model_name=model_name,
                                    id=res_id,
                                    ctx=ctx)
        return action
Exemple #14
0
    def action_breeding_input(self):
        ctx = {
            'default_work_order_id': self.id,
        }

        model_name = 'berdikari.breeding.input'
        # model = self.env[model_name]
        # rec = model.search([('work_order_id', '=', self.id)], limit=1)
        # res_id = False
        # if rec:
        #     res_id = rec.id

        res_id = False
        action = Util.jek_open_form(
            self, model_name=model_name, id=res_id, ctx=ctx
        )
        return action
Exemple #15
0
    def action_hachery(self):
        ctx = {
            'default_flock_id': self.id,
        }

        model_name = 'berdikari.fms.hatchery'
        model = self.env[model_name]
        rec = model.search([('flock_id', '=', self.id)], limit=1)
        res_id = False
        if rec:
            res_id = rec.id

        action = Util.jek_open_form(self,
                                    model_name=model_name,
                                    id=res_id,
                                    ctx=ctx)
        print(action)
        return action
Exemple #16
0
    def action_report_receive_money(self):
        if self.journal_type == False:
            self.journal_type = 'all'
        ctx = {
            'date_range':
            "{} - {}".format(
                self.date_from.strftime('%d %m %Y'),
                self.date_to.strftime('%d %m %Y'),
            ),
            'date_from':
            self.date_from,
            'date_to':
            self.date_to,
            'search_default_groupby_journal_type':
            self.journal_type,
        }

        domain = []
        if self.date_from:
            domain.append(('payment_date', '>=', self.date_from))
        else:
            domain = domain
        if self.date_to:
            domain.append(('payment_date', '<=', self.date_to))
        else:
            domain = domain
        if self.journal_type != 'all' and self.journal_type != False:
            domain.append(('journal_type', '=', self.journal_type))
        else:
            domain = domain
        if self.payment_type != 'all' and self.payment_type != False:
            domain.append(('payment_type', '=', self.payment_type))
        else:
            domain = domain

        model_name = 'account.payment'
        action = Util.jek_redirect_to_model(title='Receive Money',
                                            model_name=model_name,
                                            ctx=ctx,
                                            domain=domain)
        return action
Exemple #17
0
    def action_work_order_input(self):

        if not (self.start_date and self.end_date and self.duration):
            raise ValidationError(
                _('Start Date, End Date, and Duration may not be empty!'))

        ctx = {
            'default_flock_id': self.id,
        }

        model_name = 'berdikari.work.order'
        # model = self.env[model_name]
        # rec = model.search([('flock_id', '=', self.id)], limit=1)
        # res_id = False
        # if rec:
        #     res_id = rec.id

        res_id = False
        action = Util.jek_open_form(self,
                                    model_name=model_name,
                                    id=res_id,
                                    ctx=ctx)
        return action
Exemple #18
0
    def action_biological_used(self):
        model_name = 'berdikari.asset.biologis.used'
        model = self.env[model_name]

        for rec in self:
            ctx = {}
            domain = []
            res_id = False

            if rec.biologis_used_id:
                res_id = rec.biologis_used_id.id
            else:
                if rec.work_order_id and rec.asset_id:
                    ctx['default_work_order_id'] = rec.work_order_id.id
                    ctx['default_work_order_line_breed_id'] = rec.id
                    ctx['default_asset_id'] = rec.asset_id.id

                    domain.append(('work_order_line_breed_id', '=', rec.id))
                    rec = model.search(domain, limit=1)
                    if rec:
                        res_id = rec.id
            action = Util.jek_open_form(self, model_name=model_name, id=res_id, ctx=ctx)
            return action
Exemple #19
0
 def action_print_pr(self):
     pesan = 'File Printed'
     pesan += '\nNew Line'
     pesan += '<br/>new br'
     pesan += '\r\n new r new l'
     return Util.jek_pop1(_(pesan))
    def confirm_button(self):
        docs = {}
        format_report = self.format_report
        period_id = self.period_id
        period_seq_id = self.period_seq_id
        operating_unit_id = self.operating_unit_id
        struct_id = self.struct_id
        # ids = [1, 2]

        domain = [('operating_unit_id', '=', operating_unit_id.id),('struct_id', '=', struct_id.id), ]
        if period_id:
            domain.append(('period_id', '=', period_id.id))

        if period_seq_id:
            domain.append(('period_seq_id', '=', period_seq_id.id))

        payslip_ids = self.env['hr.payslip'].search(domain)
        ids = payslip_ids.ids

        setup = self.env['jekdoo.setup'].get_setup()
        gaji_pokok_id = setup.gaji_pokok_id
        tunjangan_perumahan_id = setup.tunjangan_perumahan_id
        tunjangan_transport_id = setup.tunjangan_transport_id
        bpjs_naker_perusahaan_id = setup.bpjs_naker_perusahaan_id
        bpjs_naker_pegawai_id = setup.bpjs_naker_pegawai_id
        potongan_bpjs_kesehatan_perusahaan_id = setup.potongan_bpjs_kesehatan_perusahaan_id
        potongan_bpjs_kesehatan_pegawai_id = setup.potongan_bpjs_kesehatan_pegawai_id
        tunjangan_jabatan_id = setup.tunjangan_jabatan_id
        potongan_pinjaman_id = setup.potongan_pinjaman_id

        for one in payslip_ids:
            employee_id = one.employee_id
            employee_id_id = employee_id.id

            gaji_pokok = 0
            tunjangan_jabatan = 0
            potongan_pinjaman = 0
            tunjangan_perumahan = 0
            tunjangan_transport = 0
            bpjs_naker_perusahaan = 0
            bpjs_naker_pegawai = 0
            potongan_bpjs_kesehatan_perusahaan = 0
            potongan_bpjs_kesehatan_pegawai = 0
            for line in one.line_ids:
                salary_rule_id_id = line.salary_rule_id.id

                if salary_rule_id_id == gaji_pokok_id.id:
                    gaji_pokok += line.total

                if salary_rule_id_id == tunjangan_jabatan_id.id:
                    tunjangan_jabatan += line.total

                if salary_rule_id_id == potongan_pinjaman_id.id:
                    potongan_pinjaman += line.total

                if format_report == 'direksi':
                    if salary_rule_id_id == tunjangan_perumahan_id.id:
                        tunjangan_perumahan += line.total

                    if salary_rule_id_id == tunjangan_transport_id.id:
                        tunjangan_transport += line.total

                if salary_rule_id_id == bpjs_naker_perusahaan_id.id:
                    bpjs_naker_perusahaan += line.total

                if salary_rule_id_id == bpjs_naker_pegawai_id.id:
                    bpjs_naker_pegawai += line.total

                if salary_rule_id_id == potongan_bpjs_kesehatan_perusahaan_id.id:
                    potongan_bpjs_kesehatan_perusahaan += line.total

                if salary_rule_id_id == potongan_bpjs_kesehatan_pegawai_id.id:
                    potongan_bpjs_kesehatan_pegawai += line.total

            bpjs_naker_total = bpjs_naker_perusahaan + bpjs_naker_pegawai
            potongan_bpjs_kesehatan_total = potongan_bpjs_kesehatan_perusahaan + potongan_bpjs_kesehatan_pegawai

            total_diterima = 0
            total_diterima += gaji_pokok
            if format_report != 'penjaga':
                total_diterima += gaji_pokok
                total_diterima += tunjangan_jabatan
                total_diterima += potongan_pinjaman
                total_diterima += tunjangan_perumahan
                total_diterima += tunjangan_transport
                total_diterima -= bpjs_naker_total
                total_diterima -= potongan_bpjs_kesehatan_total

            total_spp = 0
            satu = {}
            satu['id'] = one.id
            satu['name'] = employee_id.name
            satu['employee_id'] = employee_id_id
            currency_id = self.env.ref('base.IDR')[0]
            satu['currency_id'] = currency_id
            # import ipdb; ipdb.set_trace()
            if employee_id_id in docs:
                dua = docs[employee_id_id]

                satu['gaji_pokok'] = dua['gaji_pokok'] + gaji_pokok
                satu['tunjangan_jabatan'] = dua['tunjangan_jabatan'] + tunjangan_jabatan
                satu['potongan_pinjaman'] = dua['potongan_pinjaman'] + potongan_pinjaman
                satu['tunjangan_perumahan'] = dua['tunjangan_perumahan'] + tunjangan_perumahan
                satu['tunjangan_transport'] = dua['tunjangan_transport'] + tunjangan_transport
                satu['bpjs_naker_perusahaan'] = dua['bpjs_naker_perusahaan'] + bpjs_naker_perusahaan
                satu['bpjs_naker_pegawai'] = dua['bpjs_naker_pegawai'] + bpjs_naker_pegawai
                satu['bpjs_naker_total'] = dua['bpjs_naker_total'] + bpjs_naker_total
                satu['potongan_bpjs_kesehatan_perusahaan'] = dua['potongan_bpjs_kesehatan_perusahaan'] + potongan_bpjs_kesehatan_perusahaan
                satu['potongan_bpjs_kesehatan_pegawai'] = dua['potongan_bpjs_kesehatan_pegawai'] + potongan_bpjs_kesehatan_pegawai
                satu['potongan_bpjs_kesehatan_total'] = dua['potongan_bpjs_kesehatan_total'] + potongan_bpjs_kesehatan_total
                satu['total_diterima'] = dua['total_diterima'] + total_diterima
                satu['total_spp'] = dua['total_spp'] + total_spp
            else:
                satu['gaji_pokok'] = gaji_pokok
                satu['tunjangan_jabatan'] = tunjangan_jabatan
                satu['potongan_pinjaman'] = potongan_pinjaman
                satu['tunjangan_perumahan'] = tunjangan_perumahan
                satu['tunjangan_transport'] = tunjangan_transport
                satu['bpjs_naker_perusahaan'] = bpjs_naker_perusahaan
                satu['bpjs_naker_pegawai'] = bpjs_naker_pegawai
                satu['bpjs_naker_total'] = bpjs_naker_total
                satu['potongan_bpjs_kesehatan_perusahaan'] = potongan_bpjs_kesehatan_perusahaan
                satu['potongan_bpjs_kesehatan_pegawai'] = potongan_bpjs_kesehatan_pegawai
                satu['potongan_bpjs_kesehatan_total'] = potongan_bpjs_kesehatan_total
                satu['total_diterima'] = total_diterima
                satu['total_spp'] = total_spp

            docs[employee_id_id] = satu

        title = ''
        if format_report == 'direksi':
            report_name = 'berdikari.report_payslip_karyawan_direksi'
            title = 'Laporan Rekapitulasi Gaji Direksi / Komisaris'
        elif format_report == 'karyawan_tetap' or format_report == 'karyawan_kontrak' :
            report_name = 'berdikari.report_payslip_karyawan'
            if format_report == 'karyawan_tetap':
                title = 'Laporan Rekapitulasi Gaji Karyawan - Tetap'
            else:
                title = 'Laporan Rekapitulasi Gaji Karyawan - Kontrak'

        elif format_report == 'penjaga':
            report_name = 'berdikari.report_payslip_penjaga'
            title = 'Laporan Rekapitulasi Gaji Penjaga'
        else:
            return Util.jek_pop1('Belum di set untuk Format Report Tersebut')

        params = {'date_start': 123, 'model': docs, 'title': title, 'docs': payslip_ids}
        rep = self.env.ref(report_name)
        ret = rep.with_context(landscape=True).report_action(ids, data=params)
        return ret
Exemple #21
0
 def action_budget_confirm_plan(self):
     self.write({'confirm_plan': True})
     return Util.jek_pop1('Done')
Exemple #22
0
 def btnCashAdvance(self):
     pesan = 'pop up cash advance'
     return Util.jek_pop1(pesan)
Exemple #23
0
 def action_backup_db(self):
     msg = self.backup_db()
     return Util.jek_pop1(msg)
Exemple #24
0
    def action_close_flock(self):

        self.state = 'closed'

        return Util.jek_pop1(_('Done'))
Exemple #25
0
 def default_payment_term_id(self):
     setup = Util.get_setup(self)
     return setup.default_payment_term_id