Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda

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)

Avatar
Buang
Jawaban Terbai

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

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
3
Nov 24
1242
1
Apr 22
3483
2
Nov 21
7963
0
Okt 23
1529
Many2One Domain Diselesaikan
1
Jul 20
5834