mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[IMP] sale_timesheet_work_entry_rate: unset should behave as it if were 1.0 multiplier
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
'name': 'Timesheet Billing Rate',
|
'name': 'Timesheet Billing Rate',
|
||||||
'version': '13.0.1.0.0',
|
'version': '13.0.1.0.1',
|
||||||
'category': 'Sale',
|
'category': 'Sale',
|
||||||
'author': 'Hibou Corp.',
|
'author': 'Hibou Corp.',
|
||||||
'license': 'OPL-1',
|
'license': 'OPL-1',
|
||||||
|
|||||||
@@ -12,4 +12,11 @@
|
|||||||
<field name="timesheet_billing_rate" eval="2.0"/>
|
<field name="timesheet_billing_rate" eval="2.0"/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record id="work_input_timesheet_free" model="hr.work.entry.type">
|
||||||
|
<field name="name">Non-Productive Time</field>
|
||||||
|
<field name="code">TS_NON_PRODUCTIVE</field>
|
||||||
|
<field name="allow_timesheet" eval="True"/>
|
||||||
|
<field name="timesheet_billing_rate" eval="0.0"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
@@ -41,8 +41,13 @@ class SaleOrderLine(models.Model):
|
|||||||
for item in data:
|
for item in data:
|
||||||
if not item['product_uom_id']:
|
if not item['product_uom_id']:
|
||||||
continue
|
continue
|
||||||
if not item['work_type_id']:
|
work_type_rate = False
|
||||||
continue
|
if item['work_type_id']:
|
||||||
|
work_type_rate = work_type_map.get(item['work_type_id'][0]).timesheet_billing_rate
|
||||||
|
if work_type_rate is False:
|
||||||
|
# unset field should be 1.0 by default, you CAN set it to 0.0 if you'd like.
|
||||||
|
work_type_rate = 1.0
|
||||||
|
|
||||||
so_line_id = item['so_line'][0]
|
so_line_id = item['so_line'][0]
|
||||||
so_line = lines_map[so_line_id]
|
so_line = lines_map[so_line_id]
|
||||||
result.setdefault(so_line_id, 0.0)
|
result.setdefault(so_line_id, 0.0)
|
||||||
@@ -52,8 +57,7 @@ class SaleOrderLine(models.Model):
|
|||||||
else:
|
else:
|
||||||
qty = item['unit_amount']
|
qty = item['unit_amount']
|
||||||
|
|
||||||
work = work_type_map.get(item['work_type_id'][0])
|
qty *= work_type_rate
|
||||||
qty *= work.timesheet_billing_rate or 0.0
|
|
||||||
result[so_line_id] += qty
|
result[so_line_id] += qty
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -100,3 +100,19 @@ class TestSaleFlow(TestProjectBilling):
|
|||||||
'work_type_id': double_rate_work_entry_type.id,
|
'work_type_id': double_rate_work_entry_type.id,
|
||||||
})
|
})
|
||||||
self.assertEqual(task.sale_line_id.qty_delivered, 150.0)
|
self.assertEqual(task.sale_line_id.qty_delivered, 150.0)
|
||||||
|
|
||||||
|
# Ensure that a created timesheet WITHOUT a work entry type behaves
|
||||||
|
# the same as it would have before this module (e.g. for historic reasons)
|
||||||
|
timesheet2.write({
|
||||||
|
'work_type_id': False,
|
||||||
|
})
|
||||||
|
self.assertEqual(task.sale_line_id.qty_delivered, 150.0)
|
||||||
|
|
||||||
|
# Ensure we can bill zero even with above default.
|
||||||
|
zero_rate_work_entry_type = self.env.ref('sale_timesheet_work_entry_rate.work_input_timesheet_free')
|
||||||
|
self.assertEqual(zero_rate_work_entry_type.timesheet_billing_rate, 0.0)
|
||||||
|
|
||||||
|
timesheet2.write({
|
||||||
|
'work_type_id': zero_rate_work_entry_type.id,
|
||||||
|
})
|
||||||
|
self.assertEqual(task.sale_line_id.qty_delivered, 100.0)
|
||||||
|
|||||||
Reference in New Issue
Block a user