[MIG] quality_control_stock: Migration to 13.0

This commit is contained in:
ps-tubtim
2020-03-23 10:42:11 +07:00
committed by Enrique Martín
parent 79e2cf45fb
commit 595b1d8f6d
8 changed files with 32 additions and 28 deletions

View File

@@ -14,13 +14,13 @@ Quality control - Stock
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github
:target: https://github.com/OCA/manufacture/tree/12.0/quality_control_stock :target: https://github.com/OCA/manufacture/tree/13.0/quality_control_stock
:alt: OCA/manufacture :alt: OCA/manufacture
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/manufacture-12-0/manufacture-12-0-quality_control_stock :target: https://translation.odoo-community.org/projects/manufacture-13-0/manufacture-13-0-quality_control_stock
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/129/12.0 :target: https://runbot.odoo-community.org/runbot/129/13.0
:alt: Try me on Runbot :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@@ -45,7 +45,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/manufacture/issues>`_. Bugs are tracked on `GitHub Issues <https://github.com/OCA/manufacture/issues>`_.
In case of trouble, please check there if your issue has already been reported. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/manufacture/issues/new?body=module:%20quality_control_stock%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `feedback <https://github.com/OCA/manufacture/issues/new?body=module:%20quality_control_stock%0Aversion:%2013.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. Do not contact contributors directly about support or help with technical issues.
@@ -68,6 +68,7 @@ Contributors
* Simone Rubino <simone.rubino@agilebg.com> * Simone Rubino <simone.rubino@agilebg.com>
* Andrii Skrypka <andrijskrypa@ukr.net> * Andrii Skrypka <andrijskrypa@ukr.net>
* Ignacio José Alés <ignacio.ales@guadaltech.es> * Ignacio José Alés <ignacio.ales@guadaltech.es>
* Pimolnat Suntian <pimolnats@ecosoft.co.th>
Maintainers Maintainers
~~~~~~~~~~~ ~~~~~~~~~~~
@@ -82,6 +83,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/12.0/quality_control_stock>`_ project on GitHub. This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/13.0/quality_control_stock>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -10,7 +10,7 @@
"license": "AGPL-3", "license": "AGPL-3",
"author": "OdooMRP team, AvanzOSC, Serv. Tecnol. Avanzados - Pedro M. Baeza, " "author": "OdooMRP team, AvanzOSC, Serv. Tecnol. Avanzados - Pedro M. Baeza, "
"Agile Business Group, Odoo Community Association (OCA)", "Agile Business Group, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/manufacture/tree/12.0/quality_control_stock", "website": "https://github.com/OCA/manufacture",
"depends": ["quality_control", "stock"], "depends": ["quality_control", "stock"],
"data": [ "data": [
"security/ir.model.access.csv", "security/ir.model.access.csv",

View File

@@ -16,13 +16,17 @@ class QcInspection(models.Model):
comodel_name="stock.production.lot", compute="_compute_lot", store=True comodel_name="stock.production.lot", compute="_compute_lot", store=True
) )
@api.multi
def object_selection_values(self): def object_selection_values(self):
result = super().object_selection_values() result = super().object_selection_values()
result.extend([("stock.picking", "Picking List"), ("stock.move", "Stock Move")]) result.extend(
[
("stock.picking", "Picking List"),
("stock.move", "Stock Move"),
("stock.production.lot", "Lot/Serial Number"),
]
)
return result return result
@api.multi
@api.depends("object_id") @api.depends("object_id")
def _compute_picking(self): def _compute_picking(self):
for inspection in self: for inspection in self:
@@ -34,7 +38,6 @@ class QcInspection(models.Model):
elif inspection.object_id._name == "stock.move.line": elif inspection.object_id._name == "stock.move.line":
inspection.picking_id = inspection.object_id.picking_id inspection.picking_id = inspection.object_id.picking_id
@api.multi
@api.depends("object_id") @api.depends("object_id")
def _compute_lot(self): def _compute_lot(self):
moves = self.filtered( moves = self.filtered(
@@ -57,7 +60,6 @@ class QcInspection(models.Model):
elif inspection.object_id._name == "stock.production.lot": elif inspection.object_id._name == "stock.production.lot":
inspection.lot_id = inspection.object_id inspection.lot_id = inspection.object_id
@api.multi
@api.depends("object_id") @api.depends("object_id")
def _compute_product_id(self): def _compute_product_id(self):
"""Overriden for getting the product from a stock move.""" """Overriden for getting the product from a stock move."""
@@ -79,11 +81,8 @@ class QcInspection(models.Model):
elif self.object_id._name == "stock.move.line": elif self.object_id._name == "stock.move.line":
self.qty = self.object_id.product_qty self.qty = self.object_id.product_qty
@api.multi
def _prepare_inspection_header(self, object_ref, trigger_line): def _prepare_inspection_header(self, object_ref, trigger_line):
res = super(QcInspection, self)._prepare_inspection_header( res = super()._prepare_inspection_header(object_ref, trigger_line)
object_ref, trigger_line
)
# Fill qty when coming from pack operations # Fill qty when coming from pack operations
if object_ref and object_ref._name == "stock.move.line": if object_ref and object_ref._name == "stock.move.line":
res["qty"] = object_ref.product_qty res["qty"] = object_ref.product_qty

View File

@@ -52,7 +52,6 @@ class StockPicking(models.Model):
picking.passed_inspections + picking.failed_inspections picking.passed_inspections + picking.failed_inspections
) )
@api.multi
def action_done(self): def action_done(self):
res = super(StockPicking, self).action_done() res = super(StockPicking, self).action_done()
inspection_model = self.env["qc.inspection"] inspection_model = self.env["qc.inspection"]

View File

@@ -8,7 +8,6 @@ from odoo import api, models
class StockPickingType(models.Model): class StockPickingType(models.Model):
_inherit = "stock.picking.type" _inherit = "stock.picking.type"
@api.multi
def _create_qc_trigger(self): def _create_qc_trigger(self):
for picking_type in self: for picking_type in self:
qc_trigger = { qc_trigger = {
@@ -25,7 +24,6 @@ class StockPickingType(models.Model):
picking_types._create_qc_trigger() picking_types._create_qc_trigger()
return picking_types return picking_types
@api.multi
def write(self, vals): def write(self, vals):
res = super(StockPickingType, self).write(vals) res = super(StockPickingType, self).write(vals)
if vals.get("name") or vals.get("warehouse_id"): if vals.get("name") or vals.get("warehouse_id"):

View File

@@ -3,3 +3,4 @@
* Simone Rubino <simone.rubino@agilebg.com> * Simone Rubino <simone.rubino@agilebg.com>
* Andrii Skrypka <andrijskrypa@ukr.net> * Andrii Skrypka <andrijskrypa@ukr.net>
* Ignacio José Alés <ignacio.ales@guadaltech.es> * Ignacio José Alés <ignacio.ales@guadaltech.es>
* Pimolnat Suntian <pimolnats@ecosoft.co.th>

View File

@@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! 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/manufacture/tree/12.0/quality_control_stock"><img alt="OCA/manufacture" src="https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/manufacture-12-0/manufacture-12-0-quality_control_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/129/12.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/manufacture/tree/13.0/quality_control_stock"><img alt="OCA/manufacture" src="https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/manufacture-13-0/manufacture-13-0-quality_control_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/129/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module defines triggers that creates inspections when stock moves are done.</p> <p>This module defines triggers that creates inspections when stock moves are done.</p>
<p>It also adds some shortcuts on picking and lots to these inspections.</p> <p>It also adds some shortcuts on picking and lots to these inspections.</p>
<p><strong>Table of contents</strong></p> <p><strong>Table of contents</strong></p>
@@ -394,7 +394,7 @@ ul.auto-toc {
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/manufacture/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/manufacture/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/manufacture/issues/new?body=module:%20quality_control_stock%0Aversion:%2012.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/manufacture/issues/new?body=module:%20quality_control_stock%0Aversion:%2013.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> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@@ -416,6 +416,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Simone Rubino &lt;<a class="reference external" href="mailto:simone.rubino&#64;agilebg.com">simone.rubino&#64;agilebg.com</a>&gt;</li> <li>Simone Rubino &lt;<a class="reference external" href="mailto:simone.rubino&#64;agilebg.com">simone.rubino&#64;agilebg.com</a>&gt;</li>
<li>Andrii Skrypka &lt;<a class="reference external" href="mailto:andrijskrypa&#64;ukr.net">andrijskrypa&#64;ukr.net</a>&gt;</li> <li>Andrii Skrypka &lt;<a class="reference external" href="mailto:andrijskrypa&#64;ukr.net">andrijskrypa&#64;ukr.net</a>&gt;</li>
<li>Ignacio José Alés &lt;<a class="reference external" href="mailto:ignacio.ales&#64;guadaltech.es">ignacio.ales&#64;guadaltech.es</a>&gt;</li> <li>Ignacio José Alés &lt;<a class="reference external" href="mailto:ignacio.ales&#64;guadaltech.es">ignacio.ales&#64;guadaltech.es</a>&gt;</li>
<li>Pimolnat Suntian &lt;<a class="reference external" href="mailto:pimolnats&#64;ecosoft.co.th">pimolnats&#64;ecosoft.co.th</a>&gt;</li>
</ul> </ul>
</div> </div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
@@ -425,7 +426,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/manufacture/tree/12.0/quality_control_stock">OCA/manufacture</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/manufacture/tree/13.0/quality_control_stock">OCA/manufacture</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> <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> </div>

View File

@@ -20,8 +20,10 @@ class TestQualityControl(TransactionCase):
self.test = self.env.ref("quality_control.qc_test_1") self.test = self.env.ref("quality_control.qc_test_1")
self.picking_type = self.env.ref("stock.picking_type_out") self.picking_type = self.env.ref("stock.picking_type_out")
self.location_dest = self.env.ref("stock.stock_location_customers") self.location_dest = self.env.ref("stock.stock_location_customers")
self.sequence = self.env["ir.sequence"].search( self.group_stock_user = self.env.ref("stock.group_stock_user")
[("prefix", "like", "/OUT/")], limit=1 self.company = self.env.ref("base.main_company")
self.sequence = self.env["ir.sequence"].create(
{"code": "out", "name": "outgoing_sequence"}
) )
inspection_lines = self.inspection_model._prepare_inspection_lines(self.test) inspection_lines = self.inspection_model._prepare_inspection_lines(self.test)
self.inspection1 = self.inspection_model.create( self.inspection1 = self.inspection_model.create(
@@ -31,12 +33,14 @@ class TestQualityControl(TransactionCase):
[("picking_type_id", "=", self.picking_type.id)] [("picking_type_id", "=", self.picking_type.id)]
) )
self.lot = self.env["stock.production.lot"].create( self.lot = self.env["stock.production.lot"].create(
{"name": "Lot for tests", "product_id": self.product.id} {
"name": "Lot for tests",
"product_id": self.product.id,
"company_id": self.company.id,
}
) )
self.group_stock_user = self.env.ref("stock.group_stock_user")
self.company1 = self.env.ref("base.main_company")
self.user1_id = self._create_user( self.user1_id = self._create_user(
"user_1", [self.group_stock_user], self.company1 "user_1", [self.group_stock_user], self.company
) )
move_vals = { move_vals = {
@@ -49,7 +53,7 @@ class TestQualityControl(TransactionCase):
"quantity_done": 1.0, "quantity_done": 1.0,
} }
self.picking1 = ( self.picking1 = (
self.picking_model.sudo(self.user1_id) self.picking_model.with_user(self.user1_id)
.with_context(default_picking_type_id=self.picking_type.id) .with_context(default_picking_type_id=self.picking_type.id)
.create( .create(
{ {
@@ -296,6 +300,7 @@ class TestQualityControl(TransactionCase):
{ {
"name": "Test Picking Type", "name": "Test Picking Type",
"code": "outgoing", "code": "outgoing",
"sequence_code": "OUT",
"sequence_id": self.sequence.id, "sequence_id": self.sequence.id,
} }
) )