【发布时间】:2018-10-26 00:20:05
【问题描述】:
<record model="ir.actions.act_window" id="action_purchase_orders">
<field name="name">Purchase Orders</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">purchase.order</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('id', 'in', purchase_order_ids.ids)]</field> <------- This is not working.
</record>
<record id="purchase.form" model="ir.ui.view">
<field name="name">purchase.form</field>
<field name="model">purchase.form</field>
<field name="arch" type="xml">
<form string="Purchase Form">
<sheet>
<div class="oe_button_box" name="button_box">
<button type="action" name="%(action_purchase_orders)d" class="oe_stat_button" icon="fa-list-alt"
attrs="{'invisible':[('purchase_order_count', '=', 0)]}">
<field name="purchase_order_count" invisible="1"/>
<field name="purchase_order_ids" string="Purchase Orders" widget="statinfo" help="Purchase orders"/>
</button>
...
class PurchaseForm(models.Model):
_name = 'purchase.form'
@api.depends('purchase_order_ids')
def _purchase_order_count(self):
for pp in self:
pp.purchase_order_count = len(pp.purchase_order_ids)
purchase_order_ids = fields.Many2many('purchase.order', 'purchase_form_purchase_order_rel', 'purchase_form_id', 'purchase_order_id', 'Purchase Orders', states=READONLY_STATES)
purchase_order_count = fields.Integer(compute='_purchase_order_count', string='# of Purchase Orders')
Error:
Uncaught Error: NameError: name 'purchase_order_ids' is not defined
http://localhost:8069/web/content/801-4161526/web.assets_backend.js:144
Traceback:
Error: NameError: name 'purchase_order_ids' is not defined
at PY_ensurepy (http://localhost:8069/web/content/801-4161526/web.assets_backend.js:144:65)
at Object.py.evaluate (http://localhost:8069/web/content/801-4161526/web.assets_backend.js:259:8)
at Object.py.evaluate (http://localhost:8069/web/content/801-4161526/web.assets_backend.js:267:99)
at Object.py.evaluate (http://localhost:8069/web/content/801-4161526/web.assets_backend.js:268:194)
at Object.py.eval (http://localhost:8069/web/content/801-4161526/web.assets_backend.js:272:284)
at http://localhost:8069/web/content/801-4161526/web.assets_backend.js:377:110
at iterator (http://localhost:8069/web/content/800-e6de2a4/web.assets_common.js:14:183)
at Function.<anonymous> (http://localhost:8069/web/content/800-e6de2a4/web.assets_common.js:17:8)
at _.(anonymous function) [as reduce] (http://localhost:8069/web/content/800-e6de2a4/web.assets_common.js:69:526)
at eval_contexts (http://localhost:8069/web/content/801-4161526/web.assets_backend.js:375:136)
【问题讨论】:
标签: odoo-11