add date from datetime

This commit is contained in:
Pawan Kumar 2021-02-17 23:23:36 +05:30
parent 4f56252b57
commit b8067ee798
2 changed files with 13 additions and 7 deletions

View File

@ -8,6 +8,7 @@ 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
import dateutil.parser
class AccountAnalyticLine(models.Model):
@ -161,3 +162,8 @@ class AccountAnalyticLine(models.Model):
if self.project_id:
self.project_id._onchange_calculate_timesheet_hours()
return res
@api.onchange('start_datetime', 'end_datetime')
def _onchange_start_end_date(self):
if self.start_datetime:
self.date = self.start_datetime.date()

View File

@ -64,8 +64,8 @@
<field name="name">account.analytic.line.tree.hr_timesheet</field>
<field name="model">account.analytic.line</field>
<field name="arch" type="xml">
<tree string="Timesheet Activities" sample="1">
<field name="date"/>
<tree editable="top" string="Timesheet Activities" sample="1">
<field name="date" readonly="1" invisible="1"/>
<field name="employee_id" invisible="1"/>
<field name="project_id" required="1" options="{'no_create_edit': True}"
context="{'form_view_ref': 'project.project_project_view_form_simplified',}"/>
@ -75,8 +75,8 @@
<field name="name" optional="show" required="0"/>
<field name="start_time" widget="float_time" invisible="1"/><!--custom-->
<field name="end_time" widget="float_time" invisible="1"/><!--custom-->
<field name="start_datetime" string="Start date"/><!--custom-->
<field name="end_datetime" string="End date"/><!--custom-->
<field name="start_datetime" string="Start Time"/><!--custom-->
<field name="end_datetime" string="End Time"/><!--custom-->
<field name="unit_amount" optional="show" widget="timesheet_uom" sum="Total"
decoration-danger="unit_amount &gt; 24"/>
<field name="parent_project"/><!--custom-->
@ -161,20 +161,20 @@
</group>
<group>
<group>
<field name="date"/>
<field name="project_id" required="1"
context="{'form_view_ref': 'project.project_project_view_form_simplified',}"/>
<field name="task_id" widget="task_with_hours" context="{'default_project_id': project_id}"
domain="[('project_id', '=', project_id)]"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="date" readonly="1"/>
</group>
<group>
<!--<field name="amount"/>-->
<field name="amount" invisible="1"/>
<field name="start_time" widget="float_time" invisible="1"/><!--custom-->
<field name="end_time" widget="float_time" invisible="1"/><!--custom-->
<field name="start_datetime" string="Start date"/><!--custom-->
<field name="end_datetime" string="End date"/><!--custom-->
<field name="start_datetime" string="Start Time"/><!--custom-->
<field name="end_datetime" string="End Time"/><!--custom-->
<field name="unit_amount" widget="timesheet_uom" decoration-danger="unit_amount &gt; 24"/>
<field name="currency_id" invisible="1"/>
</group>