Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
1739 มุมมอง

in so_custom.py :

class SaleOrder(models.Model):
​_inherit = 'sale.order'
​workorder_ids = fields.One2many(comodel_name='mrp.workorder', inverse_name='sale_id', string="Workorder List")
​manufacture_order_ids = fields.One2many(comodel_name='mrp.production', ​inverse_name='sale_id', string="Manufacture Order List")
​is_customer_approve_online = fields.Boolean(related='workorder_ids.checklist_is_customer_approve_online')

    

how to adding for 'is_customer_approve_online' field, with the condition 'checklist_is_customer_approve_online' is true and workorder_ids.name != "Proofing" (I want excepting the workorder_list for the 'name' is "Proofing)

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,


Here we can add a compute function to the 'is_customer_approve_online' boolean field based on your mentioned condition. Then we can add the field in filters by inheriting the sale.order search view.


.py

is_customer_approve_online = fields.Boolean(
    string="Is Customer Approve Online",

compute='_compute_is_customer_approve_online',

store=True
)

@api.depends('workorder_ids.checklist_is_customer_approve_online', 'http://workorder_ids.name" rel="noopener nofollow noreferrer" target="_blank">workorder_ids.name')
def _compute_is_customer_approve_online(self):

for order in self:

for workorder in order.workorder_ids:

if workorder.checklist_is_customer_approve_online and http://workorder.name" rel="noopener nofollow noreferrer" target="_blank">workorder.name != 'Proofing':

order.is_customer_approve_online = True
            else:

order.is_customer_approve_online = False
                break


.XML

<record id="view_sale_order_tree_custom" model="ir.ui.view">
    <field name="name">sale.order.tree.custom</field>
    <field name="model">sale.order</field>
    <field name="inherit_id" ref="sale.view_sales_order_filter"/>
    <field name="arch" type="xml">
        <filter name="my_sale_orders_filter" position="after">
            <separator/>
            <filter name="is_customer_approve_online_filter"
                    string="Customer Approve Online"
                    domain="[('is_customer_approve_online', '=', True)]"/>
        </filter>
    </field>
</record>



Hope it helps

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
3
พ.ย. 24
1245
"THIS YEAR" FILTER STUDIO แก้ไขแล้ว
1
เม.ย. 22
3483
2
พ.ย. 21
7966
0
ต.ค. 23
1529
Many2One Domain แก้ไขแล้ว
1
ก.ค. 20
5835