Merge branch 'imp/15.0/sale_timesheet_work_entry_rat__compute_billing_amount' into '15.0'

WIP: imp/15.0/sale_timesheet_work_entry_rat__compute_billing_amount into 15.0

See merge request hibou-io/hibou-odoo/suite!1420
This commit is contained in:
Jared Kipe
2022-05-23 19:15:23 +00:00
5 changed files with 49 additions and 10 deletions

View File

@@ -2,7 +2,7 @@
{ {
'name': 'Timesheet Billing Rate', 'name': 'Timesheet Billing Rate',
'version': '15.0.1.0.0', 'version': '15.0.1.1.0',
'category': 'Sale', 'category': 'Sale',
'author': 'Hibou Corp.', 'author': 'Hibou Corp.',
'license': 'OPL-1', 'license': 'OPL-1',
@@ -10,9 +10,11 @@
'depends': [ 'depends': [
'hibou_professional', 'hibou_professional',
'hr_timesheet_work_entry', 'hr_timesheet_work_entry',
'timesheet_invoice',
'sale_timesheet', 'sale_timesheet',
], ],
'data': [ 'data': [
'views/account_templates.xml',
'views/timesheet_views.xml', 'views/timesheet_views.xml',
'views/work_entry_views.xml', 'views/work_entry_views.xml',
], ],

View File

@@ -1,9 +1,17 @@
# Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details. # Part of Hibou Suite Professional. See LICENSE_PROFESSIONAL file for full copyright and licensing details.
from odoo import fields, models from odoo import api, fields, models
class AccountAnalyticLine(models.Model): class AccountAnalyticLine(models.Model):
_inherit = 'account.analytic.line' _inherit = 'account.analytic.line'
work_billing_rate = fields.Float(related='work_type_id.timesheet_billing_rate', string='Billing Multiplier') work_billing_rate = fields.Float(related='work_type_id.timesheet_billing_rate', string='Billing Multiplier')
work_billing_amount = fields.Float(string='Billing Amount',
compute='_compute_work_billing_amount', store=True)
@api.depends('unit_amount', 'work_billing_rate')
def _compute_work_billing_amount(self):
for ts in self:
ts.work_billing_amount = ts.unit_amount * \
(ts.work_billing_rate if ts.work_type_id else 1.0)

View File

@@ -29,6 +29,7 @@ class TestSaleFlow(TestProjectBilling):
}) })
self.assertEqual(task.sale_line_id, timesheet1.so_line, "The timesheet should be linked to the SOL associated to the task since the pricing type of the project is task rate.") self.assertEqual(task.sale_line_id, timesheet1.so_line, "The timesheet should be linked to the SOL associated to the task since the pricing type of the project is task rate.")
self.assertEqual(timesheet1.work_billing_amount, 50.0)
# create a subtask # create a subtask
subtask = Task.with_context(default_project_id=self.project_task_rate.id).create({ subtask = Task.with_context(default_project_id=self.project_task_rate.id).create({
@@ -78,6 +79,7 @@ class TestSaleFlow(TestProjectBilling):
timesheet1.write({ timesheet1.write({
'work_type_id': double_rate_work_entry_type.id, 'work_type_id': double_rate_work_entry_type.id,
}) })
self.assertEqual(timesheet1.work_billing_amount, 100.0)
self.assertEqual(task.sale_line_id.qty_delivered, 100.0) self.assertEqual(task.sale_line_id.qty_delivered, 100.0)
# Ensure that a created timesheet WITHOUT a work entry type behaves # Ensure that a created timesheet WITHOUT a work entry type behaves
@@ -98,3 +100,4 @@ class TestSaleFlow(TestProjectBilling):
'work_type_id': zero_rate_work_entry_type.id, 'work_type_id': zero_rate_work_entry_type.id,
}) })
self.assertEqual(task.sale_line_id.qty_delivered, 0.0) self.assertEqual(task.sale_line_id.qty_delivered, 0.0)
self.assertEqual(timesheet1.work_billing_amount, 0.0)

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<template id="report_invoice_document_inherit" inherit_id="timesheet_invoice.report_invoice_document_inherit">
<xpath expr="//tr[@t-as='timesheet']/td[last()]" position="replace">
<td class="text-right" t-if="not timesheet.work_type_id or timesheet.work_billing_rate == 1.0">
<span t-field="timesheet.unit_amount" t-options="{&quot;widget&quot;: &quot;duration&quot;, &quot;unit&quot;: &quot;hour&quot;, &quot;round&quot;: &quot;minute&quot;}"/>
</td>
<td class="text-right" t-else="">
<del t-field="timesheet.unit_amount" class="text-muted" t-options="{&quot;widget&quot;: &quot;duration&quot;, &quot;unit&quot;: &quot;hour&quot;, &quot;round&quot;: &quot;minute&quot;}"/>
<br/>
<span t-field="timesheet.work_billing_amount" t-options="{&quot;widget&quot;: &quot;duration&quot;, &quot;unit&quot;: &quot;hour&quot;, &quot;round&quot;: &quot;minute&quot;}"/>
</td>
</xpath>
</template>
</odoo>

View File

@@ -6,17 +6,26 @@
<field name="model">project.task</field> <field name="model">project.task</field>
<field name="inherit_id" ref="hr_timesheet.view_task_form2_inherited"/> <field name="inherit_id" ref="hr_timesheet.view_task_form2_inherited"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//field[@name='timesheet_ids']/tree/field[@name='name']" position="before"> <xpath expr="//field[@name='timesheet_ids']/tree/field[@name='unit_amount']" position="after">
<field name="work_type_id" <field name="work_billing_amount" widget="timesheet_uom" />
domain="[('allow_timesheet', '=', True)]"
context="{'default_allow_timesheet': True}" />
</xpath> </xpath>
<xpath expr="//field[@name='timesheet_ids']/form//field[@name='name']" position="before"> <xpath expr="//field[@name='timesheet_ids']/form//field[@name='unit_amount']" position="after">
<field name="work_type_id" <field name="work_billing_amount" widget="timesheet_uom" />
domain="[('allow_timesheet', '=', True)]"
context="{'default_allow_timesheet': True}" />
</xpath> </xpath>
</field> </field>
</record> </record>
<template id="portal_timesheet_table_inherit" inherit_id="hr_timesheet.portal_timesheet_table">
<xpath expr="//tr[@t-as='timesheet']/td[last()]" position="replace">
<td class="text-right" t-if="not timesheet.work_type_id or timesheet.work_billing_rate == 1.0">
<span t-field="timesheet.unit_amount" t-options="{&quot;widget&quot;: &quot;duration&quot;, &quot;unit&quot;: &quot;hour&quot;, &quot;round&quot;: &quot;minute&quot;}"/>
</td>
<td class="text-right" t-else="">
<del t-field="timesheet.unit_amount" class="text-muted" t-options="{&quot;widget&quot;: &quot;duration&quot;, &quot;unit&quot;: &quot;hour&quot;, &quot;round&quot;: &quot;minute&quot;}"/>
<br/>
<span t-field="timesheet.work_billing_amount" t-options="{&quot;widget&quot;: &quot;duration&quot;, &quot;unit&quot;: &quot;hour&quot;, &quot;round&quot;: &quot;minute&quot;}"/>
</td>
</xpath>
</template>
</odoo> </odoo>