如何只显示那些有发票的销售订单? Odoo

时间:2017-10-02 07:23:44

标签: odoo odoo-10 odoo-9

问题是我只能按存储的字段过滤销售订单。但是当它存储时它不被触发,除非我通过打开表单并更改他依赖的字段来触发它们。我想要在打开树视图时计算它们,我可以使用这些字段来过滤记录。 (我使用不同的域有三种不同的操作,我使用这三个字段)

route_id = fields.Many2one('route.data', string="Route ID")
has_route_req_po = fields.Boolean(compute='_compute_has_route_completed', store=True,
    help="Field is checked if So is Sale Order and has Route with status Req. Purchase") # SO IN PROGRESS
has_route_completed = fields.Boolean(
    compute='_compute_has_route_completed', store=True)  # SO TO INVOICE
has_r_completed_no_inv = fields.Boolean(
    compute='_compute_has_route_completed', store=True)  # SO FULLY INVOICED

@api.multi
@api.depends('route_id', 'state', 'route_id.route_state')
def _compute_has_route_completed(self):
    for so in self:
        if so.state == 'sale' and so.route_id:
            if so.route_id.route_state == 'draft' or so.route_id.route_state == 'in_progress':
                so.has_route_req_po = True
                so.has_r_completed_no_inv = False
                so.has_route_completed = False
            elif so.route_id.route_state == 'done':
                # Reikia patikrinti ar so turi saskaita
                invoice = self.env['account.invoice'].search([('origin', '=', so.name)])
                if invoice:
                    so.has_r_completed_no_inv = True
                    so.has_route_completed = False
                    so.has_route_req_po = False
                else:
                    so.has_route_completed = True
                    so.has_r_completed_no_inv = False
                    so.has_route_req_po = False

单击菜单项时调用的操作。

<record id="sales_data_action_sale_order_view1" model="ir.actions.act_window">
        <field name="name">In Progress</field>
        <field name="res_model">sale.order</field>
        <field name="type">ir.actions.act_window</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="context">[('default_freight_service','=',1)]</field>
       <field name="domain">[('freight_service','=',True),('state','=','sale'),
            ('has_route_req_po','=',True)]</field>
        <field eval="False" name="view_id"/>
        <field name="help" type="html">
          <p class="oe_view_nocontent_create">
            Click to create a new.
          </p>
        </field>
    </record>

其他行为与不同的域名相同:

     <field name="domain">[('freight_service','=',True),('state','=','sale'),
            ('has_route_completed','=',True)]</field>

第三个动作:

<field name="domain">[('freight_service','=',True),('state','=','sale'),
            ('has_r_completed_no_inv','=',True)]</field>

0 个答案:

没有答案