Merge branch 'feedback_28july' into 'copy_master'
add timesheet hours context menu in sub-project See merge request prakash.jain/cor-odoo!235
This commit is contained in:
commit
add3e4783d
|
@ -9,6 +9,25 @@ class SubProject(models.Model):
|
|||
sub_project = fields.Many2many('project.project', 'project_subproject_rel', 'project_id', 'id',
|
||||
domain="[('is_sub_project', '=', True),('parent_project', '=', False)]", string='Sub Project')
|
||||
parent_project = fields.Many2one('project.project', domain="[('is_sub_project', '=', False)]", string='Parent Project')
|
||||
total_timesheet_time_sub_project = fields.Integer(compute='_compute_total_timesheet_time_sub_project')
|
||||
|
||||
@api.depends('timesheet_ids')
|
||||
def _compute_total_timesheet_time_sub_project(self):
|
||||
for project in self:
|
||||
total_time = 0.0
|
||||
value = project.timesheet_ids.search([('sub_project', '!=', False)])
|
||||
for timesheet in value:
|
||||
total_time += timesheet.unit_amount * timesheet.product_uom_id.factor_inv
|
||||
# Now convert to the proper unit of measure set in the settings
|
||||
total_time *= project.timesheet_encode_uom_id.factor
|
||||
#project.total_timesheet_time_sub_project = int(round(total_time))
|
||||
project.total_timesheet_time_sub_project = total_time
|
||||
|
||||
def action_view_custom_sub_project(self):
|
||||
action = self.env["ir.actions.actions"]._for_xml_id("hr_timesheet.timesheet_action_all")
|
||||
action['domain'] = [('sub_project', '=', self.id)]
|
||||
action['context'] = {'search_default_sub_project': self.id}
|
||||
return action
|
||||
|
||||
# @api.onchange('parent_project', 'sub_project')
|
||||
# def onchange_parent_project_sub_project(self):
|
||||
|
|
|
@ -8,6 +8,45 @@
|
|||
<field name="inherit_id" ref="project.edit_project"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<!--<xpath expr="//button[@name='%(hr_timesheet.act_hr_timesheet_line_by_project)d']" position="replace">
|
||||
<button class="oe_stat_button" name="%(hr_timesheet.act_hr_timesheet_line_by_project)d"
|
||||
type="action"
|
||||
icon="fa-calendar"
|
||||
attrs="{'invisible': ['|',('allow_timesheets', '=', False),('parent_project', '!=', False)]}"
|
||||
groups="hr_timesheet.group_hr_timesheet_user">
|
||||
<div class="o_field_widget o_stat_info">
|
||||
<div class="oe_inline">
|
||||
<span class="o_stat_value mr-1">
|
||||
<field name="total_timesheet_time" widget="statinfo" nolabel="1"/>
|
||||
</span>
|
||||
<span class="o_stat_value">
|
||||
<field name="timesheet_encode_uom_id" class="o_stat_text"
|
||||
options="{'no_open' : True}"/>
|
||||
</span>
|
||||
</div>
|
||||
<span class="o_stat_text">Recorded</span>
|
||||
</div>
|
||||
</button>
|
||||
</xpath>-->
|
||||
<div name="button_box" position="inside">
|
||||
<button class="oe_stat_button" name="action_view_custom_sub_project" type="object"
|
||||
icon="fa-calendar"
|
||||
attrs="{'invisible': ['|', ('allow_timesheets', '=', False),('parent_project', '=', False)]}"
|
||||
groups="hr_timesheet.group_hr_timesheet_user">
|
||||
<div class="o_field_widget o_stat_info">
|
||||
<div class="oe_inline">
|
||||
<span class="o_stat_value mr-1">
|
||||
<field name="total_timesheet_time_sub_project" widget="statinfo" nolabel="1"/>
|
||||
</span>
|
||||
<span class="o_stat_value">
|
||||
<field name="timesheet_encode_uom_id" class="o_stat_text"
|
||||
options="{'no_open' : True}"/>
|
||||
</span>
|
||||
</div>
|
||||
<span class="o_stat_text">Recorded</span>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
<xpath expr="//field[@name='allowed_internal_user_ids']" position="after">
|
||||
<field name="is_sub_project" invisible="1"/>
|
||||
</xpath>
|
||||
|
@ -15,8 +54,9 @@
|
|||
<field name="parent_project" attrs="{'invisible': [('is_sub_project', '=', False)]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='allowed_internal_user_ids']" position="after">
|
||||
<field name="sub_project" widget="many2many_tags" attrs="{'invisible': [('is_sub_project', '=', True)]}"
|
||||
options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"/>
|
||||
<field name="sub_project" widget="many2many_tags"
|
||||
attrs="{'invisible': [('is_sub_project', '=', True)]}"
|
||||
options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"/>
|
||||
</xpath>
|
||||
<!--<xpath expr="//page[@name='settings']" position="after">
|
||||
<page name="sub_project" string="Sub Project"
|
||||
|
@ -71,7 +111,7 @@
|
|||
<field name="privacy_visibility" optional="hide"/>
|
||||
<field name="subtask_project_id" optional="hide"/>
|
||||
<field name="label_tasks" optional="hide"/>
|
||||
<field name="company_id" optional="show" groups="base.group_multi_company"/>
|
||||
<field name="company_id" optional="show" groups="base.group_multi_company"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
|
Loading…
Reference in New Issue