[MIG] quality_control_stock: Migration to 12.0

This commit is contained in:
Ignacio Ales
2019-05-28 11:07:26 +02:00
committed by Enrique Martín
parent 493008b87d
commit 01442b9b87
11 changed files with 72 additions and 72 deletions

View File

@@ -14,13 +14,13 @@ Quality control - 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%2Fmanufacture-lightgray.png?logo=github
:target: https://github.com/OCA/manufacture/tree/11.0/quality_control_stock
:target: https://github.com/OCA/manufacture/tree/12.0/quality_control_stock
:alt: OCA/manufacture
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/manufacture-11-0/manufacture-11-0-quality_control_stock
:target: https://translation.odoo-community.org/projects/manufacture-12-0/manufacture-12-0-quality_control_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/129/11.0
:target: https://runbot.odoo-community.org/runbot/129/12.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -45,7 +45,7 @@ Bug Tracker
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.
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:%2011.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:%2012.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.
@@ -66,6 +66,7 @@ Contributors
* Pedro M. Baeza <pedro.baeza@serviciobaeza.com>
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
* Simone Rubino <simone.rubino@agilebg.com>
* Ignacio José Alés <ignacio.ales@guadaltech.es>
Maintainers
~~~~~~~~~~~
@@ -80,6 +81,6 @@ 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/manufacture <https://github.com/OCA/manufacture/tree/11.0/quality_control_stock>`_ project on GitHub.
This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/12.0/quality_control_stock>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@@ -5,7 +5,7 @@
{
"name": "Quality control - Stock",
"version": "11.0.1.0.0",
"version": "12.0.1.0.0",
"category": "Quality control",
"license": "AGPL-3",
"author": "OdooMRP team, "
@@ -13,7 +13,7 @@
"Serv. Tecnol. Avanzados - Pedro M. Baeza, "
"Agile Business Group, "
"Odoo Community Association (OCA)",
"website": "https://github.com/OCA/manufacture/tree/11.0/"
"website": "https://github.com/OCA/manufacture/tree/12.0/"
"quality_control_stock",
"depends": [
"quality_control",
@@ -21,7 +21,6 @@
],
"data": [
"security/ir.model.access.csv",
"data/quality_control_stock_data.xml",
"views/qc_inspection_view.xml",
"views/stock_picking_view.xml",
"views/stock_production_lot_view.xml",

View File

@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 Simone Rubino - Agile Business Group
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<data noupdate="1">
<record id="req_link_stock_move" model="res.request.link">
<field name="name">Stock Move</field>
<field name="object">stock.move</field>
</record>
<record id="req_link_stock_picking" model="res.request.link">
<field name="name">Picking List</field>
<field name="object">stock.picking</field>
</record>
</data>
</odoo>

View File

@@ -75,12 +75,12 @@ msgid "Picking"
msgstr ""
#. module: quality_control_stock
#: model:res.request.link,name:quality_control_stock.req_link_stock_picking
#: code:addons/quality_control_stock/models/qc_inspection.py:14
msgid "Picking List"
msgstr ""
msgstr ""c
#. module: quality_control_stock
#: model:ir.model.fields,field_description:quality_control_stock.field_qc_trigger_picking_type_id
#: model:ir.model.fields,field_descrption:quality_control_stock.field_qc_trigger_picking_type_id
msgid "Picking Type"
msgstr ""
@@ -140,7 +140,7 @@ msgid "Quality inspections from picking failed"
msgstr ""
#. module: quality_control_stock
#: model:res.request.link,name:quality_control_stock.req_link_stock_move
#: code:addons/quality_control_stock/models/qc_inspection.py:14
msgid "Stock Move"
msgstr ""

View File

@@ -3,16 +3,29 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
from odoo.fields import first
class QcInspection(models.Model):
_inherit = 'qc.inspection'
picking_id = fields.Many2one(
comodel_name="stock.picking", compute="_compute_picking", store=True)
lot_id = fields.Many2one(
comodel_name='stock.production.lot', compute="_compute_lot",
store=True)
@api.multi
def object_selection_values(self):
result = super().object_selection_values()
result.extend([
('stock.picking', "Picking List"), ('stock.move', "Stock Move")])
return result
@api.multi
@api.depends('object_id')
def _compute_picking(self):
for inspection in self:
inspection.picking_id = False
if inspection.object_id:
if inspection.object_id._name == 'stock.move':
inspection.picking_id = inspection.object_id.picking_id
@@ -24,18 +37,22 @@ class QcInspection(models.Model):
@api.multi
@api.depends('object_id')
def _compute_lot(self):
moves = self.filtered(
lambda i: i.object_id and
i.object_id._name == 'stock.move').mapped('object_id')
move_lines = self.env['stock.move.line'].search([
('lot_id', '!=', False),
('move_id', 'in', [move.id for move in moves])])
for inspection in self:
inspection.lot_id = False
if inspection.object_id:
if inspection.object_id._name == 'stock.move.line':
inspection.lot_id = \
inspection.object_id.lot_id
elif inspection.object_id._name == 'stock.move':
inspection.lot_id = \
self.env['stock.move.line'].search([
('lot_id', '!=', False),
('move_id', '=', inspection.object_id.id)
])[:1].lot_id
inspection.lot_id = first(move_lines.filtered(
lambda line: line.move_id == inspection.object_id
)).lot_id
elif inspection.object_id._name == 'stock.production.lot':
inspection.lot_id = inspection.object_id
@@ -72,12 +89,6 @@ class QcInspection(models.Model):
res['qty'] = object_ref.product_uom_qty
return res
picking_id = fields.Many2one(
comodel_name="stock.picking", compute="_compute_picking", store=True)
lot_id = fields.Many2one(
comodel_name='stock.production.lot', compute="_compute_lot",
store=True)
class QcInspectionLine(models.Model):
_inherit = 'qc.inspection.line'

View File

@@ -40,9 +40,9 @@ class StockPicking(models.Model):
def action_done(self):
res = super(StockPicking, self).action_done()
inspection_model = self.env['qc.inspection']
for operation in self.move_lines:
qc_trigger = self.env['qc.trigger'].search(
[('picking_type_id', '=', self.picking_type_id.id)])
for operation in self.move_lines:
trigger_lines = set()
for model in ['qc.trigger.product_category_line',
'qc.trigger.product_template_line',

View File

@@ -10,20 +10,20 @@ class StockPickingType(models.Model):
@api.multi
def _create_qc_trigger(self):
self.ensure_one()
for picking_type in self:
qc_trigger = {
'name': self.name,
'company_id': self.warehouse_id.company_id.id,
'picking_type_id': self.id,
'partner_selectable': True,
'name': picking_type.name,
'company_id': picking_type.warehouse_id.company_id.id,
'picking_type_id': picking_type.id,
'partner_selectable': True
}
return self.env['qc.trigger'].sudo().create(qc_trigger)
self.env['qc.trigger'].sudo().create(qc_trigger)
@api.model
def create(self, vals):
picking_type = super(StockPickingType, self).create(vals)
picking_type._create_qc_trigger()
return picking_type
@api.model_create_multi
def create(self, val_list):
picking_types = super(StockPickingType, self).create(val_list)
picking_types._create_qc_trigger()
return picking_types
@api.multi
def write(self, vals):

View File

@@ -1,3 +1,4 @@
* Pedro M. Baeza <pedro.baeza@serviciobaeza.com>
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
* Simone Rubino <simone.rubino@agilebg.com>
* Ignacio José Alés <ignacio.ales@guadaltech.es>

View File

@@ -367,7 +367,7 @@ ul.auto-toc {
!! 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/manufacture/tree/11.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-11-0/manufacture-11-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/11.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/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>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><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>.
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/manufacture/issues/new?body=module:%20quality_control_stock%0Aversion:%2011.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:%2012.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">
@@ -414,6 +414,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Pedro M. Baeza &lt;<a class="reference external" href="mailto:pedro.baeza&#64;serviciobaeza.com">pedro.baeza&#64;serviciobaeza.com</a>&gt;</li>
<li>Oihane Crucelaegui &lt;<a class="reference external" href="mailto:oihanecrucelaegi&#64;avanzosc.es">oihanecrucelaegi&#64;avanzosc.es</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>Ignacio José Alés &lt;<a class="reference external" href="mailto:ignacio.ales&#64;guadaltech.es">ignacio.ales&#64;guadaltech.es</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
@@ -423,7 +424,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
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/manufacture/tree/11.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/12.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>
</div>
</div>

View File

@@ -58,7 +58,6 @@ class TestQualityControl(TransactionCase):
'location_dest_id': self.location_dest.id
})
self.picking1.action_confirm()
self.picking1.force_assign()
sequence = 10
for line in self.picking1.move_lines.filtered(
lambda r: r.product_id == self.product):
@@ -98,7 +97,7 @@ class TestQualityControl(TransactionCase):
'test': self.test.id,
}
)]
self.picking1.do_transfer()
self.picking1.action_done()
self.assertEqual(self.picking1.created_inspections, 1,
'Only one inspection must be created')
inspection = self.picking1.qc_inspections_ids[:1]
@@ -117,7 +116,7 @@ class TestQualityControl(TransactionCase):
'test': self.test.id,
}
)]
self.picking1.do_transfer()
self.picking1.action_done()
self.assertEqual(self.picking1.created_inspections, 1,
'Only one inspection must be created')
self.assertEqual(self.picking1.qc_inspections_ids[:1].test, self.test,
@@ -130,7 +129,7 @@ class TestQualityControl(TransactionCase):
'test': self.test.id,
}
)]
self.picking1.do_transfer()
self.picking1.action_done()
self.assertEqual(self.picking1.created_inspections, 1,
'Only one inspection must be created')
self.assertEqual(self.picking1.qc_inspections_ids[:1].test, self.test,
@@ -144,7 +143,7 @@ class TestQualityControl(TransactionCase):
'partners': [(6, 0, self.partner1.ids)],
}
)]
self.picking1.do_transfer()
self.picking1.action_done()
self.assertEqual(self.picking1.created_inspections, 1,
'Only one inspection must be created')
self.assertEqual(self.picking1.qc_inspections_ids[:1].test, self.test,
@@ -158,7 +157,7 @@ class TestQualityControl(TransactionCase):
'partners': [(6, 0, self.partner1.ids)],
}
)]
self.picking1.do_transfer()
self.picking1.action_done()
self.assertEqual(self.picking1.created_inspections, 1,
'Only one inspection must be created')
self.assertEqual(self.picking1.qc_inspections_ids[:1].test, self.test,
@@ -172,7 +171,7 @@ class TestQualityControl(TransactionCase):
'partners': [(6, 0, self.partner1.ids)],
}
)]
self.picking1.do_transfer()
self.picking1.action_done()
self.assertEqual(self.picking1.created_inspections, 1,
'Only one inspection must be created')
self.assertEqual(self.picking1.qc_inspections_ids[:1].test, self.test,
@@ -186,7 +185,7 @@ class TestQualityControl(TransactionCase):
'partners': [(6, 0, self.partner2.ids)],
}
)]
self.picking1.do_transfer()
self.picking1.action_done()
self.assertEqual(self.picking1.created_inspections, 0,
'No inspection must be created')
@@ -198,7 +197,7 @@ class TestQualityControl(TransactionCase):
'partners': [(6, 0, self.partner2.ids)],
}
)]
self.picking1.do_transfer()
self.picking1.action_done()
self.assertEqual(self.picking1.created_inspections, 0,
'No inspection must be created')
@@ -210,7 +209,7 @@ class TestQualityControl(TransactionCase):
'partners': [(6, 0, self.partner2.ids)],
}
)]
self.picking1.do_transfer()
self.picking1.action_done()
self.assertEqual(self.picking1.created_inspections, 0,
'No inspection must be created')
@@ -227,7 +226,7 @@ class TestQualityControl(TransactionCase):
'test': self.test.id,
}
)]
self.picking1.do_transfer()
self.picking1.action_done()
self.assertEqual(self.picking1.created_inspections, 1,
'Only one inspection must be created')
self.assertEqual(self.picking1.qc_inspections_ids[:1].test, self.test,

View File

@@ -38,9 +38,11 @@
<group expand="0" position="inside">
<filter string="Picking"
domain="[]"
name="group_by_picking_id"
context="{'group_by': 'picking_id'}"/>
<filter string="Lot"
domain="[]"
name="group_by_lot_id"
groups="stock.group_production_lot"
context="{'group_by': 'lot_id'}"/>
</group>
@@ -71,10 +73,12 @@
<group expand="0" position="inside">
<filter string="Picking"
domain="[]"
context="{'group_by': 'picking'}"/>
name="group_by_picking_id"
context="{'group_by': 'picking_id'}"/>
<filter string="Lot"
domain="[]"
context="{'group_by': 'lot'}"/>
name="group_by_lot_id"
context="{'group_by': 'lot_id'}"/>
</group>
</field>
</record>