Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

validating the field(s) arch: Invalid XML for View Architecture!'

By
Naveen
on 8/11/13, 12:27 PM 3,729 views

The above error is caused when the below code is run:

sale.myquote.py:


from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta
import time
from openerp import pooler
from openerp.osv import fields, osv
from openerp.tools.translate import _
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT, DATETIME_FORMATS_MAP, float_compare
import openerp.addons.decimal_precision as dp
from openerp import netsvc
from openerp.addons import sale

class sale_myquote:
    _name = 'sale.myquote'
    _inherit = 'sale.order'
    _columns = {
        'name' : fields.char('Quote No',size=64,required=True),
        'cust': fields.many2one('res.partner', 'Customer', readonly=True, required=True, select=True, track_visibility='always'),
        'user_id': fields.many2one('res.partner', 'Salesman', readonly=True, required=True, select=True, track_visibility='always'),
        'qdate' : fields.date('Date'),
        'cust_ref' : fields.char('Customer Ref',size=64,required=True),
        'pricelist' : fields.many2one('product.pricelist', 'Pricelist'),
        }

class sale_myquote_order:
    _name = 'sale.myquote.order'
    _inherit = 'sale.order'
    _columns = {
        'prod' : fields.many2one('product.product', 'Product'),
        'name' :fields.many2one('product.product', 'Product'),
        'qty' : fields.integer('Quantity'),
        'price' : fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Product Price'), readonly=True),
        'tax' : fields.float('Tax'),
        'disc' : fields.float('Discount'),
        'subtotal' : fields.float('Amount'), #'subtotal' : fields.function(f_subtot, string="Amount"),
        'total_wo_tax' : fields.float('Subtotal'), #'total_wo_tax' : fields.function(f_total, string="Amount"),
        'total_tax' : fields.float('Tax'), #'total_tax' : fields.function(f_total, string="Tax"),
        'total' : fields.float('Final'), #'total' : fields.function(_total, string="Total"),
        'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of sales order lines."),
        'order_id': fields.many2one('sale.order', 'Order Reference', required=True, ondelete='cascade', select=True, readonly=True),
        }
    _order = 'order_id desc, sequence, id'
    _defaults = {
        'disc': 0.0,
        'qty': 1,
        'tax' : 4.0,
        'sequence': 10,
        'price': 0.0,
        'total' : 0.0,
    }
    """
    def f_total(self, cr, uid, ids, field_name, arg, context=None):
        res = {}
        for order in self.browse(cr, uid, ids, context=context):
            res[order.id] = {
                'total_wo_tax': 0.0,
                'total_tax': 0.0,
                'total': 0.0,
            }
            val = val1 = 0.0
            for line in order.order_line:
                val1 += line.subtotal
                val += self.tax(cr, uid, line, context=context)
            res[order.id]['total_tax'] = cur_obj.round(cr, uid, cur, val)
            res[order.id]['total_wo_tax'] = cur_obj.round(cr, uid, cur, val1)
            res[order.id]['total'] = res[order.id]['total_wo_tax'] + res[order.id]['total_tax']
        return res

    def f_subtot(self, cr, uid, ids, field_name, arg, context=None):
        cur_obj = self.pool.get('res.currency')
        res = {}
        if context is None:
            context = {}
        for line in self.browse(cr, uid, ids, context=context):
            price = line.price * (1 - (line.disc or 0.0) / 100.0)
            taxes = tax_obj.compute_all(cr, uid, line.tax, price, line.qty, line.prod, line.order_id.partner_id)
            cur = line.order_id.pricelist_id.currency_id
            res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])
        return res

    def f_subtot_tax(self, cr, uid, line, context=None):
        val = 0.0
        for c in self.pool.get('account.tax').compute_all(cr, uid, line.tax_id, line.price * (1-(line.disc or 0.0)/100.0), line.product_uom_qty, line.prod, line.order_id.partner_id)['taxes']:
            val += c.get('amount', 0.0)
        return val
        """

sale_myquote_view.ml:



<openerp>
    <data>
        <menuitem name="My Quote" id="menu_myquote" parent="sale.menu_sale_quotations"/>
        <menuitem id="menu_myquote_sub" name="My Quote" parent="menu_myquote" sequence="9"/>  
        <record id="sale_myquote_tree" model="ir.ui.view">
            <field name="name">MyQuote</field>
            <field name="model">sale.myquote</field>
            <field name="arch" type="xml">
                <tree string="MyQuote">
                    <field name="name" string="Quotation Number"/>
                    <field name="qdate"/>
                    <field name="cust"/>
                    <field name="user_id"/>
                </tree>
            </field>
        </record>
    </data>
</openerp>

ERROR TRACEBACK:


2013-08-11 16:12:54,577 4780 INFO ERP_demo openerp.modules.module: module sale_myquote: creating or updating database tables
2013-08-11 16:12:54,578 4780 INFO ERP_demo openerp.modules.loading: module sale_myquote: loading sale_myquote_view.xml
2013-08-11 16:12:55,171 4780 ERROR ERP_demo openerp.addons.base.ir.ir_ui_view: Can't render view  for model: sale.myquote
Traceback (most recent call last):
  File "/home/naveen/eclipseworkspace/openerp-7.0-20130623-231037/openerp/addons/base/ir/ir_ui_view.py", line 126, in _check_render_view
    fvg = self.pool.get(view.model).fields_view_get(cr, uid, view_id=view.id, view_type=view.type, context=context)
AttributeError: 'NoneType' object has no attribute 'fields_view_get'
2013-08-11 16:12:55,195 4780 ERROR ERP_demo openerp.tools.convert: Parse error in /home/naveen/eclipseworkspace/openerp-7.0-20130623-231037/openerp/addons/sale_myquote/sale_myquote_view.xml:12: 
<record model="ir.ui.view" id="sale_myquote_tree">
            <field name="name">MyQuote</field>
            <field name="model">sale.myquote</field>
            <field name="arch" type="xml">
                <tree string="MyQuote">
                    <field name="name" string="Quotation Number"/>
                    <field name="qdate"/>
                    <field name="cust"/>
                    <field name="user_id"/>
                    <field name="cust_ref"/>
                </tree>
            </field>
        </record>
Traceback (most recent call last):
  File "/home/naveen/eclipseworkspace/openerp-7.0-20130623-231037/openerp/tools/convert.py", line 847, in parse
    self._tags[rec.tag](self.cr, rec, n)
  File "/home/naveen/eclipseworkspace/openerp-7.0-20130623-231037/openerp/tools/convert.py", line 814, in _tag_record
    id = self.pool.get('ir.model.data')._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode, context=rec_context )
  File "/home/naveen/eclipseworkspace/openerp-7.0-20130623-231037/openerp/addons/base/ir/ir_model.py", line 963, in _update
    res_id = model_obj.create(cr, uid, values, context=context)
  File "/home/naveen/eclipseworkspace/openerp-7.0-20130623-231037/openerp/addons/base/ir/ir_ui_view.py", line 103, in create
    return super(view, self).create(cr, uid, values, context)
  File "/home/naveen/eclipseworkspace/openerp-7.0-20130623-231037/openerp/osv/orm.py", line 4470, in create
    self._validate(cr, user, [id_new], context)
  File "/home/naveen/eclipseworkspace/openerp-7.0-20130623-231037/openerp/osv/orm.py", line 1544, in _validate
    raise except_orm('ValidateError', '\n'.join(error_msgs))
except_orm: ('ValidateError', u'Error occurred while validating the field(s) arch: Invalid XML for View Architecture!')
2013-08-11 16:12:55,296 4780 ERROR ERP_demo openerp.netsvc: ValidateError
Error occurred while validating the field(s) arch: Invalid XML for View Architecture!
Traceback (most recent call last):
  File "/home/naveen/eclipseworkspace/openerp-7.0-20130623-231037/openerp/netsvc.py", line 292, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/home/naveen/eclipseworkspace/openerp-7.0-20130623-231037/openerp/service/web_services.py", line 626, in dispatch
    res = fn(db, uid, *params)
  File "/home/naveen/eclipseworkspace/openerp-7.0-20130623-231037/openerp/osv/osv.py", line 188, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/home/naveen/eclipseworkspace/openerp-7.0-20130623-231037/openerp/osv/osv.py", line 144, in wrapper
    raise except_osv(inst.name, inst.value)
except_osv: ('ValidateError', u'Error occurred while validating the field(s) arch: Invalid XML for View Architecture!')
2013-08-11 16:12:55,355 4780 INFO ERP_demo werkzeug: 127.0.0.1 - - [11/Aug/2013 16:12:55] "POST /web/dataset/call_button HTTP/1.1" 200 -

Please help.

Please post the complete error to get an answer

AJ Schrafel Paper Corp
on 8/11/13, 1:24 PM

@patently Thanks for the response. The Q has been updated.

Naveen
on 8/11/13, 2:16 PM
0
Xsias
On 8/12/13, 7:09 AM

So you have that :

sale.myquote.py:

from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta
import time
from openerp import pooler
from openerp.osv import fields, osv
from openerp.tools.translate import _
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT, DATETIME_FORMATS_MAP, float_compare
import openerp.addons.decimal_precision as dp
from openerp import netsvc
from openerp.addons import sale

class sale_myquote(osv.osv):
    _name = 'sale.myquote'
    _columns = {
        'name' : fields.char('Quote No',size=64,required=True),
        'cust': fields.many2one('res.partner', 'Customer', readonly=True, required=True, select=True, track_visibility='always'),
        'user_id': fields.many2one('res.partner', 'Salesman', readonly=True, required=True, select=True, track_visibility='always'),
        'qdate' : fields.date('Date'),
        'cust_ref' : fields.char('Customer Ref',size=64,required=True),
        'pricelist' : fields.many2one('product.pricelist', 'Pricelist'),
        }
sale_myquote()
class sale_myquote_order(osv.osv):
    _name = 'sale.myquote.order'
    _columns = {
        'prod' : fields.many2one('product.product', 'Product'),
        'name' :fields.many2one('product.product', 'Product'),
        'qty' : fields.integer('Quantity'),
        'price' : fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Product Price'), readonly=True),
        'tax' : fields.float('Tax'),
        'disc' : fields.float('Discount'),
        'subtotal' : fields.float('Amount'), #'subtotal' : fields.function(f_subtot, string="Amount"),
        'total_wo_tax' : fields.float('Subtotal'), #'total_wo_tax' : fields.function(f_total, string="Amount"),
        'total_tax' : fields.float('Tax'), #'total_tax' : fields.function(f_total, string="Tax"),
        'total' : fields.float('Final'), #'total' : fields.function(_total, string="Total"),
        'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of sales order lines."),
        'order_id': fields.many2one('sale.order', 'Order Reference', required=True, ondelete='cascade', select=True, readonly=True),
        }
    _order = 'order_id desc, sequence, id'
    _defaults = {
        'disc': 0.0,
        'qty': 1,
        'tax' : 4.0,
        'sequence': 10,
        'price': 0.0,
        'total' : 0.0,
    }
sale_myquote_order()

sale_myquote_view.xml:

<openerp>
    <data>
        <menuitem name="My Quote" id="menu_myquote" parent="sale.menu_sale_quotations"/>
        <menuitem id="menu_myquote_sub" name="My Quote" parent="menu_myquote" sequence="9"/>  
        <record id="sale_myquote_tree" model="ir.ui.view">
            <field name="name">MyQuote</field>
            <field name="model">sale.myquote</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="MyQuote">
                    <field name="name" string="Quotation Number"/>
                    <field name="qdate"/>
                    <field name="cust"/>
                    <field name="user_id"/>
                </tree>
            </field>
        </record>
    </data>
</openerp>

Imports are fine; the replacement did no good.

Naveen
on 8/12/13, 7:25 AM

I've edited my answer.

Xsias
on 8/12/13, 7:59 AM

The edit didn't work. Can you also help me here too please? : http://help.openerp.com/question/27051/how-to-add-a-column-in-sale-order-gives-validateerror/?answer=27162#post-id-27162 Thanks.

Naveen
on 8/12/13, 9:29 AM

New try, new edit.

Xsias
on 8/12/13, 9:51 AM

Same error after edit-2 too. Please help me on the other Q; it's urgent. I think everything's correct, but it doesn't work.

Naveen
on 8/12/13, 9:58 AM

I've edited my answer, please confirm that the code you are running now.

Xsias
on 8/12/13, 1:14 PM

^ Pasted the same code; no joy. Please help me with the other Q 1st, that one's urgent.

Naveen
on 8/12/13, 1:25 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 8/11/13, 12:27 PM
Seen: 3729 times
Last updated: 3/16/15, 8:10 AM