diff --git a/doc/index.rst b/doc/index.rst index ea65210d91..fab0aed170 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -6,7 +6,7 @@ The methods are: - Manual: Tryton doesn't create any invoice. - On Effort: The invoices are created based on the *Effort* hours for all - children works in state *Done*. + children works with 100% progress. - On Progress: The invoices are create proportionally to the *Progress* of the *Effort* hours of each children work. - On Timesheet: The invoices are created based on the timesheets encoded on all diff --git a/tests/scenario_project_invoice_effort.rst b/tests/scenario_project_invoice_effort.rst index 67760c8b28..1239ab52e1 100644 --- a/tests/scenario_project_invoice_effort.rst +++ b/tests/scenario_project_invoice_effort.rst @@ -137,7 +137,7 @@ Check project duration:: Do 1 task:: - >>> task.state = 'done' + >>> task.progress = 1 >>> task.save() Check project duration:: @@ -164,9 +164,9 @@ Invoice project:: Do project:: >>> set_user(project_user) - >>> task_no_effort.state = 'done' + >>> task_no_effort.progress = 1 >>> task_no_effort.save() - >>> project.state = 'done' + >>> project.progress = 1 >>> project.save() Check project duration:: diff --git a/tests/scenario_project_invoice_multiple_party.rst b/tests/scenario_project_invoice_multiple_party.rst index bf1222e3ff..6d0bcd6eb0 100644 --- a/tests/scenario_project_invoice_multiple_party.rst +++ b/tests/scenario_project_invoice_multiple_party.rst @@ -95,9 +95,9 @@ Check project duration:: Do project and subproject:: - >>> subproject.state = 'done' + >>> subproject.progress = 1 >>> subproject.save() - >>> project.state = 'done' + >>> project.progress = 1 >>> project.save() Check project duration:: diff --git a/tests/scenario_project_invoice_progress.rst b/tests/scenario_project_invoice_progress.rst index 07e3e94f2a..bd837ade89 100644 --- a/tests/scenario_project_invoice_progress.rst +++ b/tests/scenario_project_invoice_progress.rst @@ -159,12 +159,12 @@ Invoice project:: >>> project.invoiced_amount Decimal('50.00') -Do 75% of task and 100% of project:: +Do 75% of task and 80% of project:: >>> set_user(project_user) >>> task.progress = 0.75 >>> task.save() - >>> project.progress = 1. + >>> project.progress = 0.80 >>> project.save() Check project duration:: @@ -172,7 +172,7 @@ Check project duration:: >>> project.reload() >>> project.invoiced_duration == datetime.timedelta(0, 9000) True - >>> project.duration_to_invoice == datetime.timedelta(0, 8100) + >>> project.duration_to_invoice == datetime.timedelta(0, 7380) True >>> project.invoiced_amount Decimal('50.00') @@ -181,9 +181,9 @@ Invoice again project:: >>> set_user(project_invoice_user) >>> project.click('invoice') - >>> project.invoiced_duration == datetime.timedelta(0, 17100) + >>> project.invoiced_duration == datetime.timedelta(0, 16380) True >>> project.duration_to_invoice datetime.timedelta(0) >>> project.invoiced_amount - Decimal('95.00') + Decimal('91.00') diff --git a/work.py b/work.py index 88ba25e2cc..4e3315982c 100644 --- a/work.py +++ b/work.py @@ -143,7 +143,7 @@ class Work(metaclass=PoolMeta): @staticmethod def _get_duration_to_invoice_effort(works): return dict((w.id, w.effort_duration) for w in works - if w.state == 'done' and not w.invoice_line and w.effort_duration) + if w.progress == 1 and not w.invoice_line and w.effort_duration) @staticmethod def _get_duration_to_invoice_progress(works): @@ -485,7 +485,7 @@ class Work(metaclass=PoolMeta): if (not self.invoice_line and self.effort_hours - and self.state == 'done'): + and self.progress == 1): if not self.product: raise InvoicingError( gettext('project_invoice.msg_missing_product',