[NEW] Addons creation - product_rental_leads
This commit is contained in:
3
product_rental_leads/__init__.py
Executable file
3
product_rental_leads/__init__.py
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from . import models
|
58
product_rental_leads/__manifest__.py
Executable file
58
product_rental_leads/__manifest__.py
Executable file
@@ -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
|
||||||
|
<https://github.com/elabore-coop/.../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 <https://elabore.coop/web/image/res.company/1/logo?unique=f3db262>`_.
|
||||||
|
|
||||||
|
Contributors
|
||||||
|
------------
|
||||||
|
* Stéphan Sainléger <https://github.com/stephansainleger>
|
||||||
|
|
||||||
|
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": [],
|
||||||
|
}
|
22
product_rental_leads/i18n/fr.po
Normal file
22
product_rental_leads/i18n/fr.po
Normal file
@@ -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"
|
4
product_rental_leads/models/__init__.py
Normal file
4
product_rental_leads/models/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from . import crm_lead
|
||||||
|
from . import product_order
|
42
product_rental_leads/models/crm_lead.py
Executable file
42
product_rental_leads/models/crm_lead.py
Executable file
@@ -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
|
9
product_rental_leads/models/product_order.py
Normal file
9
product_rental_leads/models/product_order.py
Normal file
@@ -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"))
|
18
product_rental_leads/views/menus.xml
Normal file
18
product_rental_leads/views/menus.xml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<record id="product_action_quotations" model="ir.actions.act_window">
|
||||||
|
<field name="name">product Quotations</field>
|
||||||
|
<field name="res_model">rental.product.order</field>
|
||||||
|
<field name="view_mode">tree,form</field>
|
||||||
|
<field name="domain">[('opportunity_id', '=', active_id)]</field>
|
||||||
|
<field name="context">
|
||||||
|
{'search_default_opportunity_id': [active_id], 'default_opportunity_id': active_id}
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<menuitem id="product_quotation_menu" name="Rental Quotations" parent="product_rental_bookings.rental_product_booking_menu" sequence="0" action="product_action_quotations" />
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</odoo>
|
Reference in New Issue
Block a user