我想在销售订单(报价/销售订单)中的销售订单行中添加计算字段"标记".
我创建了模型:
class SaleOrderLine(models.Model):
_inherit = "sale.order.line"
markup = fields.Float(compute='_compute_markup', digits=dp.get_precision('.2f%'), store=True)
def _compute_markup(self, order_id, product_id, product_uom_id):
frm_cur = self.env.user.company_id.currency_id
to_cur = order_id.pricelist_id.currency_id
purchase_price = product_id.standard_price
if product_uom_id != product_id.uom_id:
purchase_price = product_id.uom_id._compute_price(purchase_price, product_uom_id)
ctx = self.env.context.copy()
ctx['date'] = order_id.date_order
price = frm_cur.with_context(ctx).compute(purchase_price, to_cur, round=False)
return price
Run Code Online (Sandbox Code Playgroud)
以及继承sale.view_order_form的新视图:
<?xml version="1.0"?>
<odoo>
<record id="view_order_form_margin" model="ir.ui.view">
<field name="name">sale.order.form.margin</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr='//field[@name="order_line"]/form/group/group/field[@name="price_unit"]' position="before">
<field name="markup"/>
</xpath>
</field>
</record>
</odoo>
Run Code Online (Sandbox Code Playgroud)
但是未显示该字段(当您检查继承当前视图的视图时,将显示该视图).我重新加载了所有内容,重新启动了服务器并清除了浏览器缓存.
欢迎任何有关该领域未被展示的提示.也许Xpath表达?谢谢.
根据此报告定义,如何更改PDF中使用的文件名,以便使用"SO-001.pdf"等名称.
<report
id = "report_custom_sale_order"
string = "Quotation / Order"
model = "sale.order"
report_type = "qweb-pdf"
file = "custom_saleorder.report_saleorder"
name = "custom_saleorder.report_saleorder"
paperformat = "custom_saleorder.paperformat_a4"
/>
Run Code Online (Sandbox Code Playgroud)
Odoo 10.
谢谢
我在Odoo 10中创建了一个新模型.该模型通过菜单项访问,该菜单项启动树视图.
树视图是可编辑的,但我希望能够启动用户想要编辑的特定记录用户正在编辑的表单视图.
是否有任何选项可以在树视图中放置一个按钮来启动表单视图?有人可以突出显示所需的步骤或指向类似的代码示例吗?
谢谢,
我想了解我应该放置什么,而不是xxxxx使用a从from 2000到的结构初始化一个1000个项的数组3000(即,数组均值的索引1为,数组均值a的2000索引2 a为2001,依此类推),b并且始终是零。
struct MyStruct
a
b
end
myArray = Vector{MyStruct}( xxxxx , 1000)
Run Code Online (Sandbox Code Playgroud)
我知道我可以进行循环并单独分配值,我只是想知道Julia中是否有更快的方法。
我有一个字节数组,其中包含用值 0 填充的文本,最多填充 16 个字节。
当我尝试将它转换为字符串时,我无法获得正确的长度/字符串,它总是检索整个 16 个字符。
我试过了:
import java.nio.charset.StandardCharsets;
public class HelloWorld{
public static void main(String []args){
// SIMULATED BYTE[] CONTAINS "ABC" PLUS CHAR(0) UNTIL FILL 16 BYTES
byte[] name = new byte[16];
for(int i=0; i<16; i++) {
name[i] = 0;
}
name[0] = 'A';
name[1] = 'B';
name[2] = 'C';
// DESIRED OUTPUT IS A STRING = "ABC".
// I.E. REMOVAL OF PADDING WITH CHAR(0)s
String nameStr = new String(name, StandardCharsets.US_ASCII);
System.out.println("#"+nameStr+"#");
System.out.println(nameStr.length());
}
}
Run Code Online (Sandbox Code Playgroud)
这是输出:
所需的检索长度是 …
我有以下几行:
XYZ2342
ABCD1323
KIL9824
Run Code Online (Sandbox Code Playgroud)
我想删除开头的所有字母,所以我会得到上面的例子:
2342
1323
9824
Run Code Online (Sandbox Code Playgroud)
我试过这个:
echo "ABC12345" | sed 's/[[:alpha:]]*[[:digit:]]//'
2345
Run Code Online (Sandbox Code Playgroud)
但它也删除了第一个数字,我怎样才能让 sed 只删除字母(注意:它们总是 ASCII)。
我正在使用 FreeBSD sed 实现,以防万一。
我想在Odoo 10中的Settings-> Technical菜单中添加一个子菜单.我尝试使用以下代码,显然已加载菜单项(您可以看到它是自定义模块创建的菜单之一)但它是没有显示.
对于为什么有任何提示/建议?
<?xml version="1.0"?>
<odoo>
<menuitem id="sale_order_custom_document"
name="Sale Order Custom Documen"
parent="base.menu_custom"
/>
</odoo>
Run Code Online (Sandbox Code Playgroud)
谢谢
如果我想指定我的函数返回一个布尔值,我会这样做:
function myfunc(a,b)::Bool
Run Code Online (Sandbox Code Playgroud)
如果我想指定返回4个Int32元素的向量怎么办?
a = Vector{Int32}(undef, 4)
Run Code Online (Sandbox Code Playgroud) 我的“ main.jl”文件中包含以下包含/导入项:
include("Global.jl")
import .Global
Run Code Online (Sandbox Code Playgroud)
由于导入此模块需要花费一些时间,并且每次执行时始终相同,因此我想提前测试是否存在.Global,以便可以绕过包含/导入。
我的想法是,我可以在文本编辑器中编辑所有更改,并使用交互式控制台重新加载整个程序,但是如果该步骤已经存在,则放弃该步骤。