From 4c07d5831be644f0e389118ec6d0e8b58c421978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phan=20Sainl=C3=A9ger?= Date: Tue, 19 Apr 2022 11:58:08 +0200 Subject: [PATCH] [NEW] Addons creation - product_rental_delay_management --- product_rental_delay_management/__init__.py | 3 + .../__manifest__.py | 59 ++++++++ product_rental_delay_management/i18n/fr.po | 141 ++++++++++++++++++ .../models/__init__.py | 4 + .../models/product_delay_lines.py | 20 +++ .../models/stock_picking.py | 32 ++++ .../security/ir.model.access.csv | 2 + .../views/stock_picking.xml | 39 +++++ 8 files changed, 300 insertions(+) create mode 100755 product_rental_delay_management/__init__.py create mode 100755 product_rental_delay_management/__manifest__.py create mode 100644 product_rental_delay_management/i18n/fr.po create mode 100644 product_rental_delay_management/models/__init__.py create mode 100644 product_rental_delay_management/models/product_delay_lines.py create mode 100644 product_rental_delay_management/models/stock_picking.py create mode 100755 product_rental_delay_management/security/ir.model.access.csv create mode 100644 product_rental_delay_management/views/stock_picking.xml diff --git a/product_rental_delay_management/__init__.py b/product_rental_delay_management/__init__.py new file mode 100755 index 0000000..cde864b --- /dev/null +++ b/product_rental_delay_management/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import models diff --git a/product_rental_delay_management/__manifest__.py b/product_rental_delay_management/__manifest__.py new file mode 100755 index 0000000..bf09dbb --- /dev/null +++ b/product_rental_delay_management/__manifest__.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +{ + "name": "Product Rental Delay Management", + "category": "Product", + "version": "14.0.1.0", + "summary": "Management delays and their costs on your rental booking", + "author": "Elabore", + "website": "https://elabore.coop/", + "installable": True, + "application": False, + "auto_install": False, + "description": """ +=============================== +Product Rental Delay Management +=============================== +This module allows the registering of delay information which impact the total booking cost. + +Installation +============ +Just install product_rental_delay_management, all dependencies will be installed by default. + +Known issues / Roadmap +====================== + +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. + +Credits +======= + +Images +------ +* Elabore: `Icon `_. + +Contributors +------------ +* Stéphan Sainléger + +Funders +------- +The development of this module has been financially supported by: +* Elabore (https://elabore.coop) + +Maintainer +---------- +This module is maintained by ELABORE. + +""", + "depends": ["product_rental_bookings"], + "data": [ + "security/ir.model.access.csv", + "views/stock_picking.xml", + ], + "qweb": [], +} diff --git a/product_rental_delay_management/i18n/fr.po b/product_rental_delay_management/i18n/fr.po new file mode 100644 index 0000000..39fd479 --- /dev/null +++ b/product_rental_delay_management/i18n/fr.po @@ -0,0 +1,141 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_rental_delay_management +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 14.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2021-09-29 14:44+0000\n" +"PO-Revision-Date: 2021-09-29 14: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: product_rental_delay_management +#: model:ir.model.fields,field_description:product_rental_delay_management.field_product_delayed__delay_cost_per_hour +#: model:ir.model.fields,field_description:product_rental_delay_management.field_product_delayed_lines__delay_cost_per_hour +msgid "Cost/Hour" +msgstr "Tarif horaire" + +#. module: product_rental_delay_management +#: model:ir.model.fields,field_description:product_rental_delay_management.field_product_delayed__create_uid +#: model:ir.model.fields,field_description:product_rental_delay_management.field_product_delayed_lines__create_uid +msgid "Created by" +msgstr "Créer par" + +#. module: product_rental_delay_management +#: model:ir.model.fields,field_description:product_rental_delay_management.field_product_delayed__create_date +#: model:ir.model.fields,field_description:product_rental_delay_management.field_product_delayed_lines__create_date +msgid "Created on" +msgstr "Créer le" + +#. module: product_rental_delay_management +#: model:ir.model.fields,field_description:product_rental_delay_management.field_product_delayed__delayed_amount +msgid "Delayed Amount" +msgstr "" + +#. module: product_rental_delay_management +#: model_terms:ir.ui.view,arch_db:product_rental_delay_management.stock_picking_form_inherit +msgid "Delayed Hours" +msgstr "" + +#. module: product_rental_delay_management +#: model:ir.model.fields,field_description:product_rental_delay_management.field_stock_picking__product_delay_line_ids +msgid "Delayed Hours " +msgstr "" + +#. module: product_rental_delay_management +#: model:ir.model.fields,field_description:product_rental_delay_management.field_product_delayed__name +msgid "Description" +msgstr "Description" + +#. module: product_rental_delay_management +#: model:ir.model.fields,field_description:product_rental_delay_management.field_product_delayed__display_name +#: model:ir.model.fields,field_description:product_rental_delay_management.field_product_delayed_lines__display_name +msgid "Display Name" +msgstr "Nom affiché" + +#. module: product_rental_delay_management +#: model:ir.model.fields.selection,name:product_rental_delay_management.selection__product_delayed__invoice_state__draft +msgid "Draft" +msgstr "Brouillon" + +#. module: product_rental_delay_management +#: model:ir.model.fields,field_description:product_rental_delay_management.field_product_delayed__id +#: model:ir.model.fields,field_description:product_rental_delay_management.field_product_delayed_lines__id +msgid "ID" +msgstr "" + +#. module: product_rental_delay_management +#: model:ir.model.fields,field_description:product_rental_delay_management.field_product_delayed__invoice_state +msgid "Invoice State" +msgstr "État de la facture" + +#. module: product_rental_delay_management +#: model:ir.model.fields,field_description:product_rental_delay_management.field_stock_picking__is_delayed +msgid "Is Delayed" +msgstr "Est reporté" + +#. module: product_rental_delay_management +#: model:ir.model.fields,field_description:product_rental_delay_management.field_product_delayed____last_update +#: model:ir.model.fields,field_description:product_rental_delay_management.field_product_delayed_lines____last_update +msgid "Last Modified on" +msgstr "Dernière modification le" + +#. module: product_rental_delay_management +#: model:ir.model.fields,field_description:product_rental_delay_management.field_product_delayed__write_uid +#: model:ir.model.fields,field_description:product_rental_delay_management.field_product_delayed_lines__write_uid +msgid "Last Updated by" +msgstr "Dernière mise à jour par" + +#. module: product_rental_delay_management +#: model:ir.model.fields,field_description:product_rental_delay_management.field_product_delayed__write_date +#: model:ir.model.fields,field_description:product_rental_delay_management.field_product_delayed_lines__write_date +msgid "Last Updated on" +msgstr "Dernière mise à jour le" + +#. module: product_rental_delay_management +#: model:ir.model,name:product_rental_delay_management.model_product_delayed +msgid "Product Delayed" +msgstr "" + +#. module: product_rental_delay_management +#: model:ir.model,name:product_rental_delay_management.model_product_delayed_lines +msgid "Product Delayed Lines" +msgstr "" + +#. module: product_rental_delay_management +#: model:ir.model.fields,field_description:product_rental_delay_management.field_product_delayed_lines__product_delay_id +msgid "Product Move" +msgstr "Mouvement du produit" + +#. module: product_rental_delay_management +#: model:ir.model.fields,field_description:product_rental_delay_management.field_product_delayed__product_id +#: model:ir.model.fields,field_description:product_rental_delay_management.field_product_delayed_lines__product_id +msgid "Product Name" +msgstr "Nom du produit" + +#. module: product_rental_delay_management +#: model:ir.model.fields,field_description:product_rental_delay_management.field_product_delayed_lines__products_checked +msgid "Select Products" +msgstr "Sélectionner les produits" + +#. module: product_rental_delay_management +#: model:ir.model.fields,field_description:product_rental_delay_management.field_product_delayed_lines__sub_total +msgid "Sub Total" +msgstr "Sous-total" + +#. module: product_rental_delay_management +#: model:ir.model.fields.selection,name:product_rental_delay_management.selection__product_delayed__invoice_state__to_invoice +msgid "To Invoice" +msgstr "A facturer" + +#. module: product_rental_delay_management +#: model:ir.model.fields,field_description:product_rental_delay_management.field_product_delayed__delayed_hours +#: model:ir.model.fields,field_description:product_rental_delay_management.field_product_delayed_lines__delayed_hours +msgid "Total Hours" +msgstr "Nombre d'heures totales" \ No newline at end of file diff --git a/product_rental_delay_management/models/__init__.py b/product_rental_delay_management/models/__init__.py new file mode 100644 index 0000000..5ce0ec1 --- /dev/null +++ b/product_rental_delay_management/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import product_delay_lines +from . import stock_picking diff --git a/product_rental_delay_management/models/product_delay_lines.py b/product_rental_delay_management/models/product_delay_lines.py new file mode 100644 index 0000000..55a677a --- /dev/null +++ b/product_rental_delay_management/models/product_delay_lines.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- + +from odoo import models, fields, api + + +class ProductDelayLines(models.Model): + _name = "product.delayed.lines" + _description = "Product Delayed Lines" + + @api.depends("delayed_hours", "delay_cost_per_hour") + def _get_subtotal(self): + for each in self: + each.sub_total = each.delayed_hours * each.delay_cost_per_hour + + product_delay_id = fields.Many2one("stock.picking", string="Product Move") + product_id = fields.Many2one("product.product", string="Product Name") + delay_cost_per_hour = fields.Float(string="Cost/Hour") + delayed_hours = fields.Float(string="Total Hours") + sub_total = fields.Float(string="Sub Total", compute="_get_subtotal", store=True) + products_checked = fields.Boolean(string="Select Products") diff --git a/product_rental_delay_management/models/stock_picking.py b/product_rental_delay_management/models/stock_picking.py new file mode 100644 index 0000000..e829fb2 --- /dev/null +++ b/product_rental_delay_management/models/stock_picking.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- + +from datetime import datetime + +from odoo import models, fields, api, _ +from odoo.exceptions import UserError +from odoo.tests import Form + + +class StockPicking(models.Model): + _inherit = "stock.picking" + + product_delay_line_ids = fields.One2many( + "product.delayed.lines", "product_delay_id", string="Delayed Hours " + ) + is_delayed = fields.Boolean(string="Is Delayed") + + @api.depends("product_delay_line_ids") + def _compute_total(self): + for record in self: + for line in record.product_delay_line_ids: + record.total_amount += line.sub_total + + def delivery(self): + product_delay_line_ids = [] + if any([each.products_checked for each in self.move_ids_without_package]): + deliver_move_id = super(StockPicking, self).delivery() + deliver_move_id.write( + { + "product_delay_line_ids": product_delay_line_ids, + } + ) diff --git a/product_rental_delay_management/security/ir.model.access.csv b/product_rental_delay_management/security/ir.model.access.csv new file mode 100755 index 0000000..20ee02f --- /dev/null +++ b/product_rental_delay_management/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_product_delayed_lines,access_product_delayed_lines,model_product_delayed_lines,,1,1,1,1 diff --git a/product_rental_delay_management/views/stock_picking.xml b/product_rental_delay_management/views/stock_picking.xml new file mode 100644 index 0000000..037c412 --- /dev/null +++ b/product_rental_delay_management/views/stock_picking.xml @@ -0,0 +1,39 @@ + + + + + view.picking.form.inherit + stock.picking + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file