diff --git a/mrp_stock_move_cost/README.rst b/mrp_stock_move_cost/README.rst deleted file mode 100644 index 18d061d56..000000000 --- a/mrp_stock_move_cost/README.rst +++ /dev/null @@ -1,34 +0,0 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html - :alt: License: AGPL-3 - -=================== -Mrp stock move cost -=================== - -* When closing the MO if the MO has a LOT: In the Unit price field of the LOT, - enter the sum of the cost of products consumed / number of units produced. -* In the move line of the product produced, the cost is equal to the sum of the - cost of products consumed, and the unit price is equal to its cost / quantity - produced. -* When change the purchase price of the lot, changes the cost of the OFS - associated with that lot. - -Bug Tracker -=========== - -Bugs are tracked on `GitHub Issues -`_. In case of trouble, -please check there if your issue has already been reported. If you spotted -it first, help us smash it by providing detailed and welcomed feedback. - -Do not contact contributors directly about support or help with technical issues. - -Credits -======= - -Contributors ------------- - -* Ana Juaristi -* Alfredo de la Fuente diff --git a/mrp_stock_move_cost/__init__.py b/mrp_stock_move_cost/__init__.py deleted file mode 100644 index e71485a30..000000000 --- a/mrp_stock_move_cost/__init__.py +++ /dev/null @@ -1,12 +0,0 @@ -from . import models -from odoo import api, SUPERUSER_ID - - -def _post_install_put_cost_in_productions(cr, registry): - """ - This method will set the production cost on already done manufacturing orders. - """ - env = api.Environment(cr, SUPERUSER_ID, {}) - productions = env["mrp.production"].search([("state", "=", "done")]) - for production in productions: - production.update_prodution_cost() diff --git a/mrp_stock_move_cost/__manifest__.py b/mrp_stock_move_cost/__manifest__.py deleted file mode 100644 index 6ec1f8bed..000000000 --- a/mrp_stock_move_cost/__manifest__.py +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2024 Alfredo de la Fuente - AvanzOSC -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -{ - "name": "Mrp Stock Move Cost", - "version": "16.0.1.1.0", - "category": "Manufacturing/Manufacturing", - "website": "https://github.com/avanzosc/mrp-addons", - "author": "AvanzOSC", - "license": "AGPL-3", - "depends": [ - "stock_move_cost", - "mrp", - ], - "data": [ - "views/mrp_production_views.xml", - ], - "installable": True, - "post_init_hook": "_post_install_put_cost_in_productions", -} diff --git a/mrp_stock_move_cost/i18n/es.po b/mrp_stock_move_cost/i18n/es.po deleted file mode 100644 index 2e2d4a234..000000000 --- a/mrp_stock_move_cost/i18n/es.po +++ /dev/null @@ -1,41 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * mrp_stock_move_cost -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 16.0+e\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-02-28 11:44+0000\n" -"PO-Revision-Date: 2024-02-28 11:44+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_stock_move_cost -#: model:ir.model.fields,field_description:mrp_stock_move_cost.field_mrp_production__cost -msgid "Cost" -msgstr "Coste" - -#. module: mrp_stock_move_cost -#: model:ir.model.fields,field_description:mrp_stock_move_cost.field_mrp_production__price_unit_cost -msgid "Cost Unit Price" -msgstr "Precio unitario coste" - -#. module: mrp_stock_move_cost -#: model:ir.model,name:mrp_stock_move_cost.model_mrp_production -msgid "Production Order" -msgstr "Orden de producción" - -#. module: mrp_stock_move_cost -#: model:ir.actions.server,name:mrp_stock_move_cost.action_cost_in_mrp_production -msgid "Put Cost" -msgstr "Poner coste" - -#. module: mrp_stock_move_cost -#: model_terms:ir.ui.view,arch_db:mrp_stock_move_cost.mrp_production_tree_view -msgid "Total cost" -msgstr "Total coste" diff --git a/mrp_stock_move_cost/i18n/mrp_stock_move_cost.pot b/mrp_stock_move_cost/i18n/mrp_stock_move_cost.pot deleted file mode 100644 index 7faa36c2a..000000000 --- a/mrp_stock_move_cost/i18n/mrp_stock_move_cost.pot +++ /dev/null @@ -1,41 +0,0 @@ -# Translation of Odoo Server. -# This file contains the translation of the following modules: -# * mrp_stock_move_cost -# -msgid "" -msgstr "" -"Project-Id-Version: Odoo Server 16.0+e\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-02-28 11:44+0000\n" -"PO-Revision-Date: 2024-02-28 11:44+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_stock_move_cost -#: model:ir.model.fields,field_description:mrp_stock_move_cost.field_mrp_production__cost -msgid "Cost" -msgstr "" - -#. module: mrp_stock_move_cost -#: model:ir.model.fields,field_description:mrp_stock_move_cost.field_mrp_production__price_unit_cost -msgid "Cost Unit Price" -msgstr "" - -#. module: mrp_stock_move_cost -#: model:ir.model,name:mrp_stock_move_cost.model_mrp_production -msgid "Production Order" -msgstr "" - -#. module: mrp_stock_move_cost -#: model:ir.actions.server,name:mrp_stock_move_cost.action_cost_in_mrp_production -msgid "Put Cost" -msgstr "" - -#. module: mrp_stock_move_cost -#: model_terms:ir.ui.view,arch_db:mrp_stock_move_cost.mrp_production_tree_view -msgid "Total cost" -msgstr "" diff --git a/mrp_stock_move_cost/models/__init__.py b/mrp_stock_move_cost/models/__init__.py deleted file mode 100644 index 995822654..000000000 --- a/mrp_stock_move_cost/models/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from . import mrp_production -from . import stock_move_line -from . import stock_lot diff --git a/mrp_stock_move_cost/models/mrp_production.py b/mrp_stock_move_cost/models/mrp_production.py deleted file mode 100644 index bdc671ec3..000000000 --- a/mrp_stock_move_cost/models/mrp_production.py +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright 2024 Alfredo de la Fuente - AvanzOSC -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from odoo import fields, models - - -class MrpProduction(models.Model): - _inherit = "mrp.production" - - price_unit_cost = fields.Float( - string="Cost Unit Price", digits="Product Price", copy=False - ) - cost = fields.Float(digits="Product Price", copy=False) - - def write(self, vals): - result = super().write(vals) - if "state" in vals and vals.get("state", False) == "done": - for production in self: - production.update_prodution_cost() - return result - - def _put_cost_in_mrp_production(self): - productions = self.filtered(lambda x: x.state == "done") - for production in productions: - production.update_prodution_cost() - - def update_prodution_cost(self): - price_unit_cost = 0 - cost = 0 - if self.move_raw_ids: - cost = sum(self.move_raw_ids.mapped("cost")) - if cost and self.move_finished_ids: - for move in self.move_finished_ids: - if move.quantity_done > 0: - move.price_unit_cost = cost / move.quantity_done - self.cost = cost - if cost and self.qty_producing: - price_unit_cost = cost / self.qty_producing - self.price_unit_cost = price_unit_cost - if self.lot_producing_id: - self.lot_producing_id.with_context(from_production=True).purchase_price = ( - price_unit_cost - ) diff --git a/mrp_stock_move_cost/models/stock_lot.py b/mrp_stock_move_cost/models/stock_lot.py deleted file mode 100644 index e6ce4d732..000000000 --- a/mrp_stock_move_cost/models/stock_lot.py +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright 2024 Alfredo de la Fuente - AvanzOSC -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from odoo import models - - -class StockLot(models.Model): - _inherit = "stock.lot" - - def write(self, vals): - result = super().write(vals) - if "from_production" not in self.env.context and "purchase_price" in vals: - for lot in self: - lot._update_stock_move_lines() - return result - - def _update_stock_move_lines(self): - cond = [("lot_id", "=", self.id)] - lines = self.env["stock.move.line"].search(cond) - if lines: - lines.write({"price_unit_cost": self.purchase_price}) - - cond = [("lot_producing_id", "=", self.id)] - productions = self.env["mrp.production"].search(cond) - if productions: - for production in productions: - production.write( - { - "price_unit_cost": self.purchase_price, - "cost": self.purchase_price * production.qty_producing, - } - ) diff --git a/mrp_stock_move_cost/models/stock_move_line.py b/mrp_stock_move_cost/models/stock_move_line.py deleted file mode 100644 index e0c5bd27f..000000000 --- a/mrp_stock_move_cost/models/stock_move_line.py +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright 2024 Alfredo de la Fuente - AvanzOSC -# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from odoo import api, models - - -class StockMoveLine(models.Model): - _inherit = "stock.move.line" - - def unlink(self): - productions = self.env["mrp.production"] - for line in self.filtered(lambda x: x.production_id): - if line.production_id not in productions: - productions += line.production_id - for line in self.filtered( - lambda x: x.move_id and x.move_id.raw_material_production_id - ): - if line.move_id.raw_material_production_id not in productions: - productions += line.move_id.raw_material_production_id - result = super().unlink() - for production in productions: - production.update_prodution_cost() - return result - - @api.model_create_multi - def create(self, vals_list): - lines = super().create(vals_list) - done_lines = lines.filtered(lambda x: x.state == "done") - if done_lines: - done_lines.search_production_and_update() - return lines - - def write(self, vals): - result = super().write(vals) - if "qty_done" in vals: - self.filtered( - lambda line: line.state == "done" - ).search_production_and_update() - return result - - def search_production_and_update(self): - for line in self: - production = self.env["mrp.production"] - if line.production_id: - production = line.production_id - if line.move_id and line.move_id.raw_material_production_id: - production = line.move_id.raw_material_production_id - if production and production.state == "done": - production.update_prodution_cost() diff --git a/mrp_stock_move_cost/views/mrp_production_views.xml b/mrp_stock_move_cost/views/mrp_production_views.xml deleted file mode 100644 index adc720ff2..000000000 --- a/mrp_stock_move_cost/views/mrp_production_views.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - mrp.production - - - - - - - - - - - - - - - - - mrp.production - - - - - - - - - - - Put Cost - - - ir.actions.server - code - - if records: - records._put_cost_in_mrp_production() - - - diff --git a/setup/mrp_stock_move_cost/odoo/addons/mrp_stock_move_cost b/setup/mrp_stock_move_cost/odoo/addons/mrp_stock_move_cost deleted file mode 120000 index b2f662590..000000000 --- a/setup/mrp_stock_move_cost/odoo/addons/mrp_stock_move_cost +++ /dev/null @@ -1 +0,0 @@ -../../../../mrp_stock_move_cost \ No newline at end of file diff --git a/setup/mrp_stock_move_cost/setup.py b/setup/mrp_stock_move_cost/setup.py deleted file mode 100644 index 28c57bb64..000000000 --- a/setup/mrp_stock_move_cost/setup.py +++ /dev/null @@ -1,6 +0,0 @@ -import setuptools - -setuptools.setup( - setup_requires=['setuptools-odoo'], - odoo_addon=True, -)