diff --git a/deltatech_mrp_cost/README.rst b/deltatech_mrp_cost/README.rst new file mode 100644 index 0000000000..d01154fe43 --- /dev/null +++ b/deltatech_mrp_cost/README.rst @@ -0,0 +1,74 @@ +======== +MRP Cost +======== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-dhongu%2Fdeltatech-lightgray.png?logo=github + :target: https://github.com/dhongu/deltatech/tree/14.0/deltatech_mrp_cost + :alt: dhongu/deltatech + +|badge1| |badge2| |badge3| + + +Features: + - Calculeaza pretul de productie ca fiind pretul real al componentelor + - Asigneaza un picking pentru materialele consumate si unul pentru cele receptionate + - Inregistrare costuri de servicii prestate de terti + - variantele au acelasi pret + + - Computes price of production as being the real price of the components + - Asigns a picking for consumed materials and one for the receptioned ones + - Registration of services costs provided by third parties + - the variants have the same price + + + De testat cum functioneaza cu mrp_account instalat + +**Table of contents** + +.. contents:: + :local: + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Terrabit +* Dorin Hongu + +Maintainers +~~~~~~~~~~~ + +.. |maintainer-dhongu| image:: https://github.com/dhongu.png?size=40px + :target: https://github.com/dhongu + :alt: dhongu + +Current maintainer: + +|maintainer-dhongu| + +This module is part of the `dhongu/deltatech `_ project on GitHub. + +You are welcome to contribute. diff --git a/deltatech_mrp_cost/__init__.py b/deltatech_mrp_cost/__init__.py new file mode 100644 index 0000000000..7d0c4f4782 --- /dev/null +++ b/deltatech_mrp_cost/__init__.py @@ -0,0 +1,6 @@ +# © 2015-2021 Deltatech +# Dorin Hongu + + + + + diff --git a/deltatech_mrp_cost/i18n/es.po b/deltatech_mrp_cost/i18n/es.po new file mode 100644 index 0000000000..37cda43440 --- /dev/null +++ b/deltatech_mrp_cost/i18n/es.po @@ -0,0 +1,151 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * deltatech_mrp_cost +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0-20190607\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-07-08 09:15+0000\n" +"PO-Revision-Date: 2019-07-08 09:15+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: deltatech_mrp_cost +#: model_terms:ir.ui.view,arch_db:deltatech_mrp_cost.report_mrporder +msgid "Amount" +msgstr "Total" + +#. module: deltatech_mrp_cost +#: model_terms:ir.ui.view,arch_db:deltatech_mrp_cost.report_mrporder +msgid "Effective Quantity" +msgstr "Cantidad Efectiva" + +#. module: deltatech_mrp_cost +#: model_terms:ir.ui.view,arch_db:deltatech_mrp_cost.report_mrporder +msgid "Price" +msgstr "Precio" + +#. module: deltatech_mrp_cost +#: model_terms:ir.ui.view,arch_db:deltatech_mrp_cost.report_mrporder +msgid "Product" +msgstr "Producto" + +#. module: deltatech_mrp_cost +#: model_terms:ir.ui.view,arch_db:deltatech_mrp_cost.report_mrporder +msgid "Quantity" +msgstr "Cantidad" + +#. module: deltatech_mrp_cost +#: model:ir.model.fields,field_description:deltatech_mrp_cost.field_mrp_production__acc_move_line_ids +msgid "Account move lines" +msgstr "Apuntes contables" + +#. module: deltatech_mrp_cost +#: model_terms:ir.ui.view,arch_db:deltatech_mrp_cost.mrp_production_acc_form_view +msgid "Accounting Entries" +msgstr "Asientos contables" + +#. module: deltatech_mrp_cost +#: model:ir.model.fields,field_description:deltatech_mrp_cost.field_mrp_workcenter__costs_hour_account_id +msgid "Analytic Account" +msgstr "Cuenta analítica" + +#. module: deltatech_mrp_cost +#: model:ir.model.fields,field_description:deltatech_mrp_cost.field_mrp_production__calculate_price +msgid "Calculate Price" +msgstr "Precio calculado" + +#. module: deltatech_mrp_cost +#: model:ir.model.fields,help:deltatech_mrp_cost.field_stock_move__qty_available +msgid "Current quantity of products.\n" +"In a context with a single Stock Location, this includes goods stored at this Location, or any of its children.\n" +"In a context with a single Warehouse, this includes goods stored in the Stock Location of this Warehouse, or any of its children.\n" +"stored in the Stock Location of the Warehouse of this Shop, or any of its children.\n" +"Otherwise, this includes goods stored in any Stock Location with 'internal' type." +msgstr "Cantidad actual de los productos.\n" +"En un contexto de una sola ubicación de Stock, esto incluye los bienes almacenados en esta ubicación, o cualquiera de sus hijas.\n" +"En un contexto de un solo almacén, esto incluye los bienes almacenados en la ubicación de Stock de ese almacén, o cualquiera de sus hijas.\n" +"En cualquier otro caso, esto incluye los bienes almacenados en cualquier ubicación de Stock de tipo 'Interna'." + +#. module: deltatech_mrp_cost +#: model:ir.model.fields,help:deltatech_mrp_cost.field_mrp_workcenter__costs_hour_account_id +msgid "Fill this only if you want automatic analytic accounting entries on production orders." +msgstr "Rellena esto sólo si quieres entradas analíticas en las listas de producción" + +#. module: deltatech_mrp_cost +#: model_terms:ir.ui.view,arch_db:deltatech_mrp_cost.report_mrporder +msgid "Finished Products" +msgstr "Productos finalizados" + +#. module: deltatech_mrp_cost +#: code:addons/deltatech_mrp_cost/models/mrp_production.py:136 +#, python-format +msgid "Invoice %s is not validated" +msgstr "Factura %s no ha sido validada" + +#. module: deltatech_mrp_cost +#: model:ir.model,name:deltatech_mrp_cost.model_account_move_line +msgid "Journal Item" +msgstr "Apunte contable" + +#. module: deltatech_mrp_cost +#: code:addons/deltatech_mrp_cost/models/mrp_production.py:133 +#, python-format +msgid "Order %s is not invoiced" +msgstr "Pedido %s no ha sido facturado" + +#. module: deltatech_mrp_cost +#: model_terms:ir.ui.view,arch_db:deltatech_mrp_cost.mrp_production_form_view +msgid "Picking" +msgstr "Albarán" + +#. module: deltatech_mrp_cost +#: model:ir.model.fields,field_description:deltatech_mrp_cost.field_account_move_line__production_id +msgid "Production" +msgstr "Producción" + +#. module: deltatech_mrp_cost +#: model:ir.model.fields,field_description:deltatech_mrp_cost.field_mrp_production__amount +msgid "Production Amount" +msgstr "Total Producción" + +#. module: deltatech_mrp_cost +#: model:ir.model,name:deltatech_mrp_cost.model_mrp_production +msgid "Production Order" +msgstr "Pedido de producción" + +#. module: deltatech_mrp_cost +#: model:ir.model.fields,field_description:deltatech_mrp_cost.field_stock_move__qty_available +msgid "Quantity On Hand" +msgstr "Cantidad a mano" + +#. module: deltatech_mrp_cost +#: model:ir.model.fields,field_description:deltatech_mrp_cost.field_mrp_production__service_amount +msgid "Service Amount" +msgstr "Total Servicios" + +#. module: deltatech_mrp_cost +#: model:ir.model,name:deltatech_mrp_cost.model_stock_move +msgid "Stock Move" +msgstr "Movimiento de existencias" + +#. module: deltatech_mrp_cost +#: model:ir.model,name:deltatech_mrp_cost.model_stock_picking +msgid "Transfer" +msgstr "Transferir" + +#. module: deltatech_mrp_cost +#: model:ir.model,name:deltatech_mrp_cost.model_mrp_workcenter +msgid "Work Center" +msgstr "Centro de producción" + +#. module: deltatech_mrp_cost +#: model:ir.model,name:deltatech_mrp_cost.model_mrp_routing_workcenter +msgid "Work Center Usage" +msgstr "Utilización del centro de producción" + diff --git a/deltatech_mrp_cost/i18n/ro.po b/deltatech_mrp_cost/i18n/ro.po new file mode 100644 index 0000000000..2084f95f9b --- /dev/null +++ b/deltatech_mrp_cost/i18n/ro.po @@ -0,0 +1,32 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * deltatech_mrp_cost +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-04-22 07:25+0000\n" +"PO-Revision-Date: 2017-04-22 07:25+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: deltatech_mrp_cost +#: model:ir.model.fields,field_description:deltatech_mrp_cost.field_mrp_production_calculate_price +msgid "Calculate Price" +msgstr "Preț calculat" + +#. module: deltatech_mrp_cost +#: model:ir.model,name:deltatech_mrp_cost.model_mrp_production +msgid "Manufacturing Order" +msgstr "Comandă producție" + +#. module: deltatech_mrp_cost +#: model:ir.model.fields,field_description:deltatech_mrp_cost.field_mrp_production_amount +msgid "Production Amount" +msgstr "Valoare producție" + diff --git a/deltatech_mrp_cost/models/__init__.py b/deltatech_mrp_cost/models/__init__.py new file mode 100644 index 0000000000..3edb30f289 --- /dev/null +++ b/deltatech_mrp_cost/models/__init__.py @@ -0,0 +1,6 @@ +# © 2015-2021 Deltatech +# Dorin Hongu 0: + planned_cost = False # nu au fost facute miscari de stoc + + if planned_cost: + for move in production.move_raw_ids: + if move.product_id.type == "product": + qty = move.product_qty + move.product_qty * move.product_id.scrap + amount += move.price_unit * qty + product_qty = production.product_qty + + else: + for move in production.move_raw_ids: + if move.product_id.type == "product": + qty = move.quantity_done + amount += abs(move.price_unit) * qty + product_qty = 0.0 + for move in production.move_finished_ids: + product_qty += move.quantity_done + if product_qty == 0.0: + product_qty = production.product_qty + + # adaugare manopera la costul estimat + + for operation in production.bom_id.operation_ids: + time_cycle = operation.get_time_cycle(quantity=product_qty, product=production.product_id) + + cycle_number = math.ceil(product_qty / operation.workcenter_id.capacity) + duration_expected = ( + operation.workcenter_id.time_start + + operation.workcenter_id.time_stop + + cycle_number * time_cycle * 100.0 / operation.workcenter_id.time_efficiency + ) + + amount += (duration_expected / 60) * operation.workcenter_id.costs_hour + + amount += production.service_amount + calculate_price = amount / product_qty + production.calculate_price = calculate_price + production.amount = amount + + def _cal_price(self, consumed_moves): + super(MrpProduction, self)._cal_price(consumed_moves) + self.ensure_one() + production = self + + # self._calculate_amount() # refac calculul + price_unit = production.calculate_price + self.move_finished_ids.write({"price_unit": price_unit}) + # functia standard nu permite si de aceea am facut o modificare in deltatech_purchase_price + self.move_finished_ids.product_price_update_before_done() + + # if production.product_tmpl_id.cost_method == 'fifo' and + # production.product_tmpl_id.standard_price != production.calculate_price: + # + # price_unit = production.calculate_price + # production.product_tmpl_id.write({'standard_price': price_unit}) + # production.product_tmpl_id.product_variant_ids.write({'standard_price': price_unit}) + # production.move_finished_ids.write({'price_unit': price_unit}) + + return True + + def check_service_invoiced(self): + # sunt servicii in bom ? + for production in self: + service_amount = 0 + for line in production.bom_id.bom_line_ids: + if line.product_id.type == "service": + # care este comanda de achizitie ? + orders = self.env["purchase.order"].search([("group_id", "=", production.procurement_group_id.id)]) + for order in orders: + if order.invoice_status != "invoiced": + raise UserError(_("Order %s is not invoiced") % order.name) + for invoice in order.invoice_ids: + if not invoice.move_id: + raise UserError(_("Invoice %s is not validated") % invoice.number) + else: + for acc_move_line in invoice.move_id.line_ids: + acc_move_line.write({"production_id": production.id}) + if acc_move_line.product_id: + service_amount += acc_move_line.debit + acc_move_line.credit + if service_amount: + production.write({"service_amount": service_amount}) + + def post_inventory(self): + self.check_service_invoiced() + + self.assign_picking() + res = super(MrpProduction, self).post_inventory() + for production in self: + acc_move_line_ids = self.env["account.move.line"] + for move in production.move_raw_ids: + acc_move_line_ids |= move.account_move_ids.line_ids + for move in production.move_finished_ids: + acc_move_line_ids |= move.account_move_ids.line_ids + if acc_move_line_ids: + acc_move_line_ids.write({"production_id": production.id}) + return res + + def _generate_moves(self): + res = super(MrpProduction, self)._generate_moves() + self.assign_picking() + return res + + def assign_picking(self): + """ + Toate produsele consumate se vor reuni intr-un picking list (Bon de consum) + toate produsele receptionate (de regula un singur produs) se vor reuni intr-un picking list (Nota de predare) + """ + for production in self: + # bon de consum + move_list = self.env["stock.move"] + picking = False + for move in production.move_raw_ids: + if not move.picking_id: + move_list += move + else: + picking = move.picking_id + if move_list: + + warehouse_id = production.location_dest_id.get_warehouse() or self.env.user.company_id.warehouse_id + picking_type = warehouse_id.pick_type_prod_consume_id + if picking_type: + if not picking: + picking = self.env["stock.picking"].create( + { + "picking_type_id": picking_type.id, + "date": production.date_planned_start, + "location_id": picking_type.default_location_src_id.id, + "location_dest_id": picking_type.default_location_dest_id.id, + "origin": production.name, + } + ) + move_list.write({"picking_id": picking.id}) + # picking.action_assign() + + # nota de predare + move_list = self.env["stock.move"] + picking = False + for move in production.move_finished_ids: + if not move.picking_id: + move_list += move + else: + picking = move.picking_id + if move_list: + warehouse_id = production.location_src_id.get_warehouse() or self.env.user.company_id.warehouse_id + + picking_type = warehouse_id.pick_type_prod_receipt_id + if picking_type: + if not picking: + picking = self.env["stock.picking"].create( + { + "picking_type_id": picking_type.id, + "date": production.date_planned_start, + "location_id": picking_type.default_location_src_id.id, + "location_dest_id": picking_type.default_location_dest_id.id, + "origin": production.name, + } + ) + move_list.write({"picking_id": picking.id}) + # picking.action_assign() + return + + def action_see_picking(self): + pickings = self.env["stock.picking"] + for move in self.move_raw_ids: + pickings |= move.picking_id + for move in self.move_finished_ids: + pickings |= move.picking_id + + action = self.env.ref("stock.action_picking_tree_all").read()[0] + if pickings: + action["domain"] = "[('id','in'," + str(pickings.ids) + " )]" + + else: + action = False + return action + + def _generate_raw_move(self, bom_line, line_data): + move = super(MrpProduction, self)._generate_raw_move(bom_line, line_data) + if bom_line.product_id.type == "service": + self._action_launch_procurement_rule(bom_line, line_data) + # if bom_line.product_id.type != 'product': + # self.service_amount += bom_line.product_id.standard_price * line_data['qty'] + + return move + + @api.model + def _prepare_service_procurement_values(self): + location = self.location_src_id + return { + "company_id": self.company_id, + "date_planned": self.date_planned_start, + "warehouse_id": location.get_warehouse(), + "group_id": self.procurement_group_id, + } + + @api.model + def _action_launch_procurement_rule(self, bom_line, line_data): + values = self._prepare_service_procurement_values() + + name = "{} for {}".format(bom_line.product_id.name, self.name) + self.env["procurement.group"].sudo().run( + bom_line.product_id, line_data["qty"], bom_line.product_uom_id, self.location_src_id, name, name, values + ) + return True diff --git a/deltatech_mrp_cost/models/mrp_routing.py b/deltatech_mrp_cost/models/mrp_routing.py new file mode 100644 index 0000000000..afb1de5b36 --- /dev/null +++ b/deltatech_mrp_cost/models/mrp_routing.py @@ -0,0 +1,15 @@ +# © 2015-2021 Deltatech +# Dorin Hongu + + + + + +MRP Cost + + + +
+

MRP Cost

+ + +

Beta License: LGPL-3 dhongu/deltatech

+
+
Features:
+
    +
  • Calculeaza pretul de productie ca fiind pretul real al componentelor
  • +
  • Asigneaza un picking pentru materialele consumate si unul pentru cele receptionate
  • +
  • Inregistrare costuri de servicii prestate de terti
  • +
  • variantele au acelasi pret
  • +
  • Computes price of production as being the real price of the components
  • +
  • Asigns a picking for consumed materials and one for the receptioned ones
  • +
  • Registration of services costs provided by third parties
  • +
  • the variants have the same price
  • +
+
+De testat cum functioneaza cu mrp_account instalat
+
+
+

Table of contents

+ +
+

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 smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Terrabit
  • +
  • Dorin Hongu
  • +
+
+
+

Maintainers

+

Current maintainer:

+

dhongu

+

This module is part of the dhongu/deltatech project on GitHub.

+

You are welcome to contribute.

+
+
+
+ + diff --git a/deltatech_mrp_cost/static/description/logo-terrabit.png b/deltatech_mrp_cost/static/description/logo-terrabit.png new file mode 100644 index 0000000000..8b23ccdd37 Binary files /dev/null and b/deltatech_mrp_cost/static/description/logo-terrabit.png differ diff --git a/deltatech_mrp_cost/static/description/main_screenshot.png b/deltatech_mrp_cost/static/description/main_screenshot.png new file mode 100644 index 0000000000..4513ca1d39 Binary files /dev/null and b/deltatech_mrp_cost/static/description/main_screenshot.png differ diff --git a/deltatech_mrp_cost/views/mrp_production_templates.xml b/deltatech_mrp_cost/views/mrp_production_templates.xml new file mode 100644 index 0000000000..f1f7fdc86d --- /dev/null +++ b/deltatech_mrp_cost/views/mrp_production_templates.xml @@ -0,0 +1,79 @@ + + + + diff --git a/deltatech_mrp_cost/views/mrp_view.xml b/deltatech_mrp_cost/views/mrp_view.xml new file mode 100644 index 0000000000..d28c796f0e --- /dev/null +++ b/deltatech_mrp_cost/views/mrp_view.xml @@ -0,0 +1,51 @@ + + + + + deltatech.mrp.production.form + mrp.production + form + + +
+
+ + + + + + + + + + + + +
+
+
+ + deltatech.mrp.production.form + mrp.production + form + + + + + + + + + + +
diff --git a/deltatech_mrp_cost/views/mrp_workcenter_view.xml b/deltatech_mrp_cost/views/mrp_workcenter_view.xml new file mode 100644 index 0000000000..3152ad4247 --- /dev/null +++ b/deltatech_mrp_cost/views/mrp_workcenter_view.xml @@ -0,0 +1,15 @@ + + + + + mrp.workcenter.form + mrp.workcenter + + + + + + + + + diff --git a/deltatech_mrp_cost/views/product_view.xml b/deltatech_mrp_cost/views/product_view.xml new file mode 100644 index 0000000000..ebb396c473 --- /dev/null +++ b/deltatech_mrp_cost/views/product_view.xml @@ -0,0 +1,15 @@ + + + + + product.category.form + product.category + + + + + + + + +