简体   繁体   English

如何在视图中显示两个字段,这两个字段在openERP中属于同一列

[英]How to show two fields in view which is of same column in class in openERP

In openERP purchase module I'm having two fields for Purchase Order Amendment which are of 'ordered quantity-old' and 'ordered quantity-new' those retrieving data from same column. 在openERP采购模块中,我有两个字段用于“采购订单修订”,分别是“从旧订购数量”和“新订购数量”的字段,它们从同一列中检索数据。 Now I want to show 现在我想展示

1. One field for 'ordered quantity- old' which should show current purchase order's 'ordered quantity' actual value from table and it should be a read only field, 1. “旧订购数量”字段应显示表中当前采购订单的“订购数量”实际值,并且应为只读字段,

2. another field for 'ordered quantity- new' which should not show any value(should be 0) and once the new changed quantity is given it should update the column in the table 2. “订购的数量-新的”另一个字段不应显示任何值(应为0),并且一旦给出了新的更改数量,则应更新表中的列

How to do this? 这个怎么做?

Thanks in advance 提前致谢

Well, your idea is to gave 2 fields but actually have 1 field, which can't be done. 好吧,您的想法是给2个字段,但实际上只有1个字段,这是无法完成的。 So simply create new field for ordered quantity - new and let it be read-only . 因此,只需为订购数量创建新字段 -new并将其设置为只读即可 And when new quantity is given simply update that field . 当给出新的数量时,只需更新该字段即可 If you still find that undesirable, set second field to be invisible, and use it as helper field. 如果仍然发现不希望出现的情况,请将第二个字段设置为不可见,并将其用作辅助字段。 Only you will now its there, store value in it and when confirming to new field simply take/store old value in it for history purposes. 现在只有您将在那里存储它的值,并且在确认新字段时只需出于历史目的将旧值存储在其中。

In view then you will have old and new, you will have splited logic which is good and user will have easier time to understand. 鉴于您将拥有新的和旧的,您将拥有分裂的逻辑,这很好,并且用户将更容易理解。

Third option is related field if you have connection to different table. 如果您已连接到其他表,则第三个选项是相关字段。

'model':fields.related('model_id','model',type="char", size=64, string="Model name")

First parameter is field in current table to which this is referenced, second if field that will be pulled from referenced table, rest is known :) 第一个参数是当前表中要对其进行引用的字段,第二个参数是要从引用表中拉出的字段,其余参数是已知的:)

Best regards 最好的祝福

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM