[Lập trình module] Lỗi Invalid XML for View Architecture!

Thảo luận trong 'Hỏi - Đáp' bắt đầu bởi Duong, 17/8/13.

  1. Duong New Member

    Mình đang viết một module, mình bị dính lỗi Invalid XML for View Architecture! xem đi xem lại khá nhiều lần rồi mà vẫn chưa giải quyết được.
    Đây là file log.
    Mã (text):
    1. 2013-08-17 16:32:22,993 3148 INFO UITs openerp.modules.loading: loading 1 modules...
    2. 2013-08-17 16:32:23,029 3148 INFO UITs openerp.modules.loading: loading 25 modules...
    3. 2013-08-17 16:32:23,065 3148 INFO UITs openerp.osv.orm: Missing many2one field definition for _inherits reference "cost_id" in "fleet.vehicle.log.fuel", using default one.
    4. 2013-08-17 16:32:23,065 3148 INFO UITs openerp.osv.orm: Missing many2one field definition for _inherits reference "cost_id" in "fleet.vehicle.log.services", using default one.
    5. 2013-08-17 16:32:23,066 3148 INFO UITs openerp.osv.orm: Missing many2one field definition for _inherits reference "cost_id" in "fleet.vehicle.log.contract", using default one.
    6. 2013-08-17 16:32:23,082 3148 INFO UITs openerp.modules.loading: loading 26 modules...
    7. 2013-08-17 16:32:23,088 3148 INFO UITs openerp.modules.module: module Transport Management: creating or updating database tables
    8. 2013-08-17 16:32:23,158 3148 INFO UITs openerp.modules.loading: module Transport Management: loading Transport_Management_view.xml
    9. 2013-08-17 16:32:23,190 3148 ERROR UITs openerp.addons.base.ir.ir_ui_view: <string>:1:0:ERROR:RELAXNGV:RELAXNG_ERR_ELEMWRONG: Did not expect element filed there
    10. 2013-08-17 16:32:23,190 3148 ERROR UITs openerp.addons.base.ir.ir_ui_view: <string>:2:0:ERROR:RELAXNGV:RELAXNG_ERR_EXTRACONTENT: Element tree has extra content: filed
    11. 2013-08-17 16:32:23,194 3148 ERROR UITs openerp.tools.convert: Parse error in file:///C:/Program%20Files/OpenERP%207.0-20130708-231042/Server/server/openerp/addons/Transport%20Management/Transport_Management_view.xml:21:
    12. <record id="Vehicle_Tree" model="ir.ui.view">
    13.       <field name="name">InfoVehicle_Tree</field>
    14.       <field name="model">info.vehicle</field>
    15.       <field name="arch" type="xml">
    16.         <tree string="Vehicle Tree">
    17.           <filed name="id_vehicle"/>
    18.           <filed name="name_vehicle"/>
    19.           <filed name="color_vehicle"/>
    20.           <filed name="brand_vehicle"/>
    21.           <filed name="licensePlate_vehicle"/>
    22.           <filed name="weight_good"/>
    23.           <filed name="fuel"/>
    24.         </tree>
    25.       </field>
    26.     </record>
    27. Traceback (most recent call last):
    28.   File "C:\Program Files\OpenERP 7.0-20130708-231042\Server\server\.\openerp\tools\convert.py", line 847, in parse
    29.   File "C:\Program Files\OpenERP 7.0-20130708-231042\Server\server\.\openerp\tools\convert.py", line 814, in _tag_record
    30.   File "C:\Program Files\OpenERP 7.0-20130708-231042\Server\server\openerp\addons\base\ir\ir_model.py", line 963, in _update
    31.   File "C:\Program Files\OpenERP 7.0-20130708-231042\Server\server\openerp\addons\base\ir\ir_ui_view.py", line 103, in create
    32.   File "C:\Program Files\OpenERP 7.0-20130708-231042\Server\server\.\openerp\osv\orm.py", line 4470, in create
    33.   File "C:\Program Files\OpenERP 7.0-20130708-231042\Server\server\.\openerp\osv\orm.py", line 1544, in _validate
    34. except_orm: ('ValidateError', u'Error occurred while validating the field(s) arch: Invalid XML for View Architecture!')
    35. 2013-08-17 16:32:23,196 3148 ERROR UITs openerp.netsvc: ValidateError
    36. Error occurred while validating the field(s) arch: Invalid XML for View Architecture!
    37. Traceback (most recent call last):
    38.   File "C:\Program Files\OpenERP 7.0-20130708-231042\Server\server\.\openerp\netsvc.py", line 292, in dispatch_rpc
    39.   File "C:\Program Files\OpenERP 7.0-20130708-231042\Server\server\.\openerp\service\web_services.py", line 626, in dispatch
    40.   File "C:\Program Files\OpenERP 7.0-20130708-231042\Server\server\.\openerp\osv\osv.py", line 188, in execute_kw
    41.   File "C:\Program Files\OpenERP 7.0-20130708-231042\Server\server\.\openerp\osv\osv.py", line 144, in wrapper
    42. except_osv: ('ValidateError', u'Error occurred while validating the field(s) arch: Invalid XML for View Architecture!')
    43. 2013-08-17 16:32:23,207 3148 INFO UITs werkzeug: 127.0.0.1 - - [17/Aug/2013 16:32:23] "POST /web/dataset/call_button HTTP/1.1" 200 -
    44.  
    Đây là file xml.
    Mã (text):
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <openerp>
    3.   <data>
    4.     <record id ="Vehicle_Form" model ="ir.ui.view">
    5.       <field name ="name">InfoVehicle_Form</field>
    6.       <field name ="model">info.vehicle</field>
    7.       <field name ="arch" type ="xml">
    8.         <form string ="Info Vehicle Form" version="7.0">
    9.           <group col="1">
    10.             <filed name ="id_vehicle"/>
    11.             <filed name ="name_vehicle"/>
    12.             <filed name ="color_vehicle"/>
    13.             <filed name ="brand_vehicle"/>
    14.             <filed name ="licensePlate_vehicle"/>
    15.             <filed name ="weight_good"/>
    16.             <filed name ="fuel"/>
    17.           </group>
    18.         </form>
    19.       </field>
    20.     </record>
    21.     <record id ="Vehicle_Tree" model ="ir.ui.view">
    22.       <field name ="name">InfoVehicle_Tree</field>
    23.       <field name ="model">info.vehicle</field>
    24.       <field name ="arch" type ="xml">
    25.         <tree string ="Vehicle Tree">
    26.           <filed name ="id_vehicle"/>
    27.           <filed name ="name_vehicle"/>
    28.           <filed name ="color_vehicle"/>
    29.           <filed name ="brand_vehicle"/>
    30.           <filed name ="licensePlate_vehicle"/>
    31.           <filed name ="weight_good"/>
    32.           <filed name ="fuel"/>
    33.         </tree>
    34.       </field>
    35.     </record>
    36.     <record id ="Vehicle_Form_Action" model ="ir.action.act_windows">
    37.       <field name="name">InfoVehicle_Action</field>
    38.       <field name="res_model">info.vehicle</field>
    39.       <field name="type">ir.actions.act_window</field>
    40.       <field name="view_type">form</field>
    41.       <field name="view_mode">tree,form</field>
    42.       <field name="view_id" ref="Vehicle_Tree"/>
    43.     </record>
    44.     <menuitem id ="Vehicle_Menu" sequence ="0" name ="Transport Management"/>
    45.     <menuitem id ="Vehicle_Item" action ="Vehicle_From_Action" parent ="Vehicle_Menu"/>
    46.     <record id ="Route_Form" model ="ir.ui.view">
    47.       <field name ="name">InfoRoute_Form</field>
    48.       <field name ="model">info.route</field>
    49.       <field name ="arch" type ="xml">
    50.         <form string ="Route Form" version="7.0">
    51.           <group col="1">
    52.             <filed name ="id_route"/>
    53.             <filed name ="name_route"/>
    54.             <filed name ="lenght_route"/>
    55.           </group>
    56.         </form>
    57.       </field>
    58.     </record>
    59.     <record id ="Route_Tree" model ="ir.ui.view">
    60.       <field name ="name">InfoRoute_Tree</field>
    61.       <field name ="model">info.route</field>
    62.       <field name ="arch" type ="xml">
    63.         <tree string ="Route Tree">
    64.           <filed name ="id_route"/>
    65.           <filed name ="name_route"/>
    66.           <filed name ="lenght_route"/>
    67.         </tree>
    68.       </field>
    69.     </record>
    70.     <record id ="Route_Form_Action" model ="ir.action.act_windows">
    71.       <field name="name">InfoRoute_Action</field>
    72.       <field name="res_model">info.route</field>
    73.       <field name="type">ir.actions.act_window</field>
    74.       <field name="view_type">form</field>
    75.       <field name="view_mode">tree,form</field>
    76.       <field name="view_id" ref="Route_Tree"/>
    77.     </record>
    78.     <menuitem id ="Route_Item" action ="Route_From_Action" parent ="Vehicle_Menu"/>
    79.     <record id ="Fuel_Form" model ="ir.ui.view">
    80.       <field name ="name">InfoFuel_Form</field>
    81.       <field name ="model">info.fuel</field>
    82.       <field name ="arch" type ="xml">
    83.         <form string ="Fuel Form" version="7.0">
    84.           <group col="1">
    85.             <filed name ="id_fuel"/>
    86.             <filed name ="name_fuel"/>
    87.             <filed name ="price_fuel"/>
    88.           </group>
    89.         </form>
    90.       </field>
    91.     </record>
    92.     <record id ="Fuel_Tree" model ="ir.ui.view">
    93.       <field name ="name">InfoFuel_Tree</field>
    94.       <field name ="model">info.fuel</field>
    95.       <field name ="arch" type ="xml">
    96.         <tree string ="Fuel Tree">
    97.           <filed name ="id_fuel"/>
    98.           <filed name ="name_fuel"/>
    99.           <filed name ="price_fuel"/>
    100.         </tree>
    101.       </field>
    102.     </record>
    103.     <record id ="Fuel_Form_Action" model ="ir.action.act_windows">
    104.       <field name="name">InfoFuel_Action</field>
    105.       <field name="res_model">info.fuel</field>
    106.       <field name="type">ir.actions.act_window</field>
    107.       <field name="view_type">form</field>
    108.       <field name="view_mode">tree,form</field>
    109.       <field name="view_id" ref="Fuel_Tree"/>
    110.     </record>
    111.     <menuitem id ="Fuel_Item" action ="Fuel_From_Action" parent ="Vehicle_Menu"/>
    112.     <record id ="Driver_Form" model ="ir.ui.view">
    113.       <field name ="name">InfoDriver_Form</field>
    114.       <field name ="model">info.driver</field>
    115.       <field name ="arch" type ="xml">
    116.         <form string ="Driver Form" version="7.0">
    117.           <group col="1">
    118.             <filed name ="id_driver"/>
    119.             <filed name ="name_driver"/>
    120.             <filed name ="old"/>
    121.           </group>
    122.         </form>
    123.       </field>
    124.     </record>
    125.     <record id ="Driver_Tree" model ="ir.ui.view">
    126.       <field name ="name">InfoDriver_Tree</field>
    127.       <field name ="model">info.driver</field>
    128.       <field name ="arch" type ="xml">
    129.         <tree string ="Driver Tree">
    130.           <filed name ="id_driver"/>
    131.           <filed name ="name_driver"/>
    132.           <filed name ="old"/>
    133.         </tree>
    134.       </field>
    135.     </record>
    136.     <record id ="Driver_Form_Action" model ="ir.action.act_windows">
    137.       <field name="name">InfoDriver_Action</field>
    138.       <field name="res_model">info.driver</field>
    139.       <field name="type">ir.actions.act_window</field>
    140.       <field name="view_type">form</field>
    141.       <field name="view_mode">tree,form</field>
    142.       <field name="view_id" ref="Driver_Tree"/>
    143.     </record>
    144.     <menuitem id ="Driver_Item" action ="Driver_From_Action" parent ="Vehicle_Menu"/>
    145.     <record id ="Assignment_Form" model ="ir.ui.view">
    146.       <field name ="name">Assignment_Form</field>
    147.       <field name ="model">assignment</field>
    148.       <field name ="arch" type ="xml">
    149.         <form string ="Assignment Form" version="7.0">
    150.           <group col="1">
    151.             <filed name ="id_Ass"/>
    152.             <filed name ="driver_id"/>
    153.             <filed name ="vehicle_id"/>
    154.             <filed name ="route_id"/>
    155.           </group>
    156.         </form>
    157.       </field>
    158.     </record>
    159.     <record id ="Assignment_Tree" model ="ir.ui.view">
    160.       <field name ="name">Assignment_Tree</field>
    161.       <field name ="model">assignment</field>
    162.       <field name ="arch" type ="xml">
    163.         <tree string ="Assignment Tree">
    164.           <filed name ="id_Ass"/>
    165.           <filed name ="driver_id"/>
    166.           <filed name ="vehicle_id"/>
    167.           <filed name ="route_id"/>
    168.         </tree>
    169.       </field>
    170.     </record>
    171.     <record id ="Assignment_Form_Action" model ="ir.action.act_windows">
    172.       <field name="name">Assignment_Action</field>
    173.       <field name="res_model">assignment</field>
    174.       <field name="type">ir.actions.act_window</field>
    175.       <field name="view_type">form</field>
    176.       <field name="view_mode">tree,form</field>
    177.       <field name="view_id" ref="Assignment_tree"/>
    178.     </record>
    179.     <menuitem id ="Assignment_Item" action ="Assignment_From_Action" parent ="Vehicle_Menu"/>
    180.     <record id ="Cost_Form" model ="ir.ui.view">
    181.       <field name ="name">Cost_Form</field>
    182.       <field name ="model">cost</field>
    183.       <field name ="arch" type ="xml">
    184.         <form string ="Cost Form" version="7.0">
    185.           <group col="1">
    186.             <filed name ="id_cost"/>
    187.             <filed name ="vehicle_id"/>
    188.             <filed name ="total"/>
    189.           </group>
    190.         </form>
    191.       </field>
    192.     </record>
    193.     <record id ="Cost_Tree" model ="ir.ui.view">
    194.       <field name ="name">Cost_Tree</field>
    195.       <field name ="model">cost</field>
    196.       <field name ="arch" type ="xml">
    197.         <tree string ="Cost Tree">
    198.           <filed name ="id_cost"/>
    199.           <filed name ="vehicle_id"/>
    200.           <filed name ="total"/>
    201.         </tree>
    202.       </field>
    203.     </record>
    204.     <record id ="Cost_Form_Action" model ="ir.action.act_windows">
    205.       <field name="name">Cost_Action</field>
    206.       <field name="res_model">cost</field>
    207.       <field name="type">ir.actions.act_window</field>
    208.       <field name="view_type">form</field>
    209.       <field name="view_mode">tree,form</field>
    210.       <field name="view_id" ref="Cost_Tree"/>
    211.     </record>
    212.     <menuitem id ="Cost_Item" action ="Cost_From_Action" parent ="Vehicle_Menu"/>
    213.   </data>
    214. </openerp>
    Mình xin cảm ơn!
  2. Dear e,

    Em đang bị báo lỗi ở Tree View, cách em định nghĩa Tree View như thế thì ko hay và khó quản lý. Em nên định nghĩa thế này thì sẻ hay hơn, em thử tham khảo nhé, a sửa lại cách định nghĩa Tree View của em như sau:

    1. <record id ="view_info_vehicle_tree" model ="ir.ui.view">
    2. <field name ="name">view.info.vehicle.tree</field>
    3. <field name ="model">info.vehicle</field>
    4. <field name ="arch" type ="xml">
    5. <tree string ="Vehicle Tree">
    6. <filed name ="id_vehicle"/>
    7. <filed name ="name_vehicle"/>
    8. <filed name ="color_vehicle"/>
    9. <filed name ="brand_vehicle"/>
    10. <filed name ="licensePlate_vehicle"/>
    11. <filed name ="weight_good"/>
    12. <filed name ="fuel"/>
    13. </tree>
    14. </field>
    15. </record>
    Hầu như các MOdule gốc đều định nghĩa giống kiểu này, với lại Field "id_vehicle" a nghĩ nó bị dư vì đa số bất kỳ Object nào đc tạo ra đều có 1 Field "ID" tự động tạo ra trong Table của nó rồi. Nếu Field này của e là Code của Vehicle thì e nên đặt tên là "code" thì sẽ dễ quản lý thông tin hơn.
    Duong thích bài này.
  3. Ah a quên mất là lỗi chính của em là chổ này nè:

    <filed name ="id_vehicle"/> ==> <field name ="id_vehicle"/>

    em sửa lại chữ "filed" thành "field" nhé
    Duong thích bài này.
  4. thinhgr Active Member

    1 đống luôn sửa chữ filed = field
  5. bruce.nguyen Active Member

    :rolleyes: đường còn dài và lắm chông gai mà ta vẩn cứ bước

Chia sẻ trang này