~openerp-dev/openobject-addons/new_account_menu_structure

« back to all changes in this revision

Viewing changes to purchase/purchase.py

  • Committer: pap(openerp)
  • Date: 2010-06-16 13:35:15 UTC
  • mfrom: (3604.1.29 trunk-dev-addons3)
  • Revision ID: pap@tinyerp.co.in-20100616133515-j2t05tg2m350t0ub
[Merge]

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
            val = val1 = 0.0
60
60
            cur=order.pricelist_id.currency_id
61
61
            for line in order.order_line:
62
 
                for c in self.pool.get('account.tax').compute_all(cr, uid, line.taxes_id, line.price_unit, line.product_qty, order.partner_address_id.id, line.product_id, order.partner_id)['taxes']:
 
62
               for c in self.pool.get('account.tax').compute_all(cr, uid, line.taxes_id, line.price_unit, line.product_qty, order.partner_address_id.id, line.product_id.id, order.partner_id)['taxes']:
63
63
                    val+= c['amount']
64
 
                val1 += line.price_subtotal
 
64
                    val1 += line.price_subtotal
65
65
            res[order.id]['amount_tax']=cur_obj.round(cr, uid, cur, val)
66
66
            res[order.id]['amount_untaxed']=cur_obj.round(cr, uid, cur, val1)
67
67
            res[order.id]['amount_total']=res[order.id]['amount_untaxed'] + res[order.id]['amount_tax']
211
211
    }
212
212
    _name = "purchase.order"
213
213
    _description = "Purchase Order"
214
 
    _log_create = True
215
214
    _order = "name desc"
216
215
 
217
216
    def unlink(self, cr, uid, ids, context=None):
259
258
 
260
259
    def wkf_approve_order(self, cr, uid, ids, context={}):
261
260
        self.write(cr, uid, ids, {'state': 'approved', 'date_approve': time.strftime('%Y-%m-%d')})
 
261
        for (id,name) in self.name_get(cr, uid, ids):
 
262
                message = _('Purchase order ') + " '" + name + "' "+_("is approved by the supplier")
 
263
                self.log(cr, uid, id, message)
262
264
        return True
263
265
 
264
266
    #TODO: implement messages system
265
267
    def wkf_confirm_order(self, cr, uid, ids, context={}):
 
268
        product = []
266
269
        todo = []
267
270
        for po in self.browse(cr, uid, ids):
268
271
            if not po.order_line:
274
277
        self.pool.get('purchase.order.line').action_confirm(cr, uid, todo, context)
275
278
        for id in ids:
276
279
            self.write(cr, uid, [id], {'state' : 'confirmed', 'validator' : uid})
 
280
            for line in po.order_line:
 
281
                product.append(line.product_id.default_code or '')
 
282
                params = ', '.join(map(lambda x : str(x), product))
 
283
            message = _('Purchase order ') + " '" + po.name + "' "+_('placed on')+ " '" + po.date_order + "' "+_('for')+" '" + params + "' "+ _("is confirmed")
 
284
            self.log(cr, uid, id, message)
277
285
        return True
278
286
 
279
287
    def wkf_warn_buyer(self, cr, uid, ids):
315
323
            # Deleting the existing instance of workflow for PO
316
324
            wf_service.trg_delete(uid, 'purchase.order', p_id, cr)
317
325
            wf_service.trg_create(uid, 'purchase.order', p_id, cr)
 
326
        for (id,name) in self.name_get(cr, uid, ids):
 
327
                message = _('Purchase order') + " '" + name + "' "+ _("is in the draft state")
 
328
                self.log(cr, uid, id, message)
318
329
        return True
319
330
 
320
331
    def action_invoice_create(self, cr, uid, ids, *args):
394
405
                wf_service = netsvc.LocalService("workflow")
395
406
                wf_service.trg_validate(uid, 'account.invoice', inv.id, 'invoice_cancel', cr)
396
407
        self.write(cr,uid,ids,{'state':'cancel'})
 
408
        message = _('Purchase order ') + " '" + purchase.name + "' "+ _("is cancelled")
 
409
        self.log(cr, uid, id, message)
397
410
        return True
398
411
 
399
412
    def action_picking_create(self,cr, uid, ids, *args):
695
708
        return res
696
709
    def action_confirm(self, cr, uid, ids, context={}):
697
710
        self.write(cr, uid, ids, {'state': 'confirmed'}, context)
 
711
        for (id,name) in self.name_get(cr, uid, ids):
 
712
            message = _('Purchase order line') + " '" + name + "' "+ _("is confirmed")
 
713
            self.log(cr, uid, id, message)
698
714
        return True
699
715
purchase_order_line()
700
716