Initial commit of mrp_production_add for 11.0

This commit is contained in:
Jared Kipe
2018-09-11 17:35:43 -07:00
committed by Bhoomi Vaishnani
parent 8fa92cd1bd
commit f71d2b348c
7 changed files with 153 additions and 0 deletions

26
mrp_production_add/README.rst Executable file
View File

@@ -0,0 +1,26 @@
*******************************
Hibou - MRP Production Add Item
*******************************
Allows a user to add a new item to an in-progress Manufacturing Order (including generating PO procurements).
For more information and add-ons, visit `Hibou.io <https://hibou.io/>`_.
.. image:: https://cloud.githubusercontent.com/assets/744550/20810612/2f3eb514-b7bf-11e6-838f-6d6efb8f7484.png
:alt: 'MRP Production Add'
:width: 988
:align: left
=============
Main Features
=============
* Button above existing Consumed Materials to add new product.
* Uses existing procurement group and routes to procure additional items.
=======
Licence
=======
Please see `LICENSE <https://github.com/hibou-io/hibou-odoo-suite/blob/master/LICENSE>`_.
Copyright Hibou Corp. 2016.

1
mrp_production_add/__init__.py Executable file
View File

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

View File

@@ -0,0 +1,17 @@
{
'name': 'MRP Production Add Item',
'author': 'Hibou Corp. <hello@hibou.io>',
'version': '11.0.1.0.0',
'category': 'Manufacturing',
'summary': 'Add Items to an existing Production',
'description': """
This module allows a production order to add additional items that are not on the product's BoM.
""",
'website': 'https://hibou.io/',
'depends': ['mrp'],
'data': [
'wizard/additem_wizard_view.xml',
'views/mrp_production.xml',
],
'installable': True,
}

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record id="mrp_production_add_production_item_form_view" model="ir.ui.view">
<field name="name">mrp.production.add_production_item.form.view</field>
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp.mrp_production_form_view" />
<field name="arch" type="xml">
<xpath expr="//field[@name='move_raw_ids']" position="before">
<group col="2" colspan="2">
<button name="%(action_add_production_item)d"
type="action"
attrs="{'invisible': [('state', 'in', ('cancel', 'done'))]}"
string="Add extra item"
class="oe_highlight"/>
</group>
</xpath>
</field>
</record>
</data>
</odoo>

View File

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

View File

@@ -0,0 +1,49 @@
from odoo import api, fields, models
from odoo.addons import decimal_precision as dp
from odoo.exceptions import UserError
class AddProductionItem(models.TransientModel):
_name = 'wiz.add.production.item'
_description = 'Add Production Item'
@api.model
def _default_production_id(self):
return self.env.context.get('active_id', False)
product_id = fields.Many2one('product.product', 'Product', required=True)
product_qty = fields.Float(
'Product Quantity', digits=dp.get_precision('Product Unit of Measure'),
required=True,
default=1.0)
product_uom_id = fields.Many2one('product.uom', 'Unit of Measure')
production_id = fields.Many2one(
'mrp.production', 'Production Order',
default=_default_production_id)
@api.onchange('product_id')
def _onchange_product_id(self):
for item in self:
if item.product_id:
item.product_uom_id = item.product_id.uom_id
else:
item.product_uom_id = False
@api.multi
def add_item(self):
for item in self:
if item.product_qty <= 0:
raise UserError('Please provide a positive quantity to add')
bom_line = self.env['mrp.bom.line'].new({
'product_id': item.product_id.id,
'product_qty': item.product_qty,
'bom_id': item.production_id.bom_id.id,
'product_uom_id': item.product_uom_id.id,
})
move = item.production_id._generate_raw_move(bom_line, {'qty': item.product_qty, 'parent_line': None})
item.production_id._adjust_procure_method()
move._action_confirm()
return True

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="view_create_add_production_item" model="ir.ui.view">
<field name="name">view.create.add_production_item</field>
<field name="model">wiz.add.production.item</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form>
<group colspan="4" col="4">
<separator string="Add Product" colspan="4"/>
<field name="product_id" colspan="2"/>
<field name="product_uom_id" colspan="2"/>
<field name="product_qty" colspan="2"/>
<field name="production_id" colspan="2"
invisible="context.get('active_id')"/>
</group>
<footer>
<button class="oe_highlight"
name="add_item"
string="Add"
type="object" />
or
<button class="oe_link"
special="cancel"
string="Cancel" />
</footer>
</form>
</field>
</record>
<record id="action_add_production_item" model="ir.actions.act_window">
<field name="name">Add Item View</field>
<field name="res_model">wiz.add.production.item</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_create_add_production_item" />
<field name="target">new</field>
</record>
</odoo>