콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

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

아바타
취소
관련 게시물 답글 화면 활동
3
11월 24
1252
1
4월 22
3491
2
11월 21
7974
0
10월 23
1542
Many2One Domain 해결 완료
1
7월 20
5837