mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[MIG] mrp_production_service: Migration to 11.0
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
|
||||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||
:alt: License: AGPL-3
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
MRP Production Service
|
||||
======================
|
||||
|
||||
This module allows to create procurement orders from manufacturing orders when
|
||||
a services is included in the Bill of Materials.
|
||||
Creates procurement orders from manufacturing orders, for services included
|
||||
in the Bill of Materials.
|
||||
|
||||
This allows users to include additional services that has to be procured as
|
||||
This allows users to include additional services that are to be procured as
|
||||
part of the manufacturing process.
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ Usage
|
||||
|
||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||
:alt: Try me on Runbot
|
||||
:target: https://runbot.odoo-community.org/runbot/129/10.0
|
||||
:target: https://runbot.odoo-community.org/runbot/129/8.0
|
||||
|
||||
|
||||
Bug Tracker
|
||||
@@ -35,13 +35,12 @@ Credits
|
||||
Images
|
||||
------
|
||||
|
||||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.png>`_.
|
||||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
|
||||
* Héctor Villarreal Ortega <hector.villarreal@eficent.com>
|
||||
|
||||
|
||||
Maintainer
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 Eficent Business and IT Consulting Services S.L.
|
||||
# (http://www.eficent.com)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 Eficent Business and IT Consulting Services S.L.
|
||||
# (http://www.eficent.com)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
@@ -6,12 +5,13 @@
|
||||
"name": "MRP Production Service",
|
||||
"summary": "Creates procurement orders from manufacturing orders, for "
|
||||
"services included in the Bill of Materials",
|
||||
"version": "10.0.1.0.0",
|
||||
"version": "11.0.1.0.0",
|
||||
"author": "Eficent,"
|
||||
"Odoo Community Association (OCA)",
|
||||
"website": "https://www.odoo-community.org",
|
||||
"category": "Warehouse Management",
|
||||
"depends": ["mrp"],
|
||||
"depends": ["mrp",
|
||||
"subcontracted_service"],
|
||||
"license": "AGPL-3",
|
||||
'installable': True,
|
||||
'application': False,
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 Eficent Business and IT Consulting Services S.L.
|
||||
# (http://www.eficent.com)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
from . import mrp_production
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2016 Eficent Business and IT Consulting Services S.L.
|
||||
# (http://www.eficent.com)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
@@ -10,28 +9,36 @@ class MrpProduction(models.Model):
|
||||
_inherit = "mrp.production"
|
||||
|
||||
@api.model
|
||||
def _prepare_service_procurement(self, line, production):
|
||||
def _prepare_service_procurement_values(self, production):
|
||||
location = production.location_src_id
|
||||
return {
|
||||
'name': '%s for %s' % (line.product_id.name, production.name),
|
||||
'origin': production.origin,
|
||||
'company_id': production.company_id.id,
|
||||
'date_planned_start': production.date_planned_start,
|
||||
'product_id': line.product_id.id,
|
||||
'product_qty': line.product_qty,
|
||||
'product_uom': line.product_uom_id.id,
|
||||
'location_id': location.id,
|
||||
'warehouse_id': location.get_warehouse().id
|
||||
'company_id': production.company_id,
|
||||
'date_planned': production.date_planned_start,
|
||||
'warehouse_id': location.get_warehouse(),
|
||||
'group_id': production.procurement_group_id,
|
||||
}
|
||||
|
||||
@api.model
|
||||
def _create_service_procurement(self, line, production):
|
||||
data = self._prepare_service_procurement(line, production)
|
||||
return self.env['procurement.order'].create(data)
|
||||
def _create_service_procurement(self, line):
|
||||
data = self._prepare_service_procurement(line)
|
||||
return self.env['procurement.rule'].create(data)
|
||||
|
||||
@api.model
|
||||
def _action_launch_procurement_rule(self, line, production):
|
||||
values = self._prepare_service_procurement_values(production)
|
||||
|
||||
name = '%s for %s' % (line.product_id.name,
|
||||
production.name)
|
||||
self.env['procurement.group'].sudo().run(
|
||||
line.product_id, line.product_qty,
|
||||
line.product_uom_id,
|
||||
production.location_src_id, name,
|
||||
name, values)
|
||||
return True
|
||||
|
||||
@api.multi
|
||||
def _generate_moves(self):
|
||||
res = super(MrpProduction, self)._generate_moves()
|
||||
res = super()._generate_moves()
|
||||
for production in self:
|
||||
factor = production.product_uom_id._compute_quantity(
|
||||
production.product_qty,
|
||||
@@ -42,5 +49,6 @@ class MrpProduction(models.Model):
|
||||
picking_type=production.bom_id.picking_type_id)
|
||||
for line in lines:
|
||||
if line[0].product_id.type == 'service':
|
||||
self._create_service_procurement(line[0], production)
|
||||
production._action_launch_procurement_rule(line[0],
|
||||
production)
|
||||
return res
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from . import test_mrp_production_service
|
||||
@@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2018 Eficent Business and IT Consulting Services S.L.
|
||||
# (http://www.eficent.com)
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||
@@ -9,14 +8,31 @@ from odoo.tests.common import TransactionCase
|
||||
class TestMrpProductionService(TransactionCase):
|
||||
def setUp(self):
|
||||
super(TestMrpProductionService, self).setUp()
|
||||
# Create products
|
||||
product_model = self.env['product.product']
|
||||
self.p1 = product_model.create({'name': '101'})
|
||||
self.p2 = product_model.create({'name': '201P'})
|
||||
self.p3 = product_model.create({'name': '202P'})
|
||||
self.service = product_model.create({'name': 'Assembly Service',
|
||||
'type': 'service'})
|
||||
|
||||
# Create products
|
||||
self.obj_warehouse = self.env['stock.warehouse']
|
||||
self.test_wh = self.obj_warehouse.create({
|
||||
'name': 'Test WH',
|
||||
'code': 'T',
|
||||
})
|
||||
self.supplier = self.env['res.partner'].create({
|
||||
'name': 'Supplier',
|
||||
'supplier': True,
|
||||
})
|
||||
self.product_model = self.env['product.product']
|
||||
self.p1 = self.product_model.create({
|
||||
'name': '101',
|
||||
'type': 'product',
|
||||
})
|
||||
self.service = self.product_model.create({
|
||||
'name': 'Galvanize Service',
|
||||
'type': 'service',
|
||||
'seller_ids': [(0, 0, {
|
||||
'name': self.supplier.id,
|
||||
'price': 100.0,
|
||||
})]
|
||||
})
|
||||
self.service.property_subcontracted_service = True
|
||||
# Create bill of materials
|
||||
self.bom_model = self.env['mrp.bom']
|
||||
self.bom = self.bom_model.create({
|
||||
@@ -27,16 +43,6 @@ class TestMrpProductionService(TransactionCase):
|
||||
})
|
||||
# Create bom lines
|
||||
self.bom_line_model = self.env['mrp.bom.line']
|
||||
self.bom_line_model.create({
|
||||
'bom_id': self.bom.id,
|
||||
'product_id': self.p2.id,
|
||||
'product_qty': 1,
|
||||
})
|
||||
self.bom_line_model.create({
|
||||
'bom_id': self.bom.id,
|
||||
'product_id': self.p3.id,
|
||||
'product_qty': 1,
|
||||
})
|
||||
self.bom_line_model.create({
|
||||
'bom_id': self.bom.id,
|
||||
'product_id': self.service.id,
|
||||
@@ -54,7 +60,7 @@ class TestMrpProductionService(TransactionCase):
|
||||
'bom_id': self.bom.id
|
||||
})
|
||||
|
||||
procurement = self.env['procurement.order'].search(
|
||||
procurement = self.env['purchase.order.line'].search(
|
||||
[('product_id', 'in',
|
||||
self.bom.bom_line_ids.mapped('product_id.id'))])
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# List the OCA project dependencies, one per line
|
||||
# Add a repository url and branch if you need a forked version
|
||||
product-attribute
|
||||
purchase-workflow
|
||||
|
||||
Reference in New Issue
Block a user