[ADD] project_name_from_lead

This commit is contained in:
clementthomas
2023-03-27 17:22:38 +02:00
parent 139e451d0c
commit 355e77fc70
7 changed files with 127 additions and 0 deletions

2
project_name_from_lead/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*.*~
*pyc

View File

@@ -0,0 +1,57 @@
=======================
project_name_from_quote
=======================
.. |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-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--analytic-lightgray.png?logo=github
:target: https://github.com/elabore-coop/project-tools
:alt: elabore/hr-tools
|badge1| |badge2| |badge3|
This module tranfers the Quote / Sale order title to the project name.
Installation
============
Use Odoo normal module installation procedure to install ``project_name_from_quote``.
Known issues / Roadmap
======================
None yet.
Bug Tracker
===========
Bugs are tracked on `our issues website <https://github.com/elabore-coop/project-tools/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
=======
Contributors
------------
* Stéphan Sainléger
Funders
-------
The development of this module has been financially supported by:
* Elabore (https://elabore.coop)
* Datactivist (https://datactivist.coop)
Maintainer
----------
This module is maintained by Elabore.

View File

@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import models

View File

@@ -0,0 +1,35 @@
# Copyright 2022 Stéphan Sainléger (Elabore)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "project_name_from_lead",
"version": "14.0.1.0.0",
"author": "Elabore",
"website": "https://elabore.coop",
"maintainer": "Clément Thomas",
"license": "AGPL-3",
"category": "Tools",
"summary": "Use lead name as project name",
# any module necessary for this one to work correctly
"depends": [
"base",
"sale_project",
],
"qweb": [
# "static/src/xml/*.xml",
],
"external_dependencies": {
"python": [],
},
# always loaded
"data": [],
# only loaded in demonstration mode
"demo": [],
"js": [],
"css": [],
"installable": True,
# Install this module automatically if all dependency have been previously
# and independently installed. Used for synergetic or glue modules.
"auto_install": False,
"application": False,
}

View File

@@ -0,0 +1 @@
from . import sale_order, crm_lead

View File

@@ -0,0 +1,17 @@
from odoo import models
class Lead(models.Model):
_inherit = 'crm.lead'
def write(self, vals):
"""update project name if project created from lead
"""
for lead in self:
if 'name' in vals:
sale = self.env['sale.order'].search([('opportunity_id','=',lead.id)])
if sale:
project = self.env['project.project'].search([('sale_order_id','=',sale.id)])
if project:
project.name = vals['name']
return super(Lead, self).write(vals)

View File

@@ -0,0 +1,12 @@
from typing import ValuesView
from odoo import models
class SaleOrderLine(models.Model):
_inherit = "sale.order.line"
def _timesheet_create_project_prepare_values(self):
values = super(SaleOrderLine, self)._timesheet_create_project_prepare_values()
if self.order_id and self.order_id.opportunity_id:
values['name'] = self.order_id.opportunity_id.name
return values