编辑:问题已在.NET 4.0中修复.
我一直在尝试使用IsChecked按钮将一组单选按钮绑定到视图模型.在审查其他帖子后,该IsChecked属性似乎根本不起作用.我已经整理了一个简短的演示,可以重现这个问题,我在下面列出了这个问题.
这是我的问题:使用MVVM绑定单选按钮是否有直接可靠的方法?谢谢.
附加信息:该IsChecked物业不起作用有两个原因:
选择按钮后,组中其他按钮的IsChecked属性不会设置为false.
选择按钮后,第一次选择按钮后,其自身的IsChecked属性不会被设置.我猜测绑定在第一次点击时被WPF破坏了.
演示项目:以下是重现问题的简单演示的代码和标记.创建一个WPF项目并使用以下内容替换Window1.xaml中的标记:
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300" Loaded="Window_Loaded">
<StackPanel>
<RadioButton Content="Button A" IsChecked="{Binding Path=ButtonAIsChecked, Mode=TwoWay}" />
<RadioButton Content="Button B" IsChecked="{Binding Path=ButtonBIsChecked, Mode=TwoWay}" />
</StackPanel>
</Window>
Run Code Online (Sandbox Code Playgroud)
使用以下代码(hack)替换Window1.xaml.cs中的代码,该代码设置视图模型:
using System.Windows;
namespace WpfApplication1
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
this.DataContext = …Run Code Online (Sandbox Code Playgroud) 以下是初始化静态只读字段的两种不同方法.两种方法之间有区别吗?如果是的话,什么时候应该优先于另一个呢?
class A
{
private static readonly string connectionString =
WebConfigurationManager.ConnectionStrings["SomeConnection"].ConnectionString;
}
class B
{
private static readonly string connectionString;
static B()
{
connectionString =
WebConfigurationManager.ConnectionStrings["SomeConnection"].ConnectionString;
}
}
Run Code Online (Sandbox Code Playgroud) 我在一个项目中看到了一段代码,其中写了以下内容:
move = Move.create({
'name': repair.name,
'product_id': repair.product_id.id,
'product_uom': repair.product_uom.id or repair.product_id.uom_id.id,
'product_uom_qty': repair.product_qty,
'partner_id': repair.address_id.id,
'location_id': repair.location_id.id,
'location_dest_id': repair.location_dest_id.id,
'restrict_lot_id': repair.lot_id.id,
})
moves |= move
moves.action_done()
Run Code Online (Sandbox Code Playgroud)
这里的含义是什么意思?
隐藏字段的最佳解决方案是什么?partner_id in
<xpath expr=".">
<field name="partner_id" />
</xpath>
Run Code Online (Sandbox Code Playgroud)
我正在 Odoo 13 上生成 .docx 文档,我检查了“report_py3o”模块,但没有适用于 Odoo 13 的版本,所以我决定进行某种迁移(我刚刚删除了“@api.multi”) Odoo 12 版本到 Odoo 13。我收到了类似odoo.exceptions.CacheMiss: ('ir.actions.report(85,).is_py3o_report_not_available', None) 的错误,我的数据库已损坏。这是完整的日志:错误日志。
odoo.exceptions.CacheMiss: ('ir.actions.report(85,).is_py3o_report_not_available', None)
Run Code Online (Sandbox Code Playgroud)
我还检查了航空模块,但它仅适用于 8.0 和 9.0。
你能帮助我吗?你有替代品吗?
这是我收到的错误消息。
ValueError: Invalid field 'view_type' on model 'ir.actions.act_window'
odoo.tools.convert.ParseError: while parsing file:/c:/users/shaileshbhai/pycharmprojects/odoodev/extra_addons/demo_hospital/view/patient.xml:15, near
<record id="patient_action_new" model="ir.actions.act_window">
<field name="name">patient name</field>
<field name="res_model">hospital.patient</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
</record>
Run Code Online (Sandbox Code Playgroud) 例如,'reonp' 是一个很好地添加到模型中的,但是当我尝试添加一个 'gradjanin' 时,Odoo 10 引发了一个错误

我试图重新启动服务器
py
class komPartnerrReon(models.Model):
_inherit = 'res.partner'
reonp = fields.Many2one('kom.reon')
gradjanin = fields.Boolean('Gradjanin', default=False) #There was an error after adding this line of code
Run Code Online (Sandbox Code Playgroud)
错误
File "C:\odoo-10.0\odoo\sql_db.py", line 231, in execute
res = self._obj.execute(query, params)
ProgrammingError: column res_partner.gradjanin does not exist
LINE 1: ...id" as "parent_id","res_partner"."name" as "name","res_partn...
Run Code Online (Sandbox Code Playgroud) 我在下面创建了几家公司 res.company
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="True">
<record id="partner_my_company_hk" model="res.partner" context="{'default_is_company': True}">
<field name="name">My company HK</field>
<field name="company_id" eval="None"/>
<field name="customer" eval="False"/>
<field name="is_company" eval="True"/>
<field name="street"></field>
<field name="city"></field>
<field name="zip"></field>
<field name="phone"></field>
<field name="email">info@my_company.com</field>
<field name="website">www.my_company.com</field>
<field name="image" type="base64" file="base/static/img/res_company_logo.png"/>
</record>
<record id="partner_my_company_us" model="res.partner">
<field name="name">My company US</field>
<field name="company_id" eval="None"/>
<field name="customer" eval="False"/>
<field name="is_company" eval="True"/>
<field name="street"></field>
<field name="city"></field>
<field name="zip"></field>
<field name="phone"></field>
<field name="email">info@my_company.com</field>
<field name="website">www.my_company.com</field>
<field name="image" type="base64" file="base/static/img/res_company_logo.png"/>
</record>
<record id="company_my_company_hk" model="res.company">
<field …Run Code Online (Sandbox Code Playgroud) odoo ×4
c# ×2
odoo-9 ×2
openerp ×2
python ×2
binding ×1
c#-2.0 ×1
c#-3.0 ×1
inheritance ×1
initializer ×1
module ×1
mvvm ×1
odoo-10 ×1
odoo-13 ×1
odoo-14 ×1
odoo-8 ×1
python-2.7 ×1
python-3.x ×1
radio-button ×1
wpf ×1
xml ×1