Skip to content

Commit

Permalink
[MIG] project_stock: Migration to 15.0
Browse files Browse the repository at this point in the history
TT40363
  • Loading branch information
victoralmau committed Nov 4, 2022
1 parent e6036bf commit fabb88e
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 78 deletions.
12 changes: 6 additions & 6 deletions project_stock/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Project Stock
: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/14.0/project_stock
:target: https://github.com/OCA/project/tree/15.0/project_stock
:alt: OCA/project
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/project-14-0/project-14-0-project_stock
:target: https://translation.odoo-community.org/projects/project-15-0/project-15-0-project_stock
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/140/14.0
:target: https://runbot.odoo-community.org/runbot/140/15.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -49,7 +49,7 @@ To configure this module, you need to:
#. Create a new project with the following options:
* `Name`: Task material
* `Operation type`: Task material
#. Go to *Project -> Configuration -> Stages* and edit some records.
#. Go to *Project -> Configuration -> Task Stages* and edit some records.
* `In progress`: Check Use Stock Moves option and add the created project.
* `Done`: Check Use Stock Moves option + Lock Stock Moves and add the created project.

Expand All @@ -74,7 +74,7 @@ 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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/project/issues/new?body=module:%20project_stock%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/project/issues/new?body=module:%20project_stock%0Aversion:%2015.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.

Expand Down Expand Up @@ -115,6 +115,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-victoralmau|

This module is part of the `OCA/project <https://github.com/OCA/project/tree/14.0/project_stock>`_ project on GitHub.
This module is part of the `OCA/project <https://github.com/OCA/project/tree/15.0/project_stock>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion project_stock/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Project Stock",
"version": "14.0.1.1.1",
"version": "15.0.1.0.0",
"category": "Project Management",
"website": "https://github.com/OCA/project",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand Down
16 changes: 16 additions & 0 deletions project_stock/migrations/15.0.1.0.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2022 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openupgradelib import openupgrade

_table_renamed = [
(
"account_analytic_tag_project_task_rel",
"account_analytic_tag_project_task_stock_rel",
),
]


@openupgrade.migrate()
def migrate(env, version):
openupgrade.rename_tables(env.cr, _table_renamed)
5 changes: 4 additions & 1 deletion project_stock/models/project_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ class ProjectTask(models.Model):
)
stock_analytic_tag_ids = fields.Many2many(
comodel_name="account.analytic.tag",
relation="account_analytic_tag_project_task_stock_rel",
column1="project_task_id",
column2="account_analytic_tag_id",
string="Move Analytic Tags",
)
stock_analytic_line_ids = fields.One2many(
Expand Down Expand Up @@ -225,7 +228,7 @@ def action_done(self):

def action_see_move_scrap(self):
self.ensure_one()
action = self.env.ref("stock.action_stock_scrap").read()[0]
action = self.env["ir.actions.actions"]._for_xml_id("stock.action_stock_scrap")
action["domain"] = [("task_id", "=", self.id)]
action["context"] = dict(self._context, default_origin=self.name)
return action
Expand Down
7 changes: 4 additions & 3 deletions project_stock/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ class StockMove(models.Model):
)

@api.onchange("product_id")
def onchange_product_id(self):
def _onchange_product_id(self):
"""It is necessary to overwrite the name to prevent set product name
from being auto-defined."""
super().onchange_product_id()
res = super()._onchange_product_id()
if self.raw_material_task_id:
self.name = self.raw_material_task_id.name
return res

def _prepare_analytic_line_from_task(self):
product = self.product_id
Expand Down Expand Up @@ -63,7 +64,7 @@ def _prepare_analytic_line_from_task(self):
if "employee_id" in analytic_line_fields:
vals["employee_id"] = (
self.env["hr.employee"]
.search([("user_id", "=", task.user_id.id)], limit=1)
.search([("user_ids", "in", task.user_id.id)], limit=1)
.id
)
# tags + distributions
Expand Down
2 changes: 1 addition & 1 deletion project_stock/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ To configure this module, you need to:
#. Create a new project with the following options:
* `Name`: Task material
* `Operation type`: Task material
#. Go to *Project -> Configuration -> Stages* and edit some records.
#. Go to *Project -> Configuration -> Task Stages* and edit some records.
* `In progress`: Check Use Stock Moves option and add the created project.
* `Done`: Check Use Stock Moves option + Lock Stock Moves and add the created project.
10 changes: 5 additions & 5 deletions project_stock/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<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 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Project Stock</title>
<style type="text/css">

Expand Down Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Project Stock</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" 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" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/project/tree/14.0/project_stock"><img alt="OCA/project" src="https://img.shields.io/badge/github-OCA%2Fproject-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/project-14-0/project-14-0-project_stock"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/140/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" 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" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/project/tree/15.0/project_stock"><img alt="OCA/project" src="https://img.shields.io/badge/github-OCA%2Fproject-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/project-15-0/project-15-0-project_stock"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/140/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module allows to consume products directly from a project task.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
Expand Down Expand Up @@ -412,7 +412,7 @@ <h1><a class="toc-backref" href="#id1">Configuration</a></h1>
</dl>
</li>
<li><dl class="first docutils">
<dt>Go to <em>Project -&gt; Configuration -&gt; Stages</em> and edit some records.</dt>
<dt>Go to <em>Project -&gt; Configuration -&gt; Task Stages</em> and edit some records.</dt>
<dd><ul class="first last">
<li><cite>In progress</cite>: Check Use Stock Moves option and add the created project.</li>
<li><cite>Done</cite>: Check Use Stock Moves option + Lock Stock Moves and add the created project.</li>
Expand Down Expand Up @@ -449,7 +449,7 @@ <h1><a class="toc-backref" href="#id3">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 smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/project/issues/new?body=module:%20project_stock%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/project/issues/new?body=module:%20project_stock%0Aversion:%2015.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">
Expand Down Expand Up @@ -479,7 +479,7 @@ <h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/victoralmau"><img alt="victoralmau" src="https://github.com/victoralmau.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/project/tree/14.0/project_stock">OCA/project</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/project/tree/15.0/project_stock">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>
Expand Down
10 changes: 5 additions & 5 deletions project_stock/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
from odoo.tests import Form, common


class TestProjectStockBase(common.SavepointCase):
class TestProjectStockBase(common.TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.product_a = cls.env["product.product"].create(
{"name": "Test product A", "type": "product", "standard_price": 10}
{"name": "Test product A", "detailed_type": "product", "standard_price": 10}
)
cls.product_b = cls.env["product.product"].create(
{"name": "Test product B", "type": "product", "standard_price": 20}
{"name": "Test product B", "detailed_type": "product", "standard_price": 20}
)
cls.product_c = cls.env["product.product"].create(
{"name": "Test product C", "type": "product", "standard_price": 0}
{"name": "Test product C", "detailed_type": "product", "standard_price": 0}
)
warehouse = cls.env["stock.warehouse"].search(
[("company_id", "=", cls.env.company.id)], limit=1
Expand Down Expand Up @@ -86,7 +86,7 @@ def _prepare_context_task(self):

def _create_task(self, products):
task_form = Form(
self.env["project.task"].with_context(self._prepare_context_task(self))
self.env["project.task"].with_context(**self._prepare_context_task(self))
)
task_form.name = "Test task"
# Save task to use default_get() correctlly in stock.moves
Expand Down
Loading

0 comments on commit fabb88e

Please sign in to comment.