Merge pull request #65 from pedrobaeza/8.0-mrp_production_real_cost

[8.0] mrp_production_real_cost
This commit is contained in:
Pedro M. Baeza
2015-12-28 10:39:45 +01:00
23 changed files with 1422 additions and 0 deletions

View File

@@ -0,0 +1,85 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
==================================
Real costs in manufacturing orders
==================================
This module allows to manage the control of Manufacturing Orders actual costs,
by creating analytic lines as defined in the MO (from *mrp_project*).
It also updates product standard price when a manufacturing orders is finished
according this formula:
(Product stock * Product standard price + Production real cost) /
(Product stock + Final product quantity)
Installation
============
This module depends on the module *product_variant_cost_price*, that is
available in:
https://github.com/OCA/product-variant
Usage
=====
Operating with a manufacture order, analytic entries adding costs will be
created when:
* Some raw material is consumed.
* A work order is finished or paused.
Also, thanks to *project_timesheet* modules, users time is also translated to
costs in the linked analytic account.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/129/8.0
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/manufacture/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed `feedback
<https://github.com/OCA/
manufacture/issues/new?body=module:%20
mrp_production_real_cost%0Aversion:%20
8.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Credits
=======
Contributors
------------
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
* Ana Juaristi <ajuaristio@gmail.com>
* Ainara Galdona <agaldona@avanzosc.es>
Images
------
* Original Odoo MRP icon
* Thanks to https://openclipart.org/detail/224801/black-and-white-calculator
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
To contribute to this module, please visit https://odoo-community.org.

View File

@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# © 2014-2015 Avanzosc
# © 2014-2015 Pedro M. Baeza
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from . import models

View File

@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
# © 2014-2015 Avanzosc
# © 2014-2015 Antiun Ingeniería
# © 2014-2015 Pedro M. Baeza
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
{
"name": "Real costs in manufacturing orders",
"version": "8.0.1.0.0",
"depends": [
"project_timesheet",
"mrp_project",
"mrp_operations_extension",
"mrp_operations_time_control",
"stock_account",
"product_variant_cost_price",
],
"author": "OdooMRP team, "
"AvanzOSC, "
"Serv. Tecnol. Avanzados - Pedro M. Baeza, "
"Antiun Ingeniería S.L., "
"Odoo Community Association (OCA)",
"category": "Manufacturing",
'data': [
"data/analytic_journal_data.xml",
"views/mrp_production_view.xml",
],
'demo': [
'demo/mrp_production_demo.xml',
],
'installable': True,
}

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" ?>
<openerp>
<data noupdate="1">
<!--Materials analytic journal -->
<record id="mrp.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>
<!--Operators analytic journal -->
<record id="mrp.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>
<!--Machines analytic journal -->
<record id="mrp.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,21 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record id="mrp.mrp_production_1" model="mrp.production">
<field name="project_id" ref="project.project_project_1"/>
<field name="analytic_account_id" search="[('name', 'ilike', '%jackson%')]"/>
</record>
<record id="mrp_operations.mrp_production_op1" model="mrp.production">
<field name="project_id" ref="project.project_project_1"/>
<field name="analytic_account_id" search="[('name', 'ilike', '%jackson%')]"/>
</record>
<record id="mrp_operations.mrp_production_mo1" model="mrp.production">
<field name="project_id" ref="project.project_project_1"/>
<field name="analytic_account_id" search="[('name', 'ilike', '%jackson%')]"/>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,97 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_production_real_costs
#
# Translators:
# Pedro M. Baeza <pedro.baeza@gmail.com>, 2015
msgid ""
msgstr ""
"Project-Id-Version: odoomrp-wip (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-11-20 18:10+0000\n"
"PO-Revision-Date: 2015-11-20 18:13+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>\n"
"Language-Team: Spanish (http://www.transifex.com/oca/odoomrp-wip-8-0/language/es/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: es\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: mrp_production_real_costs
#: field:mrp.production,percentage_difference:0
msgid "% difference"
msgstr "% diferencia"
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_mrp_bom
msgid "Bill of Material"
msgstr "Lista de material"
#. module: mrp_production_real_costs
#: field:mrp.config.settings,final_product_analytic_cost:0
msgid "Load final product analytic cost"
msgstr ""
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_mrp_production
msgid "Manufacturing Order"
msgstr "Órden de producción"
#. module: mrp_production_real_costs
#: view:mrp.production:mrp_production_real_costs.mrp_production_form_view_real_costs
msgid "Manufacturing costs"
msgstr "Costes de fabricación"
#. module: mrp_production_real_costs
#: field:mrp.production.workcenter.line,post_cost:0
msgid "Post-Operation Cost"
msgstr ""
#. module: mrp_production_real_costs
#: field:mrp.production.workcenter.line,pre_cost:0
msgid "Pre-Operation Cost"
msgstr ""
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_mrp_product_produce
msgid "Product Produce"
msgstr "Fabricar producto"
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_project_task_work
msgid "Project Task Work"
msgstr "Trabajo de tarea"
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_stock_move
msgid "Stock Move"
msgstr "Movimiento de existencias"
#. module: mrp_production_real_costs
#: help:mrp.config.settings,final_product_analytic_cost:0
msgid ""
"This will allow you to define if those BoM passed back to draft are still "
"activated or not"
msgstr "De esta manera podrás definir si aquellas LdM vueltas a estado borrador pueden mantenerse activas o no"
#. module: mrp_production_real_costs
#: field:mrp.production,real_cost:0
msgid "Total Real Cost"
msgstr ""
#. module: mrp_production_real_costs
#: field:mrp.production,unit_real_cost:0
msgid "Unit Real Cost"
msgstr ""
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_mrp_production_workcenter_line
msgid "Work Order"
msgstr "Orden de trabajo"
#. module: mrp_production_real_costs
#: code:addons/mrp_production_real_costs/models/mrp_production.py:121
#, python-format
msgid "You must define one Analytic Account for this MO: %s"
msgstr "Debe definir una cuenta analítica para esta MO: %s"

View File

@@ -0,0 +1,97 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_production_real_costs
#
# Translators:
# Massimiliano Casa <mcasa@cantiericasa.com>, 2015
msgid ""
msgstr ""
"Project-Id-Version: odoomrp-wip (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-11-20 18:10+0000\n"
"PO-Revision-Date: 2015-10-30 13:07+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>\n"
"Language-Team: Italian (http://www.transifex.com/oca/odoomrp-wip-8-0/language/it/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: it\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: mrp_production_real_costs
#: field:mrp.production,percentage_difference:0
msgid "% difference"
msgstr "% differenza"
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_mrp_bom
msgid "Bill of Material"
msgstr "Distinta base"
#. module: mrp_production_real_costs
#: field:mrp.config.settings,final_product_analytic_cost:0
msgid "Load final product analytic cost"
msgstr ""
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_mrp_production
msgid "Manufacturing Order"
msgstr "Ordine di produzione"
#. module: mrp_production_real_costs
#: view:mrp.production:mrp_production_real_costs.mrp_production_form_view_real_costs
msgid "Manufacturing costs"
msgstr "Costi di produzione"
#. module: mrp_production_real_costs
#: field:mrp.production.workcenter.line,post_cost:0
msgid "Post-Operation Cost"
msgstr "Costo Post-lavorazione"
#. module: mrp_production_real_costs
#: field:mrp.production.workcenter.line,pre_cost:0
msgid "Pre-Operation Cost"
msgstr "Costo Pre-lavorazione"
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_mrp_product_produce
msgid "Product Produce"
msgstr ""
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_project_task_work
msgid "Project Task Work"
msgstr "Attività Progetto"
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_stock_move
msgid "Stock Move"
msgstr ""
#. module: mrp_production_real_costs
#: help:mrp.config.settings,final_product_analytic_cost:0
msgid ""
"This will allow you to define if those BoM passed back to draft are still "
"activated or not"
msgstr ""
#. module: mrp_production_real_costs
#: field:mrp.production,real_cost:0
msgid "Total Real Cost"
msgstr "Costo Reale Totale "
#. module: mrp_production_real_costs
#: field:mrp.production,unit_real_cost:0
msgid "Unit Real Cost"
msgstr "Costo unitario reale"
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_mrp_production_workcenter_line
msgid "Work Order"
msgstr "Ordine di lavorazione"
#. module: mrp_production_real_costs
#: code:addons/mrp_production_real_costs/models/mrp_production.py:121
#, python-format
msgid "You must define one Analytic Account for this MO: %s"
msgstr "Bisogna definire un conto analitico per questo MO: %s"

View File

@@ -0,0 +1,96 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_production_real_costs
#
# Translators:
msgid ""
msgstr ""
"Project-Id-Version: odoomrp-wip (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-11-20 18:10+0000\n"
"PO-Revision-Date: 2015-10-30 13:07+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>\n"
"Language-Team: Portuguese (Brazil) (http://www.transifex.com/oca/odoomrp-wip-8-0/language/pt_BR/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: pt_BR\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#. module: mrp_production_real_costs
#: field:mrp.production,percentage_difference:0
msgid "% difference"
msgstr ""
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_mrp_bom
msgid "Bill of Material"
msgstr "Lista de materiais"
#. module: mrp_production_real_costs
#: field:mrp.config.settings,final_product_analytic_cost:0
msgid "Load final product analytic cost"
msgstr ""
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_mrp_production
msgid "Manufacturing Order"
msgstr "Ordem de Produção"
#. module: mrp_production_real_costs
#: view:mrp.production:mrp_production_real_costs.mrp_production_form_view_real_costs
msgid "Manufacturing costs"
msgstr ""
#. module: mrp_production_real_costs
#: field:mrp.production.workcenter.line,post_cost:0
msgid "Post-Operation Cost"
msgstr ""
#. module: mrp_production_real_costs
#: field:mrp.production.workcenter.line,pre_cost:0
msgid "Pre-Operation Cost"
msgstr ""
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_mrp_product_produce
msgid "Product Produce"
msgstr "Produzir produto"
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_project_task_work
msgid "Project Task Work"
msgstr ""
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_stock_move
msgid "Stock Move"
msgstr "Movimentação de estoque"
#. module: mrp_production_real_costs
#: help:mrp.config.settings,final_product_analytic_cost:0
msgid ""
"This will allow you to define if those BoM passed back to draft are still "
"activated or not"
msgstr "Isto permite você definir se as BOM's passadas para provisório são ativadas ou não."
#. module: mrp_production_real_costs
#: field:mrp.production,real_cost:0
msgid "Total Real Cost"
msgstr ""
#. module: mrp_production_real_costs
#: field:mrp.production,unit_real_cost:0
msgid "Unit Real Cost"
msgstr ""
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_mrp_production_workcenter_line
msgid "Work Order"
msgstr "Ordem de serviço"
#. module: mrp_production_real_costs
#: code:addons/mrp_production_real_costs/models/mrp_production.py:121
#, python-format
msgid "You must define one Analytic Account for this MO: %s"
msgstr ""

View File

@@ -0,0 +1,97 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_production_real_costs
#
# Translators:
# Dorin Hongu <dhongu@gmail.com>, 2015
msgid ""
msgstr ""
"Project-Id-Version: odoomrp-wip (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-11-20 18:10+0000\n"
"PO-Revision-Date: 2015-11-18 00:48+0000\n"
"Last-Translator: Dorin Hongu <dhongu@gmail.com>\n"
"Language-Team: Romanian (http://www.transifex.com/oca/odoomrp-wip-8-0/language/ro/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: ro\n"
"Plural-Forms: nplurals=3; plural=(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?2:1));\n"
#. module: mrp_production_real_costs
#: field:mrp.production,percentage_difference:0
msgid "% difference"
msgstr "% diferență"
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_mrp_bom
msgid "Bill of Material"
msgstr "Listă de materiale"
#. module: mrp_production_real_costs
#: field:mrp.config.settings,final_product_analytic_cost:0
msgid "Load final product analytic cost"
msgstr ""
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_mrp_production
msgid "Manufacturing Order"
msgstr "Comandă fabricație"
#. module: mrp_production_real_costs
#: view:mrp.production:mrp_production_real_costs.mrp_production_form_view_real_costs
msgid "Manufacturing costs"
msgstr "Costuri fabricație"
#. module: mrp_production_real_costs
#: field:mrp.production.workcenter.line,post_cost:0
msgid "Post-Operation Cost"
msgstr ""
#. module: mrp_production_real_costs
#: field:mrp.production.workcenter.line,pre_cost:0
msgid "Pre-Operation Cost"
msgstr ""
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_mrp_product_produce
msgid "Product Produce"
msgstr ""
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_project_task_work
msgid "Project Task Work"
msgstr ""
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_stock_move
msgid "Stock Move"
msgstr "Mișcare stoc"
#. module: mrp_production_real_costs
#: help:mrp.config.settings,final_product_analytic_cost:0
msgid ""
"This will allow you to define if those BoM passed back to draft are still "
"activated or not"
msgstr ""
#. module: mrp_production_real_costs
#: field:mrp.production,real_cost:0
msgid "Total Real Cost"
msgstr "Total costuri reale"
#. module: mrp_production_real_costs
#: field:mrp.production,unit_real_cost:0
msgid "Unit Real Cost"
msgstr ""
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_mrp_production_workcenter_line
msgid "Work Order"
msgstr "Comandă de lucru"
#. module: mrp_production_real_costs
#: code:addons/mrp_production_real_costs/models/mrp_production.py:121
#, python-format
msgid "You must define one Analytic Account for this MO: %s"
msgstr ""

View File

@@ -0,0 +1,97 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_production_real_costs
#
# Translators:
# Matjaž Mozetič <m.mozetic@matmoz.si>, 2015
msgid ""
msgstr ""
"Project-Id-Version: odoomrp-wip (8.0)\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-11-20 18:10+0000\n"
"PO-Revision-Date: 2015-10-31 05:16+0000\n"
"Last-Translator: Matjaž Mozetič <m.mozetic@matmoz.si>\n"
"Language-Team: Slovenian (http://www.transifex.com/oca/odoomrp-wip-8-0/language/sl/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: sl\n"
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n"
#. module: mrp_production_real_costs
#: field:mrp.production,percentage_difference:0
msgid "% difference"
msgstr "% razlike"
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_mrp_bom
msgid "Bill of Material"
msgstr "Kosovnica"
#. module: mrp_production_real_costs
#: field:mrp.config.settings,final_product_analytic_cost:0
msgid "Load final product analytic cost"
msgstr "Naloži zadnji analitični strošek proizvoda"
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_mrp_production
msgid "Manufacturing Order"
msgstr "Proizvodni nalog"
#. module: mrp_production_real_costs
#: view:mrp.production:mrp_production_real_costs.mrp_production_form_view_real_costs
msgid "Manufacturing costs"
msgstr "Proizvodni stroški"
#. module: mrp_production_real_costs
#: field:mrp.production.workcenter.line,post_cost:0
msgid "Post-Operation Cost"
msgstr "Po-operativni stroški"
#. module: mrp_production_real_costs
#: field:mrp.production.workcenter.line,pre_cost:0
msgid "Pre-Operation Cost"
msgstr "Pred operativni stroški"
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_mrp_product_produce
msgid "Product Produce"
msgstr "Izdelava proizvoda"
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_project_task_work
msgid "Project Task Work"
msgstr "Delo na projektnem opravilu"
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_stock_move
msgid "Stock Move"
msgstr "Premik zaloge"
#. module: mrp_production_real_costs
#: help:mrp.config.settings,final_product_analytic_cost:0
msgid ""
"This will allow you to define if those BoM passed back to draft are still "
"activated or not"
msgstr "Omogoča določanje, če naj kosovnice, ki se vračajo v stanje osnutka, ostanejo aktivirane ali ne"
#. module: mrp_production_real_costs
#: field:mrp.production,real_cost:0
msgid "Total Real Cost"
msgstr "Skupni realni stroški"
#. module: mrp_production_real_costs
#: field:mrp.production,unit_real_cost:0
msgid "Unit Real Cost"
msgstr "Realni strošek enote"
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_mrp_production_workcenter_line
msgid "Work Order"
msgstr "Delovni nalog"
#. module: mrp_production_real_costs
#: code:addons/mrp_production_real_costs/models/mrp_production.py:121
#, python-format
msgid "You must define one Analytic Account for this MO: %s"
msgstr "Potrebno je določiti analitični konto za proizvodni nalog: %s"

View File

@@ -0,0 +1,93 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * mrp_production_real_costs
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-11-28 09:04+0000\n"
"PO-Revision-Date: 2015-11-28 09:04+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_real_costs
#: field:mrp.production,percentage_difference:0
msgid "% difference"
msgstr "% khác biệt"
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_mrp_bom
msgid "Bill of Material"
msgstr "Định mức Nguyên liệu"
#. module: mrp_production_real_costs
#: field:mrp.config.settings,final_product_analytic_cost:0
msgid "Load final product analytic cost"
msgstr "Load final product analytic cost"
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_mrp_production
msgid "Manufacturing Order"
msgstr "Lệnh sản xuất"
#. module: mrp_production_real_costs
#: view:mrp.production:mrp_production_real_costs.mrp_production_form_view_real_costs
msgid "Manufacturing costs"
msgstr "Chi phí Sản xuất"
#. module: mrp_production_real_costs
#: field:mrp.production.workcenter.line,post_cost:0
msgid "Post-Operation Cost"
msgstr "Chi phí Sau sản xuất"
#. module: mrp_production_real_costs
#: field:mrp.production.workcenter.line,pre_cost:0
msgid "Pre-Operation Cost"
msgstr "Chi phí Trước sản xuất"
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_mrp_product_produce
msgid "Product Produce"
msgstr "Sản xuất sản phẩm"
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_project_task_work
msgid "Project Task Work"
msgstr "Project Task Work"
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_stock_move
msgid "Stock Move"
msgstr "Dịch chuyển kho"
#. module: mrp_production_real_costs
#: help:mrp.config.settings,final_product_analytic_cost:0
msgid "This will allow you to define if those BoM passed back to draft are still activated or not"
msgstr "This will allow you to define if those BoM passed back to draft are still activated or not"
#. module: mrp_production_real_costs
#: field:mrp.production,real_cost:0
msgid "Total Real Cost"
msgstr "Tổng chi thực tế"
#. module: mrp_production_real_costs
#: field:mrp.production,unit_real_cost:0
msgid "Unit Real Cost"
msgstr "Unit Real Cost"
#. module: mrp_production_real_costs
#: model:ir.model,name:mrp_production_real_costs.model_mrp_production_workcenter_line
msgid "Work Order"
msgstr "Hoạt động sản xuất"
#. module: mrp_production_real_costs
#: code:addons/mrp_production_real_costs/models/mrp_production.py:121
#, python-format
msgid "You must define one Analytic Account for this MO: %s"
msgstr "Bạn phải định nghĩa một Tài khoản Quản trị cho MO này: %s"

View File

@@ -0,0 +1,9 @@
# -*- coding: utf-8 -*-
# © 2014-2015 Avanzosc
# © 2014-2015 Pedro M. Baeza
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from . import mrp_bom
from . import mrp_production
from . import mrp_production_workcenter_line
from . import stock_move

View File

@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# © 2014-2015 Avanzosc
# © 2014-2015 Pedro M. Baeza
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from openerp import models, api
class MrpBom(models.Model):
_inherit = 'mrp.bom'
@api.multi
def _prepare_wc_line(self, wc_use, level=0, factor=1):
res = super(MrpBom, self)._prepare_wc_line(
wc_use, level=level, factor=factor)
wc = wc_use.workcenter_id
res['pre_cost'] = (
res.get('time_start', 0.0) * wc.pre_op_product.standard_price)
res['post_cost'] = (
res.get('time_stop', 0.0) * wc.post_op_product.standard_price)
return res

View File

@@ -0,0 +1,75 @@
# -*- coding: utf-8 -*-
# © 2014-2015 Avanzosc
# © 2014-2015 Pedro M. Baeza
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from openerp import api, fields, models
class MrpProduction(models.Model):
_inherit = 'mrp.production'
@api.multi
@api.depends('analytic_line_ids', 'analytic_line_ids.amount',
'product_qty')
def _compute_real_cost(self):
for production in self:
cost_lines = production.analytic_line_ids.filtered(
lambda l: l.amount < 0)
production.real_cost = -sum(cost_lines.mapped('amount'))
production.unit_real_cost = (
production.real_cost / production.product_qty)
analytic_line_ids = fields.One2many(
comodel_name="account.analytic.line", inverse_name="mrp_production_id",
string="Cost Lines")
real_cost = fields.Float(
"Total Real Cost", compute="_compute_real_cost", store=True)
unit_real_cost = fields.Float(
"Unit Real Cost", compute="_compute_real_cost", store=True)
@api.multi
def action_production_end(self):
res = super(MrpProduction, self).action_production_end()
self.mapped('move_created_ids2').filtered(
lambda l: l.state == 'done').product_price_update_production_done()
return res
@api.model
def _prepare_real_cost_analytic_line(
self, journal, name, production, product, general_account=None,
workorder=None, qty=1, amount=0):
"""
Prepare the vals for creating an analytic entry for real cost
:param journal: Journal of the entry
:param name: Name of the entry
:param production: Origin product
:param product: Product for the entry
:param general_account: General account for the entry
:param workorder: Origin workorder
:param qty: Quantity for the entry. This quantity will multiply both
standard and average costs for the entry costs.
:param amount: Cost for calculating real cost.
:return: Dictionary with the analytic entry vals.
"""
analytic_line_obj = self.env['account.analytic.line']
property_obj = self.env['ir.property']
general_account = (
general_account or product.property_account_expense or
product.categ_id.property_account_expense_categ or
property_obj.get('property_account_expense_categ',
'product.category'))
return {
'name': name,
'mrp_production_id': production.id,
'workorder': workorder and workorder.id or False,
'account_id': self.analytic_account_id.id,
'journal_id': journal.id,
'user_id': self.env.uid,
'date': analytic_line_obj._get_default_date(),
'product_id': product and product.id or False,
'unit_amount': qty,
'amount': amount,
'product_uom_id': product.uom_id.id,
'general_account_id': general_account.id,
}

View File

@@ -0,0 +1,103 @@
# -*- coding: utf-8 -*-
# © 2014-2015 Avanzosc
# © 2014-2015 Pedro M. Baeza
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from openerp import api, fields, models
class MrpProductionWorkcenterLine(models.Model):
_inherit = 'mrp.production.workcenter.line'
pre_cost = fields.Float('Pre-Operation Cost')
post_cost = fields.Float('Post-Operation Cost')
@api.multi
def _create_analytic_line(self):
self.ensure_one()
analytic_line_obj = self.env['account.analytic.line']
task_obj = self.env['project.task']
if self.workcenter_id.costs_hour > 0.0:
hour_uom = self.env.ref('product.product_uom_hour', False)
operation_line = self.operation_time_lines[-1]
production = self.production_id
workcenter = self.workcenter_id
product = workcenter.product_id
journal_id = workcenter.costs_journal_id or self.env.ref(
'mrp.analytic_journal_machines', False)
name = ((production.name or '') + '-' +
(self.routing_wc_line.operation.code or '') + '-' +
(product.default_code or ''))
general_acc = workcenter.costs_general_account_id or False
price = -(workcenter.costs_hour * operation_line.uptime)
analytic_vals = production._prepare_real_cost_analytic_line(
journal_id, name, production, product,
general_account=general_acc, workorder=self,
qty=operation_line.uptime, amount=price)
task = task_obj.search([('mrp_production_id', '=', production.id),
('workorder', '=', False)])
analytic_vals['task_id'] = task and task[0].id or False
analytic_vals['product_uom_id'] = hour_uom.id
analytic_line = analytic_line_obj.create(analytic_vals)
return analytic_line
@api.multi
def _create_pre_post_cost_lines(self, cost_type='pre'):
self.ensure_one()
analytic_line_obj = self.env['account.analytic.line']
task_obj = self.env['project.task']
hour_uom = self.env.ref('product.product_uom_hour', False)
production = self.production_id
workcenter = self.workcenter_id
journal_id = workcenter.costs_journal_id or self.env.ref(
'mrp.analytic_journal_machines', False)
general_acc = workcenter.costs_general_account_id or False
qty = 0
price = 0
product = False
name = ''
if cost_type == 'pre':
product = workcenter.pre_op_product
name = ((production.name or '') + '-' +
(self.routing_wc_line.operation.code or '') + '-PRE-' +
(product.default_code or ''))
price = -self.pre_cost
qty = self.time_start
elif cost_type == 'post':
product = workcenter.post_op_product
name = ((production.name or '') + '-' +
(self.routing_wc_line.operation.code or '') + '-POST-' +
(product.default_code or ''))
price = -self.post_cost
qty = self.time_stop
if price:
analytic_vals = production._prepare_real_cost_analytic_line(
journal_id, name, production, product,
general_account=general_acc, workorder=self,
qty=qty, amount=price)
task = task_obj.search([('mrp_production_id', '=', production.id),
('workorder', '=', False)])
analytic_vals['task_id'] = task[:1].id
analytic_vals['product_uom_id'] = hour_uom.id
analytic_line_obj.create(analytic_vals)
@api.multi
def action_start_working(self):
result = super(MrpProductionWorkcenterLine,
self).action_start_working()
self._create_pre_post_cost_lines(cost_type='pre')
return result
@api.multi
def action_pause(self):
result = super(MrpProductionWorkcenterLine, self).action_pause()
self._create_analytic_line()
return result
@api.multi
def action_done(self):
result = super(MrpProductionWorkcenterLine, self).action_done()
self._create_analytic_line()
self._create_pre_post_cost_lines(cost_type='post')
return result

View File

@@ -0,0 +1,66 @@
# -*- coding: utf-8 -*-
# © 2014-2015 Avanzosc
# © 2014-2015 Pedro M. Baeza
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from openerp import api, models
class StockMove(models.Model):
_inherit = 'stock.move'
@api.multi
def action_done(self):
task_obj = self.env['project.task']
analytic_line_obj = self.env['account.analytic.line']
result = super(StockMove, self).action_done()
records = self.filtered(lambda x: (x.raw_material_production_id and
x.product_id.standard_price))
for record in records:
journal_id = self.env.ref('mrp.analytic_journal_materials', False)
production = record.raw_material_production_id
name = ((production.name or '') + '-' +
(record.work_order.routing_wc_line.operation.code or '') +
'-' + (record.product_id.default_code or ''))
analytic_vals = (production._prepare_real_cost_analytic_line(
journal_id, name, production, record.product_id,
workorder=record.work_order, qty=record.product_qty,
amount=(-record.product_id.standard_price *
record.product_qty)))
task = task_obj.search([('mrp_production_id', '=', production.id),
('workorder', '=', False)])
analytic_vals['task_id'] = task and task[0].id or False
analytic_line_obj.create(analytic_vals)
return result
@api.multi
def product_price_update_production_done(self):
records = self.filtered(
lambda x: (x.production_id and
x.product_id.cost_method == 'average'))
for move in records:
prod_total_cost = move.production_id.real_cost
product = move.product_id
product_avail = product.qty_available
amount_unit = product.standard_price
tmpl_available = product.product_tmpl_id.qty_available
tmpl_price = product.product_tmpl_id.standard_price
if move.state == 'done':
product_avail -= move.product_qty
tmpl_available -= move.product_qty
new_product_price = (
(amount_unit * product_avail + prod_total_cost) /
((product_avail >= 0.0 and product_avail or 0.0) +
move.product_qty))
new_tmpl_price = ((tmpl_price * tmpl_available + prod_total_cost) /
((tmpl_available > 0.0 and tmpl_available or
0.0) + move.product_qty))
product.sudo().standard_price = new_product_price
product.sudo().product_tmpl_id.standard_price = new_tmpl_price
@api.model
def get_price_unit(self, move):
if move.production_id:
return move.production_id.real_cost / move.product_qty
else:
return super(StockMove, self).get_price_unit(move)

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 43 KiB

View File

@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# © 2015 Pedro M. Baeza
# © 2015 Antiun Ingeniería
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from . import test_mrp_production_real_cost

View File

@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
# © 2015 Pedro M. Baeza
# © 2015 Antiun Ingeniería
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from openerp.tests import common
import time
class TestMrpProductionRealCost(common.TransactionCase):
def setUp(self):
super(TestMrpProductionRealCost, self).setUp()
self.production = self.env.ref(
'mrp_operations_extension.mrp_production_opeext')
self.production.signal_workflow('button_confirm')
self.production.force_production()
def test_flow(self):
line = self.production.workcenter_lines[1]
line.pre_cost = 10
line.post_cost = 20
line.signal_workflow('button_start_working')
self.assertEqual(len(self.production.analytic_line_ids), 1)
time.sleep(1)
line.signal_workflow('button_pause')
self.assertEqual(len(self.production.analytic_line_ids), 2)
line.signal_workflow('button_resume')
time.sleep(1)
line.signal_workflow('button_done')
self.assertEqual(len(self.production.analytic_line_ids), 4)
self.production.analytic_line_ids[:1].amount = -10
self.assertTrue(self.production.real_cost)
def test_produce(self):
# Set an impossible price to see if it changes
initial_price = 999999999
self.production.product_id.standard_price = initial_price
self.production.product_id.cost_method = 'average'
self.production.action_produce(
self.production.id, self.production.product_qty, 'consume_produce')
self.assertEqual(len(self.production.analytic_line_ids), 4)
self.assertNotEqual(
initial_price, self.production.product_id.standard_price)

View File

@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="mrp.mrp_production_form_view_costs" model="ir.ui.view">
<field name="name">mrp.production.form.view.costs</field>
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp.mrp_production_form_view"/>
<field name="arch" type="xml">
<page string="Extra Information" position="inside">
<group string="Manufacturing costs">
</group>
</page>
</field>
</record>
<record id="mrp_production_form_view_real_costs" model="ir.ui.view">
<field name="name">mrp.production.form.view.real.costs</field>
<field name="model">mrp.production</field>
<field name="inherit_id" ref="mrp.mrp_production_form_view_costs"/>
<field name="arch" type="xml">
<group string="Manufacturing costs" position="inside">
<group>
<field name="real_cost" attrs="{'invisible': [('state', '!=', 'done')]}"/>
<field name="unit_real_cost" attrs="{'invisible': [('state', '!=', 'done')]}"/>
</group>
</group>
<xpath expr="//field[@name='workcenter_lines']//tree//field[@name='hour']" position="after">
<field name="pre_cost"/>
<field name="post_cost"/>
</xpath>
<xpath expr="//field[@name='workcenter_lines']//form//field[@name='hour']" position="after">
<field name="pre_cost"/>
<field name="post_cost"/>
</xpath>
</field>
</record>
<record id="mrp_production_tree_view_real_costs" model="ir.ui.view">
<field name="name">mrp.production.tree.real.costs</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="real_cost" />
</field>
</field>
</record>
</data>
</openerp>

View File

@@ -71,6 +71,9 @@ class TestMrpProject(common.TransactionCase):
def test_button_end_work(self):
work = self.env['project.task.work'].create(
{'task_id': self.task.id,
'name': 'Test',
'user_id': self.env.uid,
'hours': 0,
'date': fields.Datetime.now()})
time.sleep(1)
work.button_end_work()

View File

@@ -2,3 +2,5 @@
# Add a repository url and branch if you need a forked version
product-attribute
account-analytic
product-variant