mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
IMP l10n_us_hr_payroll Calculated distinct employee's with pay slips for Hibou Professional.
This commit is contained in:
@@ -2,7 +2,11 @@
|
||||
'name': 'USA - Payroll',
|
||||
'author': 'Hibou Corp. <hello@hibou.io>',
|
||||
'category': 'Localization',
|
||||
'depends': ['hr_payroll', 'hr_payroll_rate'],
|
||||
'depends': [
|
||||
'hr_payroll',
|
||||
'hr_payroll_rate',
|
||||
'hibou_professional',
|
||||
],
|
||||
'version': '12.0.2020.1.0',
|
||||
'description': """
|
||||
USA Payroll Rules.
|
||||
|
||||
@@ -3,4 +3,5 @@
|
||||
from . import hr_contract
|
||||
from . import hr_payslip
|
||||
from . import hr_salary_rule
|
||||
from . import update
|
||||
from . import us_payroll_config
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
|
||||
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.tools.safe_eval import safe_eval
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
26
l10n_us_hr_payroll/models/update.py
Normal file
26
l10n_us_hr_payroll/models/update.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
|
||||
|
||||
import datetime
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class PublisherWarrantyContract(models.AbstractModel):
|
||||
_inherit = 'publisher_warranty.contract'
|
||||
|
||||
def _get_hibou_modules(self):
|
||||
modules = super(PublisherWarrantyContract, self)._get_hibou_modules()
|
||||
try:
|
||||
today_date = fields.Date.today()
|
||||
last_thirty_date = today_date - datetime.timedelta(days=30)
|
||||
today = fields.Date.to_string(today_date + datetime.timedelta(days=1)) # Dates vs Datetimes, pad out a day
|
||||
last_thirty = fields.Date.to_string(last_thirty_date)
|
||||
self.env.cr.execute(
|
||||
'SELECT COUNT(DISTINCT(employee_id)) FROM hr_payslip WHERE create_date BETWEEN %s AND %s',
|
||||
(last_thirty, today))
|
||||
employee_count = self.env.cr.fetchone()[0] or 0
|
||||
modules.update({
|
||||
'l10n_us_hr_payroll': employee_count,
|
||||
})
|
||||
except:
|
||||
pass
|
||||
return modules
|
||||
Reference in New Issue
Block a user