我的问题的最终版本是这个错误:
except_orm :('查看错误',u"无法在以下视图中查找字段' purchase_order_id'组成对象模型的视图' fleet.vehicle':\ n *继承的车队车辆表格\ n \ n您错误地自定义了此视图,或者某些带来这些视图的模块与您当前的数据模型不兼容")
我遇到安装模块到openERP v7.0的问题
重置此错误:
编程错误' purchase.order.fleet_vehicle'
找不到参考字段' purchase_order_id'更新:修正此错误,当我将_colums更正为_columns(第5行)
时现在我有新的错误验证字段拱时发生了ValidateErrorError:View Architecture的XML无效!
update2:在调试模式下从服务器添加日志
非常感谢任何建议
transport_purchase.py
from openerp.osv import fields, osv
from openerp.tools.translate import _
class purchase_order_fleet_vehicle(osv.osv):
_name = 'purchase.order.fleet_vehicle'
_columns = {
'purchase_order_id':fields.many2one(obj='purchase.order', string='Purchase Order',
ondelete='cascade'),
'purchase_date':fields.date(string='Purchase Date'),
'partner_departure_id': fields.many2one(obj='res.partner', string='From'),
'partner_destination_id': fields.many2one(obj='res.partner', string='To'),
'delivery_date': fields.date(string='Delivery Date',
help='The date that will start to transport'),
'return_date': fields.date(string='Return Date',
help='The expected date to finish all the transport'),
'fleet_vehicle_id': fields.many2one(obj='fleet.vehicle', string='Vehicle', required=True,
ondelete='restrict'),
'license_plate': fields.char('License Plate', size=64, required=False, store=True),
'internal_number': fields.integer('Number'),
'employee_driver_id':fields.many2one(obj='hr.employee', string='Driver', required=True,
ondelete='restrict'),
'employee_helper_id':fields.many2one(obj='hr.employee', string='helper', required=False,
ondelete='restrict'),
'fleet_trailer_id': fields.many2one(obj='fleet.vehicle', string='Trailer',
ondelete='restrict', required=True),
'trailer_license_plate': fields.char(string='Trailer License Plate', size=64, required=False, store=True),
'cargo_ids':fields.one2many(obj='purchase.order.cargo', fields_id='purchase_order_fleet_id',
string='Cargo', required=True,
help=_('All purchase transported cargo')),
}
def fleet_trailer_id_change(self, cr, uid, ids,fleet_trailer_id):
result={}
if not fleet_trailer_id:
return {'value':result}
trailer = self.pool.get('fleet.vehicle').browse(cr,uid,fleet_trailer_id)
if trailer:
result['trailer_license_plate'] = trailer.license_plate
return {'value':result}
def fleet_vehicle_id_change(self, cr, uid, ids,fleet_vehicle_id,context):
result={}
if not fleet_vehicle_id:
return {'value':result}
vehicle = self.pool.get('fleet.vehicle').browse(cr,uid,fleet_vehicle_id)
purchase_order = self.pool.get('purchase.order').browse(cr,uid,context.get('purchase_order_id'))
if vehicle:
result['license_plate'] = vehicle.license_plate
result['employee_driver_id'] = vehicle.emp_driver_id.id
result['internal_number']=vehicle.internal_number
qprint purchase_order
` #if purchase_order:
#print "purchase_date=" + purchase_order.date_order
#result['purchase_date'] = purchase_order.date_order
#print "purchase departure id=" + purchase_order.partner_departure_id.id
#result['partner_departure_id'] = purchase_order.partner_departure_id.id
#print "purchase shipping id=" + purchase_order.partner_shipping_id.id
#result['partner_destination_id'] = purchase_order.partner_shipping_id.id
#print "deli date=" + purchase_order.delivery_date
#result['delivery_date'] = purchase_order.delivery_date
#print "deli date=" + purchase_order.return_dae
#result['return_date'] = purchase_order.return_date
#return {'value':result}
def copy(self, cr, uid, _id, default=None, context=None):
if not default:
default = {}
#default.update({
#'state': 'draft',
#})
return super(purchase_order_fleet_vehicle, self).copy(cr, uid, _id, default, context=context)
#_sql_constraints = [('vehicle_uniq', 'unique(fleet_vehicle_id,purchase_order_id)',
#'Vehicle must be unique per purchase order! Remove the duplicate vehicle'),
#('employee_unique','unique(employee_driver_id,purchase_order_id)',
#'A driver must be unique per purchase order! Remove the duplicate driver'),]
purchase_order_fleet_vehicle()
class purchase_order_cargo(osv.osv):
_name = 'purchase.order.cargo'
_columns = {
'purchase_order_fleet_id':fields.many2one( obj='purchase.order.fleet_vehicle',string='Purchase Order Vehicle', ondelete='cascade', required=True,readonly=True),
'transport_date': fields.date(string='Transport Date', required=True,
help=_('The day when the product was transported.')),
'cargo_product_id':fields.many2one(obj='product.product', string='Cargo', required=True),
'cargo_docport':fields.char(string='Port Document', size=64, required=False, readonly=False,
help=_('Associated port document of the transported product if applicable.')),
'brand':fields.char('Brand', size=64, required=False, readonly=False,
help=_('Brand of the transported product if applicable.')),
'model':fields.char('Model', size=64, required=False, readonly=False,
help=_('Model of the transported product if applicable.')),
'cargo_ident':fields.char('Identification', size=64, required=False, readonly=False,
help=_('Identification of the cargo.Ex:Id,License Plate,Chassi')),
'purchase_order_id':fields.many2one(obj='purchase.order', string='Purchase Order', required=True),
'transport_from_id': fields.many2one(obj='res.partner', string='From'),
'transport_to_id': fields.many2one(obj='res.partner', string='To'),
}
def cargo_id_change(self,cr,uid,ids,cargo_product_id,context):
result={}
if not cargo_product_id:
return {'value':result}
purchase_order = self.pool.get('purchase.order').browse(cr,uid,context.get('purchase_order_id'))
if purchase_order:
result['purchase_order_id'] = context.get('purchase_order_id')
#if [ product purchase_order_fleet_idfor product in purchase_order.order_line if cargo_product_id == product.product_id]:
return {'value':result}
def copy(self, cr, uid, _id, default=None, context=None):
if not default:
default = {}
#default.update({
#})
res_id = super(purchase_order_cargo, self).copy(cr, uid, _id, default, context)
return res_id
class purchase_order(osv.osv):
_inherit = 'purchase.order'
_columns = {
'fleet_vehicles_ids':fields.one2many(obj=
'purchase.order.fleet_vehicle', fields_id='purchase_order_id',string='Transport Vehicles',required=True),
'partner_departure_id':fields.many2one('res.partner', string='From', required=True),
'delivery_date': fields.date('Transport Start',required=True,
help=_('Expected Transport start date.')),
'return_date':fields.date('Transport Finish',required=True,
help=_('Expected Transport finish date.')),
'cargo_ids':fields.one2many(obj='purchase.order.cargo', fields_id='purchase_order_id',
string='Cargo Manifest', required=False,
help=_('All transported cargo manifest.')),
}
def _validate_data(self, cr, uid, ids):
for dates in self.browse(cr,uid,ids):
if dates.return_date < dates.delivery_date:
return False
else:
return True
#def _validate_cargo_products(self,cr,uid,ids):
#result = True
#cargo_products_ids = []
#purchase_order = self.browse(cr,uid,ids[0])
#if purchase_order:
# cargo_products_ids = [cargo.cargo_product_id.id for cargo in purchase_order.cargo_ids]
#if not cargo_products_ids:
#result = True
#else:
#line_products_ids = [line.product_id.id for line in purchase_order.order_line]
#result = set(cargo_products_ids) == set(line_products_ids)
#return result
def _validate_cargo_products_qty(self,cr,uid,ids):
result = True
msg_format=""
line_product_ids = []
line_product_qts = []
purchase_order = self.browse(cr,uid,ids[0])
if purchase_order:
cargo_product_ids = [cargo.cargo_product_id.id for cargo in purchase_order.cargo_ids]
#give all products for order line
line_product_ids = [line.product_id.id for line in purchase_order.order_line]
line_product_qts = [line.product_uom_qty for line in purchase_order.order_line]
line_product_ids_qts = {}
line_product_dif_ids = {}
for idx,prod_id in enumerate(line_product_ids):
if prod_id in line_product_ids_qts.keys():
line_product_ids_qts[prod_id]+= line_product_qts[idx]
else:
line_product_ids_qts[prod_id] = line_product_qts[idx]
if not cargo_product_ids:
result = True
else:
for cargo_product_id in set(cargo_product_ids):
line_product_ids_dict = { prod_id:qtd for prod_id,qtd in line_product_ids_qts.iteritems()
if prod_id == cargo_product_id
and int(line_product_ids_qts[prod_id]) != cargo_product_ids.count(cargo_product_id)}
line_product_dif_ids.update(line_product_ids_dict)
if len(line_product_dif_ids) > 0:
line_product_names = self.pool.get('product.product').name_get(cr,uid,line_product_dif_ids.keys(),context=None)
cargo_product_qts = [ cargo_product_ids.count(cargo_product_id) for cargo_product_id in line_product_dif_ids.keys()]
for product_name in line_product_names:
index= line_product_names.index(product_name)
msg_format = _("""Product:%s\n\tOrder=%s vs Cargo=%s\n""") % (product_name[1],
int(line_product_dif_ids[product_name[0]]),
cargo_product_qts[index])
message = _("""The following products quantities in cargo don't match\n quantities in purchase order line:\n%s
""") % (msg_format)
raise osv.except_osv(_('Error'), message)
result = False
else:
result = True
return result
#_constraints = [(_validate_data,'Error: Invalid return date', ['delivery_date','return_date']),
# (_validate_cargo_products,"Error: There is a cargo product that doesn't belongs to the purchase order line!",['cargo_ids','order_line']),
# (_validate_cargo_products_qty,"Error: In products quantities",['cargo_ids','order_line'])]
#
purchase_order()
class fleet_vehicle(osv.osv):
_inherit = 'fleet.vehicle'
_columns = {
'purchases_order_ids':fields.one2many(obj='purchase.order.fleet_vehicle',
fields_id='fleet_vehicle_id', string='Vehicle purchases'),
'internal_number': fields.integer(string='Internal Number'),
'is_trailer':fields.boolean(string='Is Trailer',required=False),
}
fleet_vehicle()
class hr_employee_driver_purchases(osv.osv):
_inherit = 'hr.employee'
_columns = {
'purchases_order_ids':fields.one2many(obj='purchase.order.fleet_vehicle',
fields_id='employee_driver_id', string='Driver purchases'),
'is_driver':fields.boolean('Is Driver', required=False),
}
hr_employee_driver_purchases()
transport_purchase.xml
<?xml version="1.0"?>
<openerp>
<data>
<!-- Purchase Order Fleet Vehicle View -->
<record model="ir.ui.view" id="purchase_order_fleet_vehicle_form_view">
<field name="name">Purchase Order Fleet Vehicle Form View</field>
<field name="model">purchase.order.fleet_vehicle</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Transport" version="7.0">
<group colspan="4" col="4">
<group colspan="2" string="Vehicle">
<field name="fleet_vehicle_id" required="1" domain="[('is_trailer','=',0)]" on_change="fleet_vehicle_id_change(fleet_vehicle_id,context)" />
<field name="internal_number" />
<field name="license_plate" />
</group>
<group colspan="2" string="Driver">
<field name="employee_driver_id" domain="[('is_driver','=', 1)]" required="1" />
<field name="employee_helper_id" required="0" />
</group>
<group colspan="2" string="Trailer">
<field name="fleet_trailer_id" domain="[('is_trailer','=',1)]"
on_change="fleet_trailer_id_change(fleet_trailer_id)" />
<field name="trailer_license_plate" />
</group>
<group colspan="2" string="Client Transport" >
<field name="partner_departure_id" />
<field name="partner_destination_id" />
</group>
<group colspan="6" col="6" string="Purchase and Transport Dates">
<field name="purchase_date"/>
<field name="delivery_date" />
<field name="return_date" />
</group>
</group>
<group col="4" string="Manifest">
<field name="cargo_ids" required="1" nolabel="1"
context="{'purchase_order_id':purchase_order_id}">
<tree editable="bottom">
<field name="purchase_order_id" invisible="1"/>
<field name="cargo_product_id" domain="[('type','=','service')]" on_change="cargo_id_change(cargo_product_id,context)"/>
<field name="cargo_ident"/>
<field name="cargo_docport"/>
<field name="brand"/>
<field name="model"/>
<field name="transport_from_id"/>
<field name="transport_to_id"/>
<field name="transport_date"/>
</tree>
</field>
</group>
</form>
</field>
</record>
<!--Purchase order Vehicle form -->
<record model="ir.ui.view" id="inherited_purchase_order_form_view">
<field name="name">Inherited purchase Order Form View</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_invoice_id']" position="after">
<field name="partner_departure_id" string="From"
context="{'search_default_customer':1, 'show_address': 1}"
required="1" attrs="{'readonly': [('state','in',['done','cancel'])]}" />
</xpath>
<xpath expr="//field[@name='partner_ref']" position="replace">
<field name="partner_ref" string="To"
context="{'search_default_customer':1, 'show_address': 1}"
required="1" attrs="{'readonly': [('state','in',['done','cancel'])]}" />
</xpath>
<xpath expr="//field[@name='client_order_ref']" position="after">
<field name="delivery_date"
attrs="{'readonly': [('state','in',['done','cancel'])]}" />
<field name="return_date"
attrs="{'readonly': [('state','in',['done','cancel'])]}" />
</xpath>
<xpath expr="/form/sheet/notebook/page[@string='Purchase Order']"
position="after">
<page string="Transport Information">
<field name="fleet_vehicles_ids"
context="{'purchase_order_id':active_id,
'search_default_customer':1,
'show_address': 1,}"
attrs="{'required':[('state','in',['progress','manual','done'])]}">
<tree>
<field name="fleet_vehicle_id"/>
<field name="internal_number" />
<field name="license_plate" />
<field name="employee_driver_id" />
<field name="employee_helper_id" />
<field name="fleet_trailer_id"/>
<field name="trailer_license_plate" />
<field name="purchase_order_id" invisible="1" />
<field name="purchase_date" invisible="1" />
<field name="partner_departure_id" invisible="1" />
<field name="partner_destination_id" invisible="1" />
<field name="delivery_date" invisible="1" />
<field name="return_date" invisible="1" />
</tree>
</field>
</page>
</xpath>
<xpath expr="/form/sheet/notebook/page[@string='Transport Information']"
position="after">
<page string="Manifest">
<field name="cargo_ids" readonly="1">
<tree nolabel="1" >
<field name="cargo_product_id"/>
<field name="cargo_ident"/>
<field name="cargo_docport"/>
<field name="brand"/>
<field name="model"/>
<field name="transport_from_id"/>
<field name="transport_to_id"/>
<field name="transport_date"/>
</tree>
</field>
</page>
</xpath>
</field>
</record>
<!-- Fleet vehicle purchase form -->
<record model="ir.ui.view" id="inherited_fleet_vehicle_form_view">
<field name="name">Inherited Fleet Vehicle Form</field>
<field name="model">fleet.vehicle</field>
<field name="inherit_id" ref="fleet.fleet_vehicle_form" />
<field name="arch" type="xml">
<xpath expr="//label[@for='tag_ids']" position="before">
<label for="internal_number" class="oe_edit_only"/>
<h2>
<field name="internal_number" class="oe_inline" />
</h2>
<label for="is_trailer" class="oe_edit_only"/>
<field name="is_trailer" string="Is Trailer"
help="Mark this if the vehicle is a trailer"/>
</xpath>
<xpath expr="/form/sheet/notebook/page[@string='General Properties']"
position="after">
<page string="Transport purchase">
<field name="purchase_order_ids" readonly="1">
<tree editable="bottom">
<field name="purchase_order_id" />
<field name="purchase_date" />
<field name="partner_departure_id" />
<field name="partner_destination_id" />
<field name="delivery_date" />
<field name="return_date" />
</tree>
</field>
</page>
</xpath>
</field>
</record>
<record model="ir.ui.view" id="inherited_employee_form_view">
<field name="name">Inherited Employee Form View</field>
<field name="model">hr.employee</field>
<field name="inherit_id" ref="hr.view_employee_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='coach_id']"
position="after">
<field name="is_driver"/>
</xpath>
<xpath expr="/form/sheet/notebook/page[@string='Personal Information']"
position="after">
<page string="Transport Purchases">
<field name="purchase_order_ids" readonly="1">
<tree editable="bottom">
<field name="purchase_order_id" />
<field name="purchase_date" />
<field name="partner_departure_id" />
<field name="partner_destination_id" />
<field name="delivery_date" />
<field name="return_date" />
</tree>
</field>
</page>
</xpath>
</field>
</record>
<report id="purchase_order_transport_order" model="purchase.order"
name="purchase.order.transport_order" rml="purchase_order_fleet_vehicle/report/transport_purchase.rml"
string="Transport Order" />
<report id="purchase_order_transport_manifest" model="purchase.order"
name="purchase.order.transport_manifest" rml="purchase_order_fleet_vehicle/report/transport_manifest.rml"
string="Transport Manifest" />
</data>
</openerp>
openerp-server.log
Traceback (most recent call last)
File "C:\OpenERP\server\.\openerp\netsvc.py", line 296, in dispatch_rpc
File "C:\OpenERP\server\.\openerp\service\web_services.py", line 632, in dispatch
File "C:\OpenERP\server\.\openerp\osv\osv.py", line 190, in execute_kw
File "C:\OpenERP\server\.\openerp\osv\osv.py", line 132, in wrapper
File "C:\OpenERP\server\.\openerp\osv\osv.py", line 199, in execute
File "C:\OpenERP\server\.\openerp\osv\osv.py", line 187, in execute_cr
File "C:\OpenERP\server\openerp\addons\base\module\module.py", line 426, in button_immediate_install
File "C:\OpenERP\server\openerp\addons\base\module\module.py", line 473, in _button_immediate_function
File "C:\OpenERP\server\.\openerp\pooler.py", line 39, in restart_pool
File "C:\OpenERP\server\.\openerp\modules\registry.py", line 233, in new
File "C:\OpenERP\server\.\openerp\modules\loading.py", line 355, in load_modules
File "C:\OpenERP\server\.\openerp\modules\loading.py", line 256, in load_marked_modules
File "C:\OpenERP\server\.\openerp\modules\loading.py", line 188, in load_module_graph
File "C:\OpenERP\server\.\openerp\modules\loading.py", line 76, in <lambda>
File "C:\OpenERP\server\.\openerp\modules\loading.py", line 124, in _load_data
File "C:\OpenERP\server\.\openerp\tools\convert.py", line 959, in convert_xml_import
File "C:\OpenERP\server\.\openerp\tools\convert.py", line 852, in parse
File "C:\OpenERP\server\.\openerp\tools\convert.py", line 819, in _tag_record
File "C:\OpenERP\server\openerp\addons\base\ir\ir_model.py", line 983, in _update
File "C:\OpenERP\server\openerp\addons\base\ir\ir_ui_view.py", line 103, in create
File "C:\OpenERP\server\.\openerp\osv\orm.py", line 4596, in create
File "C:\OpenERP\server\.\openerp\osv\orm.py", line 1577, in _validate
except_osv: ('ValidateError', u'Error occurred while validating the field(s) arch: Invalid XML for View Architecture!')
openerp-server.exe --debug
Either you wrongly customized this view, or some modules bringing those views are not compatible with your current data model
2015-04-30 13:58:38,076 5228 ERROR final openerp.addons.base.ir.ir_ui_view: Can't render view for model: purchase.order.fleet_vehicle
Traceback (most recent call last):
File "C:\OpenERP\server\openerp\addons\base\ir\ir_ui_view.py", line 126, in _check_render_view
File "c:\OpenERP\server\.\openerp\osv\orm.py", line 2293, in fields_view_get
File "c:\OpenERP\server\.\openerp\osv\orm.py", line 1970, in __view_look_dom_arch
except_orm: ('View error', u"Can't find field 'purchase_date' in the following view parts composing the view of object model 'purchase.order.fleet_vehicle':\n * Purchase Order Fleet Vehicle Form View\n\nEither you wrongly customized this view, or some modules bringing those views are not compatible with your current data model")
2015-04-30 13:58:38,121 5228 ERROR final openerp.tools.convert: Parse error in file:///C:/OpenERP/server/openerp/addons/transport_purchase/transport_purchase.xml:5:
<record model="ir.ui.view" id="purchase_order_fleet_vehicle_form_view">
<field name="name">Purchase Order Fleet Vehicle Form View</field>
<field name="model">purchase.order.fleet_vehicle</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Transport" version="7.0">
<group colspan="4" col="4">
<group colspan="2" string="Vehicle">
<field name="fleet_vehicle_id" required="1" domain="[('is_trailer','=',0)]" on_change="fleet_vehicle_id_change(fleet_vehicle_id,context)"/>
<field name="internal_number"/>
<field name="license_plate"/>
</group>
<group colspan="2" string="Driver">
<field name="employee_driver_id" domain="[('is_driver','=', 1)]" required="1"/>
<field name="employee_helper_id" required="0"/>
</group>
<group colspan="2" string="Trailer">
<field name="fleet_trailer_id" domain="[('is_trailer','=',1)]" on_change="fleet_trailer_id_change(fleet_trailer_id)"/>
<field name="trailer_license_plate"/>
</group>
<group colspan="2" string="Client Transport">
<field name="partner_departure_id"/>
<field name="partner_destination_id"/>
</group>
<group colspan="6" col="6" string="Purchase and Transport Dates">
<field name="purchase_date"/>
<field name="delivery_date"/>
<field name="return_date"/>
</group>
</group>
<group col="4" string="Manifest">
<field name="cargo_ids" required="1" nolabel="1" context="{'purchase_order_id':purchase_order_id}">
<tree editable="bottom">
<field name="purchase_order_id" invisible="1"/>
<field name="cargo_product_id" domain="[('type','=','service')]" on_change="cargo_id_change(cargo_product_id,context)"/>
<field name="cargo_ident"/>
<field name="cargo_docport"/>
<field name="brand"/>
<field name="model"/>
<field name="transport_from_id"/>
<field name="transport_to_id"/>
<field name="transport_date"/>
</tree>
</field>
</group>
</form>
</field>
</record>
答案 0 :(得分:0)
似乎数据库/视图没有正确更新, 您需要通过更新数据库和特定模块来重新启动openerp-server
首先检查数据库结构中的视图,如果该视图存在则删除该模块并卸载模块然后尝试按照这些命令安装或重新启动服务器
./openerp-server -d <db_name> all <instead of all you can define your modules>
./openerp-server -u all <this command will update all modules and sleected database you can also use this commands>