-
Notifications
You must be signed in to change notification settings - Fork 31
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
10 changed files
with
212 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,28 @@ | ||
.. 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 usability | ||
============= | ||
|
||
* On new shortcut in manufacturing orders form, to moves to consume. | ||
|
||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/avanzosc/mrp-addons/issues>`_. In case of trouble, please | ||
check there if your issue has already been reported. If you spotted it first, | ||
help us smash it by providing detailed and welcomed feedback. | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
* Ana Juaristi <anajuaristi@avanzosc.es> | ||
* Alfredo de la Fuente <alfredodelafuente@avanzosc.es> | ||
|
||
Do not contact contributors directly about support or help with technical issues. |
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 @@ | ||
from . import models |
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,21 @@ | ||
# Copyright 2019 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
{ | ||
"name": "MRP Usability", | ||
"version": "12.0.1.0.0", | ||
"author": "AvanzOSC", | ||
"license": "AGPL-3", | ||
"category": "Custom module", | ||
"website": "http://www.avanzosc.es", | ||
"contributors": [ | ||
"Ana Juaristi <ajuaristio@gmail.com>", | ||
"Alfredo de la Fuente <alfredodelafuente@avanzosc.es>" | ||
], | ||
"depends": [ | ||
"mrp", | ||
], | ||
"data": [ | ||
"views/mrp_production_views.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,37 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * mrp_usability | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 12.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2020-04-16 13:12+0000\n" | ||
"PO-Revision-Date: 2020-04-16 13:12+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_usability | ||
#: model:ir.model.fields,field_description:mrp_usability.field_mrp_production__moves_to_consume_count | ||
msgid "Moves To Consume Count" | ||
msgstr "Contador moves a consumir" | ||
|
||
#. module: mrp_usability | ||
#: model_terms:ir.ui.view,arch_db:mrp_usability.mrp_production_form_view | ||
msgid "Moves to consume" | ||
msgstr "Moves a consumir" | ||
|
||
#. module: mrp_usability | ||
#: model:ir.model,name:mrp_usability.model_mrp_production | ||
msgid "Production Order" | ||
msgstr "Órden de producción" | ||
|
||
#. module: mrp_usability | ||
#: model:ir.actions.act_window,name:mrp_usability.action_show_productions_moves_to_consume | ||
msgid "Productions moves to consume" | ||
msgstr "Moves a consumir de producción" | ||
|
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,37 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * mrp_usability | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 12.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2020-04-16 12:57+0000\n" | ||
"PO-Revision-Date: 2020-04-16 12:57+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_usability | ||
#: model:ir.model.fields,field_description:mrp_usability.field_mrp_production__moves_to_consume_count | ||
msgid "Moves To Consume Count" | ||
msgstr "" | ||
|
||
#. module: mrp_usability | ||
#: model_terms:ir.ui.view,arch_db:mrp_usability.mrp_production_form_view | ||
msgid "Moves to consume" | ||
msgstr "" | ||
|
||
#. module: mrp_usability | ||
#: model:ir.model,name:mrp_usability.model_mrp_production | ||
msgid "Production Order" | ||
msgstr "" | ||
|
||
#. module: mrp_usability | ||
#: model:ir.actions.act_window,name:mrp_usability.action_show_productions_moves_to_consume | ||
msgid "Productions moves to consume" | ||
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 @@ | ||
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,39 @@ | ||
# Copyright 2019 Alfredo de la fuente - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
from openerp import models, fields, api | ||
from odoo.models import expression | ||
from odoo.tools.safe_eval import safe_eval | ||
|
||
|
||
class MrpProduction(models.Model): | ||
_inherit = 'mrp.production' | ||
|
||
moves_to_consume_count = fields.Integer( | ||
string='', compute='_compute_moves_to_consume_count', store=True) | ||
|
||
@api.depends('move_raw_ids', 'move_raw_ids.scrapped') | ||
def _compute_moves_to_consume_count(self): | ||
for production in self.filtered( | ||
lambda c: c.move_raw_ids): | ||
moves = production.mapped('move_raw_ids').filtered( | ||
lambda x: not x.scrapped) | ||
production.moves_to_consume_count = len(moves) if moves else 0 | ||
|
||
@api.multi | ||
def button_show_moves_to_consume(self): | ||
self.ensure_one() | ||
moves = self.mapped('move_raw_ids').filtered( | ||
lambda x: not x.scrapped) | ||
action = self.env.ref( | ||
'mrp_usability.action_show_productions_moves_to_consume') | ||
action_dict = action.read()[0] if action else {} | ||
action_dict['context'] = safe_eval( | ||
action_dict.get('context', '{}')) | ||
action_dict['context'].update( | ||
{'search_default_production_id': self.id, | ||
'default_production_id': self.id}) | ||
domain = expression.AND([ | ||
[('id', 'in', moves.ids)], | ||
safe_eval(action.domain or '[]')]) | ||
action_dict.update({'domain': domain}) | ||
return action_dict if moves else 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 @@ | ||
from . import test_mrp_usability |
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,23 @@ | ||
# Copyright 2019 Oihane Crucelaegui - AvanzOSC | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo.tests import common | ||
|
||
|
||
@common.at_install(False) | ||
@common.post_install(True) | ||
class TestMrpUsability(common.SavepointCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super(TestMrpUsability, cls).setUpClass() | ||
cls.production_obj = cls.env['mrp.production'] | ||
|
||
def test_mrp_usability(self): | ||
productions = self.production_obj.search([]) | ||
for production in productions: | ||
self.assertEquals( | ||
production.moves_to_consume_count, | ||
len(production.move_raw_ids)) | ||
res = production.button_show_moves_to_consume() | ||
domain = [('id', 'in', production.move_raw_ids.ids)] | ||
self.assertEquals(domain, res.get('domain', False)) |
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,24 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<odoo> | ||
<record id="mrp_production_form_view" model="ir.ui.view"> | ||
<field name="model">mrp.production</field> | ||
<field name="inherit_id" ref="mrp.mrp_production_form_view" /> | ||
<field name="arch" type="xml"> | ||
<button name="action_view_mo_delivery" position="after"> | ||
<button type="object" name="button_show_moves_to_consume" | ||
class="oe_stat_button" icon="fa-arrows-v" groups="base.group_user"> | ||
<field name="moves_to_consume_count" widget="statinfo" string="Moves to consume"/> | ||
</button> | ||
</button> | ||
</field> | ||
</record> | ||
<record id="action_show_productions_moves_to_consume" model="ir.actions.act_window"> | ||
<field name="name">Productions moves to consume</field> | ||
<field name="res_model">stock.move</field> | ||
<field name="type">ir.actions.act_window</field> | ||
<field name="view_type">form</field> | ||
<field name="view_mode">tree,kanban,form</field> | ||
<field name="view_id" ref="stock.view_move_tree"/> | ||
<field name="search_view_id" ref="stock.view_move_search"/> | ||
</record> | ||
</odoo> |