如何修复为用户显示的所有产品的树视图?

gwbalxhn  于 2021-07-14  发布在  Java
关注(0)|答案(1)|浏览(350)

我创建了一个表来存储一些产品信息
我需要显示在树,窗体视图产品视图。但问题是,产品向所有公司用户展示。我只想向公司用户展示产品。但它也在向其他公司用户展示。
模型

class RiceProcurement(models.Model):
    _name = 'rice.procurement'
    _description = 'Rice procurement quantity manage table'

    product_select = fields.Many2one('product.template', String='Subsidised Rice', required=True,
                                     domain="[('item_type', '=', 'rice'),"
                                            "('subsidy_type_purchase', '=', 'subsidised'),('uom_id','=',3)]")

    product_qty = fields.Float(string='Quantity (in Kg)', digits='Product Unit of Measure', required=True)
    company_id = fields.Many2one('res.company',
                                 string='Company',
                                 required=True,
                                 default=lambda self: self.env.user.company_id.id)
    supplier_id = fields.Many2one('res.partner', string='Supplier', required=True)
    date_approve = fields.Datetime('Confirmation Date', default=lambda self: fields.Datetime.now(),
                                   index=True, copy=False)

树视图

<record id="rice_procurement_tree_view" model="ir.ui.view">
        <field name="name">rice.procurement.tree.view</field>
        <field name="model">rice.procurement</field>
        <field name="arch" type="xml">
            <tree string="Rice Procurement" import="0">
                <field name="product_select" domain="[('company_id','=',company_id)]"/>
                <field name="date_approve" string="Date"/>
                <field name="product_qty" sum="Total Quantity"/>
                <field name="company_id" invisible="1"/>
            </tree>
        </field>
    </record>

红外窗口

<record id="rice_procurement_action" model="ir.actions.act_window">
            <field name="name">Rice procurement</field>
            <field name="res_model">rice.procurement</field>
            <field name="view_mode">tree,form</field>
            <field name="view_mode">list</field>
            <field name="domain">[('company_id','=',company_id)]</field>
    </record>
yc0p9oo0

yc0p9oo01#

一个记录规则已经存在,它是由odoo添加的。进入“设置”->“常规设置”,如果在“多公司”中向下滚动,可以看到两个选项,一个是“常用联系人簿”,另一个是“常用产品目录”。
默认情况下,这两个布尔字段将被勾选,在您的情况下,您可以取消勾选common product catalog。
取消勾选后,将在“设置”->“技术”->“安全”->“记录规则”中显示名为“产品多公司”的记录规则,该规则最初设置为“活动”为“假”。
请参见此文件中的规则:
参考

相关问题