Skip to content

Commit

Permalink
RM11765: Provenance - Définition d'une sous arborescence
Browse files Browse the repository at this point in the history
implement #10
  • Loading branch information
pdo-axelor committed Apr 27, 2018
1 parent 9b1f988 commit cc1aff7
Show file tree
Hide file tree
Showing 15 changed files with 850 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/abs
Submodule abs updated from 1e8155 to 30743b
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import com.axelor.apps.acces.industrie.service.TransportCostService;
import com.axelor.apps.acces.industrie.service.TransportCostServiceImpl;
import com.axelor.apps.base.web.PartnerController;
import com.axelor.apps.crm.web.AccesIndustrieConvertLeadWizardController;
import com.axelor.apps.crm.web.AccesIndustrieLeadController;
import com.axelor.apps.crm.web.AccesIndustriePartnerController;
import com.axelor.apps.crm.web.ConvertLeadWizardController;
import com.axelor.apps.crm.web.LeadController;
import com.axelor.apps.sale.service.saleorder.AccesIndustrieSaleOrderLineService;
import com.axelor.apps.sale.service.saleorder.AccesIndustrieSaleOrderLineServiceImpl;
Expand All @@ -25,6 +27,7 @@ protected void configure() {
bind(LeadController.class).to(AccesIndustrieLeadController.class);
bind(PartnerController.class).to(AccesIndustriePartnerController.class);
bind(SaleOrderLineController.class).to(AccesIndustrieSaleOrderLineController.class);
bind(ConvertLeadWizardController.class).to(AccesIndustrieConvertLeadWizardController.class);

bind(TransportCostService.class).to(TransportCostServiceImpl.class);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* Axelor Business Solutions
*
* Copyright (C) 2018 Axelor (<http://axelor.com>).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.axelor.apps.crm.web;

import java.util.Map;

import com.axelor.apps.base.db.AppBase;
import com.axelor.apps.base.db.Company;
import com.axelor.apps.base.db.repo.CompanyRepository;
import com.axelor.apps.base.db.repo.PartnerRepository;
import com.axelor.apps.base.service.app.AppBaseService;
import com.axelor.apps.crm.db.Lead;
import com.axelor.apps.crm.db.repo.LeadRepository;
import com.axelor.apps.crm.exception.IExceptionMessage;
import com.axelor.apps.crm.service.ConvertLeadWizardService;
import com.axelor.exception.AxelorException;
import com.axelor.exception.db.IException;
import com.axelor.exception.service.TraceBackService;
import com.axelor.i18n.I18n;
import com.axelor.rpc.ActionRequest;
import com.axelor.rpc.ActionResponse;
import com.axelor.rpc.Context;
import com.google.inject.Inject;
import com.google.inject.Singleton;

@Singleton
public class AccesIndustrieConvertLeadWizardController extends ConvertLeadWizardController {

@Inject
protected LeadRepository leadRepo;

@Inject
protected ConvertLeadWizardService convertLeadWizardService;

@Inject
protected PartnerRepository partnerRepo;

@Inject
protected CompanyRepository companyRepo;

@Inject
protected AppBaseService appBaseService;

@Override
public void setConvertLeadIntoOpportunity(ActionRequest request, ActionResponse response) {
try {
Context context = request.getContext();
Lead lead;
if (context.getParent() != null
&& context.getParent().get("_model").equals("com.axelor.apps.base.db.Wizard")) {
lead = leadRepo.find(Long.parseLong(((Map) context.getParent().get("_lead")).get("id").toString()));
} else {
lead = leadRepo.find(Long.parseLong(((Map) context.get("_lead")).get("id").toString()));
}

if (lead == null) {
throw new AxelorException(IException.NO_VALUE, I18n.get(IExceptionMessage.CONVERT_LEAD_MISSING));
}
AppBase appBase = appBaseService.getAppBase();
response.setAttr("lead", "value", lead);
response.setAttr("amount", "value", lead.getEstimatedBudget());
response.setAttr("description", "value", lead.getDescription());
response.setAttr("source", "value", lead.getSource());
response.setAttr("user", "value", lead.getUser());
response.setAttr("team", "value", lead.getTeam());
response.setAttr("salesStageSelect", "value", "1");
response.setAttr("webSite", "value", lead.getWebSite());
response.setAttr("source", "value", lead.getSource());

// Acces Industrie
response.setAttr("subSource", "value", lead.getSubSource());

response.setAttr("department", "value", lead.getDepartment());
response.setAttr("team", "value", lead.getTeam());
response.setAttr("isCustomer", "value", true);
response.setAttr("partnerTypeSelect", "value", "1");
response.setAttr("language", "value", appBase.getDefaultPartnerLanguage());

Company company = null;

if (lead.getUser() != null && lead.getUser().getActiveCompany() != null) {
company = lead.getUser().getActiveCompany();
} else if (companyRepo.all().count() == 1) {
company = companyRepo.all().fetchOne();
}

if (company != null) {
response.setAttr("company", "value", company);
response.setAttr("currency", "value", company.getCurrency());
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}

}
12 changes: 12 additions & 0 deletions modules/acces-industrie-module/src/main/resources/domains/Lead.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<domain-models xmlns="http://axelor.com/xml/ns/domain-models"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://axelor.com/xml/ns/domain-models http://axelor.com/xml/ns/domain-models/domain-models_5.0.xsd">

<module name="crm" package="com.axelor.apps.crm.db"/>

<entity name="Lead">
<many-to-one name="subSource" ref="com.axelor.apps.base.db.SubSource" title="Sub-source"/>
</entity>

</domain-models>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<domain-models xmlns="http://axelor.com/xml/ns/domain-models"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://axelor.com/xml/ns/domain-models http://axelor.com/xml/ns/domain-models/domain-models_5.0.xsd">

<module name="crm" package="com.axelor.apps.crm.db"/>

<entity name="Opportunity">
<many-to-one name="subSource" ref="com.axelor.apps.base.db.SubSource" title="Sub-source"/>
</entity>

</domain-models>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<domain-models xmlns="http://axelor.com/xml/ns/domain-models"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://axelor.com/xml/ns/domain-models http://axelor.com/xml/ns/domain-models/domain-models_5.0.xsd">

<module name="base" package="com.axelor.apps.base.db"/>

<entity name="Source">
<one-to-many name="subSourceList" ref="com.axelor.apps.base.db.SubSource" mappedBy="source" title="Sub-sources"/>
</entity>

</domain-models>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<domain-models xmlns="http://axelor.com/xml/ns/domain-models"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://axelor.com/xml/ns/domain-models http://axelor.com/xml/ns/domain-models/domain-models_5.0.xsd">

<module name="base" package="com.axelor.apps.base.db"/>

<entity name="SubSource">
<string name="code"/>
<string name="name"/>
<many-to-one name="source" ref="com.axelor.apps.base.db.Source"/>

<unique-constraint columns="code,source"/>
</entity>

</domain-models>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"<a class='fa fa-linkedin' href='http://www.linkedin.com' target='_blank' />",,,
"<a class='fa fa-twitter' href='http://www.twitter.com' target='_blank' />",,,
"<a class='fa fa-youtube' href='http://www.youtube.com' target='_blank' />",,,
"<span class='label label-warning'>There is already a lead with this name.</span>",,,
"<span class='label label-warning'>There is already a partner with this name.</span>",,,
"Accounting",,,
"Accounting situation",,,
Expand All @@ -17,6 +18,7 @@
"Amount invoiced W.T.",,,
"Analytic distribution",,,
"Article dimension",,,
"Assign to me",,,
"Assigned to",,,
"Available stock",,,
"Balance",,,
Expand All @@ -34,6 +36,7 @@
"Carrier",,,
"Categorization",,,
"Change reserved qty",,,
"City",,,
"Civility",,,
"Client portal access",,,
"Code",,,
Expand All @@ -45,34 +48,55 @@
"Contact address",,,
"Contact details",,,
"Content",,,
"Convert",,,
"Convert into Contact",,,
"Convert into Contact ?",,,
"Convert into Partner",,,
"Convert into Partner ?",,,
"Convert into Prospect",,,
"Convert into Prospect ?",,,
"Convert into an individual partner",,,
"Convert into quotation",,,
"Convert lead",,,
"Costs",,,
"Country",,,
"Create a task",,,
"Create a task ?",,,
"Create into Opportunity",,,
"Create into Opportunity ?",,,
"Create opportunity",,,
"Currency",,,
"Customer",,,
"Customer Situation",,,
"Customer deliveries",,,
"Customer information",,,
"Customize BOM",,,
"Dates",,,
"Define as template",,,
"Delivered",,,
"Delivery",,,
"Delivery Address",,,
"Delivery information",,,
"Description",,,
"Description to display",,,
"Details Lines",,,
"Discount",,,
"Draft",,,
"Edit order",,,
"Emails",,,
"Employee",,,
"Enterprise name",,,
"Envelope",,,
"Excel Export",,,
"Factor",,,
"Finalize",,,
"Financial terms",,,
"Finish manually sale order",,,
"First name",,,
"Follow-up",,,
"Freight Carrier",,,
"Freight Carrier Mode",,,
"Function",,,
"Future qty",,,
"General contact details",,,
"Generate Elements",,,
Expand All @@ -90,21 +114,32 @@
"Internal description",,,
"Invoiced",,,
"Invoicing",,,
"Invoicing Address",,,
"Invoicing State",,,
"Invoicing follow-up",,,
"Invoicing/Payment",,,
"Label",,,
"Lead",,,
"Linked to",,,
"Links",,,
"Log a call",,,
"Log a call ?",,,
"Lose",,,
"Manual Unblock",,,
"Map",,,
"Margin",,,
"Marketing",,,
"Multiple quantities",,,
"Name",,,
"New version",,,
"Not delivered",,,
"Not invoiced",,,
"Notes",,,
"OR",,,
"Opportunity",,,
"Or Select Contact",,,
"Or Select Partner",,,
"Or Select Prospect",,,
"Order being edited",,,
"Overview",,,
"Pack lines",,,
Expand All @@ -115,7 +150,10 @@
"Partner Details",,,
"Partner Type",,,
"Partners",,,
"Personal",,,
"Postal addresses",,,
"Postal code",,,
"Primary address",,,
"Print",,,
"Print Informations",,,
"Print proforma invoice",,,
Expand All @@ -132,23 +170,35 @@
"Purchase/Costs",,,
"Purchases",,,
"Real qty",,,
"Recycle",,,
"Register a deposit",,,
"Rejection of calls",,,
"Rejection of e-mails",,,
"Reports",,,
"SO line",,,
"Sale",,,
"Sale order",,,
"Sale quotations/orders",,,
"Sales",,,
"Sales follow-up",,,
"Schedule Event",,,
"Schedule a meeting",,,
"Schedule a meeting ?",,,
"Send Email",,,
"Send email",,,
"Settings",,,
"Shipment Mode",,,
"Show Partner",,,
"Show all events",,,
"Show all stock move",,,
"Source",,,
"Start",,,
"State",,,
"Status",,,
"Stock",,,
"Stock Moves",,,
"Sub-source",,,
"Sub-sources",,,
"Supplier",,,
"Suppliers catalog",,,
"Team",,,
Expand All @@ -169,6 +219,7 @@
"Type of project's elements generated",,,
"Units",,,
"Update products prices",,,
"Validate",,,
"Validate changes",,,
"Variants",,,
"Weight",,,
Expand Down
Loading

0 comments on commit cc1aff7

Please sign in to comment.