~mga/openobject-addons/account_india

« back to all changes in this revision

Viewing changes to dm/wizard/proposition_products.py

  • Committer: Fabien Pinckaers
  • Date: 2008-11-12 05:43:45 UTC
  • mfrom: (3335.1.27 trunk-extra-addons)
  • Revision ID: fp@tinyerp.com-20081112054345-8b58ct265u3cuo7o
improvement

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
        step_ids=pool.get('dm.offer.step').search(cr, uid, [('offer_id','=',offer_id)])
67
67
        step_obj=pool.get('dm.offer.step').browse(cr, uid, step_ids)
68
68
        pprog_obj=pool.get('dm.campaign.proposition.prices_progression').browse(cr, uid, prices_prog_id)
69
 
        print "Avant : ",pprog_obj.product_ids
70
 
        if prop_obj.product_ids:
71
 
            for p in prop_obj.product_ids:
72
 
                pool.get('dm.product').unlink(cr, uid, p.id)
 
69
        if prop_obj.item_ids:
 
70
            for p in prop_obj.item_ids:
 
71
                pool.get('dm.item').unlink(cr, uid, p.id)
73
72
 
74
 
        print "Apres : ",pprog_obj.product_ids
75
73
        stp=0
76
74
 
77
75
        # Creates proposition items
78
76
        for step in step_obj:
79
 
            product_ids=pool.get('dm.step.product').search(cr, uid, [('offer_step_id','=',step.id)])
80
 
            product_obj=pool.get('dm.step.product').browse(cr, uid, product_ids)
81
 
            for product in product_obj:
82
 
                if product:
 
77
            item_ids=pool.get('dm.offer.step.item').search(cr, uid, [('offer_step_id','=',step.id)])
 
78
            item_obj=pool.get('dm.offer.step.item').browse(cr, uid, item_ids)
 
79
            for item in item_obj:
 
80
                if item:
83
81
                    if prop_obj.force_sm_price :
84
82
                        pu = prop_obj.sm_price
85
83
                    else :
86
84
                        pu = pool.get('product.pricelist').price_get(cr, uid,
87
 
                            [prop_obj.customer_pricelist_id.id], product.product_id.id,1.0,
 
85
                            [prop_obj.customer_pricelist_id.id], item.product_id.id,1.0,
88
86
                            context=context)[prop_obj.customer_pricelist_id.id]
89
87
 
90
88
                    price = pu * (1 + (stp * pprog_obj.percent_prog)) + (stp * pprog_obj.fixed_prog)
91
89
 
92
 
                    vals = {'product_id':product.product_id.id,
 
90
                    vals = {'product_id':item.product_id.id,
93
91
                            'proposition_id':data['ids'][0],
94
 
                            'item_type':product.item_type,
 
92
                            'item_type':item.item_type,
95
93
                            'price':price,
96
 
                            'offer_step_type':product.offer_step_id.type
 
94
                            'offer_step_type':item.offer_step_id.type
97
95
                            }
98
 
                    new_id=pool.get('dm.product').create(cr, uid, vals)
 
96
                    new_id=pool.get('dm.item').create(cr, uid, vals)
99
97
            stp=stp+1
100
98
 
101
99
        """
123
121
        res.sort(lambda x,y: cmp(x[1],y[1]))
124
122
        return res
125
123
 
126
 
    def _get_products(self, cr, uid, context):
127
 
        
128
 
        return {}
129
 
 
130
124
 
131
125
    def _next(self, cr, uid, data, context):
132
126
        if not data['form']['prices_progression']:
164
158
            'result': {'type': 'form', 'arch': message, 'fields':{} ,'state': [('end', 'Ok', 'gtk-ok', True)]}
165
159
        },
166
160
        }
167
 
wizard_proposition_products("wizard_proposition_products")
 
161
wizard_proposition_items("wizard_proposition_items")
168
162
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: