Skip to Content
Odoo เมนู
  • ลงชื่อเข้าใช้
  • ทดลองใช้ฟรี
  • แอป
    การเงิน
    • ระบบบัญชี
    • ระบบการออกใบแจ้งหนี้
    • ระบบบัญชีรายจ่าย
    • ระบบการจัดการข้อมูลผ่านสเปรดชีต (BI)
    • เอกสาร
    • ระบบลงลายเซ็น
    การขาย
    • ลูกค้าสัมพันธ์
    • การขาย
    • POS ร้านค้า
    • POS ร้านอาหาร
    • ระบบสมัครสมาชิก
    • การเช่า
    การจัดการเว็บไซต์
    • เครื่องมือสร้างเว็บไซต์
    • ระบบการขายออนไลน์
    • บล็อก
    • ฟอรั่ม
    • ไลฟ์แชท
    • ระบบการอบรมออนไลน์
    ซัพพลายเชน
    • คลังสินค้า
    • ระบบการผลิต
    • PLM
    • ระบบการจัดซื้อ
    • การซ่อมบำรุง
    • ระบบจัดการคุณภาพ
    ทรัพยากรบุคคล
    • ข้อมูลพนักงาน
    • ระบบสรรหาบุคลากร
    • ระบบการลา
    • การประเมิน
    • ระบบการแนะนำพนักงาน
    • ระบบจัดการยานพาหนะ
    การตลาด
    • โซเชียลมาร์เก็ตติ้ง
    • การตลาดผ่านอีเมล
    • ระบบการตลาดผ่าน SMS
    • ระบบการจัดงานอีเวนต์
    • การตลาดแบบอัตโนมัติ
    • ระบบแบบสำรวจ
    การบริการ
    • โปรเจกต์
    • ระบบบันทึกเวลา
    • ระบบการจัดการบริการภาคสนาม
    • ระบบดูแลช่วยเหลือ
    • การวางแผน
    • การนัดหมาย
    ประสิทธิผล
    • ระบบแสดงความคิดเห็น
    • ระบบการอนุมัติ
    • ไอโอที
    • VoIP
    • คลังข้อมูล
    • WhatsApp
    แอปพลิเคชันของบุคคลที่สาม Odoo สตูดิโอ แพลตฟอร์มคลาวด์ของ Odoo
  • อุตสาหกรรม
    การค้าปลีก
    • ร้านขายหนังสือ
    • ร้านขายเสื้อผ้า
    • ร้านขายเฟอร์นิเจอร์
    • ร้านขายของชำ
    • ร้านขายฮาร์ดแวร์
    • ร้านขายของเล่น
    Food & Hospitality
    • บาร์และผับ
    • ร้านอาหาร
    • อาหารฟาสต์ฟู้ด
    • Guest House
    • ตัวแทนจำหน่ายเครื่องดื่ม
    • Hotel
    อสังหาริมทรัพย์
    • Real Estate Agency
    • บริษัทสถาปัตยกรรม
    • บริษัทรับเหมา
    • การจัดการอสังหาริมทรัพย์
    • การจัดสวน
    • สมาคมเจ้าของอสังหาริมทรัพย์
    ปรึกษา
    • สำนักงานบัญชี
    • Odoo พาร์ทเนอร์
    • เอเจนซี่การตลาด
    • สำนักงานกฎหมาย
    • บริการสรรหาบุคลากร
    • การตรวจสอบและการรับรอง
    ระบบการผลิต
    • Textile
    • เหล็ก
    • เฟอร์นิเจอร์
    • อาหาร
    • Brewery
    • ของขวัญขององค์กร
    สุขภาพ & ฟิตเนส
    • ชมรมกีฬา
    • ร้านขายแว่นตา
    • ฟิตเนส
    • ผู้ประกอบวิชาชีพด้านสุขภาพ
    • ร้านขายยา
    • ร้านทำผม
    Trades
    • ช่างซ่อม
    • ฮาร์ดแวร์และการสนับสนุนด้านไอที
    • ระบบพลังงานแสงอาทิตย์
    • ช่างทำรองเท้า
    • บริการทำความสะอาด
    • HVAC Services
    อื่น ๆ
    • Nonprofit Organization
    • สำนักงานสิ่งแวดล้อม
    • ร้านเช่าป้ายโฆษณา
    • การถ่ายภาพ
    • ร้านเช่าจักรยาน
    • ตัวแทนจำหน่ายซอฟต์แวร์
    Browse all Industries
  • คอมมูนิตี้
    ศึกษา
    • บทเรียน
    • เอกสารกำกับโปรแกรม
    • การรับรอง
    • การฝึกอบรม
    • บล็อก
    • พอดแคสต์
    เพิ่มศักยภาพให้กับการศึกษา
    • โปรแกรมการศึกษา
    • Scale Up! Business Game
    • เยี่ยมชม Odoo
    รับซอฟต์แวร์
    • ดาวน์โหลด
    • เปรียบเทียบรุ่น
    • เผยแพร่
    ทำงานร่วมกัน
    • Github
    • ฟอรั่ม
    • ระบบการจัดงานอีเวนต์
    • การแปล
    • ร่วมเป็นพาร์ทเนอร์
    • Services for Partners
    • ลงทะเบียนเพื่อสร้างบัญชีบริษัทของคุณ
    รับบริการ
    • ค้นหาพาร์ทเนอร์
    • ค้นหานักบัญชี
    • พบกับที่ปรึกษา
    • บริการติดตั้งระบบเพื่อใช้งาน
    • ข้อมูลอ้างอิงลูกค้า
    • การสนับสนุน
    • อัปเกรด
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    รับการสาธิต
  • ราคา
  • ช่วยเหลือ

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • ลูกค้าสัมพันธ์
  • e-Commerce
  • ระบบบัญชี
  • สินค้าคงคลัง
  • PoS
  • โปรเจกต์
  • MRP
All apps
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
All Posts คน เหรียญรางวัล
แท็ก (View all)
odoo accounting v14 pos v15
เกี่ยวกับฟอรั่มนี้
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
All Posts คน เหรียญรางวัล
แท็ก (View all)
odoo accounting v14 pos v15
เกี่ยวกับฟอรั่มนี้
ช่วยเหลือ

how to modify fields of hr.attendance via a modification request automatically

ติดตาม

รับการแจ้งเตือนเมื่อมีกิจกรรมในโพสต์นี้

คำถามนี้ถูกตั้งค่าสถานะ
python3odoo11
2 ตอบกลับ
7956 มุมมอง
อวตาร
Dhouha

i'm using odoo 11. i have create a custom module for attendance modification request which be approuved by the manager of attendance . My goal is to limit the acces to the modification of attendance and when the manager press approuve "hr.attendance" will be modified automatically whith the new values of check_in and check_out (if it's the same employee and same date between "hr.attendance" and my request modification). The problem is when i press approuve there is no error but in the same time there is no modification. Here is my code. Any idea for help please ?

modification_request.xml

<record model="ir.ui.view" id="view_attendance_modification_request_form">
    <field name="name">attendance.modification.request.form</field>
    <field name="model">attendance.modification.request</field>
    <field name="arch" type="xml">
        <form string="Attendance modification Request">
            <header>
                <field name="state" statusbar_visible="draft,waiting,approved,cancel" widget="statusbar" />
                <button name="submit_modification" string="Submit for manager" type="object" class="btn-primary"
                        attrs="{'invisible': [('state','not in','draft')]}"/>
                <button name="modification_approval" type="object" string="Approve" class="oe_highlight"
                        groups="hr_attendance.group_hr_attendance_manager"
                        attrs="{'invisible': [('state','not in','waiting')]}"/>
                <button name="modification_rejection" type="object" string="Cancel" class="oe_highlight"
                        groups="hr_attendance.group_hr_attendance_manager"
                        attrs="{'invisible': [('state','not in','waiting')]}"/>
            </header>
            <sheet>

                <h2>
                    <group>

                        <field name="employee_id"/>
                    </group>
                </h2>
                <group  col="4" colspan="4">
                    <field name="time_check_in_1"/>
                    <field name="time_check_out_1"/>
                </group>

                <label for="note"/>
                <field name="note"/>
            </sheet>
            <field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
            <field name="activity_ids" widget="mail_activity"/>
            <field name="message_ids" widget="mail_thread"/>


        </form>
    </field>
</record>

modification_request.py

 class AttendanceModificationRequest(models.Model):
_name = 'attendance.modification.request'
_description = 'Attendance modification Request'
_inherit = ['mail.thread', 'mail.activity.mixin']

def _get_employee_id(self):
    employee_rec = self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1)
    return employee_rec.id
employee_id = fields.Many2one('hr.employee',"Employee", readonly=True,default=_get_employee_id, required=True)
user_id = fields.Many2one('res.users', string='User', track_visibility='onchange', readonly=True,
                          states={'draft': [('readonly', False)]}, default=lambda self: self.env.user)
state = fields.Selection([
    ('draft', 'Pending'),
    ('waiting', 'Waiting for approval'),
    ('approved', 'Approved'),
    ('cancel', 'Cancelled')], readonly=True,
    help="Gives the state of the attendance request modification .",
    default='draft')
modification_date = fields.Date("Date")
time_check_in_1 = fields.Datetime("Check in")
time_check_out_1 = fields.Datetime("Check out")
note = fields.Text("Note")
attendance_id = fields.Many2one('hr.attendance', string='Attendance')
@api.multi
def modification_approval(self):
    attend_signin_ids = self.env['hr.attendance']
    check_in_date = datetime.strptime(self.time_check_in_1, "%Y-%m-%d %H:%M:%S").date()
    check_out_date = datetime.strptime(self.time_check_out_1, "%Y-%m-%d %H:%M:%S").date()

    for obj in attend_signin_ids :
      attendance_check_in_date = datetime.strptime(obj.check_in, "%Y-%m-%d %H:%M:%S").date()
      attendance_check_out_date = datetime.strptime(obj.check_out, "%Y-%m-%d %H:%M:%S").date()
      if (obj.employee_id == self.employee_id) and (check_in_date == attendance_check_in_date):
           obj.check_in = self.time_check_in_1
           obj.check_out = self.time_check_out_1

    return self.write({
        'state': 'approved'
    })



0
อวตาร
ละทิ้ง
อวตาร
Anusha
คำตอบที่ดีที่สุด

Hi,

  Change the    attend_signin_ids to self.env['hr.attendance'].search([('employee_id','=',self.employee_id.id)])

def modification_approval(self):
    attend_signin_ids = self.env['hr.attendance'].search([('employee_id','=',self.employee_id.id)])
    check_in_date = datetime.strptime(self.time_check_in_1, "%Y-%m-%d %H:%M:%S").date()
    check_out_date = datetime.strptime(self.time_check_out_1, "%Y-%m-%d %H:%M:%S").date()

    for obj in attend_signin_ids :
      attendance_check_in_date = datetime.strptime(obj.check_in, "%Y-%m-%d %H:%M:%S").date()
      attendance_check_out_date = datetime.strptime(obj.check_out, "%Y-%m-%d %H:%M:%S").date()
      if (check_in_date == attendance_check_in_date):
           obj.write({'check_in': self.time_check_in_1,
                      'check_out': self.time_check_out_1})

    return self.write({
        'state': 'approved'
    })


0
อวตาร
ละทิ้ง
Dhouha
ผู้เขียน

Thanks for you answer but there's an error that display " strptime() argument 1 must be str, not bool" Do you know how to fix it ?

Anusha

check_in_date = datetime.strptime(str(self.time_check_in_1), "%Y-%m-%d %H:%M:%S").date()

conver the datetime to string in strptime()

Dhouha
ผู้เขียน

Thank you very much it works and it shows another error which said " ValueError: time data 'False' does not match format '%Y-%m-%d %H:%M:%S'". I try to found a solution so i viewed the date of the table "hr.attendance" but they are the same format ""2019-05-08 10:06:51"".I don't know where the problem is ?

อวตาร
Muhammad Mohiuddin
คำตอบที่ดีที่สุด

@Dhouha have you solved this problem?

0
อวตาร
ละทิ้ง
สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!

สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!

ลงชื่อ
Related Posts ตอบกลับ มุมมอง กิจกรรม
How to set a filter as default filter in odoo แก้ไขแล้ว
python3 odoo11
อวตาร
อวตาร
อวตาร
2
ก.พ. 24
16867
How to set default stage to when recruitement record is created แก้ไขแล้ว
python3 odoo11
อวตาร
อวตาร
1
ธ.ค. 22
5884
How to change the value of a field which depends on other fields automatically ? แก้ไขแล้ว
python3 odoo11
อวตาร
อวตาร
อวตาร
2
ธ.ค. 22
15786
how to update field of attendance via an attendance request modification
python3 odoo11
อวตาร
อวตาร
อวตาร
2
มิ.ย. 22
5879
Field Value Update In Another Module Depend On Calculation
python3 odoo11
อวตาร
0
พ.ค. 22
4667
คอมมูนิตี้
  • บทเรียน
  • เอกสารกำกับโปรแกรม
  • ฟอรั่ม
โอเพนซอร์ส
  • ดาวน์โหลด
  • Github
  • Runbot
  • การแปล
บริการ
  • โฮสติ้ง odoo.sh เซิร์ฟเวอร์
  • การสนับสนุน
  • อัปเกรด
  • การพัฒนาที่กำหนดเอง
  • การศึกษา
  • ค้นหานักบัญชี
  • ค้นหาพาร์ทเนอร์
  • ร่วมเป็นพาร์ทเนอร์
เกี่ยวกับเรา
  • บริษัทของเรา
  • ทรัพย์สินในรูปของเครื่องหมายการค้า
  • ติดต่อเรา
  • งาน
  • ระบบการจัดงานอีเวนต์
  • พอดแคสต์
  • บล็อก
  • ลูกค้า
  • กฎหมาย • ความเป็นส่วนตัว
  • ความปลอดภัย
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo เป็นชุดแอปธุรกิจแบบเปิดที่ครอบคลุมทุกความต้องการของบริษัทของคุณ อาธิ CRM eCommerce ระบบบัญชี ระบบสินค้าคงคลัง ระบบการขายหน้าร้าน โปรเจกต์ และ อีกมากมาย

ความเหนือกว่าอันเป็นเอกลักษณ์ของ Odoo คือการใช้งานที่ง่ายดายและผสานการทำงานอย่างสมบูรณ์แบบในเวลาเดียวกัน

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now