OpenERP 7数据存储在数据库中,但不显示在树视图中

时间:2016-07-07 08:13:07

标签: openerp openerp-7

sale_order.py

class glimsol_bopas(osv.osv):
    _name = 'glimsol.bopas'
    _inherit = ['mail.thread', 'ir.needaction_mixin']

    _columns = {
        'state': fields.selection([
            ('draft', 'Draft Quotation'),
            ('sent', 'Quotation Sent'),
            ('cancel', 'Cancelled'),
            ('waiting_date', 'Waiting Schedule'),
            ('progress', 'Sales Order'),
            ('manual', 'Sale to Invoice'),
            ('invoice_except', 'Invoice Exception'),
            ('done', 'Done'),
            ], 'Status', readonly=True, track_visibility='onchange',
            help="Gives the status of the quotation or sales order. \nThe exception status is automatically set when a cancel operation occurs in the processing of a document linked to the sales order. \nThe 'Waiting Schedule' status is set when the invoice is confirmed but waiting for the scheduler to run on the order date.", select=True),
            # other fields
    }
    _defaults = {
        'state': 'draft',
        # other defaults
    }

    # methods
<?xml version="1.0" encoding="utf-8"?>
    <openerp>
        <data>
            <!-- view definitions -->

            <record id="glimsol_bopas_action" model="ir.actions.act_window">
                <field name="name">B.O.Pull-out Authorization Slip (BOPAS)</field>
                <field name="type">ir.actions.act_window</field>
                <field name="res_model">glimsol.bopas</field>
                <field name="view_type">form</field>
                <field name="view_mode">tree,form,calendar,graph</field>
                <field name="view_id" ref="glimsol_bopas_tree"/>
                <!-- <field name="search_view_id" ref="glimsol_bopas_search"/> -->
                <field name="context">{}</field>
                <field name="domain">[('state','not in',('draft','sent','cancel'))]</field>
                <field name="help" type="html">
                <p class="oe_view_nocontent_create">
                    Click to create a B.O.- P.A.S.
                </p><p>
                    B.O.- P.A.S quotation.
                </p>
                </field>
            </record>
            <menuitem id="glimsol_bopas_menu" action="glimsol_bopas_action" parent="base.menu_sales" sequence="10" name="B.O.- P.A.S"/>
        </data>
    </openerp>

当我在下面的代码中添加代码

'state': 'draft',
时,数据不会显示/显示在树视图中。 但是我需要这样做以使状态“草稿报价”的状态栏使背景为蓝色。

_defaults = {
            'date_order': fields.date.context_today,
            'order_policy': 'manual',
            'state': 'draft',
            'user_id': lambda obj, cr, uid, context: uid,
            'name': lambda obj, cr, uid, context: '/',
        }

请帮助我!

谢谢,

1 个答案:

答案 0 :(得分:2)

摆脱这条线

<field name="domain">[('state','not in',('draft','sent','cancel'))]</field>

如果状态设置为draftsentcancel and,您基本上会告诉odoo显示空的创建视图(数据库中没有记录时显示的视图)默认情况下,您将新创建的记录的状态设置为draft

另一种说法是

显示状态为not in draftsentcancel

的记录