[MIG] repair_refurbish (mrp_repair_refurbish): Migration to 12.0

This commit is contained in:
Akim Juillerat
2019-03-12 16:10:30 +01:00
parent c9357202a6
commit f453767ea1
24 changed files with 46 additions and 22 deletions

View File

@@ -1 +0,0 @@
from . import test_mrp_repair_refurbish

View File

@@ -3,7 +3,7 @@
{
"name": "MRP Repair Refurbish",
"summary": "Create refurbished products during repair",
"version": "11.0.1.0.1",
"version": "12.0.1.0.1",
"category": "Manufacturing",
"website": "https://github.com/OCA/manufacture",
"author": "Eficent, Odoo Community Association (OCA)",
@@ -11,10 +11,10 @@
"application": False,
"installable": True,
"depends": [
'mrp_repair',
'repair',
],
"data": [
"views/mrp_repair_view.xml",
"views/repair_view.xml",
"data/stock_data.xml",
"views/product_template_view.xml",
"views/product_product_view.xml",

View File

@@ -1,3 +1,4 @@
from . import product_product
from . import product_template
from . import mrp_repair
from . import repair
from . import stock_move

View File

@@ -4,10 +4,12 @@
from odoo import api, fields, models
class MrpRepair(models.Model):
_inherit = 'mrp.repair'
class RepairOrder(models.Model):
_inherit = 'repair.order'
to_refurbish = fields.Boolean()
location_dest_id = fields.Many2one(
string='Delivery Location', comodel_name='stock.location')
refurbish_location_dest_id = fields.Many2one(
string='Refurbished Delivery Location', comodel_name='stock.location')
refurbish_product_id = fields.Many2one(
@@ -19,7 +21,7 @@ class MrpRepair(models.Model):
@api.onchange('product_id')
def onchange_product_id(self):
res = super(MrpRepair, self).onchange_product_id()
res = super().onchange_product_id()
self.to_refurbish = True if \
self.product_id.refurbish_product_id else False
return res
@@ -52,7 +54,9 @@ class MrpRepair(models.Model):
@api.multi
def action_repair_done(self):
res = super(MrpRepair, self).action_repair_done()
res = super(RepairOrder, self.with_context(
force_refurbish_location_dest_id=self.location_dest_id.id
)).action_repair_done()
for repair in self:
if repair.to_refurbish:
move = self.env['stock.move'].create(
@@ -64,7 +68,7 @@ class MrpRepair(models.Model):
class RepairLine(models.Model):
_inherit = 'mrp.repair.line'
_inherit = 'repair.line'
@api.onchange('type', 'repair_id')
def onchange_operation_type(self):

View File

@@ -0,0 +1,15 @@
# Copyright 2019 Camptocamp SA
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
from odoo import models, api
class StockMove(models.Model):
_inherit = 'stock.move'
@api.model
def create(self, vals):
if 'force_refurbish_location_dest_id' in self.env.context:
vals['location_dest_id'] = self.env.context[
'force_refurbish_location_dest_id']
return super().create(vals)

View File

@@ -1,2 +1,3 @@
* Jordi Ballester Alomar <jordi.ballester@eficent.com>
* Lois Rilo <lois.rilo@eficent.com>
* Akim Juillerat <akim.juillerat@camptocamp.com>

View File

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@@ -0,0 +1 @@
from . import test_repair_refurbish

View File

@@ -8,15 +8,15 @@ class TestMrpMtoWithStock(TransactionCase):
def setUp(self, *args, **kwargs):
super(TestMrpMtoWithStock, self).setUp(*args, **kwargs)
self.repair_obj = self.env['mrp.repair']
self.repair_line_obj = self.env['mrp.repair.line']
self.repair_obj = self.env['repair.order']
self.repair_line_obj = self.env['repair.line']
self.product_obj = self.env['product.product']
self.move_obj = self.env['stock.move']
self.stock_location_stock = self.env.ref('stock.stock_location_stock')
self.customer_location = self.env.ref('stock.stock_location_customers')
self.refurbish_loc = self.env.ref(
'mrp_repair_refurbish.stock_location_refurbish')
'repair_refurbish.stock_location_refurbish')
self.refurbish_product = self.product_obj.create({
'name': 'Refurbished Awesome Screen',

View File

@@ -2,9 +2,9 @@
<odoo>
<record id="view_repair_order_tree" model="ir.ui.view">
<field name="name">mrp.repair.tree</field>
<field name="model">mrp.repair</field>
<field name="inherit_id" ref="mrp_repair.view_repair_order_tree"/>
<field name="name">repair.order.tree</field>
<field name="model">repair.order</field>
<field name="inherit_id" ref="repair.view_repair_order_tree"/>
<field name="arch" type="xml">
<field name="product_id" position="after">
<field name="refurbish_product_id"/>
@@ -13,10 +13,13 @@
</record>
<record id="view_repair_order_form" model="ir.ui.view">
<field name="name">mrp.repair.form</field>
<field name="model">mrp.repair</field>
<field name="inherit_id" ref="mrp_repair.view_repair_order_form"/>
<field name="name">repair.order.form</field>
<field name="model">repair.order</field>
<field name="inherit_id" ref="repair.view_repair_order_form"/>
<field name="arch" type="xml">
<field name="location_id" position="after">
<field name="location_dest_id" attrs="{'invisible': [('to_refurbish', '=', False)], 'required': [('to_refurbish', '=', True)]}" />
</field>
<xpath expr="//group[1]" position="inside">
<group>
<field name="to_refurbish"/>
@@ -40,9 +43,9 @@
</record>
<record id="view_repair_order_form_filter" model="ir.ui.view">
<field name="name">mrp.repair.select</field>
<field name="model">mrp.repair</field>
<field name="inherit_id" ref="mrp_repair.view_repair_order_form_filter"/>
<field name="name">repair.order.select</field>
<field name="model">repair.order</field>
<field name="inherit_id" ref="repair.view_repair_order_form_filter"/>
<field name="arch" type="xml">
<field name="product_id" position="after">
<field name="to_refurbish"/>