Skip to content

Commit

Permalink
[MIG] Migration of sale_mrp_link to 11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
humanesj authored and NachoAlesLopez committed Dec 31, 2019
1 parent 34776c4 commit 47681f3
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 46 deletions.
11 changes: 6 additions & 5 deletions sale_mrp_link/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Sale MRP Link
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/sale-workflow/tree/10.0/sale_mrp_link
:target: https://github.com/OCA/sale-workflow/tree/12.0/sale_mrp_link
:alt: OCA/sale-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/sale-workflow-10-0/sale-workflow-10-0-sale_mrp_link
:target: https://translation.odoo-community.org/projects/sale-workflow-12-0/sale-workflow-12-0-sale_mrp_link
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/167/10.0
:target: https://runbot.odoo-community.org/runbot/167/12.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -51,7 +51,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-workflow/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/sale-workflow/issues/new?body=module:%20sale_mrp_link%0Aversion:%2010.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_mrp_link%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.

Expand All @@ -69,6 +69,7 @@ Contributors

* Florian da Costa <[email protected]>
* Alex Comba <[email protected]>
* Juan Humanes <[email protected]>

Maintainers
~~~~~~~~~~~
Expand All @@ -83,6 +84,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/sale-workflow <https://github.com/OCA/sale-workflow/tree/10.0/sale_mrp_link>`_ project on GitHub.
This module is part of the `OCA/sale-workflow <https://github.com/OCA/sale-workflow/tree/12.0/sale_mrp_link>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 0 additions & 2 deletions sale_mrp_link/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# -*- coding: utf-8 -*-

from . import models
4 changes: 2 additions & 2 deletions sale_mrp_link/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Alex Comba - Agile Business Group
# Copyright 2016-2018 Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
'name': 'Sale MRP Link',
'summary': 'Show manufacturing orders generated from sales order',
'version': '10.0.1.0.0',
'version': '11.0.1.0.0',
'development_status': 'Production/Stable',
'category': 'Sales Management',
'website': 'https://github.com/OCA/sale-workflow',
Expand Down
3 changes: 0 additions & 3 deletions sale_mrp_link/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
# -*- coding: utf-8 -*-

from . import mrp_production
from . import procurement_order
from . import sale_order
24 changes: 22 additions & 2 deletions sale_mrp_link/models/mrp_production.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,33 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Alex Comba - Agile Business Group
# Copyright 2016-2018 Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models
from odoo import api, fields, models


class MrpProduction(models.Model):
_inherit = 'mrp.production'

sale_order_id = fields.Many2one(
comodel_name='sale.order', string='Source Sale Order')

@api.model
def create(self, values):
if 'origin' in values:
# Checking first if this comes from a 'sale.order'
sale_id = self.env['sale.order'].search([
('name', '=', values['origin'])
], limit=1)
if sale_id:
values['sale_order_id'] = sale_id.id
if sale_id.client_order_ref:
values['origin'] = sale_id.client_order_ref
else:
# Checking if this production comes from a route
production_id = self.env['mrp.production'].search([
('name', '=', values['origin'])
])
# If so, use the 'sale_order_id' from the parent production
values['sale_order_id'] = production_id.sale_order_id.id

return super(MrpProduction, self).create(values)
22 changes: 0 additions & 22 deletions sale_mrp_link/models/procurement_order.py

This file was deleted.

1 change: 0 additions & 1 deletion sale_mrp_link/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Alex Comba - Agile Business Group
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

Expand Down
1 change: 1 addition & 0 deletions sale_mrp_link/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
* Florian da Costa <[email protected]>
* Alex Comba <[email protected]>
* Juan Humanes <[email protected]>
7 changes: 4 additions & 3 deletions sale_mrp_link/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Sale MRP Link</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="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.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/sale-workflow/tree/10.0/sale_mrp_link"><img alt="OCA/sale-workflow" src="https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/sale-workflow-10-0/sale-workflow-10-0-sale_mrp_link"><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/167/10.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="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.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/sale-workflow/tree/12.0/sale_mrp_link"><img alt="OCA/sale-workflow" src="https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/sale-workflow-12-0/sale-workflow-12-0-sale_mrp_link"><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/167/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module adds a link between the manufacturing orders and the associated sale order.
A button shown in the form view of sale orders allow the user to access to the related manufacturing orders.</p>
<p><strong>Table of contents</strong></p>
Expand Down Expand Up @@ -399,7 +399,7 @@ <h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/sale-workflow/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/sale-workflow/issues/new?body=module:%20sale_mrp_link%0Aversion:%2010.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/sale-workflow/issues/new?body=module:%20sale_mrp_link%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">
Expand All @@ -416,6 +416,7 @@ <h2><a class="toc-backref" href="#id5">Contributors</a></h2>
<ul class="simple">
<li>Florian da Costa &lt;<a class="reference external" href="mailto:florian.dacosta&#64;akretion.com">florian.dacosta&#64;akretion.com</a>&gt;</li>
<li>Alex Comba &lt;<a class="reference external" href="mailto:alex.comba&#64;agilebg.com">alex.comba&#64;agilebg.com</a>&gt;</li>
<li>Juan Humanes &lt;<a class="reference external" href="mailto:juan.humanes&#64;guadaltech.es">juan.humanes&#64;guadaltech.es</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand All @@ -425,7 +426,7 @@ <h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
<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/sale-workflow/tree/10.0/sale_mrp_link">OCA/sale-workflow</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/sale-workflow/tree/12.0/sale_mrp_link">OCA/sale-workflow</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
23 changes: 17 additions & 6 deletions sale_mrp_link/tests/test_mrp_sale_link.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Alex Comba - Agile Business Group
# Copyright 2016-2018 Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
Expand Down Expand Up @@ -38,21 +37,26 @@ def _create_product(self, name, route_ids):
'type': 'product',
'route_ids': route_ids})

def _create_sale_order(self, partner):
return self.env['sale.order'].create({'partner_id': partner.id})
def _create_sale_order(self, partner, client_ref):
return self.env['sale.order'].create({
'partner_id': partner.id,
'client_order_ref': client_ref
})

def _create_sale_order_line(self, sale_order, product, qty, price):
self.env['sale.order.line'].create({
'order_id': sale_order.id,
'product_id': product.id,
'price_unit': price,
'product_uom_qty': qty})
'product_uom_qty': qty,

})

def test_sale_to_only_one_mo(self):
"""Check manufactured order is linked to the sale order."""
bom = self._create_bom(self.product_a.product_tmpl_id)
self._create_bom_line(bom, self.product_c, 1)
so = self._create_sale_order(self.partner)
so = self._create_sale_order(self.partner, "SO1")
self._create_sale_order_line(so, self.product_a, 1, 10.0)
so.action_confirm()
mo = self.env['mrp.production'].search(
Expand All @@ -61,6 +65,8 @@ def test_sale_to_only_one_mo(self):
action = so.action_view_production()
res_id = action['res_id']
self.assertEqual(res_id, mo.id)
self.assertEqual(len(mo), so.production_count)
self.assertEqual(so.client_order_ref, mo.origin)

def test_sale_to_several_mo(self):
"""Check manufactured orders are linked to the sale order."""
Expand All @@ -69,7 +75,7 @@ def test_sale_to_several_mo(self):
bom_a = self._create_bom(self.product_a.product_tmpl_id)
self._create_bom_line(bom_a, self.product_c, 1)
self._create_bom_line(bom_a, self.product_b, 1)
so = self._create_sale_order(self.partner)
so = self._create_sale_order(self.partner, "SO2")
self._create_sale_order_line(so, self.product_a, 1, 10.0)
so.action_confirm()
mo = self.env['mrp.production'].search(
Expand All @@ -78,3 +84,8 @@ def test_sale_to_several_mo(self):
action = so.action_view_production()
mo_ids = action.get('domain')[0][2]
self.assertEqual(mo.ids, mo_ids)
self.assertEqual(len(mo), so.production_count)
# The first MO will be the one that comes from the SO, the other one
# should have the same origin as the first MO.
self.assertEqual(so.client_order_ref, mo[0].origin)
self.assertEqual(mo[0].origin, mo[1].origin)

0 comments on commit 47681f3

Please sign in to comment.