Merge branch 'cor_cr' of https://gitlab.sunarctechnologies.com/prakash.jain/cor-odoo into cor_cr
This commit is contained in:
commit
288f87b93e
|
@ -279,27 +279,27 @@
|
|||
<form string="Project Sale Employee Lines">
|
||||
<group>
|
||||
<group>
|
||||
<field name="project_id"/>
|
||||
<field name="sale_line_id"/>
|
||||
<field name="timesheet_product_id"/>
|
||||
<field name="currency_id"/>
|
||||
<field name="budgeted_uom"/>
|
||||
<field name="employee_price"/>
|
||||
<field name="employee_id"/>
|
||||
<field name="cost"/>
|
||||
<field name="role"/>
|
||||
<field name="start_date"/>
|
||||
<field name="start_date" required="1"/>
|
||||
<field name="budgeted_qty"/>
|
||||
<field name="price_unit"/>
|
||||
<field name="timesheet_hour"/>
|
||||
<field name="project_id" invisible="1"/>
|
||||
<field name="sale_line_id" invisible="1"/>
|
||||
<field name="timesheet_product_id" invisible="1"/>
|
||||
<field name="currency_id" invisible="1"/>
|
||||
<field name="budgeted_uom" invisible="1"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="employee_id"/>
|
||||
<field name="company_id"/>
|
||||
<field name="price_unit"/>
|
||||
<field name="budgeted_qty"/>
|
||||
<field name="timesheet_hour"/>
|
||||
<field name="role"/>
|
||||
<field name="employee_price"/>
|
||||
<field name="end_date"/>
|
||||
<field name="distribution_per"/>
|
||||
<field name="budgeted_hour_week"/>
|
||||
<field name="consultant_cost"/>
|
||||
<field name="hour_distribution"/>
|
||||
<field name="distribution_per"/>
|
||||
<field name="end_date"/>
|
||||
<field name="hour_distribution" invisible="1"/>
|
||||
<field name="company_id" invisible="1"/>
|
||||
</group>
|
||||
</group>
|
||||
<footer>
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
from odoo import api, fields, models
|
||||
from odoo.exceptions import UserError, AccessError, ValidationError
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timedelta
|
||||
from dateutil import relativedelta
|
||||
|
||||
|
||||
class ProjectResourceWizard(models.TransientModel):
|
||||
_name = 'project.resource.wizard'
|
||||
|
||||
|
@ -44,6 +43,10 @@ class ProjectResourceWizard(models.TransientModel):
|
|||
if self.project_id.hour_distribution == 'Percentage':
|
||||
values.update({'distribution_per': val.distribution_per})
|
||||
record.create(values)
|
||||
############
|
||||
for emp in self.project_id.sale_line_employee_ids:
|
||||
if emp.employee_id == val.employee_id and emp.end_date == False and val.start_date:
|
||||
emp.write({'end_date' : val.start_date - relativedelta.relativedelta(days=1)})
|
||||
return True
|
||||
|
||||
class ProjectResourceLine(models.Model):
|
||||
|
@ -54,8 +57,8 @@ class ProjectResourceLine(models.Model):
|
|||
project_id = fields.Many2one('project.project')
|
||||
employee_id = fields.Many2one('hr.employee')
|
||||
role = fields.Selection([('Manager', 'Manager'),('Employee', 'Employee'), ], string="Role", default="Employee")
|
||||
start_date = fields.Date(required=True)
|
||||
end_date = fields.Date(required=True)
|
||||
start_date = fields.Date()
|
||||
end_date = fields.Date()
|
||||
price_unit = fields.Float("Hourly Rate")
|
||||
budgeted_qty = fields.Float(string='Bud. Hours', digits=(16, 2))
|
||||
cost = fields.Float("Bud. Revenue", default=0.0)
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<tree editable="bottom">
|
||||
<field name="employee_id"/>
|
||||
<field name="role"/>
|
||||
<field name="start_date"/>
|
||||
<field name="start_date" required="1"/>
|
||||
<field name="end_date"/>
|
||||
<field name="distribution_per" attrs="{'invisible': [('hour_distribution','!=','Percentage')], 'required': [('hour_distribution','=','Percentage')]}"/>
|
||||
<field name="price_unit"/>
|
||||
|
|
|
@ -91,55 +91,57 @@ odoo.define('month_filter.searchUtils', function (require) {
|
|||
4: { description: _lt("Q4"), coveredMonths: [9, 10, 11] },
|
||||
};
|
||||
const MONTH_OPTIONS = {
|
||||
this_month: {
|
||||
id: 'this_month', groupNumber: 1, format: 'MMMM',
|
||||
first_month: {
|
||||
id: 'first_month', groupNumber: 1, format: 'MMMM',
|
||||
addParam: {}, granularity: 'month',
|
||||
},
|
||||
last_month: {
|
||||
id: 'last_month', groupNumber: 1, format: 'MMMM',
|
||||
addParam: { months: -1 }, granularity: 'month',
|
||||
second_month: {
|
||||
id: 'second_month', groupNumber: 1, format: 'MMMM',
|
||||
addParam: { months: +1 }, granularity: 'month',
|
||||
},
|
||||
antepenultimate_month: {
|
||||
id: 'antepenultimate_month', groupNumber: 1, format: 'MMMM',
|
||||
addParam: { months: -2 }, granularity: 'month',
|
||||
third_month: {
|
||||
id: 'third_month', groupNumber: 1, format: 'MMMM',
|
||||
addParam: { months: +2 }, granularity: 'month',
|
||||
},
|
||||
antepenultimate_month_3: {
|
||||
id: 'antepenultimate_month_3', groupNumber: 1, format: 'MMMM',
|
||||
addParam: { months: -3 }, granularity: 'month',
|
||||
fourth_month: {
|
||||
id: 'fourth_month', groupNumber: 1, format: 'MMMM',
|
||||
addParam: { months: +3 }, granularity: 'month',
|
||||
},
|
||||
antepenultimate_month_4: {
|
||||
id: 'antepenultimate_month_4', groupNumber: 1, format: 'MMMM',
|
||||
addParam: { months: -4 }, granularity: 'month',
|
||||
fifth_month: {
|
||||
id: 'fifth_month', groupNumber: 1, format: 'MMMM',
|
||||
addParam: { months: +4 }, granularity: 'month',
|
||||
},
|
||||
antepenultimate_month_5: {
|
||||
id: 'antepenultimate_month_5', groupNumber: 1, format: 'MMMM',
|
||||
addParam: { months: -5 }, granularity: 'month',
|
||||
sixth_month: {
|
||||
id: 'sixth_month', groupNumber: 1, format: 'MMMM',
|
||||
addParam: { months: +5 }, granularity: 'month',
|
||||
},
|
||||
antepenultimate_month_6: {
|
||||
id: 'antepenultimate_month_6', groupNumber: 1, format: 'MMMM',
|
||||
addParam: { months: -6 }, granularity: 'month',
|
||||
seventh_month: {
|
||||
id: 'seventh_month', groupNumber: 1, format: 'MMMM',
|
||||
addParam: { months: +6 }, granularity: 'month',
|
||||
},
|
||||
antepenultimate_month_7: {
|
||||
id: 'antepenultimate_month_7', groupNumber: 1, format: 'MMMM',
|
||||
addParam: { months: -7 }, granularity: 'month',
|
||||
eighth_month: {
|
||||
id: 'eighth_month', groupNumber: 1, format: 'MMMM',
|
||||
addParam: { months: +7 }, granularity: 'month',
|
||||
},
|
||||
antepenultimate_month_8: {
|
||||
id: 'antepenultimate_month_8', groupNumber: 1, format: 'MMMM',
|
||||
addParam: { months: -8 }, granularity: 'month',
|
||||
ninth_month: {
|
||||
id: 'ninth_month', groupNumber: 1, format: 'MMMM',
|
||||
addParam: { months: +8 }, granularity: 'month',
|
||||
},
|
||||
antepenultimate_month_9: {
|
||||
id: 'antepenultimate_month_9', groupNumber: 1, format: 'MMMM',
|
||||
addParam: { months: -9 }, granularity: 'month',
|
||||
tenth_month: {
|
||||
id: 'tenth_month', groupNumber: 1, format: 'MMMM',
|
||||
addParam: { months: +9 }, granularity: 'month',
|
||||
},
|
||||
antepenultimate_month_10: {
|
||||
id: 'antepenultimate_month_10', groupNumber: 1, format: 'MMMM',
|
||||
addParam: { months: -10 }, granularity: 'month',
|
||||
eleventh_month: {
|
||||
id: 'eleventh_month', groupNumber: 1, format: 'MMMM',
|
||||
addParam: { months: +10 }, granularity: 'month',
|
||||
},
|
||||
antepenultimate_month_11: {
|
||||
id: 'antepenultimate_month_11', groupNumber: 1, format: 'MMMM',
|
||||
addParam: { months: -11 }, granularity: 'month',
|
||||
twelfth_month: {
|
||||
id: 'twelfth_month', groupNumber: 1, format: 'MMMM',
|
||||
addParam: { months: +11 }, granularity: 'month',
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
const QUARTER_OPTIONS = {
|
||||
fourth_quarter: {
|
||||
id: 'fourth_quarter', groupNumber: 1, description: QUARTERS[4].description,
|
||||
|
@ -174,6 +176,7 @@ odoo.define('month_filter.searchUtils', function (require) {
|
|||
};
|
||||
const PERIOD_OPTIONS = Object.assign({}, MONTH_OPTIONS, QUARTER_OPTIONS, YEAR_OPTIONS);
|
||||
|
||||
|
||||
// GroupBy menu parameters
|
||||
const GROUPABLE_TYPES = [
|
||||
'boolean',
|
||||
|
@ -444,7 +447,8 @@ odoo.define('month_filter.searchUtils', function (require) {
|
|||
for (const option of Object.values(PERIOD_OPTIONS)) {
|
||||
const { id, groupNumber, description, } = option;
|
||||
const res = { id, groupNumber, };
|
||||
const date = referenceMoment.clone().set(option.setParam).add(option.addParam);
|
||||
const ref_date = referenceMoment.startOf('year');
|
||||
const date = ref_date.clone().set(option.setParam).add(option.addParam);
|
||||
if (description) {
|
||||
res.description = description.toString();
|
||||
} else {
|
||||
|
|
|
@ -7,8 +7,15 @@ from dateutil import relativedelta
|
|||
class EmployeeInherit(models.Model):
|
||||
_inherit = 'hr.employee'
|
||||
|
||||
allow_to_edit = fields.Selection(selection=[('always', 'Always'), ('specific', 'Specific')],string="Allow to edit",store=True)
|
||||
allow_to_create = fields.Selection(selection=[('always', 'Always'), ('specific', 'Specific')] , store=True)
|
||||
allow_to_edit = fields.Selection(selection=[('always', 'Always'), ('specific', 'Specific')],string="Allow to edit")
|
||||
allow_to_create = fields.Selection(selection=[('always', 'Always'), ('specific', 'Specific')] )
|
||||
permission_history = fields.One2many(comodel_name="timesheet.block.history", inverse_name="employee_id",
|
||||
string="History", required=False )
|
||||
class EmployeePublicInherit(models.Model):
|
||||
_inherit = 'hr.employee.public'
|
||||
|
||||
allow_to_edit = fields.Selection(selection=[('always', 'Always'), ('specific', 'Specific')],string="Allow to edit")
|
||||
allow_to_create = fields.Selection(selection=[('always', 'Always'), ('specific', 'Specific')] )
|
||||
permission_history = fields.One2many(comodel_name="timesheet.block.history", inverse_name="employee_id",
|
||||
string="History", required=False )
|
||||
|
||||
|
@ -30,8 +37,7 @@ class TimehseetBlock(models.Model):
|
|||
@api.model
|
||||
def create(self, values):
|
||||
current_date = datetime.today().date()
|
||||
entry_date = datetime.strptime(values['date'], "%Y-%m-%d").date()
|
||||
# values['date'] = datetime.strptime(values['date'], "%Y-%m-%d %H:%M:%S")
|
||||
entry_date = datetime.strptime(values['start_datetime'],"%Y-%m-%d %H:%M:%S").date()
|
||||
months_diff = current_date.month - entry_date.month
|
||||
employee_object = self.env['hr.employee'].sudo().search([('user_id', '=', self.env.uid)])
|
||||
project_manager_group = self.env.ref('hr_timesheet.group_timesheet_manager')
|
||||
|
@ -71,8 +77,7 @@ class TimehseetBlock(models.Model):
|
|||
def write(self, values):
|
||||
current_date = datetime.today().date()
|
||||
if 'date' in values:
|
||||
entry_date = datetime.strptime(values['date'], "%Y-%m-%d").date()
|
||||
# values['date'] = datetime.strptime(values['date'], "%Y-%m-%d %H:%M:%S")
|
||||
entry_date = datetime.strptime(values['start_datetime'],"%Y-%m-%d %H:%M:%S").date()
|
||||
else:
|
||||
res_date = str(self.date).split('.', 1)[0]
|
||||
entry_date = datetime.strptime(str(res_date), '%Y-%m-%d').date()
|
||||
|
@ -111,3 +116,11 @@ class TimehseetBlock(models.Model):
|
|||
else:
|
||||
raise AccessError('You can not create future entry')
|
||||
|
||||
|
||||
@api.onchange('end_datetime')
|
||||
def _onchange_end_datetime(self):
|
||||
if self.end_datetime:
|
||||
current_date = datetime.today().date()
|
||||
end_date = datetime.strptime(str(self.end_datetime), "%Y-%m-%d %H:%M:%S").date()
|
||||
if end_date > current_date:
|
||||
raise AccessError('End date cannot be a future date!')
|
||||
|
|
Loading…
Reference in New Issue