Merge branch 'copy_master' into 'master'

Copy master

See merge request prakash.jain/cor-odoo!237
This commit is contained in:
pawan.sharma 2022-08-01 06:55:35 +00:00
commit 31ecdc8863
5 changed files with 88 additions and 19 deletions

View File

@ -53,6 +53,7 @@ class AccountAnalyticLine(models.Model):
parent_project = fields.Many2one('project.project', related='project_id.parent_project', string='Parent Project')
sub_project = fields.Many2one('project.project', domain="[('is_sub_project', '=', True)]",
string='Sub Project')
active_project = fields.Boolean(related='project_id.active', store=True)
@api.onchange('project_id')
def _onchange_sub_project_id(self):
@ -254,8 +255,8 @@ class AccountAnalyticLine(models.Model):
value._onchange_start_end_date_time()
if value.unit_amount == 0.0:
raise ValidationError(_("Your can not fill 0.0 hour entry"))
if value.unit_amount >= 24.0:
raise ValidationError(_("Your can not fill more than 24.0 hour entry"))
# if value.unit_amount >= 24.0:
# raise ValidationError(_("Your can not fill more than 24.0 hour entry"))
return value
def write(self, vals):

View File

@ -66,7 +66,7 @@
<field name="date" readonly="1" invisible="1"/>
<field name="employee_id" invisible="1"/>
<!--<field name="project_ids" widget="many2many_tags"/>-->
<field name="project_id" required="1" options="{'no_create_edit': True}"
<field name="project_id" required="1" options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"
context="{'form_view_ref': 'project.project_project_view_form_simplified',}"
/>
<field name="sub_project" options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"/>
@ -81,6 +81,7 @@
<!--<field name="parent_project" options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"/>--><!--custom-->
<field name="company_id" invisible="1"/>
<field name="user_id" invisible="1"/>
<field name="active_project" invisible="0"/>
</tree>
</field>
</record>
@ -163,7 +164,7 @@
</group>
<group>
<group>
<field name="project_id" required="1"
<field name="project_id" required="1" options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"
context="{'form_view_ref': 'project.project_project_view_form_simplified',}"/>
<field name="sub_project"
options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"/>
@ -229,7 +230,7 @@
<calendar string="Timesheet" date_start="start_datetime" date_stop="end_datetime" date_delay="unit_amount"
color="project_id"
form_view_id="%(hr_timesheet.hr_timesheet_line_form)d" event_open_popup="true" quick_add="False">
<field name="project_id"/>
<field name="project_id" options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"/>
<field name="name"/>
<field name="start_datetime" string="Start date"/>
<field name="end_datetime" string="End date"/>

View File

@ -6,12 +6,12 @@
<field name="model">project.project</field>
<field name="inherit_id" ref="sale_timesheet.project_project_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='options_active']/div" position="after">
<div name="creation_div" attrs="{'invisible': [('id', '=', False)]}">
<label for="create_date" class="oe_inline" string="Created On"/>
<field name="create_date" readonly="1" class="oe_inline"/>
</div>
</xpath>
<xpath expr="//div[@name='options_active']/div" position="after">
<div name="creation_div" attrs="{'invisible': [('id', '=', False)]}">
<label for="create_date" class="oe_inline" string="Created On"/>
<field name="create_date" readonly="1" class="oe_inline"/>
</div>
</xpath>
<xpath expr="//button[@name='action_view_timesheet']" position="replace">
<button string="Project Overview" class="oe_stat_button" type="object" name="action_view_timesheet"
icon="fa-puzzle-piece" attrs="{'invisible': [('allow_billable', '=', False)]}" invisible="1"/>
@ -263,9 +263,9 @@
<field name="binding_model_id" ref="project.model_project_task"/>
<field name="state">code</field>
<field name="code">
if records:
action = records.action_done_task()
</field>
if records:
action = records.action_done_task()
</field>
</record>
<!-- Tags -->

View File

@ -9,6 +9,24 @@ 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')
def _compute_total_timesheet_time_sub_project(self):
for project in self:
total_time = 0.0
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
total_time *= project.timesheet_encode_uom_id.factor
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")
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):

View File

@ -1,22 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<!-- 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="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),('is_sub_project', '=', True)]}"
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>
</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),('is_sub_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"/>
<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)]}"/>
</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"
@ -27,7 +77,6 @@
</group>
</page>
</xpath>-->
</data>
</field>
</record>
@ -71,7 +120,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>