mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[IMP] : black, isort
This commit is contained in:
@@ -10,9 +10,7 @@
|
|||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"application": False,
|
"application": False,
|
||||||
"installable": True,
|
"installable": True,
|
||||||
"depends": [
|
"depends": ["repair",],
|
||||||
'repair',
|
|
||||||
],
|
|
||||||
"data": [
|
"data": [
|
||||||
"views/repair_view.xml",
|
"views/repair_view.xml",
|
||||||
"data/stock_data.xml",
|
"data/stock_data.xml",
|
||||||
|
|||||||
@@ -1,27 +1,24 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
<data>
|
<data>
|
||||||
|
|
||||||
<record id="stock_location_refurbish" model="stock.location">
|
<record id="stock_location_refurbish" model="stock.location">
|
||||||
<field name="name">Refurbish</field>
|
<field name="name">Refurbish</field>
|
||||||
<field name="location_id"
|
<field name="location_id" ref="stock.stock_location_locations_virtual" />
|
||||||
ref="stock.stock_location_locations_virtual"/>
|
|
||||||
<field name="usage">production</field>
|
<field name="usage">production</field>
|
||||||
<field name="company_id"></field>
|
<field name="company_id" />
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
<data noupdate="1">
|
<data noupdate="1">
|
||||||
|
<record forcecreate="True" id="property_stock_refurbish" model="ir.property">
|
||||||
<record forcecreate="True" id="property_stock_refurbish"
|
|
||||||
model="ir.property">
|
|
||||||
<field name="name">property_stock_refurbish</field>
|
<field name="name">property_stock_refurbish</field>
|
||||||
<field name="fields_id"
|
<field
|
||||||
search="[('model','=','product.template'),('name','=','property_stock_refurbish')]"/>
|
name="fields_id"
|
||||||
<field eval="'stock.location,'+str(stock_location_refurbish)"
|
search="[('model','=','product.template'),('name','=','property_stock_refurbish')]"
|
||||||
name="value"/>
|
/>
|
||||||
|
<field
|
||||||
|
eval="'stock.location,'+str(stock_location_refurbish)"
|
||||||
|
name="value"
|
||||||
|
/>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ from odoo import fields, models
|
|||||||
|
|
||||||
|
|
||||||
class ProductProduct(models.Model):
|
class ProductProduct(models.Model):
|
||||||
_inherit = 'product.product'
|
_inherit = "product.product"
|
||||||
|
|
||||||
refurbish_product_id = fields.Many2one(
|
refurbish_product_id = fields.Many2one(
|
||||||
comodel_name='product.product', string='Refurbished Product',
|
comodel_name="product.product",
|
||||||
domain="[('type', '=', 'product')]")
|
string="Refurbished Product",
|
||||||
|
domain="[('type', '=', 'product')]",
|
||||||
|
)
|
||||||
|
|||||||
@@ -5,40 +5,46 @@ from odoo import api, fields, models
|
|||||||
|
|
||||||
|
|
||||||
class ProductTemplate(models.Model):
|
class ProductTemplate(models.Model):
|
||||||
_inherit = 'product.template'
|
_inherit = "product.template"
|
||||||
|
|
||||||
refurbish_product_id = fields.Many2one(
|
refurbish_product_id = fields.Many2one(
|
||||||
comodel_name='product.product', string='Refurbished Product',
|
comodel_name="product.product",
|
||||||
compute='_compute_refurbish_product',
|
string="Refurbished Product",
|
||||||
inverse='_inverse_refurbish_product',
|
compute="_compute_refurbish_product",
|
||||||
search='_search_refurbish_product',
|
inverse="_inverse_refurbish_product",
|
||||||
domain="[('type', '=', 'product')]")
|
search="_search_refurbish_product",
|
||||||
|
domain="[('type', '=', 'product')]",
|
||||||
|
)
|
||||||
|
|
||||||
property_stock_refurbish = fields.Many2one(
|
property_stock_refurbish = fields.Many2one(
|
||||||
comodel_name='stock.location', string="Refurbish Location",
|
comodel_name="stock.location",
|
||||||
company_dependent=True, domain=[('usage', 'like', 'production')],
|
string="Refurbish Location",
|
||||||
|
company_dependent=True,
|
||||||
|
domain=[("usage", "like", "production")],
|
||||||
help="This stock location will be used, instead of the "
|
help="This stock location will be used, instead of the "
|
||||||
"default one, as the source location for "
|
"default one, as the source location for "
|
||||||
"stock moves generated by repair orders when refurbishing takes "
|
"stock moves generated by repair orders when refurbishing takes "
|
||||||
"place.")
|
"place.",
|
||||||
|
)
|
||||||
|
|
||||||
@api.depends('product_variant_ids',
|
@api.depends("product_variant_ids", "product_variant_ids.refurbish_product_id")
|
||||||
'product_variant_ids.refurbish_product_id')
|
|
||||||
def _compute_refurbish_product(self):
|
def _compute_refurbish_product(self):
|
||||||
unique_variants = self.filtered(lambda template:
|
unique_variants = self.filtered(
|
||||||
len(template.product_variant_ids) == 1)
|
lambda template: len(template.product_variant_ids) == 1
|
||||||
|
)
|
||||||
for template in unique_variants:
|
for template in unique_variants:
|
||||||
template.refurbish_product_id = \
|
template.refurbish_product_id = (
|
||||||
template.product_variant_ids.refurbish_product_id
|
template.product_variant_ids.refurbish_product_id
|
||||||
|
)
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def _inverse_refurbish_product(self):
|
def _inverse_refurbish_product(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
if len(rec.product_variant_ids) == 1:
|
if len(rec.product_variant_ids) == 1:
|
||||||
rec.product_variant_ids.refurbish_product_id = \
|
rec.product_variant_ids.refurbish_product_id = rec.refurbish_product_id
|
||||||
rec.refurbish_product_id
|
|
||||||
|
|
||||||
def _search_refurbish_product(self, operator, value):
|
def _search_refurbish_product(self, operator, value):
|
||||||
products = self.env['product.product'].search([
|
products = self.env["product.product"].search(
|
||||||
('refurbish_product_id', operator, value)], limit=None)
|
[("refurbish_product_id", operator, value)], limit=None
|
||||||
return [('id', 'in', products.mapped('product_tmpl_id').ids)]
|
)
|
||||||
|
return [("id", "in", products.mapped("product_tmpl_id").ids)]
|
||||||
|
|||||||
@@ -5,28 +5,32 @@ from odoo import api, fields, models
|
|||||||
|
|
||||||
|
|
||||||
class RepairOrder(models.Model):
|
class RepairOrder(models.Model):
|
||||||
_inherit = 'repair.order'
|
_inherit = "repair.order"
|
||||||
|
|
||||||
to_refurbish = fields.Boolean()
|
to_refurbish = fields.Boolean()
|
||||||
location_dest_id = fields.Many2one(
|
location_dest_id = fields.Many2one(
|
||||||
string='Delivery Location', comodel_name='stock.location')
|
string="Delivery Location", comodel_name="stock.location"
|
||||||
|
)
|
||||||
refurbish_location_dest_id = fields.Many2one(
|
refurbish_location_dest_id = fields.Many2one(
|
||||||
string='Refurbished Delivery Location', comodel_name='stock.location')
|
string="Refurbished Delivery Location", comodel_name="stock.location"
|
||||||
|
)
|
||||||
refurbish_product_id = fields.Many2one(
|
refurbish_product_id = fields.Many2one(
|
||||||
string='Refurbished product', comodel_name='product.product')
|
string="Refurbished product", comodel_name="product.product"
|
||||||
|
)
|
||||||
refurbish_lot_id = fields.Many2one(
|
refurbish_lot_id = fields.Many2one(
|
||||||
string='Refurbished Lot', comodel_name='stock.production.lot')
|
string="Refurbished Lot", comodel_name="stock.production.lot"
|
||||||
|
)
|
||||||
refurbish_move_id = fields.Many2one(
|
refurbish_move_id = fields.Many2one(
|
||||||
string='Refurbished Inventory Move', comodel_name='stock.move')
|
string="Refurbished Inventory Move", comodel_name="stock.move"
|
||||||
|
)
|
||||||
|
|
||||||
@api.onchange('product_id')
|
@api.onchange("product_id")
|
||||||
def onchange_product_id(self):
|
def onchange_product_id(self):
|
||||||
res = super().onchange_product_id()
|
res = super().onchange_product_id()
|
||||||
self.to_refurbish = True if \
|
self.to_refurbish = True if self.product_id.refurbish_product_id else False
|
||||||
self.product_id.refurbish_product_id else False
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@api.onchange('to_refurbish', 'product_id')
|
@api.onchange("to_refurbish", "product_id")
|
||||||
def _onchange_to_refurbish(self):
|
def _onchange_to_refurbish(self):
|
||||||
if self.to_refurbish:
|
if self.to_refurbish:
|
||||||
self.refurbish_product_id = self.product_id.refurbish_product_id
|
self.refurbish_product_id = self.product_id.refurbish_product_id
|
||||||
@@ -40,37 +44,47 @@ class RepairOrder(models.Model):
|
|||||||
@api.multi
|
@api.multi
|
||||||
def _get_refurbish_stock_move_dict(self):
|
def _get_refurbish_stock_move_dict(self):
|
||||||
return {
|
return {
|
||||||
'name': self.name,
|
"name": self.name,
|
||||||
'product_id': self.refurbish_product_id.id,
|
"product_id": self.refurbish_product_id.id,
|
||||||
'product_uom': self.product_uom.id or
|
"product_uom": self.product_uom.id or self.refurbish_product_id.uom_id.id,
|
||||||
self.refurbish_product_id.uom_id.id,
|
"product_uom_qty": self.product_qty,
|
||||||
'product_uom_qty': self.product_qty,
|
"partner_id": self.address_id and self.address_id.id or False,
|
||||||
'partner_id': self.address_id and
|
"location_id": self.location_dest_id.id,
|
||||||
self.address_id.id or False,
|
"location_dest_id": self.refurbish_location_dest_id.id,
|
||||||
'location_id': self.location_dest_id.id,
|
"move_line_ids": [
|
||||||
'location_dest_id': self.refurbish_location_dest_id.id,
|
(
|
||||||
'move_line_ids': [(0, 0, {
|
0,
|
||||||
'product_id': self.refurbish_product_id.id,
|
0,
|
||||||
'lot_id': self.refurbish_lot_id.id,
|
{
|
||||||
'product_uom_qty': self.product_qty,
|
"product_id": self.refurbish_product_id.id,
|
||||||
'product_uom_id': self.product_uom.id or
|
"lot_id": self.refurbish_lot_id.id,
|
||||||
self.refurbish_product_id.uom_id.id,
|
"product_uom_qty": self.product_qty,
|
||||||
'qty_done': self.product_qty,
|
"product_uom_id": self.product_uom.id
|
||||||
'package_id': False,
|
or self.refurbish_product_id.uom_id.id,
|
||||||
'result_package_id': False,
|
"qty_done": self.product_qty,
|
||||||
'location_id': self.location_dest_id.id,
|
"package_id": False,
|
||||||
'location_dest_id': self.refurbish_location_dest_id.id})]}
|
"result_package_id": False,
|
||||||
|
"location_id": self.location_dest_id.id,
|
||||||
|
"location_dest_id": self.refurbish_location_dest_id.id,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def action_repair_done(self):
|
def action_repair_done(self):
|
||||||
res = super(RepairOrder, self.with_context(
|
res = super(
|
||||||
|
RepairOrder,
|
||||||
|
self.with_context(
|
||||||
force_refurbish_location_dest_id=self.location_dest_id.id,
|
force_refurbish_location_dest_id=self.location_dest_id.id,
|
||||||
to_refurbish=self.to_refurbish,
|
to_refurbish=self.to_refurbish,
|
||||||
)).action_repair_done()
|
),
|
||||||
|
).action_repair_done()
|
||||||
for repair in self:
|
for repair in self:
|
||||||
if repair.to_refurbish:
|
if repair.to_refurbish:
|
||||||
move = self.env['stock.move'].create(
|
move = self.env["stock.move"].create(
|
||||||
repair._get_refurbish_stock_move_dict())
|
repair._get_refurbish_stock_move_dict()
|
||||||
|
)
|
||||||
move.quantity_done = repair.product_qty
|
move.quantity_done = repair.product_qty
|
||||||
move._action_done()
|
move._action_done()
|
||||||
repair.refurbish_move_id = move.id
|
repair.refurbish_move_id = move.id
|
||||||
@@ -78,18 +92,21 @@ class RepairOrder(models.Model):
|
|||||||
|
|
||||||
|
|
||||||
class RepairLine(models.Model):
|
class RepairLine(models.Model):
|
||||||
_inherit = 'repair.line'
|
_inherit = "repair.line"
|
||||||
|
|
||||||
@api.onchange('type', 'repair_id')
|
@api.onchange("type", "repair_id")
|
||||||
def onchange_operation_type(self):
|
def onchange_operation_type(self):
|
||||||
res = super(RepairLine, self).onchange_operation_type()
|
res = super(RepairLine, self).onchange_operation_type()
|
||||||
context = self.env.context
|
context = self.env.context
|
||||||
if (self.type == 'add' and 'to_refurbish' in context and
|
if self.type == "add" and "to_refurbish" in context and context["to_refurbish"]:
|
||||||
context['to_refurbish']):
|
self.location_dest_id = context["refurbish_location_dest_id"]
|
||||||
self.location_dest_id = context['refurbish_location_dest_id']
|
elif (
|
||||||
elif (self.type == 'add' and 'to_refurbish' in context and not
|
self.type == "add"
|
||||||
context['to_refurbish']):
|
and "to_refurbish" in context
|
||||||
scrap_location_id = self.env['stock.location'].search([
|
and not context["to_refurbish"]
|
||||||
('usage', '=', 'customer')], limit=1)
|
):
|
||||||
|
scrap_location_id = self.env["stock.location"].search(
|
||||||
|
[("usage", "=", "customer")], limit=1
|
||||||
|
)
|
||||||
self.location_dest_id = scrap_location_id
|
self.location_dest_id = scrap_location_id
|
||||||
return res
|
return res
|
||||||
|
|||||||
@@ -1,33 +1,33 @@
|
|||||||
# Copyright 2019 Camptocamp SA
|
# Copyright 2019 Camptocamp SA
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
|
||||||
from odoo import models, api
|
from odoo import api, models
|
||||||
|
|
||||||
|
|
||||||
class StockMove(models.Model):
|
class StockMove(models.Model):
|
||||||
|
|
||||||
_inherit = 'stock.move'
|
_inherit = "stock.move"
|
||||||
|
|
||||||
@api.model_create_multi
|
@api.model_create_multi
|
||||||
def create(self, vals_list):
|
def create(self, vals_list):
|
||||||
if 'to_refurbish' in self.env.context and \
|
if "to_refurbish" in self.env.context and self.env.context["to_refurbish"]:
|
||||||
self.env.context['to_refurbish']:
|
if "force_refurbish_location_dest_id" in self.env.context:
|
||||||
if 'force_refurbish_location_dest_id' in self.env.context:
|
|
||||||
for vals in vals_list:
|
for vals in vals_list:
|
||||||
vals['location_dest_id'] = self.env.context[
|
vals["location_dest_id"] = self.env.context[
|
||||||
'force_refurbish_location_dest_id']
|
"force_refurbish_location_dest_id"
|
||||||
|
]
|
||||||
return super().create(vals_list)
|
return super().create(vals_list)
|
||||||
|
|
||||||
|
|
||||||
class StockMoveLine(models.Model):
|
class StockMoveLine(models.Model):
|
||||||
|
|
||||||
_inherit = 'stock.move.line'
|
_inherit = "stock.move.line"
|
||||||
|
|
||||||
@api.model_create_multi
|
@api.model_create_multi
|
||||||
def create(self, vals_list):
|
def create(self, vals_list):
|
||||||
if 'to_refurbish' in self.env.context and \
|
if "to_refurbish" in self.env.context and self.env.context["to_refurbish"]:
|
||||||
self.env.context['to_refurbish']:
|
if "force_refurbish_location_dest_id" in self.env.context:
|
||||||
if 'force_refurbish_location_dest_id' in self.env.context:
|
|
||||||
for vals in vals_list:
|
for vals in vals_list:
|
||||||
vals['location_dest_id'] = self.env.context[
|
vals["location_dest_id"] = self.env.context[
|
||||||
'force_refurbish_location_dest_id']
|
"force_refurbish_location_dest_id"
|
||||||
|
]
|
||||||
return super().create(vals_list)
|
return super().create(vals_list)
|
||||||
|
|||||||
@@ -5,74 +5,73 @@ from odoo.tests.common import TransactionCase
|
|||||||
|
|
||||||
|
|
||||||
class TestMrpMtoWithStock(TransactionCase):
|
class TestMrpMtoWithStock(TransactionCase):
|
||||||
|
|
||||||
def setUp(self, *args, **kwargs):
|
def setUp(self, *args, **kwargs):
|
||||||
super(TestMrpMtoWithStock, self).setUp(*args, **kwargs)
|
super(TestMrpMtoWithStock, self).setUp(*args, **kwargs)
|
||||||
self.repair_obj = self.env['repair.order']
|
self.repair_obj = self.env["repair.order"]
|
||||||
self.repair_line_obj = self.env['repair.line']
|
self.repair_line_obj = self.env["repair.line"]
|
||||||
self.product_obj = self.env['product.product']
|
self.product_obj = self.env["product.product"]
|
||||||
self.move_obj = self.env['stock.move']
|
self.move_obj = self.env["stock.move"]
|
||||||
|
|
||||||
self.stock_location_stock = self.env.ref('stock.stock_location_stock')
|
self.stock_location_stock = self.env.ref("stock.stock_location_stock")
|
||||||
self.customer_location = self.env.ref('stock.stock_location_customers')
|
self.customer_location = self.env.ref("stock.stock_location_customers")
|
||||||
self.refurbish_loc = self.env.ref(
|
self.refurbish_loc = self.env.ref("repair_refurbish.stock_location_refurbish")
|
||||||
'repair_refurbish.stock_location_refurbish')
|
|
||||||
|
|
||||||
self.refurbish_product = self.product_obj.create({
|
self.refurbish_product = self.product_obj.create(
|
||||||
'name': 'Refurbished Awesome Screen',
|
{"name": "Refurbished Awesome Screen", "type": "product",}
|
||||||
'type': 'product',
|
)
|
||||||
})
|
self.product = self.product_obj.create(
|
||||||
self.product = self.product_obj.create({
|
{
|
||||||
'name': 'Awesome Screen',
|
"name": "Awesome Screen",
|
||||||
'type': 'product',
|
"type": "product",
|
||||||
'refurbish_product_id': self.refurbish_product.id,
|
"refurbish_product_id": self.refurbish_product.id,
|
||||||
})
|
}
|
||||||
self.material = self.product_obj.create({
|
)
|
||||||
'name': 'Materials',
|
self.material = self.product_obj.create({"name": "Materials", "type": "consu",})
|
||||||
'type': 'consu',
|
self.material2 = self.product_obj.create(
|
||||||
})
|
{"name": "Materials", "type": "product",}
|
||||||
self.material2 = self.product_obj.create({
|
)
|
||||||
'name': 'Materials',
|
|
||||||
'type': 'product',
|
|
||||||
})
|
|
||||||
self._update_product_qty(self.product, self.stock_location_stock, 10.0)
|
self._update_product_qty(self.product, self.stock_location_stock, 10.0)
|
||||||
|
|
||||||
def _update_product_qty(self, product, location, quantity):
|
def _update_product_qty(self, product, location, quantity):
|
||||||
product_qty = self.env['stock.change.product.qty'].create({
|
product_qty = self.env["stock.change.product.qty"].create(
|
||||||
'location_id': location.id,
|
{
|
||||||
'product_id': product.id,
|
"location_id": location.id,
|
||||||
'new_quantity': quantity,
|
"product_id": product.id,
|
||||||
})
|
"new_quantity": quantity,
|
||||||
|
}
|
||||||
|
)
|
||||||
product_qty.change_product_qty()
|
product_qty.change_product_qty()
|
||||||
return product_qty
|
return product_qty
|
||||||
|
|
||||||
def test_01_repair_refurbish(self):
|
def test_01_repair_refurbish(self):
|
||||||
"""Tests that locations are properly set with a product to
|
"""Tests that locations are properly set with a product to
|
||||||
refurbish, then complete repair."""
|
refurbish, then complete repair."""
|
||||||
repair = self.repair_obj.create({
|
repair = self.repair_obj.create(
|
||||||
'product_id': self.product.id,
|
{
|
||||||
'product_qty': 3.0,
|
"product_id": self.product.id,
|
||||||
'product_uom': self.product.uom_id.id,
|
"product_qty": 3.0,
|
||||||
'location_dest_id': self.customer_location.id,
|
"product_uom": self.product.uom_id.id,
|
||||||
})
|
"location_dest_id": self.customer_location.id,
|
||||||
|
}
|
||||||
|
)
|
||||||
repair.onchange_product_id()
|
repair.onchange_product_id()
|
||||||
self.assertTrue(repair.to_refurbish)
|
self.assertTrue(repair.to_refurbish)
|
||||||
repair._onchange_to_refurbish()
|
repair._onchange_to_refurbish()
|
||||||
self.assertEqual(repair.refurbish_location_dest_id,
|
self.assertEqual(repair.refurbish_location_dest_id, self.customer_location)
|
||||||
self.customer_location)
|
self.assertEqual(repair.location_dest_id, self.product.property_stock_refurbish)
|
||||||
self.assertEqual(repair.location_dest_id,
|
|
||||||
self.product.property_stock_refurbish)
|
|
||||||
line = self.repair_line_obj.with_context(
|
line = self.repair_line_obj.with_context(
|
||||||
to_refurbish=repair.to_refurbish,
|
to_refurbish=repair.to_refurbish,
|
||||||
refurbish_location_dest_id=repair.refurbish_location_dest_id,
|
refurbish_location_dest_id=repair.refurbish_location_dest_id,
|
||||||
).new({
|
).new(
|
||||||
'name': 'consume stuff to repair',
|
{
|
||||||
'repair_id': repair.id,
|
"name": "consume stuff to repair",
|
||||||
'type': 'add',
|
"repair_id": repair.id,
|
||||||
'product_id': self.material.id,
|
"type": "add",
|
||||||
'product_uom': self.material.uom_id.id,
|
"product_id": self.material.id,
|
||||||
'product_uom_qty': 1.0,
|
"product_uom": self.material.uom_id.id,
|
||||||
})
|
"product_uom_qty": 1.0,
|
||||||
|
}
|
||||||
|
)
|
||||||
line.onchange_product_id()
|
line.onchange_product_id()
|
||||||
line.onchange_operation_type()
|
line.onchange_operation_type()
|
||||||
self.assertEqual(line.location_id, repair.location_id)
|
self.assertEqual(line.location_id, repair.location_id)
|
||||||
@@ -81,59 +80,67 @@ class TestMrpMtoWithStock(TransactionCase):
|
|||||||
repair.action_validate()
|
repair.action_validate()
|
||||||
repair.action_repair_start()
|
repair.action_repair_start()
|
||||||
repair.action_repair_end()
|
repair.action_repair_end()
|
||||||
moves = self.move_obj.search([('reference', '=', repair.name)])
|
moves = self.move_obj.search([("reference", "=", repair.name)])
|
||||||
self.assertEqual(len(moves), 2)
|
self.assertEqual(len(moves), 2)
|
||||||
for m in moves:
|
for m in moves:
|
||||||
self.assertEqual(m.state, 'done')
|
self.assertEqual(m.state, "done")
|
||||||
if m.product_id == self.product:
|
if m.product_id == self.product:
|
||||||
self.assertEqual(m.location_id, self.stock_location_stock)
|
self.assertEqual(m.location_id, self.stock_location_stock)
|
||||||
self.assertEqual(m.location_dest_id, self.refurbish_loc)
|
self.assertEqual(m.location_dest_id, self.refurbish_loc)
|
||||||
self.assertEqual(m.mapped('move_line_ids.location_id'),
|
self.assertEqual(
|
||||||
self.stock_location_stock)
|
m.mapped("move_line_ids.location_id"), self.stock_location_stock
|
||||||
self.assertEqual(m.mapped('move_line_ids.location_dest_id'),
|
)
|
||||||
self.refurbish_loc)
|
self.assertEqual(
|
||||||
|
m.mapped("move_line_ids.location_dest_id"), self.refurbish_loc
|
||||||
|
)
|
||||||
elif m.product_id == self.refurbish_product:
|
elif m.product_id == self.refurbish_product:
|
||||||
self.assertEqual(m.location_id, self.refurbish_loc)
|
self.assertEqual(m.location_id, self.refurbish_loc)
|
||||||
self.assertEqual(m.location_dest_id, self.customer_location)
|
self.assertEqual(m.location_dest_id, self.customer_location)
|
||||||
self.assertEqual(m.mapped('move_line_ids.location_id'),
|
self.assertEqual(
|
||||||
self.refurbish_loc)
|
m.mapped("move_line_ids.location_id"), self.refurbish_loc
|
||||||
self.assertEqual(m.mapped('move_line_ids.location_dest_id'),
|
)
|
||||||
self.customer_location)
|
self.assertEqual(
|
||||||
|
m.mapped("move_line_ids.location_dest_id"), self.customer_location
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
self.assertTrue(False, "Unexpected move.")
|
self.assertTrue(False, "Unexpected move.")
|
||||||
|
|
||||||
def test_02_repair_no_refurbish(self):
|
def test_02_repair_no_refurbish(self):
|
||||||
"""Tests normal repairs does not fail and normal location for consumed
|
"""Tests normal repairs does not fail and normal location for consumed
|
||||||
material"""
|
material"""
|
||||||
repair = self.repair_obj.create({
|
repair = self.repair_obj.create(
|
||||||
'product_id': self.product.id,
|
{
|
||||||
'product_qty': 3.0,
|
"product_id": self.product.id,
|
||||||
'product_uom': self.product.uom_id.id,
|
"product_qty": 3.0,
|
||||||
'location_dest_id': self.customer_location.id,
|
"product_uom": self.product.uom_id.id,
|
||||||
'to_refurbish': False
|
"location_dest_id": self.customer_location.id,
|
||||||
})
|
"to_refurbish": False,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
line = self.repair_line_obj.with_context(
|
line = self.repair_line_obj.with_context(
|
||||||
to_refurbish=repair.to_refurbish,
|
to_refurbish=repair.to_refurbish,
|
||||||
refurbish_location_dest_id=repair.refurbish_location_dest_id,
|
refurbish_location_dest_id=repair.refurbish_location_dest_id,
|
||||||
).create({
|
).create(
|
||||||
'name': 'consume stuff to repair',
|
{
|
||||||
'repair_id': repair.id,
|
"name": "consume stuff to repair",
|
||||||
'type': 'add',
|
"repair_id": repair.id,
|
||||||
'product_id': self.material2.id,
|
"type": "add",
|
||||||
'product_uom': self.material2.uom_id.id,
|
"product_id": self.material2.id,
|
||||||
'product_uom_qty': 1.0,
|
"product_uom": self.material2.uom_id.id,
|
||||||
'price_unit': 50.0,
|
"product_uom_qty": 1.0,
|
||||||
'location_id': self.stock_location_stock.id,
|
"price_unit": 50.0,
|
||||||
'location_dest_id': self.customer_location.id
|
"location_id": self.stock_location_stock.id,
|
||||||
})
|
"location_dest_id": self.customer_location.id,
|
||||||
|
}
|
||||||
|
)
|
||||||
line.onchange_product_id()
|
line.onchange_product_id()
|
||||||
line.onchange_operation_type()
|
line.onchange_operation_type()
|
||||||
# Complete repair:
|
# Complete repair:
|
||||||
repair.action_validate()
|
repair.action_validate()
|
||||||
repair.action_repair_start()
|
repair.action_repair_start()
|
||||||
repair.action_repair_end()
|
repair.action_repair_end()
|
||||||
move = self.move_obj.search([
|
move = self.move_obj.search(
|
||||||
('product_id', '=', self.material2.id)],
|
[("product_id", "=", self.material2.id)], order="create_date desc", limit=1
|
||||||
order='create_date desc', limit=1)[0]
|
)[0]
|
||||||
self.assertEqual(move.location_dest_id, self.customer_location)
|
self.assertEqual(move.location_dest_id, self.customer_location)
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
|
|
||||||
<record id="product_normal_form_view" model="ir.ui.view">
|
<record id="product_normal_form_view" model="ir.ui.view">
|
||||||
<field name="name">product.product.form</field>
|
<field name="name">product.product.form</field>
|
||||||
<field name="model">product.product</field>
|
<field name="model">product.product</field>
|
||||||
@@ -13,5 +12,4 @@
|
|||||||
</group>
|
</group>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@@ -1,31 +1,32 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
|
|
||||||
<record id="product_template_only_form_view" model="ir.ui.view">
|
<record id="product_template_only_form_view" model="ir.ui.view">
|
||||||
<field name="name">product.template.product.form</field>
|
<field name="name">product.template.product.form</field>
|
||||||
<field name="model">product.template</field>
|
<field name="model">product.template</field>
|
||||||
<field name="inherit_id" ref="product.product_template_only_form_view" />
|
<field name="inherit_id" ref="product.product_template_only_form_view" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<group name="inventory" position="after">
|
<group name="inventory" position="after">
|
||||||
<group name="refurbish" string="Refurbish" attrs="{'invisible':[('product_variant_count', '>', 1)]}">
|
<group
|
||||||
|
name="refurbish"
|
||||||
|
string="Refurbish"
|
||||||
|
attrs="{'invisible':[('product_variant_count', '>', 1)]}"
|
||||||
|
>
|
||||||
<field name="refurbish_product_id" />
|
<field name="refurbish_product_id" />
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="view_template_property_form" model="ir.ui.view">
|
<record id="view_template_property_form" model="ir.ui.view">
|
||||||
<field name="name">product.template.stock.property.form.inherit</field>
|
<field name="name">product.template.stock.property.form.inherit</field>
|
||||||
<field name="model">product.template</field>
|
<field name="model">product.template</field>
|
||||||
<field name="inherit_id" ref="stock.view_template_property_form" />
|
<field name="inherit_id" ref="stock.view_template_property_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
|
<field name="property_stock_production" position="after">
|
||||||
<field name="property_stock_production"
|
<field
|
||||||
position="after">
|
name="property_stock_refurbish"
|
||||||
<field name="property_stock_refurbish"
|
domain="[('usage','=','production')]"
|
||||||
domain="[('usage','=','production')]"/>
|
/>
|
||||||
</field>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
|
|
||||||
<record id="view_repair_order_tree" model="ir.ui.view">
|
<record id="view_repair_order_tree" model="ir.ui.view">
|
||||||
<field name="name">repair.order.tree</field>
|
<field name="name">repair.order.tree</field>
|
||||||
<field name="model">repair.order</field>
|
<field name="model">repair.order</field>
|
||||||
@@ -11,37 +10,45 @@
|
|||||||
</field>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="view_repair_order_form" model="ir.ui.view">
|
<record id="view_repair_order_form" model="ir.ui.view">
|
||||||
<field name="name">repair.order.form</field>
|
<field name="name">repair.order.form</field>
|
||||||
<field name="model">repair.order</field>
|
<field name="model">repair.order</field>
|
||||||
<field name="inherit_id" ref="repair.view_repair_order_form" />
|
<field name="inherit_id" ref="repair.view_repair_order_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="location_id" position="after">
|
<field name="location_id" position="after">
|
||||||
<field name="location_dest_id" attrs="{'invisible': [('to_refurbish', '=', False)], 'required': [('to_refurbish', '=', True)]}" />
|
<field
|
||||||
|
name="location_dest_id"
|
||||||
|
attrs="{'invisible': [('to_refurbish', '=', False)], 'required': [('to_refurbish', '=', True)]}"
|
||||||
|
/>
|
||||||
</field>
|
</field>
|
||||||
<xpath expr="//group[1]" position="inside">
|
<xpath expr="//group[1]" position="inside">
|
||||||
<group>
|
<group>
|
||||||
<field name="to_refurbish" />
|
<field name="to_refurbish" />
|
||||||
</group>
|
</group>
|
||||||
<group attrs="{'invisible': [('to_refurbish', '=', False)]}">
|
<group attrs="{'invisible': [('to_refurbish', '=', False)]}">
|
||||||
<field name="refurbish_product_id"
|
<field
|
||||||
attrs="{'required': [('to_refurbish', '=', True)]}"/>
|
name="refurbish_product_id"
|
||||||
<field name="refurbish_lot_id"
|
attrs="{'required': [('to_refurbish', '=', True)]}"
|
||||||
|
/>
|
||||||
|
<field
|
||||||
|
name="refurbish_lot_id"
|
||||||
domain="[('product_id', '=', refurbish_product_id)]"
|
domain="[('product_id', '=', refurbish_product_id)]"
|
||||||
context="{'default_product_id': refurbish_product_id}"
|
context="{'default_product_id': refurbish_product_id}"
|
||||||
groups="stock.group_production_lot"/>
|
groups="stock.group_production_lot"
|
||||||
<field name="refurbish_location_dest_id"
|
/>
|
||||||
attrs="{'required': [('to_refurbish', '=', True)]}"/>
|
<field
|
||||||
|
name="refurbish_location_dest_id"
|
||||||
|
attrs="{'required': [('to_refurbish', '=', True)]}"
|
||||||
|
/>
|
||||||
</group>
|
</group>
|
||||||
</xpath>
|
</xpath>
|
||||||
<field name="operations"
|
<field name="operations" position='attributes'>
|
||||||
position='attributes'>
|
<attribute
|
||||||
<attribute name='context'>{'default_product_uom_qty': product_qty, 'to_refurbish': to_refurbish, 'refurbish_location_dest_id': location_dest_id}</attribute>
|
name='context'
|
||||||
|
>{'default_product_uom_qty': product_qty, 'to_refurbish': to_refurbish, 'refurbish_location_dest_id': location_dest_id}</attribute>
|
||||||
</field>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
<record id="view_repair_order_form_filter" model="ir.ui.view">
|
<record id="view_repair_order_form_filter" model="ir.ui.view">
|
||||||
<field name="name">repair.order.select</field>
|
<field name="name">repair.order.select</field>
|
||||||
<field name="model">repair.order</field>
|
<field name="model">repair.order</field>
|
||||||
@@ -53,5 +60,4 @@
|
|||||||
</field>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
Reference in New Issue
Block a user