Move 124 sale modules to oca-sale, create oca-project with 56 project modules from oca-workflow-process

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Ernad Husremovic 2025-08-30 18:04:10 +02:00
parent 9eb7ae5807
commit 6094c218b2
2332 changed files with 125826 additions and 0 deletions

View file

@ -0,0 +1,46 @@
# Service tracking: Copy tasks in project
Odoo addon: sale_project_copy_tasks
## Installation
```bash
pip install odoo-bringout-oca-project-sale_project_copy_tasks
```
## Dependencies
This addon depends on:
- sale_project
## Manifest Information
- **Name**: Service tracking: Copy tasks in project
- **Version**: 16.0.1.0.4
- **Category**: Sales
- **License**: LGPL-3
- **Installable**: True
## Source
Based on [OCA/project](https://github.com/OCA/project) branch 16.0, addon `sale_project_copy_tasks`.
## License
This package maintains the original LGPL-3 license from the upstream Odoo project.
## Documentation
- Overview: doc/OVERVIEW.md
- Architecture: doc/ARCHITECTURE.md
- Models: doc/MODELS.md
- Controllers: doc/CONTROLLERS.md
- Wizards: doc/WIZARDS.md
- Reports: doc/REPORTS.md
- Security: doc/SECURITY.md
- Install: doc/INSTALL.md
- Usage: doc/USAGE.md
- Configuration: doc/CONFIGURATION.md
- Dependencies: doc/DEPENDENCIES.md
- Troubleshooting: doc/TROUBLESHOOTING.md
- FAQ: doc/FAQ.md

View file

@ -0,0 +1,32 @@
# Architecture
```mermaid
flowchart TD
U[Users] -->|HTTP| V[Views and QWeb Templates]
V --> C[Controllers]
V --> W[Wizards Transient Models]
C --> M[Models and ORM]
W --> M
M --> R[Reports]
DX[Data XML] --> M
S[Security ACLs and Groups] -. enforces .-> M
subgraph Sale_project_copy_tasks Module - sale_project_copy_tasks
direction LR
M:::layer
W:::layer
C:::layer
V:::layer
R:::layer
S:::layer
DX:::layer
end
classDef layer fill:#eef8ff,stroke:#6ea8fe,stroke-width:1px
```
Notes
- Views include tree/form/kanban templates and report templates.
- Controllers provide website/portal routes when present.
- Wizards are UI flows implemented with `models.TransientModel`.
- Data XML loads data/demo records; Security defines groups and access.

View file

@ -0,0 +1,3 @@
# Configuration
Refer to Odoo settings for sale_project_copy_tasks. Configure related models, access rights, and options as needed.

View file

@ -0,0 +1,3 @@
# Controllers
This module does not define custom HTTP controllers.

View file

@ -0,0 +1,5 @@
# Dependencies
This addon depends on:
- [sale_project](https://github.com/bringout/oca-ocb-sale/tree/681dc8d5fff638cb0862a34e48091a2098d091f8/odoo-bringout-oca-ocb-sale_project)

View file

@ -0,0 +1,4 @@
# FAQ
- Q: Which Odoo version? A: 16.0 (OCA/OCB packaged).
- Q: How to enable? A: Start server with --addon sale_project_copy_tasks or install in UI.

View file

@ -0,0 +1,7 @@
# Install
```bash
pip install odoo-bringout-oca-project-sale_project_copy_tasks"
# or
uv pip install odoo-bringout-oca-project-sale_project_copy_tasks"
```

View file

@ -0,0 +1,14 @@
# Models
Detected core models and extensions in sale_project_copy_tasks.
```mermaid
classDiagram
class product_template
class sale_order
class sale_order_line
```
Notes
- Classes show model technical names; fields omitted for brevity.
- Items listed under _inherit are extensions of existing models.

View file

@ -0,0 +1,6 @@
# Overview
Packaged Odoo addon: sale_project_copy_tasks. Provides features documented in upstream Odoo 16 under this addon.
- Source: OCA/OCB 16.0, addon sale_project_copy_tasks
- License: LGPL-3

View file

@ -0,0 +1,3 @@
# Reports
This module does not define custom reports.

View file

@ -0,0 +1,8 @@
# Security
This module does not define custom security rules or access controls beyond Odoo defaults.
Default Odoo security applies:
- Base user access through standard groups
- Model access inherited from dependencies
- No custom row-level security rules

View file

@ -0,0 +1,5 @@
# Troubleshooting
- Ensure Python and Odoo environment matches repo guidance.
- Check database connectivity and logs if startup fails.
- Validate that dependent addons listed in DEPENDENCIES.md are installed.

View file

@ -0,0 +1,7 @@
# Usage
Start Odoo including this addon (from repo root):
```bash
python3 scripts/nix_odoo_web_server.py --db-name mydb --addon sale_project_copy_tasks
```

View file

@ -0,0 +1,3 @@
# Wizards
This module does not include UI wizards.

View file

@ -0,0 +1,42 @@
[project]
name = "odoo-bringout-oca-project-sale_project_copy_tasks"
version = "16.0.0"
description = "Service tracking: Copy tasks in project - Copy tasks into sale order's project"
authors = [
{ name = "Ernad Husremovic", email = "hernad@bring.out.ba" }
]
dependencies = [
"odoo-bringout-oca-project-sale_project>=16.0.0",
"requests>=2.25.1"
]
readme = "README.md"
requires-python = ">= 3.11"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Office/Business",
]
[project.urls]
homepage = "https://github.com/bringout/0"
repository = "https://github.com/bringout/0"
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.metadata]
allow-direct-references = true
[tool.hatch.build.targets.wheel]
packages = ["sale_project_copy_tasks"]
[tool.rye]
managed = true
dev-dependencies = [
"pytest>=8.4.1",
]

View file

@ -0,0 +1,107 @@
=======================================
Service tracking: Copy tasks in project
=======================================
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9e20fdd9c2b8d3bec01955b01a331d15686762e3456aab9a386fd3802557e855
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproject-lightgray.png?logo=github
:target: https://github.com/OCA/project/tree/16.0/sale_project_copy_tasks
:alt: OCA/project
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/project-16-0/project-16-0-sale_project_copy_tasks
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/project&target_branch=16.0
:alt: Try me on Runboat
|badge1| |badge2| |badge3| |badge4| |badge5|
This module allows creating tasks in an existing project from the sales order through setting the product with a project template with the desired task.
**Table of contents**
.. contents::
:local:
Use Cases / Context
===================
The use case is when an Odoo customer sells the same services with the same tasks constantly and the tasks should be linked with existing project. Standard Odoo would always create a new project.
Usage
=====
1. Go to Project > Projects.
2. Create project.
3. Go to Project > Tasks.
4. Create tasks for the project created in step 2.
5. Go to Sales > Products > Products.
6. Create product whose type is service, the service tracking is to copy the task into the sales order project and project template select project created in step 2.
7. Go to Sales > Quotation > Quotation.
8. Create quotation with products created in step 6.
9. Confirm the quotation. The tasks from project templates in products will be created in same project.
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/project/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/project/issues/new?body=module:%20sale_project_copy_tasks%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
Credits
=======
Authors
~~~~~~~
* Moduon
Contributors
~~~~~~~~~~~~
* Eduardo de Miguel (`Moduon <https://www.moduon.team/>`__)
* Emilio Pascual (`Moduon <https://www.moduon.team/>`__)
* Rafael Blasco (`Moduon <https://www.moduon.team/>`__)
Maintainers
~~~~~~~~~~~
This module is maintained by the OCA.
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
.. |maintainer-shide| image:: https://github.com/shide.png?size=40px
:target: https://github.com/shide
:alt: shide
.. |maintainer-EmilioPascual| image:: https://github.com/EmilioPascual.png?size=40px
:target: https://github.com/EmilioPascual
:alt: EmilioPascual
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-shide| |maintainer-EmilioPascual|
This module is part of the `OCA/project <https://github.com/OCA/project/tree/16.0/sale_project_copy_tasks>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View file

@ -0,0 +1,4 @@
# Copyright 2023 Moduon Team S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)
from . import models

View file

@ -0,0 +1,19 @@
# Copyright 2023 Moduon Team S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)
{
"name": "Service tracking: Copy tasks in project",
"summary": "Copy tasks into sale order's project",
"version": "16.0.1.0.4",
"author": "Moduon, Odoo Community Association (OCA)",
"maintainers": ["shide", "EmilioPascual"],
"website": "https://github.com/OCA/project",
"license": "LGPL-3",
"category": "Sales",
"depends": ["sale_project"],
"data": [
"views/product_template_views.xml",
"views/sale_order_views.xml",
],
"installable": True,
}

View file

@ -0,0 +1,74 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_project_service_tracking_copy_tasks
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: sale_project_service_tracking_copy_tasks
#: model:ir.model.fields.selection,name:sale_project_service_tracking_copy_tasks.selection__product_template__service_tracking__copy_tasks_in_project
msgid "Copy tasks into sales order's project"
msgstr "Kopiraj zadatke u projekt prodajnog naloga"
#. module: sale_project_service_tracking_copy_tasks
#: model:ir.model.fields,field_description:sale_project_service_tracking_copy_tasks.field_product_template__display_name
#: model:ir.model.fields,field_description:sale_project_service_tracking_copy_tasks.field_sale_order__display_name
#: model:ir.model.fields,field_description:sale_project_service_tracking_copy_tasks.field_sale_order_line__display_name
msgid "Display Name"
msgstr "Prikazani naziv"
#. module: sale_project_service_tracking_copy_tasks
#: model:ir.model.fields,field_description:sale_project_service_tracking_copy_tasks.field_product_template__id
#: model:ir.model.fields,field_description:sale_project_service_tracking_copy_tasks.field_sale_order__id
#: model:ir.model.fields,field_description:sale_project_service_tracking_copy_tasks.field_sale_order_line__id
msgid "ID"
msgstr "ID"
#. module: sale_project_service_tracking_copy_tasks
#: model:ir.model.fields,field_description:sale_project_service_tracking_copy_tasks.field_product_template____last_update
#: model:ir.model.fields,field_description:sale_project_service_tracking_copy_tasks.field_sale_order____last_update
#: model:ir.model.fields,field_description:sale_project_service_tracking_copy_tasks.field_sale_order_line____last_update
msgid "Last Modified on"
msgstr "Zadnje mijenjano"
#. module: sale_project_service_tracking_copy_tasks
#: model:ir.model.fields,help:sale_project_service_tracking_copy_tasks.field_product_product__service_tracking
#: model:ir.model.fields,help:sale_project_service_tracking_copy_tasks.field_product_template__service_tracking
msgid ""
"On Sales order confirmation, this product can generate a project and/or task. From those, you can track the service you are selling.\n"
" 'In sale order's project': Will use the sale order's configured project if defined or fallback to creating a new project based on the selected template."
msgstr ""
#. module: sale_project_service_tracking_copy_tasks
#: model:ir.model,name:sale_project_service_tracking_copy_tasks.model_product_template
msgid "Product Template"
msgstr "Predložak artikla"
#. module: sale_project_service_tracking_copy_tasks
#: model_terms:ir.ui.view,arch_db:sale_project_service_tracking_copy_tasks.view_order_form_inherit_sale_project
msgid "Project"
msgstr "Projekat"
#. module: sale_project_service_tracking_copy_tasks
#: model:ir.model,name:sale_project_service_tracking_copy_tasks.model_sale_order
msgid "Sales Order"
msgstr "Prodajni nalog"
#. module: sale_project_service_tracking_copy_tasks
#: model:ir.model,name:sale_project_service_tracking_copy_tasks.model_sale_order_line
msgid "Sales Order Line"
msgstr "Stavka prodajne narudžbe"
#. module: sale_project_service_tracking_copy_tasks
#: model:ir.model.fields,field_description:sale_project_service_tracking_copy_tasks.field_product_product__service_tracking
#: model:ir.model.fields,field_description:sale_project_service_tracking_copy_tasks.field_product_template__service_tracking
msgid "Service Tracking"
msgstr "Praćenje usluge"

View file

@ -0,0 +1,79 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_project_service_tracking_copy_tasks
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-10-31 10:48+0000\n"
"PO-Revision-Date: 2024-01-11 16:33+0000\n"
"Last-Translator: Ivorra78 <informatica@totmaterial.es>\n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"
#. module: sale_project_copy_tasks
#: model:ir.model.fields.selection,name:sale_project_copy_tasks.selection__product_template__service_tracking__copy_tasks_in_project
msgid "Copy tasks into sale order's project"
msgstr "Copiar tareas en el proyecto de la orden de venta"
#. module: sale_project_copy_tasks
#: model:ir.model.fields,field_description:sale_project_copy_tasks.field_product_product__service_tracking
#: model:ir.model.fields,field_description:sale_project_copy_tasks.field_product_template__service_tracking
msgid "Create on Order"
msgstr "Crear sobre Pedido"
#. module: sale_project_copy_tasks
#: model:ir.model.fields,help:sale_project_copy_tasks.field_product_product__service_tracking
#: model:ir.model.fields,help:sale_project_copy_tasks.field_product_template__service_tracking
msgid ""
"On Sales order confirmation, this product can generate a project and/or "
"task. From those, you can track the service you are selling.\n"
" 'In sale order's project': Will use the sale order's configured "
"project if defined or fallback to creating a new project based on "
"the selected template."
msgstr ""
"En la confirmación de la orden de venta, este producto puede generar un "
"proyecto y / o tarea. A partir de ellos, puede realizar un "
"seguimiento del servicio que está vendiendo.\n"
" 'En el proyecto de la orden de venta': usará el proyecto "
"configurado de la orden de venta si está definido o se utilizará como "
"respaldo para crear un nuevo proyecto basado en la plantilla "
"seleccionada."
#. module: sale_project_copy_tasks
#: model:ir.model,name:sale_project_copy_tasks.model_product_template
msgid "Product Template"
msgstr "Plantilla de producto"
#. module: sale_project_copy_tasks
#: model_terms:ir.ui.view,arch_db:sale_project_copy_tasks.view_order_form_inherit_sale_project_copy_taks
msgid "Project"
msgstr "Proyecto"
#. module: sale_project_copy_tasks
#: model:ir.model,name:sale_project_copy_tasks.model_sale_order
msgid "Sales Order"
msgstr "Pedido de venta"
#. module: sale_project_copy_tasks
#: model:ir.model,name:sale_project_copy_tasks.model_sale_order_line
msgid "Sales Order Line"
msgstr "Línea de pedido de venta"
#~ msgid "Display Name"
#~ msgstr "Nombre mostrado"
#~ msgid "ID"
#~ msgstr "Identificación"
#~ msgid "Last Modified on"
#~ msgstr "Última modificación el"
#~ msgid "Service Tracking"
#~ msgstr "Seguimiento del servicio"

View file

@ -0,0 +1,61 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_project_copy_tasks
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-12-19 16:36+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"
#. module: sale_project_copy_tasks
#: model:ir.model.fields.selection,name:sale_project_copy_tasks.selection__product_template__service_tracking__copy_tasks_in_project
msgid "Copy tasks into sale order's project"
msgstr "Copia lavori nel progetto dell'ordine di vendita"
#. module: sale_project_copy_tasks
#: model:ir.model.fields,field_description:sale_project_copy_tasks.field_product_template__service_tracking
msgid "Create on Order"
msgstr "Crea un ordine"
#. module: sale_project_copy_tasks
#: model:ir.model.fields,help:sale_project_copy_tasks.field_product_product__service_tracking
#: model:ir.model.fields,help:sale_project_copy_tasks.field_product_template__service_tracking
msgid ""
"On Sales order confirmation, this product can generate a project and/or task. From those, you can track the service you are selling.\n"
" 'In sale order's project': Will use the sale order's configured project if defined or fallback to creating a new project based on the selected template."
msgstr ""
"Alla conferma dell'ordine di vendita, questo prodotto può generare un "
"progetto e/o un lavoro. Da questi, si possono tracciare i servizi "
"venduti.\n"
" 'Nel progetto dell'ordine di vendita': se definito utilizzerà il "
"progetto configurato nell'ordine di vendita o in alternativa creerà "
"un nuovo progetto basato sul modello selezionato."
#. module: sale_project_copy_tasks
#: model:ir.model,name:sale_project_copy_tasks.model_product_template
msgid "Product Template"
msgstr "Modello prodotto"
#. module: sale_project_copy_tasks
#: model_terms:ir.ui.view,arch_db:sale_project_copy_tasks.view_order_form_inherit_sale_project_copy_taks
msgid "Project"
msgstr "Progetto"
#. module: sale_project_copy_tasks
#: model:ir.model,name:sale_project_copy_tasks.model_sale_order
msgid "Sales Order"
msgstr "Ordine di vendita"
#. module: sale_project_copy_tasks
#: model:ir.model,name:sale_project_copy_tasks.model_sale_order_line
msgid "Sales Order Line"
msgstr "Riga ordine di vendita"

View file

@ -0,0 +1,53 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_project_copy_tasks
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: sale_project_copy_tasks
#: model:ir.model.fields.selection,name:sale_project_copy_tasks.selection__product_template__service_tracking__copy_tasks_in_project
msgid "Copy tasks into sale order's project"
msgstr ""
#. module: sale_project_copy_tasks
#: model:ir.model.fields,field_description:sale_project_copy_tasks.field_product_product__service_tracking
#: model:ir.model.fields,field_description:sale_project_copy_tasks.field_product_template__service_tracking
msgid "Create on Order"
msgstr ""
#. module: sale_project_copy_tasks
#: model:ir.model.fields,help:sale_project_copy_tasks.field_product_product__service_tracking
#: model:ir.model.fields,help:sale_project_copy_tasks.field_product_template__service_tracking
msgid ""
"On Sales order confirmation, this product can generate a project and/or task. From those, you can track the service you are selling.\n"
" 'In sale order's project': Will use the sale order's configured project if defined or fallback to creating a new project based on the selected template."
msgstr ""
#. module: sale_project_copy_tasks
#: model:ir.model,name:sale_project_copy_tasks.model_product_template
msgid "Product"
msgstr ""
#. module: sale_project_copy_tasks
#: model_terms:ir.ui.view,arch_db:sale_project_copy_tasks.view_order_form_inherit_sale_project_copy_taks
msgid "Project"
msgstr ""
#. module: sale_project_copy_tasks
#: model:ir.model,name:sale_project_copy_tasks.model_sale_order
msgid "Sales Order"
msgstr ""
#. module: sale_project_copy_tasks
#: model:ir.model,name:sale_project_copy_tasks.model_sale_order_line
msgid "Sales Order Line"
msgstr ""

View file

@ -0,0 +1,74 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_project_service_tracking_copy_tasks
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: sale_project_service_tracking_copy_tasks
#: model:ir.model.fields.selection,name:sale_project_service_tracking_copy_tasks.selection__product_template__service_tracking__copy_tasks_in_project
msgid "Copy tasks into sales order's project"
msgstr ""
#. module: sale_project_service_tracking_copy_tasks
#: model:ir.model.fields,field_description:sale_project_service_tracking_copy_tasks.field_product_template__display_name
#: model:ir.model.fields,field_description:sale_project_service_tracking_copy_tasks.field_sale_order__display_name
#: model:ir.model.fields,field_description:sale_project_service_tracking_copy_tasks.field_sale_order_line__display_name
msgid "Display Name"
msgstr ""
#. module: sale_project_service_tracking_copy_tasks
#: model:ir.model.fields,field_description:sale_project_service_tracking_copy_tasks.field_product_template__id
#: model:ir.model.fields,field_description:sale_project_service_tracking_copy_tasks.field_sale_order__id
#: model:ir.model.fields,field_description:sale_project_service_tracking_copy_tasks.field_sale_order_line__id
msgid "ID"
msgstr ""
#. module: sale_project_service_tracking_copy_tasks
#: model:ir.model.fields,field_description:sale_project_service_tracking_copy_tasks.field_product_template____last_update
#: model:ir.model.fields,field_description:sale_project_service_tracking_copy_tasks.field_sale_order____last_update
#: model:ir.model.fields,field_description:sale_project_service_tracking_copy_tasks.field_sale_order_line____last_update
msgid "Last Modified on"
msgstr ""
#. module: sale_project_service_tracking_copy_tasks
#: model:ir.model.fields,help:sale_project_service_tracking_copy_tasks.field_product_product__service_tracking
#: model:ir.model.fields,help:sale_project_service_tracking_copy_tasks.field_product_template__service_tracking
msgid ""
"On Sales order confirmation, this product can generate a project and/or task. From those, you can track the service you are selling.\n"
" 'In sale order's project': Will use the sale order's configured project if defined or fallback to creating a new project based on the selected template."
msgstr ""
#. module: sale_project_service_tracking_copy_tasks
#: model:ir.model,name:sale_project_service_tracking_copy_tasks.model_product_template
msgid "Product Template"
msgstr ""
#. module: sale_project_service_tracking_copy_tasks
#: model_terms:ir.ui.view,arch_db:sale_project_service_tracking_copy_tasks.view_order_form_inherit_sale_project
msgid "Project"
msgstr ""
#. module: sale_project_service_tracking_copy_tasks
#: model:ir.model,name:sale_project_service_tracking_copy_tasks.model_sale_order
msgid "Sales Order"
msgstr ""
#. module: sale_project_service_tracking_copy_tasks
#: model:ir.model,name:sale_project_service_tracking_copy_tasks.model_sale_order_line
msgid "Sales Order Line"
msgstr ""
#. module: sale_project_service_tracking_copy_tasks
#: model:ir.model.fields,field_description:sale_project_service_tracking_copy_tasks.field_product_product__service_tracking
#: model:ir.model.fields,field_description:sale_project_service_tracking_copy_tasks.field_product_template__service_tracking
msgid "Service Tracking"
msgstr ""

View file

@ -0,0 +1,6 @@
# Copyright 2023 Moduon Team S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)
from . import product_template
from . import sale_order
from . import sale_order_line

View file

@ -0,0 +1,14 @@
# Copyright 2023 Moduon Team S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)
from odoo import fields, models
class ProductTemplate(models.Model):
_inherit = "product.template"
service_tracking = fields.Selection(
selection_add=[
("copy_tasks_in_project", "Copy tasks into sale order's project"),
],
)

View file

@ -0,0 +1,58 @@
# Copyright 2023 Moduon Team S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)
from odoo import api, models
class SaleOrder(models.Model):
_inherit = "sale.order"
@api.depends("order_line.product_id.service_tracking")
def _compute_visible_project(self):
"""Let users select a project on matching orders.
Affects orders where at least one line has a product with
its service tracking configured as 'copy_tasks_in_project'.
"""
result = super()._compute_visible_project()
for order in self:
order.visible_project = "copy_tasks_in_project" in order.order_line.mapped(
"product_id.service_tracking"
)
return result
def _get_order_project_data(self):
self.ensure_one()
if not self.analytic_account_id:
self._create_analytic_account()
return dict(
partner_id=self.partner_id.id,
sale_order_id=self.id,
analytic_account_id=self.analytic_account_id.id,
name=self.name,
)
@api.returns("project.project")
def create_order_project(self):
pp_model = self.env["project.project"]
created_projects = pp_model.browse()
for order in self:
projects = order.mapped("order_line.product_id.project_template_id")
new_project = projects[0].copy(
dict(
type_ids=projects.mapped("type_ids").ids,
active=True,
tasks=False,
**order._get_order_project_data(),
)
)
created_projects |= new_project
order.project_id = new_project
new_project.analytic_account_id.partner_id = order.partner_id
order._onchange_project_id()
new_project.sudo().message_post_with_view(
"mail.message_origin_link",
values={"self": order.project_id, "origin": order},
subtype_id=self.env.ref("mail.mt_note").id,
)
return created_projects

View file

@ -0,0 +1,79 @@
# Copyright 2023 Moduon Team S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)
from odoo import models
class SaleOrderLine(models.Model):
_inherit = "sale.order.line"
def _timesheet_service_generation(self):
"""Adds task inheritance from project_templates
Creates the project in sale order if needed and copies tasks
from product project_template to order project.
"""
so_model = self.env["sale.order"]
mt_note = self.env.ref("mail.mt_note")
# Check lines that need to inherit project template tasks
sol_copy_tasks = self.filtered(
lambda sol: sol.is_service
and sol.product_id.service_tracking == "copy_tasks_in_project"
and sol.product_id.project_template_id
)
# Remove lines with tasks
sol_copy_tasks -= (
self.env["project.task"]
.sudo()
.search(
[
("sale_line_id", "in", sol_copy_tasks.ids),
]
)
.mapped("sale_line_id")
)
# Create sale order projects automatically
# for lines that don't have projects associated
new_projects = (
sol_copy_tasks.filtered(lambda sol: not sol.order_id.project_id)
.mapped("order_id")
.create_order_project()
)
# Copy task from line template_projects if don't have one associated
orders_linked = so_model.browse()
for sol_to_copy_task in sol_copy_tasks:
order = sol_to_copy_task.order_id
target_project = sol_to_copy_task.project_id or order.project_id
# If line don't have associated project, assign to it
sol_to_copy_task.project_id = target_project
# Notify order on project
if target_project not in new_projects and order not in orders_linked:
target_project.sudo().message_post_with_view(
"mail.message_origin_link",
values={"self": target_project, "origin": order},
subtype_id=mt_note.id,
)
orders_linked |= order
default_task_data = {
"project_id": sol_to_copy_task.project_id.id,
"sale_line_id": sol_to_copy_task.id,
"sale_order_id": order.id,
"partner_id": order.partner_id.id,
"email_from": order.partner_id.email,
"date_deadline": order.commitment_date,
"active": True,
}
tasks = sol_to_copy_task.product_id.project_template_id.with_context(
active_test=False
).tasks
for task in tasks:
task.copy(
dict(
default_task_data,
name=task.name,
stage_id=task.stage_id.id,
)
)
return super()._timesheet_service_generation()

View file

@ -0,0 +1 @@
The use case is when an Odoo customer sells the same services with the same tasks constantly and the tasks should be linked with existing project. Standard Odoo would always create a new project.

View file

@ -0,0 +1,3 @@
* Eduardo de Miguel (`Moduon <https://www.moduon.team/>`__)
* Emilio Pascual (`Moduon <https://www.moduon.team/>`__)
* Rafael Blasco (`Moduon <https://www.moduon.team/>`__)

View file

@ -0,0 +1 @@
This module allows creating tasks in an existing project from the sales order through setting the product with a project template with the desired task.

View file

@ -0,0 +1,9 @@
1. Go to Project > Projects.
2. Create project.
3. Go to Project > Tasks.
4. Create tasks for the project created in step 2.
5. Go to Sales > Products > Products.
6. Create product whose type is service, the service tracking is to copy the task into the sales order project and project template select project created in step 2.
7. Go to Sales > Quotation > Quotation.
8. Create quotation with products created in step 6.
9. Confirm the quotation. The tasks from project templates in products will be created in same project.

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View file

@ -0,0 +1,447 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>Service tracking: Copy tasks in project</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
.subscript {
vertical-align: sub;
font-size: smaller }
.superscript {
vertical-align: super;
font-size: smaller }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden;
}
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left, table.align-left {
clear: left ;
float: left ;
margin-right: 1em }
img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
.align-center {
clear: both ;
text-align: center }
.align-right {
text-align: right }
/* reset inner alignment in figures */
div.align-right {
text-align: inherit }
/* div.align-center * { */
/* text-align: left } */
.align-top {
vertical-align: top }
.align-middle {
vertical-align: middle }
.align-bottom {
vertical-align: bottom }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }
pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic, pre.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
border: 0px;
border-top: 2px solid;
border-bottom: 2px solid;
border-collapse: collapse;
}
table.docutils.booktabs * {
border: 0px;
}
table.docutils.booktabs th {
border-bottom: thin solid;
text-align: left;
}
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
</style>
</head>
<body>
<div class="document" id="service-tracking-copy-tasks-in-project">
<h1 class="title">Service tracking: Copy tasks in project</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9e20fdd9c2b8d3bec01955b01a331d15686762e3456aab9a386fd3802557e855
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/project/tree/16.0/sale_project_copy_tasks"><img alt="OCA/project" src="https://img.shields.io/badge/github-OCA%2Fproject-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/project-16-0/project-16-0-sale_project_copy_tasks"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/project&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows creating tasks in an existing project from the sales order through setting the product with a project template with the desired task.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#use-cases-context" id="toc-entry-1">Use Cases / Context</a></li>
<li><a class="reference internal" href="#usage" id="toc-entry-2">Usage</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-3">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-4">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-5">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-6">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-7">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="use-cases-context">
<h1><a class="toc-backref" href="#toc-entry-1">Use Cases / Context</a></h1>
<p>The use case is when an Odoo customer sells the same services with the same tasks constantly and the tasks should be linked with existing project. Standard Odoo would always create a new project.</p>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
<ol class="arabic simple">
<li>Go to Project &gt; Projects.</li>
<li>Create project.</li>
<li>Go to Project &gt; Tasks.</li>
<li>Create tasks for the project created in step 2.</li>
<li>Go to Sales &gt; Products &gt; Products.</li>
<li>Create product whose type is service, the service tracking is to copy the task into the sales order project and project template select project created in step 2.</li>
<li>Go to Sales &gt; Quotation &gt; Quotation.</li>
<li>Create quotation with products created in step 6.</li>
<li>Confirm the quotation. The tasks from project templates in products will be created in same project.</li>
</ol>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/project/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/project/issues/new?body=module:%20sale_project_copy_tasks%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-4">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-5">Authors</a></h2>
<ul class="simple">
<li>Moduon</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<ul class="simple">
<li>Eduardo de Miguel (<a class="reference external" href="https://www.moduon.team/">Moduon</a>)</li>
<li>Emilio Pascual (<a class="reference external" href="https://www.moduon.team/">Moduon</a>)</li>
<li>Rafael Blasco (<a class="reference external" href="https://www.moduon.team/">Moduon</a>)</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/shide"><img alt="shide" src="https://github.com/shide.png?size=40px" /></a> <a class="reference external image-reference" href="https://github.com/EmilioPascual"><img alt="EmilioPascual" src="https://github.com/EmilioPascual.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/project/tree/16.0/sale_project_copy_tasks">OCA/project</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,4 @@
# Copyright 2023 Moduon Team S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)
from . import test_copy_task

View file

@ -0,0 +1,188 @@
# Copyright 2023 Moduon Team S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)
from odoo.tests.common import TransactionCase
class TestCopyTasks(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.plan = cls.env["account.analytic.plan"].create(
{
"name": "Projects Plan",
"company_id": False,
}
)
cls.analytic_account_sale = cls.env["account.analytic.account"].create(
{
"name": "Project for selling timesheet - AA",
"code": "AA-2030",
"plan_id": cls.plan.id,
}
)
# Create projects
cls.project_template = cls.env["project.project"].create(
{
"name": "Project template",
}
)
cls.project_template_state = cls.env["project.task.type"].create(
{
"name": "Only stage in project template",
"sequence": 1,
"project_ids": [(4, cls.project_template.id)],
}
)
cls.project_template_tasks = cls.env["project.task"].create(
[
{
"name": "Task template 1",
"stage_id": cls.project_template_state.id,
"project_id": cls.project_template.id,
},
{
"name": "Task template 2",
"stage_id": cls.project_template_state.id,
"project_id": cls.project_template.id,
},
{
"name": "Task template 3",
"stage_id": cls.project_template_state.id,
"project_id": cls.project_template.id,
},
{
"name": "Task template 4",
"stage_id": cls.project_template_state.id,
"project_id": cls.project_template.id,
},
]
)
# Create service products
uom_hour = cls.env.ref("uom.product_uom_hour")
cls.product_order_service1 = cls.env["product.product"].create(
{
"name": "Service Ordered, create task in project's order",
"standard_price": 30,
"list_price": 90,
"type": "service",
"invoice_policy": "order",
"uom_id": uom_hour.id,
"uom_po_id": uom_hour.id,
"default_code": "SERV-COPY-TASK",
"service_tracking": "copy_tasks_in_project",
"project_id": False,
"project_template_id": cls.project_template.id,
}
)
def test_sale_order_with_copy_tasks(self):
so_model = self.env["sale.order"].with_context(tracking_disable=True)
sol_model = self.env["sale.order.line"].with_context(tracking_disable=True)
partner = self.env["res.partner"].create({"name": "Test Partner"})
sale_order_1 = so_model.create(
{
"partner_id": partner.id,
"partner_invoice_id": partner.id,
"partner_shipping_id": partner.id,
}
)
so_1_line_1_copy_task = sol_model.create(
{
"name": self.product_order_service1.name,
"product_id": self.product_order_service1.id,
"product_uom_qty": 1,
"product_uom": self.product_order_service1.uom_id.id,
"price_unit": self.product_order_service1.list_price,
"order_id": sale_order_1.id,
}
)
sale_order_1.action_confirm()
# Project must be created and all tasks inherited
self.assertEqual(
sale_order_1.name,
sale_order_1.project_id.name,
"SO1: Project name different than sale project",
)
self.assertEqual(
so_1_line_1_copy_task.project_id,
sale_order_1.project_id,
"SO1L1: Sale project different from line",
)
self.assertTrue(
sale_order_1.project_id.analytic_account_id,
"SO1: Analytic account not created",
)
self.assertEqual(
sale_order_1.project_id.analytic_account_id,
sale_order_1.analytic_account_id,
"SO1: Different analytic accounts",
)
self.assertEqual(
len(sale_order_1.project_id.task_ids),
len(self.project_template_tasks),
"SO1L1: Different number of tasks inherited",
)
# Cancel and draft sale in order to add more lines
so_1_line_2_copy_task = sol_model.create(
{
"name": self.product_order_service1.name,
"product_id": self.product_order_service1.id,
"product_uom_qty": 1,
"product_uom": self.product_order_service1.uom_id.id,
"price_unit": self.product_order_service1.list_price,
"order_id": sale_order_1.id,
}
)
# New tasks must be added to the existing project
self.assertEqual(
so_1_line_2_copy_task.project_id,
sale_order_1.project_id,
"SO1L2: New added Line project different from line",
)
self.assertEqual(
len(sale_order_1.project_id.task_ids),
len(self.project_template_tasks) * 2,
"SO1L2: Different number of tasks inherited when adding another line",
)
# New sale order for the same project
sale_order_2 = so_model.create(
{
"partner_id": partner.id,
"partner_invoice_id": partner.id,
"partner_shipping_id": partner.id,
"project_id": sale_order_1.project_id.id, # Specify project
}
)
sale_order_2._onchange_project_id()
so_2_line_1_copy_tasks = sol_model.create(
{
"product_id": self.product_order_service1.id,
"product_uom_qty": 1,
"product_uom": self.product_order_service1.uom_id.id,
"price_unit": self.product_order_service1.list_price,
"order_id": sale_order_2.id,
}
)
sale_order_2.action_confirm()
self.assertNotEqual(
sale_order_2.name,
sale_order_2.project_id.name,
"SO2: Project has been renamed",
)
self.assertEqual(
so_2_line_1_copy_tasks.project_id,
sale_order_2.project_id,
"SO2L1: Line project different from line",
)
self.assertEqual(
len(sale_order_2.project_id.task_ids),
len(self.project_template_tasks) * 3,
"SO2L1: Different number of tasks inherited",
)

View file

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 Moduon Team S.L.
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) -->
<odoo>
<record
id="product_template_form_inherit_service_tracking_copy_tasks"
model="ir.ui.view"
>
<field
name="name"
>product.tempale.for.view.inherit.service.tracking.copy.tasks</field>
<field name="model">product.template</field>
<field
name="inherit_id"
ref="sale_project.product_template_form_view_invoice_policy_inherit_sale_project"
/>
<field name="arch" type="xml">
<xpath expr="//field[@name='project_template_id']" position="attributes">
<attribute
name="attrs"
>{'invisible': [('service_tracking', 'not in', ['task_in_project', 'project_only', 'copy_tasks_in_project'])], 'required': [('service_tracking', 'in', ['copy_tasks_in_project'])]}</attribute>
</xpath>
</field>
</record>
</odoo>

View file

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 Moduon Team S.L.
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0) -->
<odoo>
<record model="ir.ui.view" id="view_order_form_inherit_sale_project_copy_taks">
<field name="name">sale.order.form.inherit.sale.project.copy.tasks</field>
<field name="model">sale.order</field>
<field
name="inherit_id"
ref="sale_project.view_order_form_inherit_sale_project"
/>
<field name="arch" type="xml">
<xpath
expr="//group[@name='sale_info']//field[@name='project_id']"
position="attributes"
>
<attribute name="options">{}</attribute>
<attribute
name="context"
>{'default_partner_id': partner_id, 'default_sale_order_id': active_id}</attribute>
<attribute
name="attrs"
>{'invisible': [('visible_project', '=', False)]}</attribute>
</xpath>
<xpath expr="//field[@name='order_line']//tree" position="inside">
<field string="Project" name="project_id" optional="hidden" />
</xpath>
</field>
</record>
</odoo>