diff --git a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/web/InvoiceController.java b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/web/InvoiceController.java
index a4c20c94..a4b40771 100644
--- a/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/web/InvoiceController.java
+++ b/modules/axelor-open-suite/axelor-account/src/main/java/com/axelor/apps/account/web/InvoiceController.java
@@ -23,6 +23,7 @@ import com.axelor.apps.account.db.InvoicePayment;
import com.axelor.apps.account.db.PaymentCondition;
import com.axelor.apps.account.db.PaymentMode;
import com.axelor.apps.account.db.PaymentVoucher;
+import com.axelor.apps.account.db.Journal;
import com.axelor.apps.account.db.repo.InvoiceRepository;
import com.axelor.apps.account.exception.IExceptionMessage;
import com.axelor.apps.account.service.AccountingSituationService;
@@ -36,6 +37,7 @@ import com.axelor.apps.base.db.BankDetails;
import com.axelor.apps.base.db.Company;
import com.axelor.apps.base.db.Currency;
import com.axelor.apps.base.db.Partner;
+import com.axelor.apps.base.db.PartnerCategory;
import com.axelor.apps.base.db.PriceList;
import com.axelor.apps.base.db.PrintingSettings;
import com.axelor.apps.base.db.Wizard;
@@ -1013,5 +1015,37 @@ public class InvoiceController {
response.setView(ActionView.define(name).add("html", fileLink).map());
}
+
+
+ /**
+ * set default value for automatic invoice Journal = supplier Purchase Journal
+ *
+ * @param request
+ * @param response
+ * @throws AxelorException
+ */
+ public void setDefaultJournalSupplier(ActionRequest request, ActionResponse response) {
+ Invoice invoice = request.getContext().asType(Invoice.class);
+ Company company = invoice.getCompany();
+ Partner partner = invoice.getPartner();
+ PartnerCategory partnerCategory = partner.getPartnerCategory();
+ Journal journal = null ;
+ Integer operationTypeSelect = invoice.getOperationTypeSelect();
+
+ if (company != null && partner != null && operationTypeSelect != null ) {
+ if (operationTypeSelect.intValue() == InvoiceRepository.OPERATION_TYPE_SUPPLIER_PURCHASE) {
+ if( partnerCategory != null){
+ if(partnerCategory.getCode().equals("FRETG")){
+ journal = company.getAccountConfig().getSupplierPurchaseJournalForeigners();
+ }
+ if(partnerCategory.getCode().equals("FRLOC")){
+ journal = company.getAccountConfig().getSupplierPurchaseJournalLocal();
+ }
+ }
+ response.setValue("journal", journal);
+ }
+ }
+
+ }
}
diff --git a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/AccountConfig.xml b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/AccountConfig.xml
index efeb4555..fe427f25 100644
--- a/modules/axelor-open-suite/axelor-account/src/main/resources/domains/AccountConfig.xml
+++ b/modules/axelor-open-suite/axelor-account/src/main/resources/domains/AccountConfig.xml
@@ -27,7 +27,9 @@
-
+
+
+