diff --git a/product_rental_leads/__init__.py b/product_rental_leads/__init__.py new file mode 100755 index 0000000..cde864b --- /dev/null +++ b/product_rental_leads/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import models diff --git a/product_rental_leads/__manifest__.py b/product_rental_leads/__manifest__.py new file mode 100755 index 0000000..0c60e74 --- /dev/null +++ b/product_rental_leads/__manifest__.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- +{ + "name": "Product Rental Leads", + "category": "Product", + "version": "14.0.1.0", + "summary": "Link a CRM lead to a Rental booking", + "author": "Elabore", + "website": "https://elabore.coop/", + "installable": True, + "application": False, + "auto_install": False, + "description": """ +==================== +Product Rental Leads +==================== +This module allows to link a Rental Booking to a CRM lead. + +Installation +============ +Just install product_rental_leads, 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", "crm"], + "data": [ + "views/menus.xml", + ], + "qweb": [], +} diff --git a/product_rental_leads/i18n/fr.po b/product_rental_leads/i18n/fr.po new file mode 100644 index 0000000..16480d6 --- /dev/null +++ b/product_rental_leads/i18n/fr.po @@ -0,0 +1,22 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_rental_inspection +# +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_leads +#: model:ir.model.fields,field_description:product_rental_leads.field_rental_product_order__opportunity_id +#: model:ir.model.fields,field_description:product_rental_leads.field_wizard_product_service__opportunity_id +msgid "CRM" +msgstr "CRM" \ No newline at end of file diff --git a/product_rental_leads/models/__init__.py b/product_rental_leads/models/__init__.py new file mode 100644 index 0000000..8677d6d --- /dev/null +++ b/product_rental_leads/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +from . import crm_lead +from . import product_order diff --git a/product_rental_leads/models/crm_lead.py b/product_rental_leads/models/crm_lead.py new file mode 100755 index 0000000..eab1c33 --- /dev/null +++ b/product_rental_leads/models/crm_lead.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- + +from odoo import models, fields, api + + +class CrmLead(models.Model): + _inherit = "crm.lead" + + product_model = fields.Many2one("product.product", string="Product Model") + from_date = fields.Datetime("From Date") + to_date = fields.Datetime("To Date") + sale_number = fields.Integer( + compute="_compute_sale_amount_total", string="Number of Quotations", default="5" + ) + order_ids = fields.One2many( + "rental.product.order", "opportunity_id", string="Orders" + ) + company_id = fields.Many2one( + "res.company", string="Company", default=lambda self: self.env.user.company_id + ) + + @api.depends("order_ids") + def _compute_sale_amount_total(self): + for lead in self: + total = 0.0 + nbr = 0 + company_currency = ( + lead.company_currency or self.env.user.company_id.currency_id + ) + for order in lead.order_ids: + if order.state in ( + "draft", + "confirm", + ): + nbr += 1 + if order.state not in ("draft", "sent", "cancel"): + total += order.currency_id.compute( + order.untaxed_amount, company_currency + ) + lead.sale_amount_total = total + lead.sale_number = nbr + return True diff --git a/product_rental_leads/models/product_order.py b/product_rental_leads/models/product_order.py new file mode 100644 index 0000000..f89941a --- /dev/null +++ b/product_rental_leads/models/product_order.py @@ -0,0 +1,9 @@ +# -*- coding: utf-8 -*- + +from odoo import models, fields, _ + + +class RentalProductOrder(models.Model): + _inherit = "rental.product.order" + + opportunity_id = fields.Many2one("crm.lead", string=_("Opportunity")) diff --git a/product_rental_leads/views/menus.xml b/product_rental_leads/views/menus.xml new file mode 100644 index 0000000..cf3f174 --- /dev/null +++ b/product_rental_leads/views/menus.xml @@ -0,0 +1,18 @@ + + + + + + product Quotations + rental.product.order + tree,form + [('opportunity_id', '=', active_id)] + + {'search_default_opportunity_id': [active_id], 'default_opportunity_id': active_id} + + + + + + + \ No newline at end of file