mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[FIX+IMP] mrp_sale_info: Isolate procurement group + tests
This commit is contained in:
committed by
Kevin Khao
parent
4cbca4f229
commit
87be1b473f
@@ -25,7 +25,8 @@ MRP Sale Info
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
|
||||
This module extends the functionality of sale_mrp and adds related fields to Manufacturing Orders and Work Orders:
|
||||
This module extends the functionality of Odoo for adding related fields to
|
||||
Manufacturing Orders and Work Orders:
|
||||
|
||||
* Sale order
|
||||
* Customer
|
||||
@@ -63,11 +64,15 @@ Authors
|
||||
Contributors
|
||||
~~~~~~~~~~~~
|
||||
|
||||
* Rafael Blasco <rafabn@antiun.com>
|
||||
* Antonio Espinosa <antonioea@antiun.com>
|
||||
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
|
||||
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
|
||||
* Ana Juaristi <anajuaristi@avanzosc.es>
|
||||
* `AvanzOsc <http://www.avanzosc.es>`_:
|
||||
|
||||
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
|
||||
* Ana Juaristi <anajuaristi@avanzosc.es>
|
||||
* `Tecnativa <https://www.tecnativa.com>`_:
|
||||
|
||||
* Antonio Espinosa
|
||||
* Rafael Blasco
|
||||
* Pedro M. Baeza
|
||||
* Rubén Bravo <rubenred18@gmail.com>
|
||||
|
||||
Maintainers
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# Copyright 2016 Antiun Ingenieria S.L. - Javier Iniesta
|
||||
# Copyright 2019 Rubén Bravo <rubenred18@gmail.com>
|
||||
# Copyright 2020 Tecnativa - Pedro M. Baeza
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
{
|
||||
"name": "MRP Sale Info",
|
||||
@@ -15,8 +16,6 @@
|
||||
'installable': True,
|
||||
"depends": [
|
||||
"mrp",
|
||||
"sale_mrp",
|
||||
"stock",
|
||||
"sale_stock",
|
||||
],
|
||||
"data": [
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# Copyright 2016 Antiun Ingenieria S.L. - Javier Iniesta
|
||||
# Copyright 2019 Rubén Bravo <rubenred18@gmail.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import mrp_production
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# Copyright 2016 Antiun Ingenieria S.L. - Javier Iniesta
|
||||
# Copyright 2019 Rubén Bravo <rubenred18@gmail.com>
|
||||
# Copyright 2020 Tecnativa - Pedro M. Baeza
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo import fields, models
|
||||
@@ -8,9 +9,12 @@ from odoo import fields, models
|
||||
class MrpProduction(models.Model):
|
||||
_inherit = "mrp.production"
|
||||
|
||||
source_procurement_group_id = fields.Many2one(
|
||||
comodel_name='procurement.group', readonly=True,
|
||||
)
|
||||
sale_id = fields.Many2one(
|
||||
comodel_name='sale.order', string='Sale order', readonly=True,
|
||||
store=True, related='procurement_group_id.sale_id')
|
||||
store=True, related='source_procurement_group_id.sale_id')
|
||||
partner_id = fields.Many2one(
|
||||
comodel_name='res.partner', related='sale_id.partner_id',
|
||||
string='Customer', store=True)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# Copyright 2019 Rubén Bravo <rubenred18@gmail.com>
|
||||
# Copyright 2020 Tecnativa - Pedro M. Baeza
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
||||
|
||||
from odoo import models
|
||||
@@ -13,8 +14,6 @@ class StockRule(models.Model):
|
||||
product_id, product_qty, product_uom, location_id, name,
|
||||
origin, values, bom
|
||||
)
|
||||
res.update({
|
||||
'procurement_group_id': values.get(
|
||||
'group_id').id if values.get('group_id', False) else False,
|
||||
})
|
||||
res["source_procurement_group_id"] = values.get(
|
||||
"group_id").id if values.get('group_id', False) else False
|
||||
return res
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
* Rafael Blasco <rafabn@antiun.com>
|
||||
* Antonio Espinosa <antonioea@antiun.com>
|
||||
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
|
||||
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
|
||||
* Ana Juaristi <anajuaristi@avanzosc.es>
|
||||
* `AvanzOsc <http://www.avanzosc.es>`_:
|
||||
|
||||
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
|
||||
* Ana Juaristi <anajuaristi@avanzosc.es>
|
||||
* `Tecnativa <https://www.tecnativa.com>`_:
|
||||
|
||||
* Antonio Espinosa
|
||||
* Rafael Blasco
|
||||
* Pedro M. Baeza
|
||||
* Rubén Bravo <rubenred18@gmail.com>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
This module extends the functionality of sale_mrp and adds related fields to Manufacturing Orders and Work Orders:
|
||||
This module extends the functionality of Odoo for adding related fields to
|
||||
Manufacturing Orders and Work Orders:
|
||||
|
||||
* Sale order
|
||||
* Customer
|
||||
|
||||
@@ -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.14: http://docutils.sourceforge.net/" />
|
||||
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
|
||||
<title>MRP Sale Info</title>
|
||||
<style type="text/css">
|
||||
|
||||
@@ -368,7 +368,8 @@ ul.auto-toc {
|
||||
!! 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/mrp_sale_info"><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-mrp_sale_info"><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 extends the functionality of sale_mrp and adds related fields to Manufacturing Orders and Work Orders:</p>
|
||||
<p>This module extends the functionality of Odoo for adding related fields to
|
||||
Manufacturing Orders and Work Orders:</p>
|
||||
<blockquote>
|
||||
<ul class="simple">
|
||||
<li>Sale order</li>
|
||||
@@ -413,11 +414,17 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||
<div class="section" id="contributors">
|
||||
<h2><a class="toc-backref" href="#id5">Contributors</a></h2>
|
||||
<ul class="simple">
|
||||
<li>Rafael Blasco <<a class="reference external" href="mailto:rafabn@antiun.com">rafabn@antiun.com</a>></li>
|
||||
<li>Antonio Espinosa <<a class="reference external" href="mailto:antonioea@antiun.com">antonioea@antiun.com</a>></li>
|
||||
<li><a class="reference external" href="http://www.avanzosc.es">AvanzOsc</a>:<ul>
|
||||
<li>Oihane Crucelaegui <<a class="reference external" href="mailto:oihanecrucelaegi@avanzosc.es">oihanecrucelaegi@avanzosc.es</a>></li>
|
||||
<li>Pedro M. Baeza <<a class="reference external" href="mailto:pedro.baeza@serviciosbaeza.com">pedro.baeza@serviciosbaeza.com</a>></li>
|
||||
<li>Ana Juaristi <<a class="reference external" href="mailto:anajuaristi@avanzosc.es">anajuaristi@avanzosc.es</a>></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
|
||||
<li>Antonio Espinosa</li>
|
||||
<li>Rafael Blasco</li>
|
||||
<li>Pedro M. Baeza</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Rubén Bravo <<a class="reference external" href="mailto:rubenred18@gmail.com">rubenred18@gmail.com</a>></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
3
mrp_sale_info/tests/__init__.py
Normal file
3
mrp_sale_info/tests/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import test_mrp_sale_info
|
||||
39
mrp_sale_info/tests/test_mrp_sale_info.py
Normal file
39
mrp_sale_info/tests/test_mrp_sale_info.py
Normal file
@@ -0,0 +1,39 @@
|
||||
# Copyright 2020 Tecnativa - Pedro M. Baeza
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from odoo.tests import common
|
||||
|
||||
|
||||
class TestMrpSaleInfo(common.SavepointCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.product = cls.env["product.product"].create({
|
||||
"name": "Test mrp_sale_info product",
|
||||
"type": "product",
|
||||
"route_ids": [
|
||||
(4, cls.env.ref("mrp.route_warehouse0_manufacture").id),
|
||||
(4, cls.env.ref("stock.route_warehouse0_mto").id),
|
||||
],
|
||||
})
|
||||
cls.bom = cls.env["mrp.bom"].create({
|
||||
"product_tmpl_id": cls.product.product_tmpl_id.id,
|
||||
})
|
||||
cls.partner = cls.env["res.partner"].create({"name": "Test client"})
|
||||
cls.sale_order = cls.env["sale.order"].create({
|
||||
"partner_id": cls.partner.id,
|
||||
"order_line": [
|
||||
(0, 0, {
|
||||
"product_id": cls.product.id,
|
||||
"product_uom_qty": 1,
|
||||
"price_unit": 1,
|
||||
}),
|
||||
]
|
||||
})
|
||||
|
||||
def test_mrp_sale_info(self):
|
||||
prev_productions = self.env["mrp.production"].search([])
|
||||
self.sale_order.action_confirm()
|
||||
production = self.env["mrp.production"].search([]) - prev_productions
|
||||
self.assertEqual(production.sale_id, self.sale_order)
|
||||
self.assertEqual(production.partner_id, self.partner)
|
||||
Reference in New Issue
Block a user