Merge branch 'development' of http://103.74.223.20:8085/prakash.jain/cor-odoo into pawan_branch
This commit is contained in:
commit
1c72c2c356
|
@ -1,9 +1,13 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details
|
||||
|
||||
from odoo import api, exceptions, fields, models, _
|
||||
from odoo import api, exceptions, fields, models, tools, _
|
||||
from odoo.exceptions import UserError, AccessError, ValidationError
|
||||
from odoo.osv import expression
|
||||
import math
|
||||
from datetime import datetime, time, timedelta
|
||||
from odoo.tools.float_utils import float_round
|
||||
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT, ustr
|
||||
|
||||
class AccountAnalyticLine(models.Model):
|
||||
_inherit = 'account.analytic.line'
|
||||
|
@ -34,6 +38,35 @@ class AccountAnalyticLine(models.Model):
|
|||
raise ValidationError(_("End time cannot be earlier than Start time"))
|
||||
self.unit_amount = res
|
||||
|
||||
@api.model
|
||||
def export_data(self, fields):
|
||||
index = range(len(fields))
|
||||
fields_name = dict(zip(fields, index))
|
||||
res = super(AccountAnalyticLine, self).export_data(fields)
|
||||
for index, val in enumerate(res['datas']):
|
||||
if fields_name.get('date') >=0:
|
||||
tdateindex = fields_name.get('date')
|
||||
tdate = res['datas'][index][tdateindex]
|
||||
if tdate:
|
||||
res['datas'][index][tdateindex] = datetime.strftime(tdate, "%d/%m/%Y")
|
||||
if fields_name.get('task_id') >=0:
|
||||
taskindex = fields_name.get('task_id')
|
||||
ttask = res['datas'][index][taskindex]
|
||||
if type(ttask)==bool:
|
||||
res['datas'][index][taskindex] = ''
|
||||
if fields_name.get('start_time') >=0:
|
||||
starttimeindex = fields_name.get('start_time')
|
||||
starttime = float(res['datas'][index][starttimeindex])
|
||||
if starttime:
|
||||
start_time = tools.format_duration(starttime)
|
||||
res['datas'][index][starttimeindex] = start_time
|
||||
if fields_name.get('end_time') >=0:
|
||||
endtimeindex = fields_name.get('end_time')
|
||||
endtime = float(res['datas'][index][endtimeindex])
|
||||
if endtime:
|
||||
end_time = tools.format_duration(endtime)
|
||||
res['datas'][index][endtimeindex] = end_time
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
|
|
|
@ -16,12 +16,26 @@ class PlanningShift(models.Model):
|
|||
_inherit = 'planning.slot'
|
||||
|
||||
project_id = fields.Many2one('project.project', string="Project", domain="[('company_id', '=', company_id), ('allow_forecast', '=', True)]", check_company=True)
|
||||
budgeted_hours = fields.Float("Budgeted hours", default=0, compute='_compute_budgeted_hours', store=True)
|
||||
task_id = fields.Many2one('project.task', string="Task", domain="[('company_id', '=', company_id), ('project_id', '=', project_id)]", check_company=True)
|
||||
|
||||
_sql_constraints = [
|
||||
('project_required_if_task', "CHECK( (task_id IS NOT NULL AND project_id IS NOT NULL) OR (task_id IS NULL) )", "If the planning is linked to a task, the project must be set too."),
|
||||
]
|
||||
|
||||
@api.depends('project_id', 'employee_id')
|
||||
def _compute_budgeted_hours(self):
|
||||
for slot in self:
|
||||
if slot.project_id and slot.employee_id:
|
||||
if slot.project_id.project_type == 'hours_no_limit':
|
||||
slot.budgeted_hours = slot.project_id.budgeted_hours
|
||||
#print("slot.project_id.project_type", slot.project_id.project_type)
|
||||
if slot.project_id.project_type == 'hours_in_consultant':
|
||||
cons = self.env['project.sale.line.employee.map'].search([('employee_id','=',slot.employee_id.id),('project_id','=',slot.project_id.id)], limit=1)
|
||||
slot.budgeted_hours = cons and cons.budgeted_qty or 0
|
||||
else:
|
||||
slot.budgeted_hours = 0
|
||||
|
||||
@api.onchange('task_id')
|
||||
def _onchange_task_id(self):
|
||||
if not self.project_id:
|
||||
|
@ -46,7 +60,9 @@ class PlanningShift(models.Model):
|
|||
project_ids = self.env['project.project'].search(
|
||||
[('privacy_visibility', '=', 'followers'), ('allow_forecast', '=', True),
|
||||
('allowed_internal_user_ids', 'in', self.employee_id.user_id.id)]).ids
|
||||
emp_all_project_ids = manager_id + emp_project_ids + project_ids
|
||||
consul_ids = self.env['project.sale.line.employee.map'].search([('employee_id', '=', self.employee_id.id)])
|
||||
consul_project_ids = [val.project_id.id for val in consul_ids]
|
||||
emp_all_project_ids = manager_id + emp_project_ids + project_ids + consul_project_ids
|
||||
domain = [('id', 'in', list(set(emp_all_project_ids)))]
|
||||
result = {
|
||||
'domain': {'project_id': domain},
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='role_id']" position="after">
|
||||
<field name="project_id" context="{'default_allow_forecast': True}"/>
|
||||
<field name="budgeted_hours"/>
|
||||
<field name="task_id" attrs="{'invisible': [('project_id', '=', False)]}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
|
|
Loading…
Reference in New Issue