15
15
# GNU Affero General Public License for more details.
17
17
# You should have received a copy of the GNU Affero General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
20
##############################################################################
37
38
'price_type': lambda *a: 'tax_excluded',
41
def refund(self, cr, uid, ids, date=None, period_id=None, description=None):
44
for old_inv_id in ids:
45
new_id = super(account_invoice,self).refund(cr, uid, ids, date=date, period_id=period_id, description=description)
47
map_old_new[old_inv_id] = new_id[0]
49
for old_inv_id in map_old_new.keys():
50
old_inv_record = self.read(cr, uid, [old_inv_id], ['price_type'])[0]['price_type']
51
self.write(cr, uid, [map_old_new[old_inv_id]], {'price_type' : old_inv_record})
41
56
class account_invoice_line(osv.osv):
71
86
res[line.id]['price_subtotal'] = cur and cur_obj.round(cr, uid, cur, res_init[line.id]) or res_init[line.id]
72
87
for tax in tax_obj.compute_inv(cr, uid, product_taxes, res_init[line.id]/line.quantity, line.quantity):
73
res[line.id]['price_subtotal'] = res[line.id]['price_subtotal'] - round(tax['amount'], int(config['price_accuracy']))
88
res[line.id]['price_subtotal'] = res[line.id]['price_subtotal'] - round(tax['amount'], self.pool.get('decimal.precision').precision_get(cr, uid, 'Account'))
75
90
res[line.id]['price_subtotal'] = cur and cur_obj.round(cr, uid, cur, res_init[line.id]) or res_init[line.id]
85
100
res[line.id]['price_subtotal'] = res[line.id]['price_subtotal'] - tax['amount']
86
101
res[line.id]['data'].append( tax)
88
res[line.id]['price_subtotal']= round(res[line.id]['price_subtotal'], int(config['price_accuracy']))
89
res[line.id]['price_subtotal_incl']= round(res[line.id]['price_subtotal_incl'], int(config['price_accuracy']))
103
res[line.id]['price_subtotal']= round(res[line.id]['price_subtotal'], self.pool.get('decimal.precision').precision_get(cr, uid, 'Account'))
104
res[line.id]['price_subtotal_incl']= round(res[line.id]['price_subtotal_incl'], self.pool.get('decimal.precision').precision_get(cr, uid, 'Account'))
92
107
def _price_unit_default(self, cr, uid, context=None):
143
158
return super(account_invoice_line, self).product_id_change_unit_price_inv(cr, uid, tax_id, price_unit, qty, address_invoice_id, product, partner_id, context=context)
145
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, context=None):
160
def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None):
146
161
# note: will call product_id_change_unit_price_inv with context...
148
# Temporary trap, for bad context that came from koo:
163
# Temporary trap, for bad context that came from koo:
149
164
# if isinstance(context, str):
150
165
# print "str context:", context
152
167
ctx = (context and context.copy()) or {}
153
168
ctx.update({'price_type': ctx.get('price_type','tax_excluded')})
154
return super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, context=ctx)
169
return super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id=currency_id, context=ctx)
155
170
account_invoice_line()
157
172
class account_invoice_tax(osv.osv):
166
181
cur_obj = self.pool.get('res.currency')
167
182
cur = inv.currency_id
168
183
company_currency = inv.company_id.currency_id.id
170
185
for line in inv.invoice_line:
171
186
data = self.pool.get('account.invoice.line')._amount_line2(cr, uid, [line.id], [], [], context)[line.id]
172
187
for tax in data['data']:
204
219
t['amount'] = cur_obj.round(cr, uid, cur, t['amount'])
205
220
t['base_amount'] = cur_obj.round(cr, uid, cur, t['base_amount'])
206
221
t['tax_amount'] = cur_obj.round(cr, uid, cur, t['tax_amount'])
208
223
return tax_grouped
209
224
account_invoice_tax()