⚠️ HIGH |
Category: Odoo Tips |
ID: T04 |
Owner: CEO
T04 — Payroll Accounting trên Odoo 19 — Lessons Learned
1. hr.version thay hr.contract
Odoo 19 dùnghr.version thay vì hr.contract. Payslip dùng version_id.
is_in_contract và is_current: computed, KHÔNG stored → không filter qua domain, phải filter trong Pythonstate field: KHÔNG tồn tại trên hr.versionemployment_type_id: KHÔNG tồn tại trên hr.version, thay bằng contract_type_id2. Work Entries
generate_work_entries(employee_ids, date_from, date_to) trên hr.employeegenerate_work_entries return [] (empty) cho attendance-based employees — đây là ĐÚNG, không phải lỗi3. Payroll Journal
journal_id nằm trên hr.payroll.structure (NOT structure_type)hr.payroll.structure.type không có journal_id và không truy cập được qua JSON-24. Account Mapping trên Salary Rules
account_debit và account_credit nằm trên hr.salary.rule (NOT hr.payslip.line) BASIC/ALW: Nợ 6421/6411 Có 3341
BHXH NV: Nợ 3341 Có 33831 (trừ vào lương → nộp BHXH)
BHXH CT: Nợ 6421/6411 Có 33831 (CP DN → nộp BHXH)
TNCN: Nợ 3341 Có 33351
KPCĐ: Nợ 6421/6411 Có 33821
5. XML-RPC Gotcha: action_payslip_done returns None
hr.payslip.action_payslip_done() returns Noneallow_none=False mặc địnhTypeError: cannot marshal None unless allow_none is enabledxmlrpc.client.Fault chứa 'cannot marshal None', coi như thành công, verify state sau đóvalidated (KHÔNG phải done)6. Odoo 19 Account — Multi-company
account.account KHÔNG có company_id field (dùng company_ids many2many)[('company_id', 'in', [3,6,7])] → query không filter, filter Python7. Phân chia chi phí lương theo bộ phận
@EXPENSE account khác nhau theo Structure (Hourly=6411, Regular=6421)8. Multi-company default gotcha
Khi create records qua API, Odoo gán default cho company-specific fields dựa trên company của API user (KHÔNG phải company_id trong vals). Ảnh hưởng: journal_id, warehouse_id, sequence_id...context={'allowed_company_ids': [co_id]} nhưng XML-RPC không hỗ trợ context dễ dàngChecklist trước khi apply production
📚 Published from Company Knowledge Base — T04
Last updated: 2026-03-11
Review by: 2026-06-09