~openerp-commiter/openobject-addons/trunk-addons-fixes

« back to all changes in this revision

Viewing changes to sale/stock.py

  • Committer: DHS(OpenERP)
  • Date: 2010-10-26 07:16:33 UTC
  • mfrom: (4280.1.186 openobject-addons)
  • Revision ID: dhs@tinyerp.com-20101026071633-v9t8xjhwx71i4zwo
[MERGE] Merged main branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
116
116
        result = super(stock_picking, self).action_invoice_create(cursor, user,
117
117
                ids, journal_id=journal_id, group=group, type=type,
118
118
                context=context)
119
 
 
120
119
        picking_ids = result.keys()
121
120
        invoice_ids = result.values()
122
 
 
123
121
        invoices = {}
124
122
        for invoice in invoice_obj.browse(cursor, user, invoice_ids,
125
123
                context=context):
127
125
 
128
126
        for picking in picking_obj.browse(cursor, user, picking_ids,
129
127
                context=context):
130
 
 
131
128
            if not picking.sale_id:
132
129
                continue
133
130
            sale_lines = picking.sale_id.order_line
134
131
            invoice_created = invoices[result[picking.id]]
135
 
 
136
132
            for inv in invoice_obj.browse(cursor, user, [invoice_created.id], context=context):
137
133
                if not inv.fiscal_position:
138
134
                    invoice_obj.write(cursor, user, [inv.id], {'fiscal_position': picking.sale_id.fiscal_position.id}, context=context)
139
 
 
140
135
            if picking.sale_id.client_order_ref:
141
136
                inv_name = picking.sale_id.client_order_ref + " : " + invoice_created.name
142
137
                invoice_obj.write(cursor, user, [invoice_created.id], {'name': inv_name}, context=context)
143
 
 
144
138
            for sale_line in sale_lines:
145
139
                if sale_line.product_id.type == 'service' and sale_line.invoiced == False:
146
140
                    if group:
182
176
                        'account_analytic_id': account_analytic_id,
183
177
                        'notes':sale_line.notes
184
178
                    }, context=context)
185
 
                    self.pool.get('sale.order.line').write(cursor, user, [sale_line.id], {'invoiced':True,
 
179
                    self.pool.get('sale.order.line').write(cursor, user, [sale_line.id], {'invoiced': True,
186
180
                        'invoice_lines': [(6, 0, [invoice_line_id])],
187
181
                    })
188
 
 
189
182
        return result
190
183
 
191
184
    def action_cancel(self, cr, uid, ids, context={}):
194
187
            call_ship_end = True
195
188
            if pick.sale_id:
196
189
                for picks in pick.sale_id.picking_ids:
197
 
                    if picks.state not in ('done','cancel'):
 
190
                    if picks.state not in ('done', 'cancel'):
198
191
                        call_ship_end = False
199
192
                        break
200
193
                if call_ship_end: