继承时如果使用了不同的名称能否使用视图继承
-
我有一个需求是这样的。一个朋友为一家连锁店装了很多摄像头,这些设备经常出问题,所以会有很多报修之类的东西处理,修好后也有一堆费用需要处理。因为各种不同的费用在填写的时候有许多字段都是一样的,我就想用继承了来实现,代码如下:
<br />class FeeBase(osv.osv):<br /> """<br /> 费用基本类型,作为维护费用来使用<br /> """<br /> _name="tms.feebase"<br /><br /> _columns={<br /> "processid":fields.char(string="ProcessId",size=100,required=False), <br /> "feedate":fields.date(string="Fee Date"),<br /> "store_id":fields.many2one("tms.store",string="Store"),<br /> "storenum":fields.related("store_id","name",type="char",string="Store Num"),<br /> "province":fields.function(get_province_name,type="char",string="Province"),<br /> "feetype_id":fields.many2one("tms.feetype","Fee Type"),<br /> "payman":fields.many2one("res.users","Pay Man"),<br /> "amount":fields.float(string="Amount"),<br /> "accountamount":fields.float(string="Account Amount"),<br /> "accountperiod":fields.char(string="Account Period", size=20,required=False),<br /> "oanum":fields.char(string="OA Num",size=100),<br /> "remark":fields.text(string="Remark"),<br /> "state":fields.selection([("draft","Draft"),("hasexported","Has Exported"),("hasoa","Has Input OANum"),("hasback","Has Back")],<br /> string="States"),<br /> }<br />
```
class FeeForSend(osv.osv):
_inherit="tms.feebase"
_name = "tms.feeforsend"
_columns={
"sendcompany":fields.many2one("tms.sendcompany","Send Company"),
"sendordernum":fields.char(string="Send Order num",size=100,required=True),
"sendproduct":fields.char(string="Send Product", size=200,required=True),
}
```
```
class FeeForProductIt(osv.osv):
_inherit="tms.feebase"
_name = "tms.feeforproductit"
_columns={
"productname":fields.char(string="Product Name",size=200),
"productprice":fields.float(string="Product Price"),
"productcount":fields.integer(string="Product Count"),
"accountproductprice":fields.integer(string="Account Product Price"),
"accountproductcount":fields.integer(string="Account Product Count")
}
FeeForProductIt()
class FeeForItService(osv.osv):
_inherit="tms.feebase"
_name = "tms.feeforitservice"
FeeForItService()
```
```
<record model="ir.ui.view" id="view_tms_feebase_tree">
<field name="name">tms.feebase.tree</field>
<field name="model">tms.feebase</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="维护费登记">
<field name="processid"/>
<field name="store_id" />
<field name="province"/>
<field name="storenum"/>
<field name="accountperiod"/>
<field name="feetype_id"/>
<field name="feedate"/>
<field name="payman"/>
<field name="amount" sum="Account" />
<field name="accountamount" sum="Account Amount"/>
<field name="state"/>
<field name="oanum"/>
</tree>
</field>
</record>
```
从代码中可以看出每个子类与父类相差很小,在视图中只需要多添加几个字段或者完全不用添加。但当我使用视图的继承的机制时发现如果对象在继承时_name与父类不一样,视图是不能继承的。
有没有什么办法可以让我能够共用父类的视图?