[IMP]account: remove address_id form compute_all
bzr revid: sbh@tinyerp.com-20120329124138-isbvzt8z4drn7fwn
This commit is contained in:
parent
4094f53f77
commit
d9359aacfb
|
@ -2060,7 +2060,7 @@ class account_tax(osv.osv):
|
|||
cur_price_unit+=amount2
|
||||
return res
|
||||
|
||||
def compute_all(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None, force_excluded=False):
|
||||
def compute_all(self, cr, uid, taxes, price_unit, quantity, product=None, partner=None, force_excluded=False):
|
||||
"""
|
||||
:param force_excluded: boolean used to say that we don't want to consider the value of field price_include of
|
||||
tax. It's used in encoding by line where you don't matter if you encoded a tax with that boolean to True or
|
||||
|
@ -2080,7 +2080,7 @@ class account_tax(osv.osv):
|
|||
tex.append(tax)
|
||||
else:
|
||||
tin.append(tax)
|
||||
tin = self.compute_inv(cr, uid, tin, price_unit, quantity, address_id=address_id, product=product, partner=partner)
|
||||
tin = self.compute_inv(cr, uid, tin, price_unit, quantity, product=product, partner=partner)
|
||||
for r in tin:
|
||||
totalex -= r.get('amount', 0.0)
|
||||
totlex_qty = 0.0
|
||||
|
@ -2088,7 +2088,7 @@ class account_tax(osv.osv):
|
|||
totlex_qty = totalex/quantity
|
||||
except:
|
||||
pass
|
||||
tex = self._compute(cr, uid, tex, totlex_qty, quantity, address_id=address_id, product=product, partner=partner)
|
||||
tex = self._compute(cr, uid, tex, totlex_qty, quantity,product=product, partner=partner)
|
||||
for r in tex:
|
||||
totalin += r.get('amount', 0.0)
|
||||
return {
|
||||
|
@ -2097,13 +2097,13 @@ class account_tax(osv.osv):
|
|||
'taxes': tin + tex
|
||||
}
|
||||
|
||||
def compute(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None):
|
||||
def compute(self, cr, uid, taxes, price_unit, quantity, product=None, partner=None):
|
||||
logger = netsvc.Logger()
|
||||
logger.notifyChannel("warning", netsvc.LOG_WARNING,
|
||||
"Deprecated, use compute_all(...)['taxes'] instead of compute(...) to manage prices with tax included")
|
||||
return self._compute(cr, uid, taxes, price_unit, quantity, address_id, product, partner)
|
||||
|
||||
def _compute(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None):
|
||||
def _compute(self, cr, uid, taxes, price_unit, quantity,product=None, partner=None):
|
||||
"""
|
||||
Compute tax values for given PRICE_UNIT, QUANTITY and a buyer/seller ADDRESS_ID.
|
||||
|
||||
|
@ -2112,7 +2112,7 @@ class account_tax(osv.osv):
|
|||
tax = {'name':'', 'amount':0.0, 'account_collected_id':1, 'account_paid_id':2}
|
||||
one tax for each tax id in IDS and their children
|
||||
"""
|
||||
res = self._unit_compute(cr, uid, taxes, price_unit, address_id, product, partner, quantity)
|
||||
res = self._unit_compute(cr, uid, taxes, price_unit, product, partner, quantity)
|
||||
total = 0.0
|
||||
precision_pool = self.pool.get('decimal.precision')
|
||||
for r in res:
|
||||
|
@ -2123,8 +2123,8 @@ class account_tax(osv.osv):
|
|||
total += r['amount']
|
||||
return res
|
||||
|
||||
def _unit_compute_inv(self, cr, uid, taxes, price_unit, address_id=None, product=None, partner=None):
|
||||
taxes = self._applicable(cr, uid, taxes, price_unit, address_id, product, partner)
|
||||
def _unit_compute_inv(self, cr, uid, taxes, price_unit, product=None, partner=None):
|
||||
taxes = self._applicable(cr, uid, taxes, price_unit, product, partner)
|
||||
obj_partener_address = self.pool.get('res.partner')
|
||||
res = []
|
||||
taxes.reverse()
|
||||
|
@ -2150,8 +2150,7 @@ class account_tax(osv.osv):
|
|||
amount = tax.amount
|
||||
|
||||
elif tax.type=='code':
|
||||
address = address_id and obj_partener_address.browse(cr, uid, address_id) or None
|
||||
localdict = {'price_unit':cur_price_unit, 'address':address, 'product':product, 'partner':partner}
|
||||
localdict = {'price_unit':cur_price_unit, 'product':product, 'partner':partner}
|
||||
exec tax.python_compute_inv in localdict
|
||||
amount = localdict['result']
|
||||
elif tax.type=='balance':
|
||||
|
@ -2185,7 +2184,7 @@ class account_tax(osv.osv):
|
|||
del res[-1]
|
||||
amount = price_unit
|
||||
|
||||
parent_tax = self._unit_compute_inv(cr, uid, tax.child_ids, amount, address_id, product, partner)
|
||||
parent_tax = self._unit_compute_inv(cr, uid, tax.child_ids, amount, product, partner)
|
||||
res.extend(parent_tax)
|
||||
|
||||
total = 0.0
|
||||
|
@ -2197,7 +2196,7 @@ class account_tax(osv.osv):
|
|||
r['todo'] = 0
|
||||
return res
|
||||
|
||||
def compute_inv(self, cr, uid, taxes, price_unit, quantity, address_id=None, product=None, partner=None):
|
||||
def compute_inv(self, cr, uid, taxes, price_unit, quantity, product=None, partner=None):
|
||||
"""
|
||||
Compute tax values for given PRICE_UNIT, QUANTITY and a buyer/seller ADDRESS_ID.
|
||||
Price Unit is a VAT included price
|
||||
|
@ -2207,7 +2206,7 @@ class account_tax(osv.osv):
|
|||
tax = {'name':'', 'amount':0.0, 'account_collected_id':1, 'account_paid_id':2}
|
||||
one tax for each tax id in IDS and their children
|
||||
"""
|
||||
res = self._unit_compute_inv(cr, uid, taxes, price_unit, address_id, product, partner=None)
|
||||
res = self._unit_compute_inv(cr, uid, taxes, price_unit, product, partner=None)
|
||||
total = 0.0
|
||||
obj_precision = self.pool.get('decimal.precision')
|
||||
for r in res:
|
||||
|
|
|
@ -70,12 +70,12 @@ class mrp_repair(osv.osv):
|
|||
for line in repair.operations:
|
||||
#manage prices with tax included use compute_all instead of compute
|
||||
if line.to_invoice:
|
||||
tax_calculate = tax_obj.compute_all(cr, uid, line.tax_id, line.price_unit, line.product_uom_qty, repair.partner_invoice_id.id, line.product_id, repair.partner_id)
|
||||
tax_calculate = tax_obj.compute_all(cr, uid, line.tax_id, line.price_unit, line.product_uom_qty, line.product_id, repair.partner_id)
|
||||
for c in tax_calculate['taxes']:
|
||||
val += c['amount']
|
||||
for line in repair.fees_lines:
|
||||
if line.to_invoice:
|
||||
tax_calculate = tax_obj.compute_all(cr, uid, line.tax_id, line.price_unit, line.product_uom_qty, repair.partner_invoice_id.id, line.product_id, repair.partner_id)
|
||||
tax_calculate = tax_obj.compute_all(cr, uid, line.tax_id, line.price_unit, line.product_uom_qty, line.product_id, repair.partner_id)
|
||||
for c in tax_calculate['taxes']:
|
||||
val += c['amount']
|
||||
res[repair.id] = cur_obj.round(cr, uid, cur, val)
|
||||
|
@ -683,7 +683,7 @@ class mrp_repair_line(osv.osv, ProductChangeMixin):
|
|||
location_id = location_id and location_id[0] or False
|
||||
|
||||
if type == 'add':
|
||||
# TOCHECK: Find stock location for user's company warehouse or
|
||||
# TOCHECK: Find stock location for user's company warehouse or
|
||||
# repair order's company's warehouse (company_id field is added in fix of lp:831583)
|
||||
args = company_id and [('company_id', '=', company_id)] or []
|
||||
warehouse_ids = warehouse_obj.search(cr, uid, args, context=context)
|
||||
|
|
|
@ -49,7 +49,7 @@ class purchase_order(osv.osv):
|
|||
cur = order.pricelist_id.currency_id
|
||||
for line in order.order_line:
|
||||
val1 += line.price_subtotal
|
||||
for c in self.pool.get('account.tax').compute_all(cr, uid, line.taxes_id, line.price_unit, line.product_qty, order.partner_id.id, line.product_id.id, order.partner_id)['taxes']:
|
||||
for c in self.pool.get('account.tax').compute_all(cr, uid, line.taxes_id, line.price_unit, line.product_qty, line.product_id.id, order.partner_id)['taxes']:
|
||||
val += c.get('amount', 0.0)
|
||||
res[order.id]['amount_tax']=cur_obj.round(cr, uid, cur, val)
|
||||
res[order.id]['amount_untaxed']=cur_obj.round(cr, uid, cur, val1)
|
||||
|
@ -161,7 +161,7 @@ class purchase_order(osv.osv):
|
|||
'date_order':fields.date('Order Date', required=True, states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)]}, select=True, help="Date on which this document has been created."),
|
||||
'date_approve':fields.date('Date Approved', readonly=1, select=True, help="Date on which purchase order has been approved"),
|
||||
'partner_id':fields.many2one('res.partner', 'Supplier', required=True, states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)],'done':[('readonly',True)]}, change_default=True),
|
||||
'dest_address_id':fields.many2one('res.partner', 'Destination Address', domain="[('parent_id','=',partner_id)]",
|
||||
'dest_address_id':fields.many2one('res.partner', 'Destination Address', domain="[('parent_id','=',partner_id)]",
|
||||
states={'confirmed':[('readonly',True)], 'approved':[('readonly',True)],'done':[('readonly',True)]},
|
||||
help="Put an address if you want to deliver directly from the supplier to the customer." \
|
||||
"In this case, it will remove the warehouse link and set the customer location."
|
||||
|
@ -292,7 +292,7 @@ class purchase_order(osv.osv):
|
|||
return True
|
||||
|
||||
def _prepare_inv_line(self, cr, uid, account_id, order_line, context=None):
|
||||
"""Collects require data from purchase order line that is used to create invoice line
|
||||
"""Collects require data from purchase order line that is used to create invoice line
|
||||
for that purchase order line
|
||||
:param account_id: Expense account of the product of PO line if any.
|
||||
:param browse_record order_line: Purchase order line browse record
|
||||
|
@ -374,7 +374,7 @@ class purchase_order(osv.osv):
|
|||
'partner_id': order.partner_id.id,
|
||||
'currency_id': order.pricelist_id.currency_id.id,
|
||||
'journal_id': len(journal_ids) and journal_ids[0] or False,
|
||||
'invoice_line': [(6, 0, inv_lines)],
|
||||
'invoice_line': [(6, 0, inv_lines)],
|
||||
'origin': order.name,
|
||||
'fiscal_position': order.fiscal_position.id or order.partner_id.property_account_position.id,
|
||||
'payment_term': order.partner_id.property_payment_term and order.partner_id.property_payment_term.id or False,
|
||||
|
@ -415,7 +415,7 @@ class purchase_order(osv.osv):
|
|||
if inv:
|
||||
wf_service.trg_validate(uid, 'account.invoice', inv.id, 'invoice_cancel', cr)
|
||||
self.write(cr,uid,ids,{'state':'cancel'})
|
||||
|
||||
|
||||
for (id, name) in self.name_get(cr, uid, ids):
|
||||
wf_service.trg_validate(uid, 'purchase.order', id, 'purchase_cancel', cr)
|
||||
message = _("Purchase order '%s' is cancelled.") % name
|
||||
|
@ -434,7 +434,7 @@ class purchase_order(osv.osv):
|
|||
'company_id': order.company_id.id,
|
||||
'move_lines' : [],
|
||||
}
|
||||
|
||||
|
||||
def _prepare_order_line_move(self, cr, uid, order, order_line, picking_id, context=None):
|
||||
return {
|
||||
'name': order.name + ': ' + (order_line.name or ''),
|
||||
|
@ -475,7 +475,7 @@ class purchase_order(osv.osv):
|
|||
will be added. A new picking will be created if omitted.
|
||||
:return: list of IDs of pickings used/created for the given order lines (usually just one)
|
||||
"""
|
||||
if not picking_id:
|
||||
if not picking_id:
|
||||
picking_id = self.pool.get('stock.picking').create(cr, uid, self._prepare_order_picking(cr, uid, order, context=context))
|
||||
todo_moves = []
|
||||
stock_move = self.pool.get('stock.move')
|
||||
|
@ -727,7 +727,7 @@ class purchase_order_line(osv.osv):
|
|||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
|
||||
res = {'value': {'price_unit': price_unit or 0.0, 'name': name or '', 'notes': notes or '', 'product_uom' : uom_id or False}}
|
||||
if not product_id:
|
||||
return res
|
||||
|
@ -751,7 +751,7 @@ class purchase_order_line(osv.osv):
|
|||
context_partner = {'lang': lang, 'partner_id': partner_id}
|
||||
product = product_product.browse(cr, uid, product_id, context=context_partner)
|
||||
res['value'].update({'name': product.name, 'notes': notes or product.description_purchase})
|
||||
|
||||
|
||||
# - set a domain on product_uom
|
||||
res['domain'] = {'product_uom': [('category_id','=',product.uom_id.category_id.id)]}
|
||||
|
||||
|
@ -759,7 +759,7 @@ class purchase_order_line(osv.osv):
|
|||
product_uom_po_id = product.uom_po_id.id
|
||||
if not uom_id:
|
||||
uom_id = product_uom_po_id
|
||||
|
||||
|
||||
if product.uom_id.category_id.id != product_uom.browse(cr, uid, uom_id, context=context).category_id.id:
|
||||
res['warning'] = {'title': _('Warning'), 'message': _('Selected UOM does not belong to the same category as the product UOM')}
|
||||
uom_id = product_uom_po_id
|
||||
|
@ -789,7 +789,7 @@ class purchase_order_line(osv.osv):
|
|||
# - determine price_unit and taxes_id
|
||||
price = product_pricelist.price_get(cr, uid, [pricelist_id],
|
||||
product.id, qty or 1.0, partner_id, {'uom': uom_id, 'date': date_order})[pricelist_id]
|
||||
|
||||
|
||||
taxes = account_tax.browse(cr, uid, map(lambda x: x.id, product.supplier_taxes_id))
|
||||
fpos = fiscal_position_id and account_fiscal_position.browse(cr, uid, fiscal_position_id, context=context) or False
|
||||
taxes_ids = account_fiscal_position.map_tax(cr, uid, fpos, taxes)
|
||||
|
|
|
@ -65,7 +65,7 @@ class sale_order(osv.osv):
|
|||
|
||||
def _amount_line_tax(self, cr, uid, line, context=None):
|
||||
val = 0.0
|
||||
for c in self.pool.get('account.tax').compute_all(cr, uid, line.tax_id, line.price_unit * (1-(line.discount or 0.0)/100.0), line.product_uom_qty, line.order_id.partner_invoice_id.id, line.product_id, line.order_id.partner_id)['taxes']:
|
||||
for c in self.pool.get('account.tax').compute_all(cr, uid, line.tax_id, line.price_unit * (1-(line.discount or 0.0)/100.0), line.product_uom_qty, line.product_id, line.order_id.partner_id)['taxes']:
|
||||
val += c.get('amount', 0.0)
|
||||
return val
|
||||
|
||||
|
@ -784,7 +784,7 @@ class sale_order(osv.osv):
|
|||
return True
|
||||
|
||||
def _get_date_planned(self, cr, uid, order, line, start_date, context=None):
|
||||
date_planned = datetime.strptime(start_date, DEFAULT_SERVER_DATE_FORMAT) + relativedelta(days=line.delay or 0.0)
|
||||
date_planned = datetime.strptime(start_date, DEFAULT_SERVER_DATE_FORMAT) + relativedelta(days=line.delay or 0.0)
|
||||
date_planned = (date_planned - timedelta(days=order.company_id.security_lead)).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
return date_planned
|
||||
|
||||
|
@ -920,7 +920,7 @@ class sale_order_line(osv.osv):
|
|||
context = {}
|
||||
for line in self.browse(cr, uid, ids, context=context):
|
||||
price = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
|
||||
taxes = tax_obj.compute_all(cr, uid, line.tax_id, price, line.product_uom_qty, line.order_id.partner_invoice_id.id, line.product_id, line.order_id.partner_id)
|
||||
taxes = tax_obj.compute_all(cr, uid, line.tax_id, price, line.product_uom_qty, line.product_id, line.order_id.partner_id)
|
||||
cur = line.order_id.pricelist_id.currency_id
|
||||
res[line.id] = cur_obj.round(cr, uid, cur, taxes['total'])
|
||||
return res
|
||||
|
|
Loading…
Reference in New Issue