-
-
Notifications
You must be signed in to change notification settings - Fork 466
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
306 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
.. 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 | ||
|
||
=============== | ||
MRP Produce UOS | ||
=============== | ||
|
||
This module adds the field uos quantity to Product Produce wizard allowing the | ||
user to use the uos quantity (instead of the standard uom) to specify the | ||
quantity to be produced. | ||
|
||
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/95/8.0 | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/manufacture/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback | ||
`here <https://github.com/OCA/manufacture/issues/new?body=module:%20mrp_produce_uos%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Alex Comba <alex.comba@agilebg.com> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
To contribute to this module, please visit http://odoo-community.org. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2015 Alex Comba - Agile Business Group | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from . import models | ||
from . import wizard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2015 Alex Comba - Agile Business Group | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
{ | ||
'name': 'MRP Produce UOS', | ||
'version': '8.0.1.0.0', | ||
'category': 'Manufacturing', | ||
'author': "Agile Business Group, Odoo Community Association (OCA)", | ||
'website': 'http://www.agilebg.com', | ||
'license': 'AGPL-3', | ||
'depends': [ | ||
'mrp', | ||
], | ||
'data': [ | ||
'wizard/mrp_product_produce_view.xml', | ||
], | ||
'installable': True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * mrp_produce_uos | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 8.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2015-09-24 13:45+0000\n" | ||
"PO-Revision-Date: 2015-09-24 15:45+0100\n" | ||
"Last-Translator: Alex Comba <alex.comba@agilebg.com>\n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: \n" | ||
"Language: it\n" | ||
"X-Generator: Poedit 1.7.5\n" | ||
|
||
#. module: mrp_produce_uos | ||
#: model:ir.model,name:mrp_produce_uos.model_mrp_product_produce | ||
msgid "Product Produce" | ||
msgstr "Produci Prodotto" | ||
|
||
#. module: mrp_produce_uos | ||
#: field:mrp.product.produce,product_uos_qty:0 | ||
msgid "Select Quantity (UOS)" | ||
msgstr "Seleziona la quantità (UOS)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * mrp_produce_uos | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 8.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2015-09-24 13:44+0000\n" | ||
"PO-Revision-Date: 2015-09-24 13:44+0000\n" | ||
"Last-Translator: <>\n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: mrp_produce_uos | ||
#: model:ir.model,name:mrp_produce_uos.model_mrp_product_produce | ||
msgid "Product Produce" | ||
msgstr "" | ||
|
||
#. module: mrp_produce_uos | ||
#: field:mrp.product.produce,product_uos_qty:0 | ||
msgid "Select Quantity (UOS)" | ||
msgstr "" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2015 Alex Comba - Agile Business Group | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from . import mrp_production |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2015 Alex Comba - Agile Business Group | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from openerp import models, api | ||
|
||
|
||
class MrpProduction(models.Model): | ||
_inherit = 'mrp.production' | ||
|
||
@api.model | ||
def action_produce(self, production_id, production_qty, | ||
production_mode, wiz=False): | ||
res = super(MrpProduction, self).action_produce( | ||
production_id, production_qty, production_mode, wiz) | ||
|
||
mrp_production = self.browse(production_id) | ||
|
||
for move in mrp_production.move_created_ids2: | ||
product_uom_qty = move.product_uom_qty | ||
p_qty = mrp_production.product_qty | ||
p_uos_qty = mrp_production.product_uos_qty | ||
product_uos_qty = p_uos_qty * (product_uom_qty / p_qty) | ||
# I used sql to avoid | ||
# https://github.com/odoo/odoo/blob/8.0/addons/stock/stock.py#L1980 | ||
self.env.cr.execute( | ||
'UPDATE stock_move SET product_uos_qty = %s ' | ||
'WHERE id = %s', | ||
(product_uos_qty, move.id) | ||
) | ||
|
||
return res |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2015 Alex Comba - Agile Business Group | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from . import test_mrp_produce_uos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2015 Alex Comba - Agile Business Group | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from openerp.tests.common import TransactionCase | ||
|
||
|
||
class TestMrpProduceUos(TransactionCase): | ||
|
||
def setUp(self): | ||
super(TestMrpProduceUos, self).setUp() | ||
self.product_model = self.env['product.product'] | ||
self.bom_model = self.env['mrp.bom'] | ||
self.production_model = self.env['mrp.production'] | ||
self.wizard_model = self.env['mrp.product.produce'] | ||
|
||
self.product_a = self.product_model.create({ | ||
'name': 'Product A', | ||
'list_price': 30, | ||
'uom_id': self.env.ref('product.product_uom_meter').id, | ||
'uom_po_id': self.env.ref('product.product_uom_meter').id, | ||
'uos_id': self.env.ref('product.product_uom_unit').id, | ||
}) | ||
|
||
self.product_b = self.product_model.create({ | ||
'name': 'Product B', | ||
'standard_price': 10, | ||
}) | ||
|
||
self.bom = self.bom_model.create({ | ||
'product_tmpl_id': self.product_a.product_tmpl_id.id, | ||
'product_qty': 1, | ||
'product_uom': self.env.ref('product.product_uom_meter').id, | ||
'bom_line_ids': [ | ||
(0, 0, { | ||
'product_id': self.product_b.id, | ||
'product_qty': 2, | ||
}), | ||
], | ||
}) | ||
|
||
def prepare_production(self): | ||
self.production = self.production_model.create({ | ||
'product_id': self.product_a.id, | ||
'product_qty': 0.5, | ||
'product_uos_qty': 1, | ||
'bom_id': self.bom.id, | ||
'product_uom': self.product_a.uom_id.id, | ||
'product_uos': self.product_a.uos_id.id, | ||
}) | ||
self.wizard = self.wizard_model.with_context( | ||
{'active_id': self.production.id}).create({ | ||
'product_id': self.product_a.id, | ||
}) | ||
|
||
def produce(self): | ||
self.production.action_confirm() | ||
self.wizard.product_uos_qty = 0.5 | ||
self.wizard._onchange_product_uos_qty() | ||
self.production_model.action_produce( | ||
self.production.id, self.wizard.product_qty, | ||
'consume_produce', self.wizard) | ||
self.production.refresh() | ||
self.assertEqual( | ||
len(self.production.move_created_ids2), 1) | ||
self.move_produced = self.production.move_created_ids2[0] | ||
|
||
self.assertEqual(self.move_produced.product_uom_qty, 0.25) | ||
self.assertEqual(self.move_produced.product_uos_qty, 0.5) | ||
|
||
self.assertEqual( | ||
len(self.production.move_created_ids), 1) | ||
self.move_to_produce = self.production.move_created_ids[0] | ||
|
||
self.assertEqual(self.move_to_produce.product_uom_qty, 0.25) | ||
self.assertEqual(self.move_to_produce.product_uos_qty, 0.5) | ||
|
||
def test_action_produce(self): | ||
self.prepare_production() | ||
self.produce() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2015 Alex Comba - Agile Business Group | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from . import mrp_product_produce |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# -*- coding: utf-8 -*- | ||
# (c) 2015 Alex Comba - Agile Business Group | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from openerp import api, fields, models | ||
import openerp.addons.decimal_precision as dp | ||
|
||
|
||
class MrpProductProduce(models.TransientModel): | ||
_inherit = 'mrp.product.produce' | ||
|
||
@api.model | ||
def _default_product_uos_qty(self): | ||
mrp_production = self.env['mrp.production'].browse( | ||
self.env.context['active_id']) | ||
product_qty = self._get_product_qty() | ||
p_qty = mrp_production.product_qty | ||
p_uos_qty = mrp_production.product_uos_qty | ||
product_uos_qty = p_uos_qty * (product_qty / p_qty) | ||
return product_uos_qty | ||
|
||
product_uos_qty = fields.Float( | ||
'Select Quantity (UOS)', | ||
digits=dp.get_precision('Product Unit of Measure'), | ||
default=_default_product_uos_qty,) | ||
|
||
@api.onchange('product_uos_qty') | ||
def _onchange_product_uos_qty(self): | ||
mrp_production = self.env['mrp.production'].browse( | ||
self.env.context['active_id']) | ||
p_qty = mrp_production.product_qty | ||
p_uos_qty = mrp_production.product_uos_qty | ||
self.product_qty = p_qty * (self.product_uos_qty / p_uos_qty) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<openerp> | ||
<data> | ||
|
||
<record id="mrp_product_produce_view_form" model="ir.ui.view"> | ||
<field name="name">mrp.product.produce.view.form</field> | ||
<field name="model">mrp.product.produce</field> | ||
<field name="inherit_id" ref="mrp.view_mrp_product_produce_wizard"/> | ||
<field name="arch" type="xml"> | ||
<field name="product_qty" position="before"> | ||
<field name="product_uos_qty"/> | ||
</field> | ||
</field> | ||
</record> | ||
|
||
</data> | ||
</openerp> |