hide main timesheet hour menu for sub-project

This commit is contained in:
pawan.sharma 2022-08-01 11:50:53 +05:30
parent b240db41c6
commit b8ed434e47
2 changed files with 26 additions and 18 deletions

View File

@ -11,17 +11,16 @@ class SubProject(models.Model):
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:
record = self.env['account.analytic.line'].search([(('sub_project', '=', project.id))])
for timesheet in record:
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
#project.total_timesheet_time_sub_project = int(round(total_time))
def action_view_custom_sub_project(self):
action = self.env["ir.actions.actions"]._for_xml_id("hr_timesheet.timesheet_action_all")

View File

@ -1,18 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="edit_project_inherited" model="ir.ui.view">
<field name="name">project.project.form.inherit</field>
<!-- Inherit Timesheet Project Invoice Form View-->
<record id="project_invoice_form_inherited" model="ir.ui.view">
<field name="name">project.project.invoice.form.inherit</field>
<field name="model">project.project</field>
<field name="inherit_id" ref="project.edit_project"/>
<field name="inherit_id" ref="hr_timesheet.project_invoice_form"/>
<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)]}"
<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),('is_sub_project', '=', True)]}"
groups="hr_timesheet.group_hr_timesheet_user">
<div class="o_field_widget o_stat_info">
<div class="oe_inline">
@ -27,11 +26,22 @@
<span class="o_stat_text">Recorded</span>
</div>
</button>
</xpath>-->
</xpath>
</data>
</field>
</record>
<!-- Inherit Project Form View-->
<record id="edit_project_inherited" model="ir.ui.view">
<field name="name">project.project.form.inherit</field>
<field name="model">project.project</field>
<field name="inherit_id" ref="project.edit_project"/>
<field name="arch" type="xml">
<data>
<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)]}"
attrs="{'invisible': ['|', ('allow_timesheets', '=', False),('is_sub_project', '=', False)]}"
groups="hr_timesheet.group_hr_timesheet_user">
<div class="o_field_widget o_stat_info">
<div class="oe_inline">
@ -48,7 +58,7 @@
</button>
</div>
<xpath expr="//field[@name='allowed_internal_user_ids']" position="after">
<field name="is_sub_project" invisible="1"/>
<field name="is_sub_project" invisible="0"/>
</xpath>
<xpath expr="//field[@name='allowed_internal_user_ids']" position="after">
<field name="parent_project" attrs="{'invisible': [('is_sub_project', '=', False)]}"/>
@ -67,7 +77,6 @@
</group>
</page>
</xpath>-->
</data>
</field>
</record>