[ADD] mrp_production_estimated_cost

This commit is contained in:
alfredo
2014-10-21 15:34:21 +02:00
committed by Oihane Crucelaegui
parent 8d5cd3e357
commit b1386f3a72
20 changed files with 1441 additions and 0 deletions

View File

@@ -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.

View File

@@ -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

View File

@@ -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 <alfredodelafuente@avanzosc.es>",
"Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>",
"Ana Juaristi <ajuaristio@gmail.com>",
"Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>",
],
"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,
}

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" ?>
<openerp>
<data noupdate="1">
<!--Estimated materials analytic journal -->
<record id="analytic_journal_materials" model="account.analytic.journal">
<field name="name">Materials</field>
<field name="code">MAT</field>
<field name="type">general</field>
<field name="active">True</field>
</record>
<!--Estimated operators analytic journal -->
<record id="analytic_journal_operators" model="account.analytic.journal">
<field name="name">Operators</field>
<field name="code">OPE</field>
<field name="type">general</field>
<field name="active">True</field>
</record>
<!--Estimated machines analytic journal -->
<record id="analytic_journal_machines" model="account.analytic.journal">
<field name="name">Machines</field>
<field name="code">MACH</field>
<field name="type">general</field>
<field name="active">True</field>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data noupdate="1">
<record id="fictitious_mrp_production_code" model="ir.sequence.type">
<field name="name">Fictitious MRP Production</field>
<field name="code">fictitious.mrp.production</field>
</record>
<record id="fictitious_mrp_production" model="ir.sequence">
<field name="name">Fictitious MRP Production</field>
<field name="code">fictitious.mrp.production</field>
<field eval="6" name="padding"/>
<field name="prefix">FMO</field>
</record>
</data>
</openerp>

View File

@@ -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')]}"

View File

@@ -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 ""

View File

@@ -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

View File

@@ -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'))

View File

@@ -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")

View File

@@ -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

View File

@@ -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')
)

View File

@@ -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')

View File

@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_account_analytic_line_form_inh_estimatedcost" model="ir.ui.view">
<field name="name">view.account.analytic.line.form.inh.estimatedcost</field>
<field name="model">account.analytic.line</field>
<field name="inherit_id" ref="account.view_account_analytic_line_form"/>
<field name="arch" type="xml">
<group string="General Accounting" position="after">
<group string="Production Information" colspan="4" col="8">
<field name="estim_std_cost" colspan="2"/>
<field name="estim_avg_cost" colspan="2"/>
</group>
</group>
</field>
</record>
<record id="view_account_analytic_line_tree_inh_estimatedcost" model="ir.ui.view">
<field name="name">view.account.analytic.line.tree.inh.estimatedcost</field>
<field name="model">account.analytic.line</field>
<field name="inherit_id" ref="account.view_account_analytic_line_tree"/>
<field name="arch" type="xml">
<field name="journal_id" position="after">
<field name="estim_std_cost" />
<field name="estim_avg_cost" />
</field>
</field>
</record>
<record id="estimated_cost_list_view" model="ir.ui.view">
<field name="name">estimated.cost.list.view</field>
<field name="model">account.analytic.line</field>
<field name="priority" eval="50"/>
<field name="arch" type="xml">
<tree string="Estimated Costs">
<field name="date"/>
<field name="ref"/>
<field name="name"/>
<field name="journal_id"/>
<field name="estim_avg_cost"/>
<field name="estim_std_cost"/>
<field name="amount"/>
<field name="unit_amount"/>
<field name="account_id"/>
<field name="mrp_production_id"/>
<field name="workorder"/>
<field name="company_id"/>
</tree>
</field>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="mrp.mrp_bom_tree_parent_view" model="ir.ui.view">
<field name="name">mrp.bom.tree.parent.view</field>
<field name="model">mrp.bom</field>
<field name="arch" type="xml">
<tree string="MRP BoMs">
<field name="code"/>
<field name="name"/>
</tree>
</field>
</record>
<record id="mrp_bom_product_tree_view" model="ir.ui.view">
<field name="name">mrp.bom.product.tree.view</field>
<field name="model">mrp.bom</field>
<field name="inherit_id" ref="mrp.mrp_bom_tree_parent_view"/>
<field name="arch" type="xml">
<field name="name" position="after">
<field name="product_id"/>
<field name="product_qty"/>
<field name="product_uom"/>
<field name="product_standard_price"/>
<field name="product_manual_standard_price"/>
</field>
</field>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="mrp_production_project_form_view_inh_estimatedcost" model="ir.ui.view">
<field name="name">mrp.production.project.form.view.inh.estimatedcost</field>
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp_project_link.mrp_production_project_form_view"/>
<field name="arch" type="xml">
<field name="project_id" position="after">
<field name="active" />
</field>
</field>
</record>
<record id="mrp_production_form_view_inh_estimatedcost" model="ir.ui.view">
<field name="name">mrp.production.form.view.inh.estimatedcost</field>
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
<field name="arch" type="xml">
<button name="button_confirm" position="attributes">
<attribute name="states"></attribute>
<attribute name="attrs">{'invisible':['|',('active','=',False),('state','!=','draft')]}</attribute>
</button>
<button name="action_cancel" position="after">
<button name="calculate_production_estimated_cost" states="draft,ready,in_production" string="Create Estimated Costs" type="object"/>
<button name="load_product_std_price" string="Load Cost on Product" type="object" attrs="{'invisible':[('std_cost', '=', 0)]}"/>
</button>
<page string="Extra Information" position="inside">
<group string="Manufacturing costs">
<group>
<field name="std_cost" />
<field name="unit_std_cost" />
<field name="avg_cost" />
<field name="unit_avg_cost" />
</group>
<group>
<field name="product_cost"/>
<field name="product_manual_cost"/>
</group>
</group>
</page>
<xpath expr="//field[@name='product_uom']/.." position="after">
</xpath>
</field>
</record>
<record id="mrp_production_tree_view_inh_estimatedcost" model="ir.ui.view">
<field name="name">mrp.production.tree.view.inh.estimatedcost</field>
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp.mrp_production_tree_view"/>
<field name="arch" type="xml">
<field name="product_uom" position="after">
<field name="product_cost"/>
<field name="product_manual_cost"/>
</field>
</field>
</record>
<record id="action_estimated_costs_per_production" model="ir.actions.act_window">
<field name="name">Estimated costs from production order</field>
<field name="res_model">account.analytic.line</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('mrp_production_id','=',active_id),('task_id','=',False)]</field>
</record>
<record model="ir.ui.view" id="mrp.mrp_production_buttons">
<field name="name">mrp.production.buttons</field>
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp.mrp_production_form_view" />
<field name="arch" type="xml">
<div class="oe_title" position="after">
<div class="oe_right oe_button_box" name="buttons">
</div>
</div>
</field>
</record>
<record model="ir.ui.view" id="mrp_production_buttons_inh_estimatedcost">
<field name="name">mrp.production.buttons.inh.estimatedcost</field>
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp.mrp_production_buttons" />
<field name="arch" type="xml">
<div name="buttons" position="inside">
<button class="oe_inline oe_stat_button"
type="object"
string="Estim. Costs"
name="action_show_estimated_costs"
icon="fa-bar-chart">
</button>
</div>
</field>
</record>
<record id="mrp_fictitious_production_action" model="ir.actions.act_window">
<field name="name">Fictitious Manufacturing Orders to estimate costs</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mrp.production</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,calendar,graph,gantt</field>
<field name="view_id" eval="False"/>
<field name="search_view_id" ref="mrp.view_mrp_production_filter"/>
<field name="context">{'default_active': False}</field>
<field name="domain">[('active','=',False)]</field>
</record>
<menuitem action="mrp_fictitious_production_action" id="menu_mrp_fictitious_production_action"
parent="mrp.menu_mrp_manufacturing" sequence="10"/>
</data>
</openerp>

View File

@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="product_template_form_view_inh_estimatedcost" model="ir.ui.view">
<field name="name">product.template.form.view.inh.estimatedcost</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<field name="standard_price" position="after">
<field name="manual_standard_cost" />
</field>
</field>
</record>
<record id="product_product_form_view_bom_button_inh_estimatedcost" model="ir.ui.view">
<field name="name">product.product.form.view.bom.button.inh.estimatedcost</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="mrp.product_product_form_view_bom_button"/>
<field name="arch" type="xml">
<button name="action_view_bom" position="after">
<button class="oe_inline oe_stat_button"
name="%(act_product_create_fictitious_of)d"
string="Create Fictitious MO" type="action"
attrs="{'invisible':[('type', '=', 'service')]}" icon="fa-flask" />
</button>
</field>
</record>
<record id="product_template_form_view_bom_button_inh_estimatedcost" model="ir.ui.view">
<field name="name">product.template.form.view.bom.button.inh.estimatedcost</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="mrp.product_template_form_view_bom_button"/>
<field name="arch" type="xml">
<button name="action_view_mos" position="before">
<button class="oe_inline oe_stat_button"
name="%(act_product_create_fictitious_of)d"
string="Create Fictitious MO" type="action"
attrs="{'invisible':[('type', '=', 'service')]}" icon="fa-flask" />
</button>
</field>
</record>
</data>
</openerp>

View File

@@ -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

View File

@@ -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)]"
}

View File

@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="wiz_create_fictitious_of_view" model="ir.ui.view">
<field name="name">wiz.create.fictitious.of.view</field>
<field name="model">wiz.create.fictitious.of</field>
<field name="arch" type="xml">
<form string="Create fictitious MO">
<group string="Create fictitious MO">
<field name="date_planned" />
<field name="load_on_product" />
<field name="project_id" />
</group>
<footer>
<button name="do_create_fictitious_of" type="object" string="Create fictitius MO" class="oe_highlight" />
or
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>
<record id="act_product_create_fictitious_of" model="ir.actions.act_window">
<field name="name">Create fictitious MO</field>
<field name="res_model">wiz.create.fictitious.of</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="wiz_create_fictitious_of_view" />
<field name="target">new</field>
</record>
<act_window name="Create fictitious MO"
res_model="wiz.create.fictitious.of"
src_model="product.product"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_run_create_fictitious_of"/>
<act_window name="Create fictitious MO"
res_model="wiz.create.fictitious.of"
src_model="product.template"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_run_template_create_fictitious_of"/>
</data>
</openerp>