提交 9c08c57c 编写于 作者: yujiaming's avatar yujiaming

button_confirm, get_name行为

上级 975ce6e0
package cn.ibizlab.businesscentral.core.extensions.service; package cn.ibizlab.businesscentral.core.extensions.service;
import cn.ibizlab.businesscentral.core.odoo_account.domain.Account_move; import cn.ibizlab.businesscentral.core.odoo_account.domain.Account_move;
import cn.ibizlab.businesscentral.core.odoo_account.service.impl.Account_moveServiceImpl; import cn.ibizlab.businesscentral.core.odoo_base.domain.Res_company;
import cn.ibizlab.businesscentral.core.odoo_base.domain.Res_currency; import cn.ibizlab.businesscentral.core.odoo_base.domain.Res_currency;
import cn.ibizlab.businesscentral.core.odoo_base.domain.Res_partner; import cn.ibizlab.businesscentral.core.odoo_base.domain.Res_partner;
import cn.ibizlab.businesscentral.core.odoo_base.service.impl.Res_partnerServiceImpl; import cn.ibizlab.businesscentral.core.odoo_ir.domain.Ir_sequence;
import cn.ibizlab.businesscentral.core.odoo_product.domain.Product_product; import cn.ibizlab.businesscentral.core.odoo_product.domain.Product_product;
import cn.ibizlab.businesscentral.core.odoo_product.domain.Product_supplierinfo; import cn.ibizlab.businesscentral.core.odoo_product.domain.Product_supplierinfo;
import cn.ibizlab.businesscentral.core.odoo_product.domain.Product_template; import cn.ibizlab.businesscentral.core.odoo_product.domain.Product_template;
import cn.ibizlab.businesscentral.core.odoo_product.service.impl.Product_productServiceImpl;
import cn.ibizlab.businesscentral.core.odoo_product.service.impl.Product_templateServiceImpl;
import cn.ibizlab.businesscentral.core.odoo_purchase.domain.Account_move_purchase_order_rel; import cn.ibizlab.businesscentral.core.odoo_purchase.domain.Account_move_purchase_order_rel;
import cn.ibizlab.businesscentral.core.odoo_purchase.domain.Purchase_order_line; import cn.ibizlab.businesscentral.core.odoo_purchase.domain.Purchase_order_line;
import cn.ibizlab.businesscentral.core.odoo_purchase.service.impl.Purchase_orderServiceImpl; import cn.ibizlab.businesscentral.core.odoo_purchase.service.impl.Purchase_orderServiceImpl;
...@@ -31,18 +29,16 @@ import java.util.*; ...@@ -31,18 +29,16 @@ import java.util.*;
public class Purchase_orderExService extends Purchase_orderServiceImpl { public class Purchase_orderExService extends Purchase_orderServiceImpl {
@Autowired @Autowired
Account_moveServiceImpl accountMoveService; protected cn.ibizlab.businesscentral.core.odoo_account.service.IAccount_moveService accountMoveService;
@Autowired @Autowired
Product_productServiceImpl productService; protected cn.ibizlab.businesscentral.core.odoo_product.service.IProduct_productService productService;
@Autowired @Autowired
Product_templateServiceImpl productTemplateService; protected cn.ibizlab.businesscentral.core.odoo_product.service.IProduct_templateService productTemplateService;
@Autowired @Autowired
Res_partnerServiceImpl partnerService; protected cn.ibizlab.businesscentral.core.odoo_ir.service.IIr_sequenceService sequenceService;
@Override @Override
protected Class currentModelClass() { protected Class currentModelClass() {
...@@ -82,63 +78,104 @@ public class Purchase_orderExService extends Purchase_orderServiceImpl { ...@@ -82,63 +78,104 @@ public class Purchase_orderExService extends Purchase_orderServiceImpl {
@Override @Override
@Transactional @Transactional
public Purchase_order button_confirm(Purchase_order et) { public Purchase_order button_confirm(Purchase_order et) {
// if(StringUtils.compare(et.getState(), "draft") == 0 || StringUtils.compare(et.getState(), "sent") == 0){ if(StringUtils.compare(et.getState(), "draft") == 0 || StringUtils.compare(et.getState(), "sent") == 0){
// // 链接_add_supplier_to_product() // 链接_add_supplier_to_product()
// List<Purchase_order_line> lines = purchaseOrderLineService.selectByOrderId(et.getId()); /**
// for(Purchase_order_line line : lines){ * 如果供应商未注册此产品,则将合作伙伴添加到该产品的供应商列表中。
// // 联系人partner * 我们限制一个产品的供应商数量为10家,以避免一些通用产品(“杂项”)可能造成的混乱。
// Res_partner partner = partnerService.get(et.getPartnerId()); */
// 获取该采购订单对应的采购订单行记录
List<Purchase_order_line> lines = purchaseOrderLineService.selectByOrderId(et.getId());
for(Purchase_order_line line : lines){
/**
* 将联系人partner或联系人的上级作为供应商
* 当联系人存在上级时,将联系人的上级作为供应商
* 当联系人不存在所属公司时,直接将联系人作为供应商
*/
Res_partner partner = resPartnerService.get(et.getPartnerId());
if(partner.getParentId() != null){
partner = resPartnerService.get(partner.getParentId());
}
// 获取Product_product的供应商
Product_product product = productService.getById(et.getProductId());
// if判断的条件2
Boolean condition2 = false;
// 根据产品供应商信息表product_supplierinfo查找当前的供应商是否已存在
String sellerIds = product.getSellerIds();
// //
// // 获取Product_product的供应商 // 判断是否将当前的供应商加入产品供应商信息表product_supplierinfo中
// Product_product product = productService.getById(et.getProductId()); if(line.getProductId() != null && condition2 && product.getSellerIds().length() <= 10){
// if(line.getProductId() != null && ("") &&product.getSellerIds().length() <= 10){ // 获取币种currency
// // 币种currency Res_currency toCurrency = new Res_currency();
// Res_currency toCurrency = new Res_currency(); if(partner.getPropertyPurchaseCurrencyId() !=null && et.getCurrencyId() != null){
// if(partner.getPropertyPurchaseCurrencyId() !=null && et.getCurrencyId() != null){ toCurrency = resCurrencyService.getById(partner.getPropertyPurchaseCurrencyId());
// toCurrency = resCurrencyService.getById(partner.getPropertyPurchaseCurrencyId()); }else if(partner.getPropertyPurchaseCurrencyId() !=null && et.getCurrencyId() == null){
// }else if(partner.getPropertyPurchaseCurrencyId() !=null && et.getCurrencyId() == null){ toCurrency = resCurrencyService.getById(partner.getPropertyPurchaseCurrencyId());
// toCurrency = resCurrencyService.getById(partner.getPropertyPurchaseCurrencyId()); }else if(partner.getPropertyPurchaseCurrencyId() ==null && et.getCurrencyId() != null){
// }else if(partner.getPropertyPurchaseCurrencyId() ==null && et.getCurrencyId() != null){ toCurrency = resCurrencyService.getById(partner.getPropertyPurchaseCurrencyId());
// toCurrency = resCurrencyService.getById(partner.getPropertyPurchaseCurrencyId()); }
// }
// // 价格price, 将价格转换成当前所用币种 // 将price转换成当前所用币种的price,还未处理,需要调用Res_currency 中的_convert()方法
// Double price = 0.0; Double price = line.getPriceUnit();
// if(et.getCurrencyId() == toCurrency.getId()){ // if(et.getCurrencyId() == toCurrency.getId()){
// price = line.getPriceUnit(); // price = line.getPriceUnit();
// }else{ // }else{
//// price = line.getPriceUnit() * //// price = line.getPriceUnit() *
// } // }
//
// // // 计算模板的UoM的价格,因为供应商的UoM与该UoM相关
// Product_template productTemplate = productTemplateService.get(product.getProductTmplId()); Product_template productTemplate = productTemplateService.get(product.getProductTmplId());
// if(productTemplate.getUomPoId() != line.getProductUom()){ if(productTemplate.getUomPoId() != line.getProductUom()){
// Long default_uom = productTemplate.getUomPoId(); Long default_uom = productTemplate.getUomPoId();
// // 计算price // 计算price, 暂未处理,需要调用uom_uom.py中的_compute_price()方法
// } // price =
// }
// // 创建供应商价格表记录
// Product_supplierinfo supplierinfo = new Product_supplierinfo(); // 创建供应商价格表记录
// supplierinfo.setName(partner.getId()); Product_supplierinfo supplierinfo = new Product_supplierinfo();
// supplierinfo.setSequence(); supplierinfo.setName(partner.getId());
// supplierinfo.setMinQty(0.0); // 设置序号sequence
// supplierinfo.setPrice(price); Integer sequence = 1;
// supplierinfo.setCurrencyId(toCurrency.getId()); if(product.getSellerIds() != null){
// supplierinfo.setDelay(0); // 拿到sellerIds对应的一系列sequence,取最大的序号+1
// sequence = 1;
// // 按条件查找供应商 }
// supplierinfo.setSequence(sequence);
// supplierinfo.setMinQty(0.0);
// } supplierinfo.setPrice(price);
// } supplierinfo.setCurrencyId(toCurrency.getId());
supplierinfo.setDelay(0);
/**
* 如果订单合作伙伴是一个联系地址,那么将在母公司上创建一个新的supplierinfo。
* 在本例中,我们保留产品名称和代码。
*/
// 按条件查找供应商
// 未处理,需要调用product.py中的_select_seller()方法
}
}
// log.warn("_add_supplier_to_product()"); // log.warn("_add_supplier_to_product()");
//// if(StringUtils.compare(, "one_step") == 0 || ){
//// // button_approve() Res_company resCompany = resCompanyService.get(et.getCompanyId());
//// log.warn("button_approve()"); // if判断三个条件
//// }else{ Boolean condition1 = StringUtils.compare(resCompany.getPoDoubleValidation(), "one_step") == 0;
//// et.setState("to approve"); // 暂未处理,这里需要需要调用Res_currency 中的_convert()方法
//// } Boolean condition2 = false;
// } // Boolean condition2 = StringUtils.compare(resCompany.getPoDoubleValidation(), "two_step")==0 && et.getAmountTotal() < ;
// this.update(et); // 这里需要调用odoo/models.py中的user_has_groups()方法,暂未处理
Boolean condition3 = false;
// 处理双重验证过程
if( condition1 || condition2 || condition3){
// 调用button_approve()
log.warn("button_approve()");
}else{
et.setState("to approve");
}
}
this.update(et);
return super.button_confirm(et); return super.button_confirm(et);
} }
/** /**
...@@ -175,14 +212,16 @@ public class Purchase_orderExService extends Purchase_orderServiceImpl { ...@@ -175,14 +212,16 @@ public class Purchase_orderExService extends Purchase_orderServiceImpl {
@Override @Override
@Transactional @Transactional
public Purchase_order get_name(Purchase_order et) { public Purchase_order get_name(Purchase_order et) {
//
// String name = et.getName(); // 当订单的name是new时自动为其创建一个name
// if(et.getPartnerRef() != null){ if(StringUtils.compare(et.getName(), "new") == 0){
// name += " (" + et.getPartnerRef() + ")"; if(et.getDateOrder() != null){
// } // sequence_date
// if( && et.getAmountTotal() != null){ Ir_sequence sequence = new Ir_sequence();
// name += ": " + sequenceService.get_next_by_code(sequence);
// } et.setName(sequence.getNextChar());
}
}
return super.get_name(et); return super.get_name(et);
} }
} }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册