Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
1728 Lượt xem

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)

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 11 24
1242
1
thg 4 22
3483
2
thg 11 21
7963
0
thg 10 23
1529
Many2One Domain Đã xử lý
1
thg 7 20
5834