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

Hello,

I need to auto create a sales order (no quotation) when a sales order or a quotation is save. Therefore I created a short module, which looks like follows:

class sale_order(osv.osv):

    

    _inherit = 'sale.order'

    

    def create(self, cr, uid, vals, context=None):

        result = super(sale_order, self).create(cr, uid, vals, context=context)

        if not vals.get('order_line', '/') == '/':

            wf_service = netsvc.LocalService('workflow')

            wf_service.trg_validate(uid, 'sale.order', result, 'order_confirm', cr)

        return result

 

This works but I have one problem. My module is called when the "save" and the "update" button is used. This isn't good and I'll run this coding only if button "save" is used. So I would like to now how can I check in coding, which button is pressed? Can anybody tell me or give me an example, how can I check which button is used?

Thanks a lot!

Leo

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

On my side it doesn't work. The inherit of sale.view_order_form is working, because in the developer mode I can see the context 'update'. But in my python code I doesn't get any value with context.get('update'). Do you have any idea, why this isn't working? Must I do something else to get the value of the context? 

Thanks for helping!

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

You can use context to achieve it. Inherit sale.view_order_form and replace "update" button like this :

<button name="button_dummy" context="{'update': True}"  states="draft,sent" string="(update)" type="object" class="oe_edit_only oe_link"/>

Then in your python code you can test : if context.get('update',False):  ....

Hope it helps!

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
เม.ย. 24
1001
How to modify ''paiment'' button ? แก้ไขแล้ว
2
เม.ย. 24
1009
0
ก.พ. 24
1690
1
ธ.ค. 22
4520
1
ส.ค. 22
4976