mirror of
https://github.com/OCA/manufacture.git
synced 2025-01-28 16:37:15 +02:00
90
mrp_analytic_cost_material/README.rst
Normal file
90
mrp_analytic_cost_material/README.rst
Normal file
@@ -0,0 +1,90 @@
|
||||
======================================
|
||||
Manufacturing Materials Analytic Costs
|
||||
======================================
|
||||
|
||||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
|
||||
:target: https://odoo-community.org/page/development-status
|
||||
:alt: Beta
|
||||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
|
||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||
:alt: License: AGPL-3
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmanufacture-lightgray.png?logo=github
|
||||
:target: https://github.com/OCA/manufacture/tree/14.0/mrp_analytic_cost_material
|
||||
:alt: OCA/manufacture
|
||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||
:target: https://translation.odoo-community.org/projects/manufacture-14-0/manufacture-14-0-mrp_analytic_cost_material
|
||||
:alt: Translate me on Weblate
|
||||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
||||
:target: https://runbot.odoo-community.org/runbot/129/14.0
|
||||
:alt: Try me on Runbot
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
|
||||
Manufacturing costs are only generated when a Manufacturing Order is closed.
|
||||
|
||||
This feature allows to track costs while the manufacturing is in progress.
|
||||
This is done for raw materials used, by generating Analytic Items when the stock is reserved.
|
||||
|
||||
**Table of contents**
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
To use:
|
||||
|
||||
* On the Manufacturing Order, set the Analytic Account to use. This may correspond to a Project.
|
||||
* On Manufacturing Orders, when a stock reservation is triggered, Analytic Items are automatically generated .
|
||||
|
||||
To analyze costs:
|
||||
|
||||
* Go to Manufacturing > Reports > Analytic Items. The cost data is available there and can be used for analysis.
|
||||
* At Project > Dashboard, "Project Overview" form, a summary of the costs for the corresponding Analytic Account is presented.
|
||||
|
||||
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:%20mrp_analytic_cost_material%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
|
||||
Do not contact contributors directly about support or help with technical issues.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Authors
|
||||
~~~~~~~
|
||||
|
||||
* Open Source Integrators
|
||||
|
||||
Contributors
|
||||
~~~~~~~~~~~~
|
||||
|
||||
* Daniel Reis <dreis@opensourceintegrators.com>
|
||||
* Chandresh Thakkar <cthakkr@opensourceintegrators.com>
|
||||
|
||||
Maintainers
|
||||
~~~~~~~~~~~
|
||||
|
||||
This module is maintained by the OCA.
|
||||
|
||||
.. image:: https://odoo-community.org/logo.png
|
||||
:alt: Odoo Community Association
|
||||
:target: https://odoo-community.org
|
||||
|
||||
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.
|
||||
|
||||
This module is part of the `OCA/manufacture <https://github.com/OCA/manufacture/tree/14.0/mrp_analytic_cost_material>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
4
mrp_analytic_cost_material/__init__.py
Normal file
4
mrp_analytic_cost_material/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
# Copyright (C) 2020 Open Source Integrators
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import models
|
||||
18
mrp_analytic_cost_material/__manifest__.py
Normal file
18
mrp_analytic_cost_material/__manifest__.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Copyright (C) 2020 Open Source Integrators
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
"name": "Manufacturing Materials Analytic Costs",
|
||||
"summary": "Track raw material costs as Analytic Items during the \
|
||||
manufacturing process",
|
||||
"version": "14.0.1.0.1",
|
||||
"category": "Manufacturing",
|
||||
"author": "Open Source Integrators, Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/manufacture",
|
||||
"license": "AGPL-3",
|
||||
"depends": ["mrp_analytic", "account"],
|
||||
"data": ["views/account_analytic_line_view.xml", "views/mrp_production_views.xml"],
|
||||
"maintainer": "dreispt",
|
||||
"development_status": "Alpha",
|
||||
"installable": True,
|
||||
}
|
||||
5
mrp_analytic_cost_material/models/__init__.py
Normal file
5
mrp_analytic_cost_material/models/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
# Copyright (C) 2020 Open Source Integrators
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import account_analytic_line
|
||||
from . import mrp_production
|
||||
22
mrp_analytic_cost_material/models/account_analytic_line.py
Normal file
22
mrp_analytic_cost_material/models/account_analytic_line.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# Copyright (C) 2020 Open Source Integrators
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class AccountAnalyticLine(models.Model):
|
||||
_inherit = "account.analytic.line"
|
||||
|
||||
stock_move_id = fields.Many2one(
|
||||
"stock.move",
|
||||
string="Related Stock Move",
|
||||
)
|
||||
manufacturing_order_id = fields.Many2one(
|
||||
"mrp.production",
|
||||
string="Related Manufacturing Order",
|
||||
)
|
||||
product_category_id = fields.Many2one(
|
||||
related="product_id.categ_id",
|
||||
string="Product Category",
|
||||
store=True,
|
||||
)
|
||||
44
mrp_analytic_cost_material/models/mrp_production.py
Normal file
44
mrp_analytic_cost_material/models/mrp_production.py
Normal file
@@ -0,0 +1,44 @@
|
||||
# Copyright (C) 2020 Open Source Integrators
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models
|
||||
|
||||
|
||||
class MrpProduction(models.Model):
|
||||
_inherit = "mrp.production"
|
||||
|
||||
def _prepare_material_analytic_line(self):
|
||||
self.ensure_one()
|
||||
order = self.raw_material_production_id
|
||||
return {
|
||||
"name": self.product_id.default_code or "",
|
||||
"account_id": order.analytic_account_id.id or False,
|
||||
"ref": order.name,
|
||||
"unit_amount": self.product_uom_qty,
|
||||
"company_id": order.company_id.id,
|
||||
"manufacturing_order_id": order.id,
|
||||
"product_id": self.product_id.id or False,
|
||||
"stock_move_id": self.id,
|
||||
}
|
||||
|
||||
def generate_analytic_line(self):
|
||||
"""Generate Analytic Lines Manually."""
|
||||
# FIXME: this is a placeholder for final logic
|
||||
# TODO: when should Analytic Items generation be triggered?
|
||||
# TODO: what to do if prevous items were already generated?
|
||||
AnalyticLine = self.env["account.analytic.line"].sudo()
|
||||
order_raw_moves = self.mapped("move_raw_ids")
|
||||
existing_items = AnalyticLine.search(
|
||||
[("stock_move_id ", "in", order_raw_moves.ids)]
|
||||
)
|
||||
for order in self.filtered("analytic_account_id"):
|
||||
for line in order.move_raw_ids:
|
||||
line_vals = line._prepare_material_analytic_line()
|
||||
if line in existing_items:
|
||||
analytic_line = existing_items.filter(
|
||||
lambda x: x.stock_move_id == line
|
||||
)
|
||||
analytic_line.write(line_vals)
|
||||
else:
|
||||
analytic_line = AnalyticLine.create(line_vals)
|
||||
analytic_line.on_change_unit_amount()
|
||||
4
mrp_analytic_cost_material/readme/CONTRIBUTORS.rst
Normal file
4
mrp_analytic_cost_material/readme/CONTRIBUTORS.rst
Normal file
@@ -0,0 +1,4 @@
|
||||
* `Open Source Integrators <https://opensourceintegrators.com>`:
|
||||
|
||||
* Daniel Reis <dreis@opensourceintegrators.com>
|
||||
* Chandresh Thakkar <cthakkr@opensourceintegrators.com>
|
||||
4
mrp_analytic_cost_material/readme/DESCRIPTION.rst
Normal file
4
mrp_analytic_cost_material/readme/DESCRIPTION.rst
Normal file
@@ -0,0 +1,4 @@
|
||||
Manufacturing costs are only generated when a Manufacturing Order is closed.
|
||||
|
||||
This feature allows to track costs while the manufacturing is in progress.
|
||||
This is done for raw materials used, by generating Analytic Items when the stock is reserved.
|
||||
9
mrp_analytic_cost_material/readme/USAGE.rst
Normal file
9
mrp_analytic_cost_material/readme/USAGE.rst
Normal file
@@ -0,0 +1,9 @@
|
||||
To use:
|
||||
|
||||
* On the Manufacturing Order, set the Analytic Account to use. This may correspond to a Project.
|
||||
* On Manufacturing Orders, when a stock reservation is triggered, Analytic Items are automatically generated .
|
||||
|
||||
To analyze costs:
|
||||
|
||||
* Go to Manufacturing > Reports > Analytic Items. The cost data is available there and can be used for analysis.
|
||||
* At Project > Dashboard, "Project Overview" form, a summary of the costs for the corresponding Analytic Account is presented.
|
||||
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<record id="custom_account_analytic_line_form_view" model="ir.ui.view">
|
||||
<field name="name">account.analytic.line.custom.form</field>
|
||||
<field name="model">account.analytic.line</field>
|
||||
<field name="inherit_id" ref="analytic.view_account_analytic_line_form" />
|
||||
<field name="arch" type="xml">
|
||||
<group name="amount" position="after">
|
||||
<group name="manufacture" string="Manufacture">
|
||||
<field name="stock_move_id" />
|
||||
<field name="manufacturing_order_id" />
|
||||
<field name="product_category_id" />
|
||||
</group>
|
||||
</group>
|
||||
</field>
|
||||
</record>
|
||||
<record id="custom_account_analytic_line_filter_view" model="ir.ui.view">
|
||||
<field name="name">account.analytic.line.custom.filter</field>
|
||||
<field name="model">account.analytic.line</field>
|
||||
<field name="inherit_id" ref="analytic.view_account_analytic_line_filter" />
|
||||
<field name="arch" type="xml">
|
||||
<filter name="date" position="after">
|
||||
<filter
|
||||
name="related-mo"
|
||||
string="Related to MO"
|
||||
domain="[('manufacturing_order_id','!=',False)]"
|
||||
/>
|
||||
<filter
|
||||
string="Manufacturing Order"
|
||||
name="group_by_mo"
|
||||
domain="[]"
|
||||
context="{'group_by': 'manufacturing_order_id'}"
|
||||
/>
|
||||
<filter
|
||||
string="Product Category"
|
||||
name="product_category"
|
||||
domain="[]"
|
||||
context="{'group_by': 'product_category_id'}"
|
||||
/>
|
||||
</filter>
|
||||
</field>
|
||||
</record>
|
||||
<record id="action_new_mrp_analytic_items" model="ir.actions.act_window">
|
||||
<field name="name">Analytic Items</field>
|
||||
<field name="res_model">account.analytic.line</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="context">{'search_default_related-mo': True}</field>
|
||||
</record>
|
||||
<menuitem
|
||||
id="custom_account_analytic_line_menu"
|
||||
name="Analytic Items"
|
||||
parent="mrp.menu_mrp_reporting"
|
||||
action="action_new_mrp_analytic_items"
|
||||
sequence="30"
|
||||
/>
|
||||
</odoo>
|
||||
18
mrp_analytic_cost_material/views/mrp_production_views.xml
Normal file
18
mrp_analytic_cost_material/views/mrp_production_views.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<record id="custom_mrp_production_form_view" model="ir.ui.view">
|
||||
<field name="name">custom.mrp.production.form</field>
|
||||
<field name="model">mrp.production</field>
|
||||
<field name="inherit_id" ref="mrp.mrp_production_form_view" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr='//button[@name="button_mark_done"]' position='before'>
|
||||
<button
|
||||
name="generate_analytic_line"
|
||||
class="btn-primary"
|
||||
type="object"
|
||||
string="Generate Material Analytic Items"
|
||||
/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -1 +1,3 @@
|
||||
# See https://github.com/OCA/odoo-community.org/blob/master/website/Contribution/CONTRIBUTING.rst#oca_dependencies-txt
|
||||
|
||||
account-analytic
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../mrp_analytic_cost_material
|
||||
6
setup/mrp_analytic_cost_material/setup.py
Normal file
6
setup/mrp_analytic_cost_material/setup.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
||||
Reference in New Issue
Block a user