Initial import from Docker volume

This commit is contained in:
root
2025-12-26 13:11:43 +00:00
commit 4998dc066a
13336 changed files with 1767801 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.

View File

@@ -0,0 +1,205 @@
===============================
Project Invoice Effort Scenario
===============================
Imports::
>>> import datetime as dt
>>> from decimal import Decimal
>>> from proteus import Model
>>> from trytond.modules.account.tests.tools import create_chart, get_accounts
>>> from trytond.modules.account_invoice.tests.tools import create_payment_term
>>> from trytond.modules.company.tests.tools import create_company, get_company
>>> from trytond.tests.tools import activate_modules, set_user
Activate modules::
>>> config = activate_modules('project_invoice')
Create company::
>>> _ = create_company()
>>> company = get_company()
Create project user::
>>> User = Model.get('res.user')
>>> Group = Model.get('res.group')
>>> project_user = User()
>>> project_user.name = 'Project'
>>> project_user.login = 'project'
>>> project_group, = Group.find([('name', '=', 'Project Administration')])
>>> timesheet_group, = Group.find([('name', '=', 'Timesheet Administration')])
>>> project_user.groups.extend([project_group, timesheet_group])
>>> project_user.save()
Create project invoice user::
>>> project_invoice_user = User()
>>> project_invoice_user.name = 'Project Invoice'
>>> project_invoice_user.login = 'project_invoice'
>>> project_invoice_group, = Group.find([('name', '=', 'Project Invoice')])
>>> project_group, = Group.find([('name', '=', 'Project Administration')])
>>> project_invoice_user.groups.extend(
... [project_invoice_group, project_group])
>>> project_invoice_user.save()
Create chart of accounts::
>>> _ = create_chart(company)
>>> accounts = get_accounts(company)
>>> revenue = accounts['revenue']
Create payment term::
>>> payment_term = create_payment_term()
>>> payment_term.save()
Create customer::
>>> Party = Model.get('party.party')
>>> customer = Party(name='Customer')
>>> customer.customer_payment_term = payment_term
>>> customer.save()
Create employee::
>>> Employee = Model.get('company.employee')
>>> employee = Employee()
>>> party = Party(name='Employee')
>>> party.save()
>>> employee.party = party
>>> employee.company = company
>>> employee.save()
Create account category::
>>> ProductCategory = Model.get('product.category')
>>> account_category = ProductCategory(name="Account Category")
>>> account_category.accounting = True
>>> account_category.account_revenue = revenue
>>> account_category.save()
Create products::
>>> ProductUom = Model.get('product.uom')
>>> hour, = ProductUom.find([('name', '=', 'Hour')])
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
>>> ProductTemplate = Model.get('product.template')
>>> template = ProductTemplate()
>>> template.name = 'Service'
>>> template.default_uom = hour
>>> template.type = 'service'
>>> template.list_price = Decimal('20')
>>> template.account_category = account_category
>>> template.save()
>>> product, = template.products
>>> template = ProductTemplate()
>>> template.name = 'Service Fixed'
>>> template.default_uom = unit
>>> template.type = 'service'
>>> template.list_price = Decimal('50')
>>> template.account_category = account_category
>>> template.save()
>>> product_fixed, = template.products
Create a Project::
>>> set_user(project_user)
>>> ProjectWork = Model.get('project.work')
>>> project = ProjectWork()
>>> project.name = 'Test effort'
>>> project.type = 'project'
>>> project.party = customer
>>> project.project_invoice_method = 'effort'
>>> project.product = product
>>> project.effort_duration = dt.timedelta(hours=1)
>>> task = project.children.new()
>>> task.name = 'Task 1'
>>> task.type = 'task'
>>> task.product = product
>>> task.effort_duration = dt.timedelta(hours=5)
>>> task_no_effort = project.children.new()
>>> task_no_effort.name = "Task 2"
>>> task_no_effort.type = 'task'
>>> task_no_effort.effort_duration = None
>>> task_fixed = project.children.new()
>>> task_fixed.name = "Task 2"
>>> task_fixed.type = 'task'
>>> task_fixed.effort_duration = dt.timedelta(hours=2)
>>> task_fixed.product = product_fixed
>>> project.save()
>>> task, task_no_effort, task_fixed = project.children
Check project amounts::
>>> project.reload()
>>> project.invoiced_amount
Decimal('0')
>>> project.amount_to_invoice
Decimal('0.00')
Do 1 task::
>>> task.progress = 1
>>> task.save()
Check project amounts::
>>> project.reload()
>>> project.invoiced_amount
Decimal('0')
>>> project.amount_to_invoice
Decimal('100.00')
Invoice project::
>>> set_user(project_invoice_user)
>>> project.click('invoice')
>>> project.amount_to_invoice
Decimal('0.00')
>>> project.invoiced_amount
Decimal('100.00')
Do project::
>>> set_user(project_user)
>>> task_no_effort.progress = 1
>>> task_no_effort.save()
>>> task_fixed.progress = 1
>>> task_fixed.save()
>>> project.progress = 1
>>> project.save()
Check project amounts::
>>> project.reload()
>>> project.amount_to_invoice
Decimal('70.00')
>>> project.invoiced_amount
Decimal('100.00')
Invoice again project::
>>> set_user(project_invoice_user)
>>> project.click('invoice')
>>> project.amount_to_invoice
Decimal('0.00')
>>> project.invoiced_amount
Decimal('170.00')
Try to change invoice line quantity::
>>> set_user(1)
>>> ProjectWork = Model.get('project.work')
>>> task = ProjectWork(task.id)
>>> task.invoice_line.quantity = 1
>>> task.invoice_line.save()
Traceback (most recent call last):
...
InvoiceLineValidationError: ...
>>> task.invoice_line.quantity = 5
>>> task.invoice_line.save()

View File

@@ -0,0 +1,119 @@
=========================================
Project Invoice Multiple Parties Scenario
=========================================
Imports::
>>> import datetime as dt
>>> from decimal import Decimal
>>> from proteus import Model
>>> from trytond.modules.account.tests.tools import create_chart, get_accounts
>>> from trytond.modules.company.tests.tools import create_company, get_company
>>> from trytond.tests.tools import activate_modules
Activate modules::
>>> config = activate_modules('project_invoice')
Create company::
>>> _ = create_company()
>>> company = get_company()
Create chart of accounts::
>>> _ = create_chart(company)
>>> accounts = get_accounts(company)
>>> revenue = accounts['revenue']
Create two customers::
>>> Party = Model.get('party.party')
>>> customer1 = Party(name='Customer 1')
>>> customer1.save()
>>> customer2 = Party(name='Customer 2')
>>> customer2.save()
Create account category::
>>> ProductCategory = Model.get('product.category')
>>> account_category = ProductCategory(name="Account Category")
>>> account_category.accounting = True
>>> account_category.account_revenue = revenue
>>> account_category.save()
Create product::
>>> ProductUom = Model.get('product.uom')
>>> hour, = ProductUom.find([('name', '=', 'Hour')])
>>> ProductTemplate = Model.get('product.template')
>>> template = ProductTemplate()
>>> template.name = 'Service'
>>> template.default_uom = hour
>>> template.type = 'service'
>>> template.list_price = Decimal('20')
>>> template.account_category = account_category
>>> template.save()
>>> product, = template.products
Create a Project with multiple customers::
>>> ProjectWork = Model.get('project.work')
>>> project = ProjectWork()
>>> project.name = 'Test multiple party'
>>> project.type = 'project'
>>> project.party = customer1
>>> project.project_invoice_method = 'effort'
>>> project.product = product
>>> project.effort_duration = dt.timedelta(hours=1)
>>> subproject = project.children.new()
>>> subproject.name = 'Subproject'
>>> subproject.type = 'project'
>>> subproject.party = customer2
>>> subproject.project_invoice_method = 'effort'
>>> subproject.product = product
>>> subproject.effort_duration = dt.timedelta(hours=5)
>>> project.save()
>>> subproject, = project.children
Check project amounts::
>>> project.reload()
>>> project.amount_to_invoice
Decimal('0.00')
>>> project.invoiced_amount
Decimal('0')
Do project and subproject::
>>> subproject.progress = 1
>>> subproject.save()
>>> project.progress = 1
>>> project.save()
Check project amounts::
>>> project.reload()
>>> project.amount_to_invoice
Decimal('120.00')
>>> project.invoiced_amount
Decimal('0')
Invoice project::
>>> project.click('invoice')
>>> project.amount_to_invoice
Decimal('0.00')
>>> project.invoiced_amount
Decimal('120.00')
>>> Invoice = Model.get('account.invoice')
>>> invoices = Invoice.find([])
>>> len(invoices)
2
>>> sorted([i.party.name for i in invoices])
['Customer 1', 'Customer 2']

View File

@@ -0,0 +1,208 @@
=================================
Project Invoice Progress Scenario
=================================
Imports::
>>> import datetime as dt
>>> from decimal import Decimal
>>> from proteus import Model
>>> from trytond.modules.account.tests.tools import create_chart, get_accounts
>>> from trytond.modules.account_invoice.tests.tools import create_payment_term
>>> from trytond.modules.company.tests.tools import create_company, get_company
>>> from trytond.tests.tools import activate_modules, set_user
Activate modules::
>>> config = activate_modules('project_invoice')
Create company::
>>> _ = create_company()
>>> company = get_company()
Create project user::
>>> User = Model.get('res.user')
>>> Group = Model.get('res.group')
>>> project_user = User()
>>> project_user.name = 'Project'
>>> project_user.login = 'project'
>>> project_group, = Group.find([('name', '=', 'Project Administration')])
>>> timesheet_group, = Group.find([('name', '=', 'Timesheet Administration')])
>>> project_user.groups.extend([project_group, timesheet_group])
>>> project_user.save()
Create project invoice user::
>>> project_invoice_user = User()
>>> project_invoice_user.name = 'Project Invoice'
>>> project_invoice_user.login = 'project_invoice'
>>> project_invoice_group, = Group.find([('name', '=', 'Project Invoice')])
>>> project_group, = Group.find([('name', '=', 'Project Administration')])
>>> project_invoice_user.groups.extend(
... [project_invoice_group, project_group])
>>> project_invoice_user.save()
Create chart of accounts::
>>> _ = create_chart(company)
>>> accounts = get_accounts(company)
>>> revenue = accounts['revenue']
Create payment term::
>>> payment_term = create_payment_term()
>>> payment_term.save()
Create customer::
>>> Party = Model.get('party.party')
>>> customer = Party(name='Customer')
>>> customer.customer_payment_term = payment_term
>>> customer.save()
Create employee::
>>> Employee = Model.get('company.employee')
>>> employee = Employee()
>>> party = Party(name='Employee')
>>> party.save()
>>> employee.party = party
>>> employee.company = company
>>> employee.save()
Create account category::
>>> ProductCategory = Model.get('product.category')
>>> account_category = ProductCategory(name="Account Category")
>>> account_category.accounting = True
>>> account_category.account_revenue = revenue
>>> account_category.save()
Create product::
>>> ProductUom = Model.get('product.uom')
>>> hour, = ProductUom.find([('name', '=', 'Hour')])
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
>>> unit.rounding = 0.01
>>> unit.digits = 2
>>> unit.save()
>>> ProductTemplate = Model.get('product.template')
>>> template = ProductTemplate()
>>> template.name = 'Service'
>>> template.default_uom = hour
>>> template.type = 'service'
>>> template.list_price = Decimal('20')
>>> template.account_category = account_category
>>> template.save()
>>> product, = template.products
>>> template = ProductTemplate()
>>> template.name = 'Service Fixed'
>>> template.default_uom = unit
>>> template.type = 'service'
>>> template.list_price = Decimal('50')
>>> template.account_category = account_category
>>> template.save()
>>> product_fixed, = template.products
Create a Project::
>>> set_user(project_user)
>>> ProjectWork = Model.get('project.work')
>>> TimesheetWork = Model.get('timesheet.work')
>>> project = ProjectWork()
>>> project.name = 'Test effort'
>>> project.type = 'project'
>>> project.party = customer
>>> project.project_invoice_method = 'progress'
>>> project.product = product
>>> project.effort_duration = dt.timedelta(hours=1)
>>> task = project.children.new()
>>> task.name = 'Task 1'
>>> task.type = 'task'
>>> task.product = product
>>> task.effort_duration = dt.timedelta(hours=5)
>>> task_fixed = project.children.new()
>>> task_fixed.name = 'Task 2'
>>> task_fixed.type = 'task'
>>> task_fixed.product = product
>>> task_fixed.product = product_fixed
>>> project.save()
>>> task, task_fixed = project.children
Check project amounts::
>>> project.reload()
>>> project.amount_to_invoice
Decimal('0.00')
>>> project.invoiced_amount
Decimal('0.00')
Do 50% of task::
>>> task.progress = 0.5
>>> task.save()
>>> task_fixed.progress = 0.5
>>> task_fixed.save()
Check project amounts::
>>> project.reload()
>>> project.amount_to_invoice
Decimal('75.00')
>>> project.invoiced_amount
Decimal('0.00')
Invoice project::
>>> set_user(project_invoice_user)
>>> project.click('invoice')
>>> project.amount_to_invoice
Decimal('0.00')
>>> project.invoiced_amount
Decimal('75.00')
Do 75% and 90% of tasks and 80% of project::
>>> set_user(project_user)
>>> task.progress = 0.75
>>> task.save()
>>> task_fixed.progress = 0.9
>>> task_fixed.save()
>>> project.progress = 0.80
>>> project.save()
Check project amounts::
>>> project.reload()
>>> project.amount_to_invoice
Decimal('61.00')
>>> project.invoiced_amount
Decimal('75.00')
Invoice again project::
>>> set_user(project_invoice_user)
>>> project.click('invoice')
>>> project.amount_to_invoice
Decimal('0.00')
>>> project.invoiced_amount
Decimal('136.00')
Try to change invoice line quantity::
>>> set_user(1)
>>> ProjectWork = Model.get('project.work')
>>> task = ProjectWork(task.id)
>>> invoice_line = task.invoiced_progress[0].invoice_line
>>> invoice_line.quantity = 2.
>>> invoice_line.save()
Traceback (most recent call last):
...
InvoiceLineValidationError: ...
>>> invoice_line.quantity = 2.5
>>> invoice_line.save()

View File

@@ -0,0 +1,237 @@
==================================
Project Invoice Timesheet Scenario
==================================
Imports::
>>> import datetime as dt
>>> from decimal import Decimal
>>> from proteus import Model
>>> from trytond.modules.account.tests.tools import create_chart, get_accounts
>>> from trytond.modules.account_invoice.tests.tools import create_payment_term
>>> from trytond.modules.company.tests.tools import create_company, get_company
>>> from trytond.tests.tools import activate_modules, set_user
>>> today = dt.date.today()
>>> yesterday = today - dt.timedelta(days=1)
Activate modules::
>>> config = activate_modules('project_invoice')
Create company::
>>> _ = create_company()
>>> company = get_company()
Create project user::
>>> User = Model.get('res.user')
>>> Group = Model.get('res.group')
>>> project_user = User()
>>> project_user.name = 'Project'
>>> project_user.login = 'project'
>>> project_group, = Group.find([('name', '=', 'Project Administration')])
>>> timesheet_group, = Group.find([('name', '=', 'Timesheet Administration')])
>>> project_user.groups.extend([project_group, timesheet_group])
>>> project_user.save()
Create project invoice user::
>>> project_invoice_user = User()
>>> project_invoice_user.name = 'Project Invoice'
>>> project_invoice_user.login = 'project_invoice'
>>> project_invoice_group, = Group.find([('name', '=', 'Project Invoice')])
>>> project_group, = Group.find([('name', '=', 'Project Administration')])
>>> invoice_group, = Group.find([('name', '=', 'Account')])
>>> project_invoice_user.groups.extend(
... [project_invoice_group, project_group, invoice_group])
>>> project_invoice_user.save()
Create chart of accounts::
>>> _ = create_chart(company)
>>> accounts = get_accounts(company)
>>> revenue = accounts['revenue']
Create payment term::
>>> payment_term = create_payment_term()
>>> payment_term.save()
Create customer::
>>> Party = Model.get('party.party')
>>> customer = Party(name='Customer')
>>> customer.customer_payment_term = payment_term
>>> customer.save()
Create employee::
>>> Employee = Model.get('company.employee')
>>> employee = Employee()
>>> party = Party(name='Employee')
>>> party.save()
>>> employee.party = party
>>> employee.company = company
>>> employee.save()
Create account category::
>>> ProductCategory = Model.get('product.category')
>>> account_category = ProductCategory(name="Account Category")
>>> account_category.accounting = True
>>> account_category.account_revenue = revenue
>>> account_category.save()
Create product::
>>> ProductUom = Model.get('product.uom')
>>> hour, = ProductUom.find([('name', '=', 'Hour')])
>>> ProductTemplate = Model.get('product.template')
>>> template = ProductTemplate()
>>> template.name = 'Service'
>>> template.default_uom = hour
>>> template.type = 'service'
>>> template.list_price = Decimal('20')
>>> template.account_category = account_category
>>> template.save()
>>> product, = template.products
Create a Project::
>>> set_user(project_user)
>>> ProjectWork = Model.get('project.work')
>>> project = ProjectWork()
>>> project.name = 'Test timesheet'
>>> project.type = 'project'
>>> project.party = customer
>>> project.project_invoice_method = 'timesheet'
>>> project.product = product
>>> project.timesheet_available = True
>>> task = ProjectWork()
>>> task.name = 'Task 1'
>>> task.timesheet_available = True
>>> task.type = 'task'
>>> task.product = product
>>> project.children.append(task)
>>> project.save()
>>> task, = project.children
Add a task without timesheet work::
>>> task2 = project.children.new()
>>> task2.name = 'Task 2'
>>> task2.type = 'task'
>>> project.save()
Create timesheets::
>>> TimesheetLine = Model.get('timesheet.line')
>>> line = TimesheetLine()
>>> line.date = yesterday
>>> line.employee = employee
>>> line.duration = dt.timedelta(hours=3)
>>> line.work, = task.timesheet_works
>>> line.save()
>>> line = TimesheetLine()
>>> line.date = today
>>> line.employee = employee
>>> line.duration = dt.timedelta(hours=2)
>>> line.work, = project.timesheet_works
>>> line.save()
Check project amounts::
>>> project.reload()
>>> project.amount_to_invoice
Decimal('100.00')
>>> project.invoiced_amount
Decimal('0.00')
Invoice project up to yesterday::
>>> set_user(project_user)
>>> project.project_invoice_timesheet_up_to = yesterday
>>> project.save()
>>> set_user(project_invoice_user)
>>> project.click('invoice')
>>> project.amount_to_invoice
Decimal('0.00')
>>> project.invoiced_amount
Decimal('60.00')
>>> project.project_invoice_timesheet_up_to = today
>>> project.save()
>>> project.amount_to_invoice
Decimal('40.00')
>>> set_user(project_invoice_user)
>>> Invoice = Model.get('account.invoice')
>>> invoice, = Invoice.find([])
>>> invoice.total_amount
Decimal('60.00')
Invoice all project::
>>> set_user(project_user)
>>> project.project_invoice_timesheet_up_to = None
>>> project.save()
>>> set_user(project_invoice_user)
>>> project.click('invoice')
>>> project.amount_to_invoice
Decimal('0.00')
>>> project.invoiced_amount
Decimal('100.00')
>>> set_user(project_invoice_user)
>>> _, invoice = Invoice.find([], order=[('id', 'ASC')])
>>> invoice.total_amount
Decimal('40.00')
Create more timesheets::
>>> set_user(project_user)
>>> TimesheetLine = Model.get('timesheet.line')
>>> line = TimesheetLine()
>>> line.employee = employee
>>> line.duration = dt.timedelta(hours=4)
>>> line.work, = task.timesheet_works
>>> line.save()
Check project amounts::
>>> project.reload()
>>> project.amount_to_invoice
Decimal('80.00')
>>> project.invoiced_amount
Decimal('100.00')
Invoice again project::
>>> set_user(project_invoice_user)
>>> project.click('invoice')
>>> project.amount_to_invoice
Decimal('0.00')
>>> project.invoiced_amount
Decimal('180.00')
>>> set_user(project_invoice_user)
>>> _, _, invoice = Invoice.find([], order=[('id', 'ASC')])
>>> invoice.total_amount
Decimal('80.00')
Try to change invoice line quantity::
>>> set_user(1)
>>> TimesheetLine = Model.get('timesheet.line')
>>> line = TimesheetLine(line.id)
>>> line.invoice_line.quantity = 5
>>> line.invoice_line.save()
Traceback (most recent call last):
...
InvoiceLineValidationError: ...
>>> line.invoice_line.quantity = 4
>>> line.invoice_line.save()

View File

@@ -0,0 +1,12 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.tests.test_tryton import ModuleTestCase
class ProjectInvoiceTestCase(ModuleTestCase):
'Test Project Invoice module'
module = 'project_invoice'
del ModuleTestCase

View File

@@ -0,0 +1,8 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.tests.test_tryton import load_doc_tests
def load_tests(*args, **kwargs):
return load_doc_tests(__name__, __file__, *args, **kwargs)