diff --git a/project_task_material_cost/README.rst b/project_task_material_cost/README.rst new file mode 100644 index 0000000000..e8110e6560 --- /dev/null +++ b/project_task_material_cost/README.rst @@ -0,0 +1,78 @@ +========================== +Project Task Material Cost +========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:c5e2f4af8af1772861c42036ed313cd9a9ca21b566bc4564a336673b2d13f540 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproject-lightgray.png?logo=github + :target: https://github.com/OCA/project/tree/18.0/project_task_material_cost + :alt: OCA/project +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/project-18-0/project-18-0-project_task_material_cost + :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=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module add cost in material. + +**Table of contents** + +.. contents:: + :local: + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Ecosoft + +Contributors +------------ + +- `Ecosoft `__: + + - Saran Lim. + +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. + +This module is part of the `OCA/project `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/project_task_material_cost/__init__.py b/project_task_material_cost/__init__.py new file mode 100644 index 0000000000..7ac22df0e0 --- /dev/null +++ b/project_task_material_cost/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0). + +from . import models diff --git a/project_task_material_cost/__manifest__.py b/project_task_material_cost/__manifest__.py new file mode 100644 index 0000000000..3ca8c6929e --- /dev/null +++ b/project_task_material_cost/__manifest__.py @@ -0,0 +1,15 @@ +# Copyright 2026 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0). + +{ + "name": "Project Task Material Cost", + "summary": "Add cost product in a Task Material", + "version": "18.0.1.0.0", + "category": "Project Management", + "author": "Ecosoft, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/project", + "license": "AGPL-3", + "installable": True, + "depends": ["project_task_material"], + "data": ["views/project_view.xml"], +} diff --git a/project_task_material_cost/models/__init__.py b/project_task_material_cost/models/__init__.py new file mode 100644 index 0000000000..0a5efeb294 --- /dev/null +++ b/project_task_material_cost/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0). + +from . import project diff --git a/project_task_material_cost/models/project.py b/project_task_material_cost/models/project.py new file mode 100644 index 0000000000..4af9e106dc --- /dev/null +++ b/project_task_material_cost/models/project.py @@ -0,0 +1,23 @@ +# Copyright 2026 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0). + +from odoo import api, fields, models + + +class ProjectTaskMaterial(models.Model): + _inherit = "project.task.material" + + cost = fields.Float( + compute="_compute_purchase_price", + min_display_digits="Product Price", + store=True, + readonly=False, + copy=False, + precompute=True, + groups="base.group_user", + ) + + @api.depends("product_id") + def _compute_purchase_price(self): + for line in self: + line.cost = line.product_id.standard_price or 0.0 diff --git a/project_task_material_cost/pyproject.toml b/project_task_material_cost/pyproject.toml new file mode 100644 index 0000000000..4231d0cccb --- /dev/null +++ b/project_task_material_cost/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/project_task_material_cost/readme/CONTRIBUTORS.md b/project_task_material_cost/readme/CONTRIBUTORS.md new file mode 100644 index 0000000000..00068c02ef --- /dev/null +++ b/project_task_material_cost/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- [Ecosoft](http://ecosoft.co.th): + - Saran Lim. \<\> diff --git a/project_task_material_cost/readme/DESCRIPTION.md b/project_task_material_cost/readme/DESCRIPTION.md new file mode 100644 index 0000000000..5d71022235 --- /dev/null +++ b/project_task_material_cost/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This module add cost in material. diff --git a/project_task_material_cost/static/description/icon.png b/project_task_material_cost/static/description/icon.png new file mode 100644 index 0000000000..3a0328b516 Binary files /dev/null and b/project_task_material_cost/static/description/icon.png differ diff --git a/project_task_material_cost/static/description/index.html b/project_task_material_cost/static/description/index.html new file mode 100644 index 0000000000..428bc61601 --- /dev/null +++ b/project_task_material_cost/static/description/index.html @@ -0,0 +1,426 @@ + + + + + +Project Task Material Cost + + + +
+

Project Task Material Cost

+ + +

Beta License: AGPL-3 OCA/project Translate me on Weblate Try me on Runboat

+

This module add cost in material.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Ecosoft
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

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.

+

This module is part of the OCA/project project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/project_task_material_cost/tests/__init__.py b/project_task_material_cost/tests/__init__.py new file mode 100644 index 0000000000..3ce48a3091 --- /dev/null +++ b/project_task_material_cost/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0). + +from . import test_task_material_cost diff --git a/project_task_material_cost/tests/test_task_material_cost.py b/project_task_material_cost/tests/test_task_material_cost.py new file mode 100644 index 0000000000..191c113047 --- /dev/null +++ b/project_task_material_cost/tests/test_task_material_cost.py @@ -0,0 +1,22 @@ +# Copyright 2026 Ecosoft Co., Ltd. (http://ecosoft.co.th) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3.0). + +from odoo.tests import tagged + +from odoo.addons.project_task_material.tests.test_create_material_lines import ( + ProjectTaskMaterial, +) + + +@tagged("post_install", "-at_install") +class ProjectTaskMaterialCost(ProjectTaskMaterial): + def test_01_add_task_material_cost(self): + """Add product with cost""" + self.action.write( + {"material_ids": [(0, 0, {"product_id": self.product.id, "quantity": 4.0})]} + ) + self.assertEqual(len(self.task.material_ids.ids), 1) + self.assertEqual( + self.task.material_ids.cost, + self.task.material_ids.product_id.standard_price, + ) diff --git a/project_task_material_cost/views/project_view.xml b/project_task_material_cost/views/project_view.xml new file mode 100644 index 0000000000..8650829b95 --- /dev/null +++ b/project_task_material_cost/views/project_view.xml @@ -0,0 +1,16 @@ + + + + project.task.form.material + project.task + + + + + + + +