~vauxoo/addons-vauxoo/rico_contract_fix_email_and_more_dev_ernesto

« back to all changes in this revision

Viewing changes to account_analytic_analysis_rent/wizard/lines_invoice_create.py

  • Committer: Rodo
  • Date: 2013-08-02 22:27:05 UTC
  • Revision ID: rodo@vauxoo.com-20130802222705-1pgk8quq4km89apk
[IMP][account_analytic_account_rent] add counter in feature, add warning in product-prodlot

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
        fiscal_pos_obj = self.pool.get('account.fiscal.position')
50
50
        product_uom_obj = self.pool.get('product.uom')
51
51
        invoice_line_obj = self.pool.get('account.invoice.line')
 
52
        feature_line_obj = self.pool.get('product.feature.line')
52
53
        invoices = []
53
54
        if context is None:
54
55
            context = {}
96
97
            invoices.append(last_invoice)
97
98
            context2 = context.copy()
98
99
            context2['lang'] = partner.lang
99
 
            cr.execute("SELECT product_id, to_invoice, unit_amount, product_uom_id, w_start, w_end, name, amount " \
 
100
            cr.execute("SELECT product_id, to_invoice, unit_amount, product_uom_id, w_start, w_end, name, amount, feature_id " \
100
101
                    "FROM account_analytic_line as line " \
101
102
                    "WHERE account_id = %s " \
102
103
                        "AND id IN %s AND to_invoice IS NOT NULL " , (account.id, tuple(ids),))
103
104
 
104
 
            for product_id, factor_id, qty, uom, w_start, w_end, name, amount in cr.fetchall():
 
105
            for product_id, factor_id, qty, uom, w_start, w_end, name, amount, feature_id in cr.fetchall():
105
106
                product = product_obj.browse(cr, uid, product_id, context2)
106
107
                if not product:
107
108
                    raise osv.except_osv(_('Error'), _('At least one line has no product !'))
114
115
                    pl = account.pricelist_id.id
115
116
                    price = pro_price_obj.price_get(cr,uid,[pl], product_id or data.get('product', False), qty or 1.0, account.partner_id.id, context=ctx)[pl]
116
117
                else:
117
 
                    print 'por eso sale en cero'
118
118
                    price = 0.0
119
119
 
120
120
                taxes = product.taxes_id
134
134
                    'uos_id': uom,
135
135
                    'account_id': account_id,
136
136
                    'account_analytic_id': account.id,
137
 
                    'w_start': w_start,
138
 
                    'w_end': w_end,
 
137
                    'w_start': int(w_start or 0),
 
138
                    'w_end': int(w_end or 0),
139
139
                }
140
 
 
 
140
                feature_line_obj.write(cr, uid, feature_id, {'counter': int(w_end or 0)}, context=context)
141
141
                #
142
142
                # Compute for lines
143
143
                #
188
188
        res = super(lines_create, self).default_get(
189
189
            cr, uid, fields, context=context)
190
190
        analytic_obj = self.pool.get('account.analytic.account')
 
191
        product_obj = self.pool.get('product.product')
191
192
        line_obj = self.pool.get('account.analytic.line')
192
193
        lines_ids=[]
193
194
        if context.get('active_model') == 'account.analytic.account':
218
219
                    date_line=datetime.strptime(line.date, "%Y-%m-%d")
219
220
                    #~ date_new=datetime.strptime(month, "%Y-%m-%d")
220
221
                    if str(month)==str(date_line.month):
 
222
                        for feature in contract.feature_ids:
 
223
                                if feature.id==line.feature_id.id:
 
224
                                    line_obj.write(cr, uid, line.id, {'w_start':feature.counter}, context=context)
221
225
                        lines_ids.append(line.id)
222
226
        res['value']={'line_ids':lines_ids}
223
227
        return res