From b1386f3a72aabd9d5416b25ec5fe35be5e434dbc Mon Sep 17 00:00:00 2001 From: alfredo Date: Tue, 21 Oct 2014 15:34:21 +0200 Subject: [PATCH] [ADD] mrp_production_estimated_cost --- .../README.rst | 24 ++ .../__init__.py | 19 ++ .../__openerp__.py | 50 +++ .../data/analytic_journal_data.xml | 26 ++ .../fictitious_mrp_production_sequence.xml | 15 + .../i18n/es.po | 267 ++++++++++++++++ .../mrp_production_project_estimated_cost.pot | 267 ++++++++++++++++ .../models/__init__.py | 22 ++ .../models/account_analytic_line.py | 28 ++ .../models/mrp_bom.py | 30 ++ .../models/mrp_production.py | 286 ++++++++++++++++++ .../models/product.py | 28 ++ .../models/project_project.py | 26 ++ .../views/account_analytic_line_view.xml | 53 ++++ .../views/mrp_bom_view.xml | 30 ++ .../views/mrp_production_view.xml | 110 +++++++ .../views/product_view.xml | 41 +++ .../wizard/__init__.py | 18 ++ .../wizard/wiz_create_fictitious_of.py | 56 ++++ .../wizard/wiz_create_fictitious_of_view.xml | 45 +++ 20 files changed, 1441 insertions(+) create mode 100644 mrp_production_project_estimated_cost/README.rst create mode 100644 mrp_production_project_estimated_cost/__init__.py create mode 100644 mrp_production_project_estimated_cost/__openerp__.py create mode 100644 mrp_production_project_estimated_cost/data/analytic_journal_data.xml create mode 100644 mrp_production_project_estimated_cost/data/fictitious_mrp_production_sequence.xml create mode 100644 mrp_production_project_estimated_cost/i18n/es.po create mode 100644 mrp_production_project_estimated_cost/i18n/mrp_production_project_estimated_cost.pot create mode 100644 mrp_production_project_estimated_cost/models/__init__.py create mode 100644 mrp_production_project_estimated_cost/models/account_analytic_line.py create mode 100644 mrp_production_project_estimated_cost/models/mrp_bom.py create mode 100644 mrp_production_project_estimated_cost/models/mrp_production.py create mode 100644 mrp_production_project_estimated_cost/models/product.py create mode 100644 mrp_production_project_estimated_cost/models/project_project.py create mode 100644 mrp_production_project_estimated_cost/views/account_analytic_line_view.xml create mode 100644 mrp_production_project_estimated_cost/views/mrp_bom_view.xml create mode 100644 mrp_production_project_estimated_cost/views/mrp_production_view.xml create mode 100644 mrp_production_project_estimated_cost/views/product_view.xml create mode 100644 mrp_production_project_estimated_cost/wizard/__init__.py create mode 100644 mrp_production_project_estimated_cost/wizard/wiz_create_fictitious_of.py create mode 100644 mrp_production_project_estimated_cost/wizard/wiz_create_fictitious_of_view.xml diff --git a/mrp_production_project_estimated_cost/README.rst b/mrp_production_project_estimated_cost/README.rst new file mode 100644 index 000000000..5bf2d33c9 --- /dev/null +++ b/mrp_production_project_estimated_cost/README.rst @@ -0,0 +1,24 @@ +Estimated costs in manufacturing orders +======================================= +With this module when a production order is confirmed, some analytic lines +are automatically generated, in order to estimate the costs of the production +order. + +At the same time, the estimated allocation of materials, machinery operators +and costs will be made. + +In materials case, an analytic line will be generated for each material to +consume in the order. For operators imputation in each operation, it will +be generated one line, so that the number of lines will be equal to the number +of operators in the operation. In machines case, there will be created two +analytic lines for each operation in the associated routing, one per hour cost +and the other per cycle cost. + +It has also created the new menu option "Fictitious Manufacturing Orders to +estimate costs". When a new MO is created and the new field "active" is equal +to false, the MO will be considered as a fictional MO, what with can not be +confirmed, and only is valid to estimate costs. To estimate costs will have to +press the "Compute data" button in tab "Work Orders". These fictitious MO will +have a different sequence. +From the product form may create a fictitious MO. + diff --git a/mrp_production_project_estimated_cost/__init__.py b/mrp_production_project_estimated_cost/__init__.py new file mode 100644 index 000000000..4270b1259 --- /dev/null +++ b/mrp_production_project_estimated_cost/__init__.py @@ -0,0 +1,19 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +############################################################################## +from . import models +from . import wizard diff --git a/mrp_production_project_estimated_cost/__openerp__.py b/mrp_production_project_estimated_cost/__openerp__.py new file mode 100644 index 000000000..87703d2cf --- /dev/null +++ b/mrp_production_project_estimated_cost/__openerp__.py @@ -0,0 +1,50 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +############################################################################## + +{ + "name": "Estimated costs in manufacturing orders", + "version": "1.0", + "category": "Manufacturing", + "author": "OdooMRP team," + "AvanzOSC," + "Serv. Tecnol. Avanzados - Pedro M. Baeza", + "website": "http://www.odoomrp.com", + "contributors": [ + "Alfredo de la Fuente ", + "Pedro M. Baeza ", + "Ana Juaristi ", + "Oihane Crucelaegui ", + ], + "depends": [ + "product", + "analytic", + "mrp", + "mrp_operations_extension", + "mrp_project_link", + ], + "data": [ + "data/analytic_journal_data.xml", + "data/fictitious_mrp_production_sequence.xml", + "wizard/wiz_create_fictitious_of_view.xml", + "views/account_analytic_line_view.xml", + "views/mrp_production_view.xml", + "views/product_view.xml", + "views/mrp_bom_view.xml" + ], + "installable": True, +} diff --git a/mrp_production_project_estimated_cost/data/analytic_journal_data.xml b/mrp_production_project_estimated_cost/data/analytic_journal_data.xml new file mode 100644 index 000000000..56a9f588d --- /dev/null +++ b/mrp_production_project_estimated_cost/data/analytic_journal_data.xml @@ -0,0 +1,26 @@ + + + + + + Materials + MAT + general + True + + + + Operators + OPE + general + True + + + + Machines + MACH + general + True + + + diff --git a/mrp_production_project_estimated_cost/data/fictitious_mrp_production_sequence.xml b/mrp_production_project_estimated_cost/data/fictitious_mrp_production_sequence.xml new file mode 100644 index 000000000..c6091eeb9 --- /dev/null +++ b/mrp_production_project_estimated_cost/data/fictitious_mrp_production_sequence.xml @@ -0,0 +1,15 @@ + + + + + Fictitious MRP Production + fictitious.mrp.production + + + Fictitious MRP Production + fictitious.mrp.production + + FMO + + + diff --git a/mrp_production_project_estimated_cost/i18n/es.po b/mrp_production_project_estimated_cost/i18n/es.po new file mode 100644 index 000000000..a52ff6d15 --- /dev/null +++ b/mrp_production_project_estimated_cost/i18n/es.po @@ -0,0 +1,267 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_production_project_estimated_cost +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-02-24 15:19+0000\n" +"PO-Revision-Date: 2015-02-24 16:25+0100\n" +"Last-Translator: \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" + +#. module: mrp_production_project_estimated_cost +#: code:addons/mrp_production_project_estimated_cost/models/mrp_production.py:165 +#, python-format +msgid "%s-%s" +msgstr "%s-%s" + +#. module: mrp_production_project_estimated_cost +#: code:addons/mrp_production_project_estimated_cost/models/mrp_production.py:187 +#, python-format +msgid "%s-%s Post-operation" +msgstr "%s-%s Post-operación" + +#. module: mrp_production_project_estimated_cost +#: code:addons/mrp_production_project_estimated_cost/models/mrp_production.py:178 +#, python-format +msgid "%s-%s Pre-operation" +msgstr "%s-%s Pre-operación" + +#. module: mrp_production_project_estimated_cost +#: code:addons/mrp_production_project_estimated_cost/models/mrp_production.py:238 +#, python-format +msgid "%s-%s-%s" +msgstr "%s-%s-%s" + +#. module: mrp_production_project_estimated_cost +#: code:addons/mrp_production_project_estimated_cost/models/mrp_production.py:200 +#, python-format +msgid "%s-%s-C-%s" +msgstr "%s-%s-C-%s" + +#. module: mrp_production_project_estimated_cost +#: code:addons/mrp_production_project_estimated_cost/models/mrp_production.py:215 +#, python-format +msgid "%s-%s-H-%s" +msgstr "%s-%s-H-%s" + +#. module: mrp_production_project_estimated_cost +#: field:mrp.production,active:0 +msgid "Active" +msgstr "Activa" + +#. module: mrp_production_project_estimated_cost +#: model:ir.model,name:mrp_production_project_estimated_cost.model_account_analytic_line +msgid "Analytic Line" +msgstr "Línea analítica" + +#. module: mrp_production_project_estimated_cost +#: field:project.project,automatic_creation:0 +msgid "Automatic Creation" +msgstr "Creación automática" + +#. module: mrp_production_project_estimated_cost +#: model:ir.model,name:mrp_production_project_estimated_cost.model_mrp_bom +msgid "Bill of Material" +msgstr "Lista de material" + +#. module: mrp_production_project_estimated_cost +#: view:wiz.create.fictitious.of:mrp_production_project_estimated_cost.wiz_create_fictitious_of_view +msgid "Cancel" +msgstr "Cancelar" + +#. module: mrp_production_project_estimated_cost +#: field:mrp.production,analytic_line_ids:0 +msgid "Cost Lines" +msgstr "Líneas de costes" + +#. module: mrp_production_project_estimated_cost +#: view:mrp.production:mrp_production_project_estimated_cost.mrp_production_form_view_inh_estimatedcost +msgid "Create Estimated Costs" +msgstr "Crear costes estimados" + +#. module: mrp_production_project_estimated_cost +#: view:product.product:mrp_production_project_estimated_cost.product_product_form_view_bom_button_inh_estimatedcost +#: view:product.template:mrp_production_project_estimated_cost.product_template_form_view_bom_button_inh_estimatedcost +msgid "Create Fictitious MO" +msgstr "Crea OF ficticia" + +#. module: mrp_production_project_estimated_cost +#: model:ir.actions.act_window,name:mrp_production_project_estimated_cost.act_product_create_fictitious_of +#: model:ir.actions.act_window,name:mrp_production_project_estimated_cost.action_run_create_fictitious_of +#: model:ir.actions.act_window,name:mrp_production_project_estimated_cost.action_run_template_create_fictitious_of +#: view:wiz.create.fictitious.of:mrp_production_project_estimated_cost.wiz_create_fictitious_of_view +msgid "Create fictitious MO" +msgstr "CrearOF ficticia" + +#. module: mrp_production_project_estimated_cost +#: field:wiz.create.fictitious.of,create_uid:0 +msgid "Created by" +msgstr "Creado por" + +#. module: mrp_production_project_estimated_cost +#: field:wiz.create.fictitious.of,create_date:0 +msgid "Created on" +msgstr "Creado el" + +#. module: mrp_production_project_estimated_cost +#: field:mrp.production,partner:0 +msgid "Customer" +msgstr "Cliente" + +#. module: mrp_production_project_estimated_cost +#: view:mrp.production:mrp_production_project_estimated_cost.mrp_production_buttons_inh_estimatedcost +msgid "Estim. Costs" +msgstr "Costes estim." + +#. module: mrp_production_project_estimated_cost +#: field:account.analytic.line,estim_avg_cost:0 +#: field:mrp.production,avg_cost:0 +msgid "Estimated Average Cost" +msgstr "Coste medio estimado" + +#. module: mrp_production_project_estimated_cost +#: field:mrp.production,unit_avg_cost:0 +msgid "Estimated Average Unit Cost" +msgstr "Coste medio estimado por unidad" + +#. module: mrp_production_project_estimated_cost +#: view:account.analytic.line:mrp_production_project_estimated_cost.estimated_cost_list_view +msgid "Estimated Costs" +msgstr "Costes estimados" + +#. module: mrp_production_project_estimated_cost +#: field:account.analytic.line,estim_std_cost:0 +#: field:mrp.production,std_cost:0 +msgid "Estimated Standard Cost" +msgstr "Coste estándar estimado" + +#. module: mrp_production_project_estimated_cost +#: field:mrp.production,unit_std_cost:0 +msgid "Estimated Standard Unit Cost" +msgstr "Coste estándar estimado por unidad" + +#. module: mrp_production_project_estimated_cost +#: model:ir.actions.act_window,name:mrp_production_project_estimated_cost.action_estimated_costs_per_production +msgid "Estimated costs from production order" +msgstr "Costes estimados desde orden de producción" + +#. module: mrp_production_project_estimated_cost +#: view:mrp.production:mrp_production_project_estimated_cost.mrp_production_form_view_inh_estimatedcost +msgid "Extra Information" +msgstr "Información extra" + +#. module: mrp_production_project_estimated_cost +#: model:ir.actions.act_window,name:mrp_production_project_estimated_cost.mrp_fictitious_production_action +#: model:ir.ui.menu,name:mrp_production_project_estimated_cost.menu_mrp_fictitious_production_action +msgid "Fictitious Manufacturing Orders to estimate costs" +msgstr "Órdenes de producción ficiticias para estimar costes" + +#. module: mrp_production_project_estimated_cost +#: view:account.analytic.line:mrp_production_project_estimated_cost.view_account_analytic_line_form_inh_estimatedcost +msgid "General Accounting" +msgstr "Contabilidad general" + +#. module: mrp_production_project_estimated_cost +#: field:wiz.create.fictitious.of,id:0 +msgid "ID" +msgstr "ID" + +#. module: mrp_production_project_estimated_cost +#: field:wiz.create.fictitious.of,write_uid:0 +msgid "Last Updated by" +msgstr "Última actualización por" + +#. module: mrp_production_project_estimated_cost +#: field:wiz.create.fictitious.of,write_date:0 +msgid "Last Updated on" +msgstr "Última actualización el" + +#. module: mrp_production_project_estimated_cost +#: view:mrp.production:mrp_production_project_estimated_cost.mrp_production_form_view_inh_estimatedcost +msgid "Load Cost on Product" +msgstr "Cargar coste en el producto" + +#. module: mrp_production_project_estimated_cost +#: field:wiz.create.fictitious.of,load_on_product:0 +msgid "Load cost on product" +msgstr "Cargar coste en el producto" + +#. module: mrp_production_project_estimated_cost +#: field:product.template,manual_standard_cost:0 +msgid "Manual Standard Cost" +msgstr "Coste estándar manual" + +#. module: mrp_production_project_estimated_cost +#: model:ir.model,name:mrp_production_project_estimated_cost.model_mrp_production +msgid "Manufacturing Order" +msgstr "Órden de producción" + +#. module: mrp_production_project_estimated_cost +#: view:mrp.production:mrp_production_project_estimated_cost.mrp_production_form_view_inh_estimatedcost +msgid "Manufacturing costs" +msgstr "Costes de fabricación" + +#. module: mrp_production_project_estimated_cost +#: code:addons/mrp_production_project_estimated_cost/models/mrp_production.py:164 +#, python-format +msgid "One consume line has no product assigned." +msgstr "Una de las líneas de consumo no tiene producto asignado." + +#. module: mrp_production_project_estimated_cost +#: model:ir.model,name:mrp_production_project_estimated_cost.model_product_template +msgid "Product Template" +msgstr "Plantilla de producto" + +#. module: mrp_production_project_estimated_cost +#: view:account.analytic.line:mrp_production_project_estimated_cost.view_account_analytic_line_form_inh_estimatedcost +msgid "Production Information" +msgstr "Información de la fabricación" + +#. module: mrp_production_project_estimated_cost +#: model:ir.model,name:mrp_production_project_estimated_cost.model_project_project +#: field:wiz.create.fictitious.of,project_id:0 +msgid "Project" +msgstr "Proyecto" + +#. module: mrp_production_project_estimated_cost +#: field:wiz.create.fictitious.of,date_planned:0 +msgid "Scheduled Date" +msgstr "Fecha programada" + +#. module: mrp_production_project_estimated_cost +#: code:addons/mrp_production_project_estimated_cost/models/mrp_production.py:198 +#: code:addons/mrp_production_project_estimated_cost/models/mrp_production.py:213 +#: code:addons/mrp_production_project_estimated_cost/models/mrp_production.py:233 +#, python-format +msgid "There is at least this workcenter without product: %s" +msgstr "Esta máquina no tiene un producto asignado: %s" + +#. module: mrp_production_project_estimated_cost +#: code:addons/mrp_production_project_estimated_cost/models/mrp_production.py:257 +#, python-format +msgid "You must define Income account in the product \"%s\", or in the product category" +msgstr "Debe definir la cuenta de entrada en el producto \"%s\", o en la categoría del producto" + +#. module: mrp_production_project_estimated_cost +#: code:addons/mrp_production_project_estimated_cost/models/mrp_production.py:261 +#, python-format +msgid "You must define one Analytic Account for this MO: %s" +msgstr "Debe definir una cuenta analítica para esta MO: %s" + +#. module: mrp_production_project_estimated_cost +#: view:wiz.create.fictitious.of:mrp_production_project_estimated_cost.wiz_create_fictitious_of_view +msgid "or" +msgstr "o" + +#. module: mrp_production_project_estimated_cost +#: view:mrp.production:mrp_production_project_estimated_cost.mrp_production_form_view_inh_estimatedcost +msgid "{'invisible':['|',('active','=',False),('state','!=','draft')]}" +msgstr "{'invisible':['|',('active','=',False),('state','!=','draft')]}" + diff --git a/mrp_production_project_estimated_cost/i18n/mrp_production_project_estimated_cost.pot b/mrp_production_project_estimated_cost/i18n/mrp_production_project_estimated_cost.pot new file mode 100644 index 000000000..8ca00b888 --- /dev/null +++ b/mrp_production_project_estimated_cost/i18n/mrp_production_project_estimated_cost.pot @@ -0,0 +1,267 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_production_project_estimated_cost +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2015-02-24 15:18+0000\n" +"PO-Revision-Date: 2015-02-24 15:18+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_production_project_estimated_cost +#: code:addons/mrp_production_project_estimated_cost/models/mrp_production.py:165 +#, python-format +msgid "%s-%s" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: code:addons/mrp_production_project_estimated_cost/models/mrp_production.py:187 +#, python-format +msgid "%s-%s Post-operation" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: code:addons/mrp_production_project_estimated_cost/models/mrp_production.py:178 +#, python-format +msgid "%s-%s Pre-operation" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: code:addons/mrp_production_project_estimated_cost/models/mrp_production.py:238 +#, python-format +msgid "%s-%s-%s" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: code:addons/mrp_production_project_estimated_cost/models/mrp_production.py:200 +#, python-format +msgid "%s-%s-C-%s" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: code:addons/mrp_production_project_estimated_cost/models/mrp_production.py:215 +#, python-format +msgid "%s-%s-H-%s" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: field:mrp.production,active:0 +msgid "Active" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: model:ir.model,name:mrp_production_project_estimated_cost.model_account_analytic_line +msgid "Analytic Line" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: field:project.project,automatic_creation:0 +msgid "Automatic Creation" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: model:ir.model,name:mrp_production_project_estimated_cost.model_mrp_bom +msgid "Bill of Material" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: view:wiz.create.fictitious.of:mrp_production_project_estimated_cost.wiz_create_fictitious_of_view +msgid "Cancel" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: field:mrp.production,analytic_line_ids:0 +msgid "Cost Lines" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: view:mrp.production:mrp_production_project_estimated_cost.mrp_production_form_view_inh_estimatedcost +msgid "Create Estimated Costs" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: view:product.product:mrp_production_project_estimated_cost.product_product_form_view_bom_button_inh_estimatedcost +#: view:product.template:mrp_production_project_estimated_cost.product_template_form_view_bom_button_inh_estimatedcost +msgid "Create Fictitious MO" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: model:ir.actions.act_window,name:mrp_production_project_estimated_cost.act_product_create_fictitious_of +#: model:ir.actions.act_window,name:mrp_production_project_estimated_cost.action_run_create_fictitious_of +#: model:ir.actions.act_window,name:mrp_production_project_estimated_cost.action_run_template_create_fictitious_of +#: view:wiz.create.fictitious.of:mrp_production_project_estimated_cost.wiz_create_fictitious_of_view +msgid "Create fictitious MO" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: field:wiz.create.fictitious.of,create_uid:0 +msgid "Created by" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: field:wiz.create.fictitious.of,create_date:0 +msgid "Created on" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: field:mrp.production,partner:0 +msgid "Customer" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: view:mrp.production:mrp_production_project_estimated_cost.mrp_production_buttons_inh_estimatedcost +msgid "Estim. Costs" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: field:account.analytic.line,estim_avg_cost:0 +#: field:mrp.production,avg_cost:0 +msgid "Estimated Average Cost" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: field:mrp.production,unit_avg_cost:0 +msgid "Estimated Average Unit Cost" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: view:account.analytic.line:mrp_production_project_estimated_cost.estimated_cost_list_view +msgid "Estimated Costs" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: field:account.analytic.line,estim_std_cost:0 +#: field:mrp.production,std_cost:0 +msgid "Estimated Standard Cost" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: field:mrp.production,unit_std_cost:0 +msgid "Estimated Standard Unit Cost" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: model:ir.actions.act_window,name:mrp_production_project_estimated_cost.action_estimated_costs_per_production +msgid "Estimated costs from production order" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: view:mrp.production:mrp_production_project_estimated_cost.mrp_production_form_view_inh_estimatedcost +msgid "Extra Information" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: model:ir.actions.act_window,name:mrp_production_project_estimated_cost.mrp_fictitious_production_action +#: model:ir.ui.menu,name:mrp_production_project_estimated_cost.menu_mrp_fictitious_production_action +msgid "Fictitious Manufacturing Orders to estimate costs" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: view:account.analytic.line:mrp_production_project_estimated_cost.view_account_analytic_line_form_inh_estimatedcost +msgid "General Accounting" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: field:wiz.create.fictitious.of,id:0 +msgid "ID" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: field:wiz.create.fictitious.of,write_uid:0 +msgid "Last Updated by" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: field:wiz.create.fictitious.of,write_date:0 +msgid "Last Updated on" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: view:mrp.production:mrp_production_project_estimated_cost.mrp_production_form_view_inh_estimatedcost +msgid "Load Cost on Product" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: field:wiz.create.fictitious.of,load_on_product:0 +msgid "Load cost on product" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: field:product.template,manual_standard_cost:0 +msgid "Manual Standard Cost" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: model:ir.model,name:mrp_production_project_estimated_cost.model_mrp_production +msgid "Manufacturing Order" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: view:mrp.production:mrp_production_project_estimated_cost.mrp_production_form_view_inh_estimatedcost +msgid "Manufacturing costs" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: code:addons/mrp_production_project_estimated_cost/models/mrp_production.py:164 +#, python-format +msgid "One consume line has no product assigned." +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: model:ir.model,name:mrp_production_project_estimated_cost.model_product_template +msgid "Product Template" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: view:account.analytic.line:mrp_production_project_estimated_cost.view_account_analytic_line_form_inh_estimatedcost +msgid "Production Information" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: model:ir.model,name:mrp_production_project_estimated_cost.model_project_project +#: field:wiz.create.fictitious.of,project_id:0 +msgid "Project" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: field:wiz.create.fictitious.of,date_planned:0 +msgid "Scheduled Date" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: code:addons/mrp_production_project_estimated_cost/models/mrp_production.py:198 +#: code:addons/mrp_production_project_estimated_cost/models/mrp_production.py:213 +#: code:addons/mrp_production_project_estimated_cost/models/mrp_production.py:233 +#, python-format +msgid "There is at least this workcenter without product: %s" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: code:addons/mrp_production_project_estimated_cost/models/mrp_production.py:257 +#, python-format +msgid "You must define Income account in the product \"%s\", or in the product category" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: code:addons/mrp_production_project_estimated_cost/models/mrp_production.py:261 +#, python-format +msgid "You must define one Analytic Account for this MO: %s" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: view:wiz.create.fictitious.of:mrp_production_project_estimated_cost.wiz_create_fictitious_of_view +msgid "or" +msgstr "" + +#. module: mrp_production_project_estimated_cost +#: view:mrp.production:mrp_production_project_estimated_cost.mrp_production_form_view_inh_estimatedcost +msgid "{'invisible':['|',('active','=',False),('state','!=','draft')]}" +msgstr "" + diff --git a/mrp_production_project_estimated_cost/models/__init__.py b/mrp_production_project_estimated_cost/models/__init__.py new file mode 100644 index 000000000..7db71fe6f --- /dev/null +++ b/mrp_production_project_estimated_cost/models/__init__.py @@ -0,0 +1,22 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +############################################################################## +from . import account_analytic_line +from . import mrp_production +from . import product +from . import project_project +from . import mrp_bom diff --git a/mrp_production_project_estimated_cost/models/account_analytic_line.py b/mrp_production_project_estimated_cost/models/account_analytic_line.py new file mode 100644 index 000000000..9f545a822 --- /dev/null +++ b/mrp_production_project_estimated_cost/models/account_analytic_line.py @@ -0,0 +1,28 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +############################################################################## +from openerp import models, fields +import openerp.addons.decimal_precision as dp + + +class AccountAnalyticLine(models.Model): + _inherit = 'account.analytic.line' + + estim_std_cost = fields.Float(string='Estimated Standard Cost', + digits=dp.get_precision('Product Price')) + estim_avg_cost = fields.Float(string='Estimated Average Cost', + digits=dp.get_precision('Product Price')) diff --git a/mrp_production_project_estimated_cost/models/mrp_bom.py b/mrp_production_project_estimated_cost/models/mrp_bom.py new file mode 100644 index 000000000..3e55eca2d --- /dev/null +++ b/mrp_production_project_estimated_cost/models/mrp_bom.py @@ -0,0 +1,30 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +############################################################################## + +from openerp import models, fields + + +class MrpBom(models.Model): + + _inherit = "mrp.bom" + + product_standard_price = fields.Float(string="Product Standard Price", + related="product_id.standard_price") + product_manual_standard_price = fields.Float( + string="Product Manual Standard Price", + related="product_id.manual_standard_cost") diff --git a/mrp_production_project_estimated_cost/models/mrp_production.py b/mrp_production_project_estimated_cost/models/mrp_production.py new file mode 100644 index 000000000..8f422ef1d --- /dev/null +++ b/mrp_production_project_estimated_cost/models/mrp_production.py @@ -0,0 +1,286 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +############################################################################## +from openerp import models, fields, api, exceptions, _ + + +class MrpProduction(models.Model): + _inherit = 'mrp.production' + + @api.one + @api.depends('analytic_line_ids', 'analytic_line_ids.estim_std_cost', + 'product_qty') + def get_unit_std_cost(self): + self.std_cost = sum([line.estim_std_cost for line in + self.analytic_line_ids]) + self.unit_std_cost = self.std_cost / self.product_qty + + @api.one + @api.depends('analytic_line_ids', 'analytic_line_ids.estim_avg_cost', + 'product_qty') + def get_unit_avg_cost(self): + self.avg_cost = sum([line.estim_avg_cost for line in + self.analytic_line_ids]) + self.unit_avg_cost = self.avg_cost / self.product_qty + + @api.one + def _count_created_estimated_cost(self): + analytic_line_obj = self.env['account.analytic.line'] + cond = [('mrp_production_id', '=', self.id), + ('task_id', '=', False)] + analytic_lines = analytic_line_obj.search(cond) + self.created_estimated_cost = len(analytic_lines) + + active = fields.Boolean( + 'Active', default=lambda self: self.env.context.get('default_active', + True)) + name = fields.Char( + string='Referencen', required=True, readonly=True, copy="False", + states={'draft': [('readonly', False)]}, default="/") + created_estimated_cost = fields.Integer( + compute="_count_created_estimated_cost", string="Estimated Costs") + std_cost = fields.Float(string="Estimated Standard Cost", + compute="get_unit_std_cost", store=True) + avg_cost = fields.Float(string="Estimated Average Cost", + compute="get_unit_avg_cost", store=True) + unit_std_cost = fields.Float(string="Estimated Standard Unit Cost", + compute="get_unit_std_cost", store=True) + unit_avg_cost = fields.Float(string="Estimated Average Unit Cost", + compute="get_unit_avg_cost", store=True) + product_manual_cost = fields.Float( + string="Product Manual Cost", + related="product_id.manual_standard_cost") + product_cost = fields.Float(string="Product Cost", + related="product_id.standard_price") + analytic_line_ids = fields.One2many("account.analytic.line", + "mrp_production_id", + string="Cost Lines") + + @api.model + def create(self, values): + sequence_obj = self.pool['ir.sequence'] + if 'active' not in values or values['active']: + values['active'] = True + values['name'] = sequence_obj.get(self._cr, self._uid, + 'mrp.production') + else: + values['name'] = sequence_obj.get(self._cr, self._uid, + 'fictitious.mrp.production') + return super(MrpProduction, self).create(values) + + @api.multi + def unlink(self): + analytic_line_obj = self.env['account.analytic.line'] + for production in self: + cond = [('mrp_production_id', '=', production.id)] + analytic_line_obj.search(cond).unlink() + if production.project_id.automatic_creation: + production.project_id.unlink() + analytic_lines = analytic_line_obj.search( + [('account_id', '=', production.analytic_account_id.id)]) + if not analytic_lines: + production.analytic_account_id.unlink() + return super(MrpProduction, self).unlink() + + @api.multi + def action_confirm(self): + res = super(MrpProduction, self).action_confirm() + self.calculate_production_estimated_cost() + return res + + @api.multi + def action_compute(self, properties=None): + project_obj = self.env['project.project'] + res = super(MrpProduction, self).action_compute(properties=properties) + for record in self: + if not record.project_id: + project = project_obj.search([('name', '=', record.name)], + limit=1) + if not project: + project_vals = {'name': record.name, + 'use_tasks': True, + 'use_timesheets': True, + 'use_issues': True, + 'automatic_creation': True, + } + project = project_obj.create(project_vals) + record.project_id = project.id + record.analytic_account_id = project.analytic_account_id.id + return res + + @api.multi + def action_show_estimated_costs(self): + self.ensure_one() + analytic_line_obj = self.env['account.analytic.line'] + id2 = self.env.ref( + 'mrp_production_project_estimated_cost.estimated_cost_list_view') + search_view = self.env.ref('mrp_project_link.account_analytic_line' + '_mrp_search_view') + analytic_line_list = analytic_line_obj.search( + [('mrp_production_id', '=', self.id), + ('task_id', '=', False)]) + self = self.with_context(search_default_group_production=1, + search_default_group_workorder=1, + search_default_group_journal=1) + return { + 'view_type': 'form', + 'view_mode': 'tree', + 'res_model': 'account.analytic.line', + 'views': [(id2.id, 'tree')], + 'search_view_id': search_view.id, + 'view_id': False, + 'type': 'ir.actions.act_window', + 'target': 'new', + 'domain': "[('id','in',[" + + ','.join(map(str, analytic_line_list.ids)) + "])]", + 'context': self.env.context + } + + @api.multi + def calculate_production_estimated_cost(self): + analytic_line_obj = self.env['account.analytic.line'] + for record in self: + cond = [('mrp_production_id', '=', record.id)] + analytic_line_obj.search(cond).unlink() + journal = record.env.ref('mrp_production_project_estimated_cost.' + 'analytic_journal_materials', False) + for line in record.product_lines: + if not line.product_id: + raise exceptions.Warning( + _("One consume line has no product assigned.")) + name = _('%s-%s' % (record.name, line.work_order.name or '')) + vals = record._prepare_estim_cost_analytic_line( + journal, name, record, line.work_order, line.product_id, + line.product_qty) + analytic_line_obj.create(vals) + journal = record.env.ref('mrp_production_project_estimated_cost.' + 'analytic_journal_machines', False) + for line in record.workcenter_lines: + op_wc_lines = line.routing_wc_line.op_wc_lines + wc = op_wc_lines.filtered(lambda r: r.workcenter == + line.workcenter_id) or \ + line.workcenter_id + if (wc.time_start and line.workcenter_id.pre_op_product): + name = (_('%s-%s Pre-operation') % + (record.name, line.workcenter_id.name)) + vals = record._prepare_estim_cost_analytic_line( + journal, name, record, line, + line.workcenter_id.pre_op_product, wc.time_start) + amount = line.workcenter_id.pre_op_product.standard_price + vals['amount'] = amount + analytic_line_obj.create(vals) + if (wc.time_stop and line.workcenter_id.post_op_product): + name = (_('%s-%s Post-operation') % + (record.name, line.workcenter_id.name)) + vals = record._prepare_estim_cost_analytic_line( + journal, name, record, line, + line.workcenter_id.post_op_product, wc.time_stop) + amount = line.workcenter_id.post_op_product.standard_price + vals['amount'] = amount + analytic_line_obj.create(vals) + if line.cycle and line.workcenter_id.costs_cycle: + if not line.workcenter_id.product_id: + raise exceptions.Warning( + _("There is at least this workcenter without " + "product: %s") % line.workcenter_id.name) + name = (_('%s-%s-C-%s') % + (record.name, line.routing_wc_line.operation.code, + line.workcenter_id.name)) + vals = record._prepare_estim_cost_analytic_line( + journal, name, record, line, + line.workcenter_id.product_id, line.cycle) + cost = line.workcenter_id.costs_cycle + vals['estim_avg_cost'] = line.cycle * cost + vals['estim_std_cost'] = vals['estim_avg_cost'] + analytic_line_obj.create(vals) + if line.hour and line.workcenter_id.costs_hour: + if not line.workcenter_id.product_id: + raise exceptions.Warning( + _("There is at least this workcenter without " + "product: %s") % line.workcenter_id.name) + name = (_('%s-%s-H-%s') % + (record.name, line.routing_wc_line.operation.code, + line.workcenter_id.name)) + hour = line.hour + if wc.time_stop and not line.workcenter_id.post_op_product: + hour += wc.time_stop + if wc.time_start and not line.workcenter_id.pre_op_product: + hour += wc.time_start + vals = record._prepare_estim_cost_analytic_line( + journal, name, record, line, + line.workcenter_id.product_id, hour) + cost = line.workcenter_id.costs_hour + vals['estim_avg_cost'] = hour * cost + vals['estim_std_cost'] = vals['estim_avg_cost'] + analytic_line_obj.create(vals) + if wc.op_number > 0 and line.hour: + if not line.workcenter_id.product_id: + raise exceptions.Warning( + _("There is at least this workcenter without " + "product: %s") % line.workcenter_id.name) + journal_wk = record.env.ref( + 'mrp_production_project_estimated_cost.analytic_' + 'journal_operators', False) + name = (_('%s-%s-%s') % + (record.name, line.routing_wc_line.operation.code, + line.workcenter_id.product_id.name)) + vals = record._prepare_estim_cost_analytic_line( + journal_wk, name, record, line, + line.workcenter_id.product_id, + line.hour * wc.op_number) + vals['estim_avg_cost'] = (wc.op_number * wc.op_avg_cost * + line.hour) + vals['estim_std_cost'] = vals['estim_avg_cost'] + analytic_line_obj.create(vals) + + def _prepare_estim_cost_analytic_line(self, journal, name, production, + workorder, product, qty): + analytic_line_obj = self.env['account.analytic.line'] + general_account = (product.property_account_income or + product.categ_id.property_account_income_categ or + False) + if not general_account: + raise exceptions.Warning( + _('You must define Income account in the product "%s", or in' + ' the product category') % (product.name)) + if not self.analytic_account_id: + raise exceptions.Warning( + _('You must define one Analytic Account for this MO: %s') % + (production.name)) + vals = { + 'name': name, + 'mrp_production_id': production.id, + 'workorder': workorder.id, + 'account_id': self.analytic_account_id.id, + 'journal_id': journal.id, + 'user_id': self._uid, + 'date': analytic_line_obj._get_default_date(), + 'product_id': product.id, + 'unit_amount': qty, + 'product_uom_id': product.uom_id.id, + 'general_account_id': general_account.id, + 'estim_std_cost': qty * product.manual_standard_cost, + 'estim_avg_cost': qty * product.standard_price, + } + return vals + + @api.multi + def load_product_std_price(self): + for record in self: + product = record.product_id + if record.unit_std_cost: + product.manual_standard_cost = record.unit_std_cost diff --git a/mrp_production_project_estimated_cost/models/product.py b/mrp_production_project_estimated_cost/models/product.py new file mode 100644 index 000000000..8c2306e39 --- /dev/null +++ b/mrp_production_project_estimated_cost/models/product.py @@ -0,0 +1,28 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +############################################################################## + +from openerp import models, fields +import openerp.addons.decimal_precision as dp + + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + manual_standard_cost = fields.Float( + string='Manual Standard Cost', digits=dp.get_precision('Product Price') + ) diff --git a/mrp_production_project_estimated_cost/models/project_project.py b/mrp_production_project_estimated_cost/models/project_project.py new file mode 100644 index 000000000..1c5c05013 --- /dev/null +++ b/mrp_production_project_estimated_cost/models/project_project.py @@ -0,0 +1,26 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +############################################################################## + +from openerp import models, fields + + +class ProjectProject(models.Model): + + _inherit = 'project.project' + + automatic_creation = fields.Boolean('Automatic Creation') diff --git a/mrp_production_project_estimated_cost/views/account_analytic_line_view.xml b/mrp_production_project_estimated_cost/views/account_analytic_line_view.xml new file mode 100644 index 000000000..95c9f7cd4 --- /dev/null +++ b/mrp_production_project_estimated_cost/views/account_analytic_line_view.xml @@ -0,0 +1,53 @@ + + + + + view.account.analytic.line.form.inh.estimatedcost + account.analytic.line + + + + + + + + + + + + + view.account.analytic.line.tree.inh.estimatedcost + account.analytic.line + + + + + + + + + + + estimated.cost.list.view + account.analytic.line + + + + + + + + + + + + + + + + + + + + + diff --git a/mrp_production_project_estimated_cost/views/mrp_bom_view.xml b/mrp_production_project_estimated_cost/views/mrp_bom_view.xml new file mode 100644 index 000000000..256462531 --- /dev/null +++ b/mrp_production_project_estimated_cost/views/mrp_bom_view.xml @@ -0,0 +1,30 @@ + + + + + mrp.bom.tree.parent.view + mrp.bom + + + + + + + + + + mrp.bom.product.tree.view + mrp.bom + + + + + + + + + + + + + diff --git a/mrp_production_project_estimated_cost/views/mrp_production_view.xml b/mrp_production_project_estimated_cost/views/mrp_production_view.xml new file mode 100644 index 000000000..2ff2db9c2 --- /dev/null +++ b/mrp_production_project_estimated_cost/views/mrp_production_view.xml @@ -0,0 +1,110 @@ + + + + + mrp.production.project.form.view.inh.estimatedcost + mrp.production + + + + + + + + + + mrp.production.form.view.inh.estimatedcost + mrp.production + + + + + + + + + + + + + + + + + + + + + + + + + mrp.production.tree.view.inh.estimatedcost + mrp.production + + + + + + + + + + + Estimated costs from production order + account.analytic.line + tree,form + [('mrp_production_id','=',active_id),('task_id','=',False)] + + + + mrp.production.buttons + mrp.production + + +
+
+
+
+
+
+ + + mrp.production.buttons.inh.estimatedcost + mrp.production + + +
+ +
+
+
+ + + Fictitious Manufacturing Orders to estimate costs + ir.actions.act_window + mrp.production + form + tree,form,calendar,graph,gantt + + + {'default_active': False} + [('active','=',False)] + + + + +
+
diff --git a/mrp_production_project_estimated_cost/views/product_view.xml b/mrp_production_project_estimated_cost/views/product_view.xml new file mode 100644 index 000000000..ffabc299a --- /dev/null +++ b/mrp_production_project_estimated_cost/views/product_view.xml @@ -0,0 +1,41 @@ + + + + + product.template.form.view.inh.estimatedcost + product.template + + + + + + + + + product.product.form.view.bom.button.inh.estimatedcost + product.product + + + + + + + product.template.form.view.bom.button.inh.estimatedcost + product.template + + + + + + + diff --git a/mrp_production_project_estimated_cost/wizard/__init__.py b/mrp_production_project_estimated_cost/wizard/__init__.py new file mode 100644 index 000000000..3b124e3fe --- /dev/null +++ b/mrp_production_project_estimated_cost/wizard/__init__.py @@ -0,0 +1,18 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +############################################################################## +from . import wiz_create_fictitious_of diff --git a/mrp_production_project_estimated_cost/wizard/wiz_create_fictitious_of.py b/mrp_production_project_estimated_cost/wizard/wiz_create_fictitious_of.py new file mode 100644 index 000000000..9d2811d8e --- /dev/null +++ b/mrp_production_project_estimated_cost/wizard/wiz_create_fictitious_of.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +############################################################################## +# For copyright and license notices, see __openerp__.py file in root directory +############################################################################## +from openerp import models, fields, api + + +class WizCreateFictitiousOf(models.TransientModel): + _name = "wiz.create.fictitious.of" + + date_planned = fields.Datetime( + string='Scheduled Date', required=True, default=fields.Datetime.now()) + load_on_product = fields.Boolean("Load cost on product") + project_id = fields.Many2one("project.project", string="Project") + + @api.multi + def do_create_fictitious_of(self): + production_obj = self.env['mrp.production'] + product_obj = self.env['product.product'] + self.ensure_one() + active_ids = self.env.context['active_ids'] + active_model = self.env.context['active_model'] + production_list = [] + if active_model == 'product.template': + cond = [('product_tmpl_id', 'in', active_ids)] + product_list = product_obj.search(cond) + else: + product_list = product_obj.browse(active_ids) + for product in product_list: + vals = {'product_id': product.id, + 'product_template': product.product_tmpl_id.id, + 'product_qty': 1, + 'date_planned': self.date_planned, + 'user_id': self._uid, + 'active': False, + 'product_uom': product.uom_id.id, + 'project_id': self.project_id.id + } + new_production = production_obj.create(vals) + new_production.action_compute() + production_list.append(new_production.id) + if self.load_on_product: + for production_id in production_list: + try: + production = production_obj.browse(production_id) + production.calculate_production_estimated_cost() + production.load_product_std_price() + except: + continue + return {'view_type': 'form', + 'view_mode': 'tree,form', + 'res_model': 'mrp.production', + 'type': 'ir.actions.act_window', + 'domain': "[('id','in'," + str(production_list) + "), " + "('active','=',False)]" + } diff --git a/mrp_production_project_estimated_cost/wizard/wiz_create_fictitious_of_view.xml b/mrp_production_project_estimated_cost/wizard/wiz_create_fictitious_of_view.xml new file mode 100644 index 000000000..04f7535cb --- /dev/null +++ b/mrp_production_project_estimated_cost/wizard/wiz_create_fictitious_of_view.xml @@ -0,0 +1,45 @@ + + + + + wiz.create.fictitious.of.view + wiz.create.fictitious.of + +
+ + + + + +
+
+
+
+
+ + Create fictitious MO + wiz.create.fictitious.of + form + form + + new + + + +
+