mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
[IMP] mrp_progress_button: black, isort, prettier
This commit is contained in:
committed by
AaronHForgeFlow
parent
89fb7ef419
commit
0dd628175c
@@ -10,11 +10,7 @@
|
|||||||
"category": "Manufacturing",
|
"category": "Manufacturing",
|
||||||
"version": "12.0.1.0.0",
|
"version": "12.0.1.0.0",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
"depends": [
|
"depends": ["mrp"],
|
||||||
"mrp"
|
"data": ["views/production.xml"],
|
||||||
],
|
|
||||||
"data": [
|
|
||||||
"views/production.xml"
|
|
||||||
],
|
|
||||||
"installable": True,
|
"installable": True,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,16 +3,19 @@
|
|||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from odoo import api, models
|
from odoo import api, models
|
||||||
|
|
||||||
|
|
||||||
class MrpProduction(models.Model):
|
class MrpProduction(models.Model):
|
||||||
_inherit = 'mrp.production'
|
_inherit = "mrp.production"
|
||||||
|
|
||||||
@api.multi
|
@api.multi
|
||||||
def action_progress(self):
|
def action_progress(self):
|
||||||
self.write({
|
self.write(
|
||||||
'state': 'progress',
|
{
|
||||||
'date_start': datetime.now(),
|
"state": "progress",
|
||||||
})
|
"date_start": datetime.now(),
|
||||||
|
}
|
||||||
|
)
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
Simple module that add a button on MO to mark the Manufacturing Order to
|
Simple module that add a button on MO to mark the Manufacturing Order to
|
||||||
*In Progress* state. This module is usefull only when you do not use routing and
|
*In Progress* state. This module is usefull only when you do not use routing and
|
||||||
operations. Indeed, the *In Progress* state is automatically put when the
|
operations. Indeed, the *In Progress* state is automatically put when the
|
||||||
first operation is started.
|
first operation is started.
|
||||||
|
|||||||
@@ -6,63 +6,78 @@ from odoo.tests.common import TransactionCase
|
|||||||
|
|
||||||
|
|
||||||
class TestProgressButton(TransactionCase):
|
class TestProgressButton(TransactionCase):
|
||||||
|
|
||||||
def setUp(self, *args, **kwargs):
|
def setUp(self, *args, **kwargs):
|
||||||
super(TestProgressButton, self).setUp(*args, **kwargs)
|
super(TestProgressButton, self).setUp(*args, **kwargs)
|
||||||
self.production_model = self.env['mrp.production']
|
self.production_model = self.env["mrp.production"]
|
||||||
self.bom_model = self.env['mrp.bom']
|
self.bom_model = self.env["mrp.bom"]
|
||||||
self.stock_location_stock = self.env.ref('stock.stock_location_stock')
|
self.stock_location_stock = self.env.ref("stock.stock_location_stock")
|
||||||
self.manufacture_route = self.env.ref(
|
self.manufacture_route = self.env.ref("mrp.route_warehouse0_manufacture")
|
||||||
'mrp.route_warehouse0_manufacture')
|
self.uom_unit = self.env.ref("uom.product_uom_unit")
|
||||||
self.uom_unit = self.env.ref('uom.product_uom_unit')
|
|
||||||
|
|
||||||
self.product_manuf = self.env['product.product'].create({
|
self.product_manuf = self.env["product.product"].create(
|
||||||
'name': 'Manuf',
|
{
|
||||||
'type': 'product',
|
"name": "Manuf",
|
||||||
'uom_id': self.uom_unit.id,
|
"type": "product",
|
||||||
'route_ids': [(4, self.manufacture_route.id)]
|
"uom_id": self.uom_unit.id,
|
||||||
})
|
"route_ids": [(4, self.manufacture_route.id)],
|
||||||
self.product_raw_material = self.env['product.product'].create({
|
}
|
||||||
'name': 'Raw Material',
|
)
|
||||||
'type': 'product',
|
self.product_raw_material = self.env["product.product"].create(
|
||||||
'uom_id': self.uom_unit.id,
|
{
|
||||||
})
|
"name": "Raw Material",
|
||||||
|
"type": "product",
|
||||||
|
"uom_id": self.uom_unit.id,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
self._update_product_qty(self.product_raw_material,
|
self._update_product_qty(
|
||||||
self.stock_location_stock, 1)
|
self.product_raw_material, self.stock_location_stock, 1
|
||||||
|
)
|
||||||
|
|
||||||
self.bom = self.env['mrp.bom'].create({
|
self.bom = self.env["mrp.bom"].create(
|
||||||
'product_id': self.product_manuf.id,
|
{
|
||||||
'product_tmpl_id': self.product_manuf.product_tmpl_id.id,
|
"product_id": self.product_manuf.id,
|
||||||
'bom_line_ids': ([
|
"product_tmpl_id": self.product_manuf.product_tmpl_id.id,
|
||||||
(0, 0, {
|
"bom_line_ids": (
|
||||||
'product_id': self.product_raw_material.id,
|
[
|
||||||
'product_qty': 1,
|
(
|
||||||
'product_uom_id': self.uom_unit.id
|
0,
|
||||||
}),
|
0,
|
||||||
])
|
{
|
||||||
})
|
"product_id": self.product_raw_material.id,
|
||||||
|
"product_qty": 1,
|
||||||
|
"product_uom_id": self.uom_unit.id,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
def _update_product_qty(self, product, location, quantity):
|
def _update_product_qty(self, product, location, quantity):
|
||||||
"""Update Product quantity."""
|
"""Update Product 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_manufacture_with_forecast_stock(self):
|
def test_manufacture_with_forecast_stock(self):
|
||||||
"""
|
"""
|
||||||
Test Manufacture mto with stock based on forecast quantity
|
Test Manufacture mto with stock based on forecast quantity
|
||||||
and no link between sub assemblies MO's and Main MO raw material
|
and no link between sub assemblies MO's and Main MO raw material
|
||||||
"""
|
"""
|
||||||
production = self.production_model.create({
|
production = self.production_model.create(
|
||||||
'product_id': self.product_manuf.id,
|
{
|
||||||
'product_qty': 1,
|
"product_id": self.product_manuf.id,
|
||||||
'product_uom_id': self.uom_unit.id,
|
"product_qty": 1,
|
||||||
'bom_id': self.bom.id
|
"product_uom_id": self.uom_unit.id,
|
||||||
})
|
"bom_id": self.bom.id,
|
||||||
|
}
|
||||||
|
)
|
||||||
production.action_progress()
|
production.action_progress()
|
||||||
self.assertEqual(production.state, 'progress')
|
self.assertEqual(production.state, "progress")
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<odoo>
|
<odoo>
|
||||||
|
|
||||||
<record id="mrp_production_progress_button_form_view" model="ir.ui.view">
|
<record id="mrp_production_progress_button_form_view" model="ir.ui.view">
|
||||||
<field name="model">mrp.production</field>
|
<field name="model">mrp.production</field>
|
||||||
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
|
<field name="inherit_id" ref="mrp.mrp_production_form_view" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<button name="action_assign" position="after">
|
<button name="action_assign" position="after">
|
||||||
<button name="action_progress" attrs="{'invisible': ['|', ('state', '!=', 'confirmed'), ('routing_id', '!=', False)]}"
|
<button
|
||||||
type="object" string="Mark As Started" class="oe_highlight"/>
|
name="action_progress"
|
||||||
|
attrs="{'invisible': ['|', ('state', '!=', 'confirmed'), ('routing_id', '!=', False)]}"
|
||||||
|
type="object"
|
||||||
|
string="Mark As Started"
|
||||||
|
class="oe_highlight"
|
||||||
|
/>
|
||||||
</button>
|
</button>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
1
setup/mrp_progress_button/odoo/addons/mrp_progress_button
Symbolic link
1
setup/mrp_progress_button/odoo/addons/mrp_progress_button
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../../../mrp_progress_button
|
||||||
6
setup/mrp_progress_button/setup.py
Normal file
6
setup/mrp_progress_button/setup.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import setuptools
|
||||||
|
|
||||||
|
setuptools.setup(
|
||||||
|
setup_requires=['setuptools-odoo'],
|
||||||
|
odoo_addon=True,
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user