تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
1215 أدوات العرض

Hello

Here is my problem, in the Sale order line, I have a field called design, this design consists of some fields that the user should fill and they are related to the selected design

I want to make something like when selecting the design, these related fields, which are selection fields, in a way that the sale order can't be saved without filling them for every sale order line

how can I redirect to a wizard or other form once this design is selected



الصورة الرمزية
إهمال
أفضل إجابة

Hi,

To achieve this, you can create a wizard that will be triggered when a design is selected in the Sale Order line.

By adding the following code in your sale order model it will return a wizard that you created:@api.onchange('product_id')

    def _onchange_product_id(self):

        if self.product_id.design:

            return {

                'name': 'Design Details',

                'view_mode': 'form',

                'res_model': 'sale.order.design.wizard',

                'target': 'new',

                'type': 'ir.actions.act_window',

                'context': {'default_sale_order_line_id': self.id},

            }

For checking constraints use the following code:

@api.constrains('design_field_1', 'design_field_2')

    def _check_design_fields(self):

        for line in self:

            if line.product_id.design and (not line.design_field_1 or not line.design_field_2):

                raise ValidationError('You must fill in all design fields for the selected design.')


For creating wizard, go through the link below mentioned:

https://www.cybrosys.com/blog/how-to-create-and-manage-wizard-in-odoo-17


Hope it helps.

الصورة الرمزية
إهمال
الكاتب

'context': {'default_sale_order_line_id': self.id},

if the sale order is not created or even the sol, then there is no id to pass
also I searched and I am not able to redirect and open a wizard in an onchange function
and I tried it to make sure but no wizard appears

المنشورات ذات الصلة الردود أدوات العرض النشاط
1
يناير 25
3498
2
أغسطس 24
5884
6
ديسمبر 22
8870
1
مايو 25
6158
0
مارس 24
2255