Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] project_task_purchase: module to allow to create purchase order… #1276

Open
wants to merge 1 commit into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions project_task_purchase/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
=====================
Project Task Purchase
=====================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:0d769cd9e032168e3dff0c0b40c1a178ff53b36e0600b018d14ad5344b4e03cc
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/17.0/project_task_purchase
:alt: OCA/project
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/project-17-0/project-17-0-project_task_purchase
: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=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows you to create a purchase order from a task and link
them.

**Table of contents**

.. contents::
:local:

Usage
=====

- Go to a task.
- Press the "Create purchase order" button.
- It will create a new purchase order that will be linked to the task.

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:%20project_task_purchase%0Aversion:%2017.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
-------

* Jarsa

Contributors
------------

- Alan Ramos <[email protected]>

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 <https://github.com/OCA/project/tree/17.0/project_task_purchase>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions project_task_purchase/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2023 - Jarsa
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0).

from . import models
19 changes: 19 additions & 0 deletions project_task_purchase/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2023 - Jarsa
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0).

{
"name": "Project Task Purchase",
"summary": "Create purchase orders from project tasks",
"version": "17.0.1.0.0",
"category": "Project Management",
"author": "Jarsa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/project",
"license": "LGPL-3",
"installable": True,
"depends": ["project", "purchase"],
"data": [
"security/res_groups.xml",
"views/project_task_view.xml",
"views/purchase_order_view.xml",
],
}
55 changes: 55 additions & 0 deletions project_task_purchase/i18n/es_MX.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * project_task_purchase
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-08-03 14:46+0000\n"
"PO-Revision-Date: 2023-08-03 08:47-0600\n"
"Last-Translator: Jesús Alan Ramos Rodríguez <[email protected]>\n"
"Language-Team: \n"
"Language: es_MX\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: Poedit 3.3.2\n"

#. module: project_task_purchase
#: model:res.groups,name:project_task_purchase.group_project_task_purchase
msgid "Allow to create purchase orders from tasks"
msgstr "Permitir crear órdenes de compra a partir de tareas"

#. module: project_task_purchase
#: model_terms:ir.ui.view,arch_db:project_task_purchase.project_task_view_form
msgid "Create Purchase Order"
msgstr "Crear orden de compra"

#. module: project_task_purchase
#: model:ir.model,name:project_task_purchase.model_purchase_order
msgid "Purchase Order"
msgstr "Orden de compra"

#. module: project_task_purchase
#: model:ir.model.fields,field_description:project_task_purchase.field_project_task__purchase_order_count
msgid "Purchase Order Count"
msgstr "Recuento de órdenes de compra"

#. module: project_task_purchase
#: model:ir.model.fields,field_description:project_task_purchase.field_project_task__purchase_order_ids
msgid "Purchase Orders"
msgstr "Ordenes de Compra"

#. module: project_task_purchase
#: model_terms:ir.ui.view,arch_db:project_task_purchase.project_task_view_form
msgid "Purchases"
msgstr "Compras"

#. module: project_task_purchase
#: model:ir.model,name:project_task_purchase.model_project_task
#: model:ir.model.fields,field_description:project_task_purchase.field_purchase_order__task_id
#: model_terms:ir.ui.view,arch_db:project_task_purchase.purchase_order_view_form
msgid "Task"
msgstr "Tarea"
5 changes: 5 additions & 0 deletions project_task_purchase/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2023 - Jarsa
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0).

from . import project_task
from . import purchase_order
62 changes: 62 additions & 0 deletions project_task_purchase/models/project_task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Copyright 2023 - Jarsa
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0).

from odoo import fields, models


class ProjectTask(models.Model):
_inherit = "project.task"

purchase_order_ids = fields.One2many(
comodel_name="purchase.order",
inverse_name="task_id",
string="Purchase Orders",
readonly=True,
)
purchase_order_count = fields.Integer(
compute="_compute_purchase_order_count",
)

def action_create_purchase_order(self):
self.ensure_one()
return {

Check warning on line 22 in project_task_purchase/models/project_task.py

View check run for this annotation

Codecov / codecov/patch

project_task_purchase/models/project_task.py#L21-L22

Added lines #L21 - L22 were not covered by tests
"type": "ir.actions.act_window",
"name": "Purchase Order",
"res_model": "purchase.order",
"view_mode": "form",
"context": {
"default_task_id": self.id,
"default_origin": self.name,
},
}

def action_view_purchase_orders(self):
self.ensure_one()
action = {

Check warning on line 35 in project_task_purchase/models/project_task.py

View check run for this annotation

Codecov / codecov/patch

project_task_purchase/models/project_task.py#L34-L35

Added lines #L34 - L35 were not covered by tests
"type": "ir.actions.act_window",
"name": "Purchase Order",
"res_model": "purchase.order",
"context": {
"default_task_id": self.id,
"default_origin": self.name,
},
}
if self.purchase_order_count == 1:
action.update(

Check warning on line 45 in project_task_purchase/models/project_task.py

View check run for this annotation

Codecov / codecov/patch

project_task_purchase/models/project_task.py#L45

Added line #L45 was not covered by tests
{
"res_id": self.purchase_order_ids.id,
"view_mode": "form",
}
)
else:
action.update(

Check warning on line 52 in project_task_purchase/models/project_task.py

View check run for this annotation

Codecov / codecov/patch

project_task_purchase/models/project_task.py#L52

Added line #L52 was not covered by tests
{
"domain": [("id", "in", self.purchase_order_ids.ids)],
"view_mode": "tree,form",
}
)
return action

Check warning on line 58 in project_task_purchase/models/project_task.py

View check run for this annotation

Codecov / codecov/patch

project_task_purchase/models/project_task.py#L58

Added line #L58 was not covered by tests

def _compute_purchase_order_count(self):
for task in self:
task.purchase_order_count = len(task.purchase_order_ids)

Check warning on line 62 in project_task_purchase/models/project_task.py

View check run for this annotation

Codecov / codecov/patch

project_task_purchase/models/project_task.py#L62

Added line #L62 was not covered by tests
23 changes: 23 additions & 0 deletions project_task_purchase/models/purchase_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2023 - Jarsa
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl-3.0).

from odoo import fields, models


class PurchaseOrder(models.Model):
_inherit = "purchase.order"

task_id = fields.Many2one(
comodel_name="project.task",
readonly=True,
)

def action_view_task(self):
self.ensure_one()
return {

Check warning on line 17 in project_task_purchase/models/purchase_order.py

View check run for this annotation

Codecov / codecov/patch

project_task_purchase/models/purchase_order.py#L16-L17

Added lines #L16 - L17 were not covered by tests
"type": "ir.actions.act_window",
"name": "Project Task",
"res_model": "project.task",
"view_mode": "form",
"res_id": self.task_id.id,
}
3 changes: 3 additions & 0 deletions project_task_purchase/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
1 change: 1 addition & 0 deletions project_task_purchase/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Alan Ramos \<<[email protected]>\>
2 changes: 2 additions & 0 deletions project_task_purchase/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module allows you to create a purchase order from a task and link
them.
3 changes: 3 additions & 0 deletions project_task_purchase/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Go to a task.
- Press the "Create purchase order" button.
- It will create a new purchase order that will be linked to the task.
9 changes: 9 additions & 0 deletions project_task_purchase/security/res_groups.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="group_project_task_purchase" model="res.groups">
<field name="name">Allow to create purchase orders from tasks</field>
<field name="users" eval="[(4, ref('base.user_admin'))]" />
</record>

</odoo>
Loading
Loading