merge
bzr revid: christophe@tinyerp.com-20081021153614-09zn819ohj12lr5d
This commit is contained in:
commit
0dd6cb8dca
|
@ -857,26 +857,11 @@ class account_invoice_line(osv.osv):
|
|||
taxep=None
|
||||
lang=self.pool.get('res.partner').read(cr, uid, [partner_id])[0]['lang']
|
||||
tax_obj = self.pool.get('account.tax')
|
||||
part = self.pool.get('res.partner').browse(cr, uid, partner_id)
|
||||
if type in ('out_invoice', 'out_refund'):
|
||||
part = self.pool.get('res.partner').browse(cr, uid, partner_id)
|
||||
taxep = part.property_account_position and part.property_account_position.account_tax
|
||||
if not taxep or not taxep.id:
|
||||
tax_id = map(lambda x: x.id, res.taxes_id)
|
||||
else:
|
||||
tax_id = [taxep.id]
|
||||
for t in res.taxes_id:
|
||||
if not t.tax_group==taxep.tax_group:
|
||||
tax_id.append(t.id)
|
||||
tax_id = self.pool.get('account.fiscal.position').map_tax(cr, uid, part, res.taxes_id)
|
||||
else:
|
||||
part = self.pool.get('res.partner').browse(cr, uid, partner_id)
|
||||
taxep = part.property_account_position and part.property_account_position.account_supplier_tax
|
||||
if not taxep or not taxep.id:
|
||||
tax_id = map(lambda x: x.id, res.supplier_taxes_id)
|
||||
else:
|
||||
tax_id = [taxep.id]
|
||||
for t in res.supplier_taxes_id:
|
||||
if not t.tax_group==taxep.tax_group:
|
||||
tax_id.append(t.id)
|
||||
tax_id = self.pool.get('account.fiscal.position').map_tax(cr, uid, part, res.supplier_taxes_id)
|
||||
if type in ('in_invoice', 'in_refund'):
|
||||
result = self.product_id_change_unit_price_inv(cr, uid, tax_id, price_unit, qty, address_invoice_id, product, partner_id, context=context)
|
||||
else:
|
||||
|
|
|
@ -37,16 +37,24 @@ class account_fiscal_position(osv.osv):
|
|||
_columns = {
|
||||
'name': fields.char('Fiscal Position', size=64, translate=True, required=True),
|
||||
'company_id': fields.many2one('res.company', 'Company'),
|
||||
'account_tax': fields.many2one(
|
||||
'account.tax', 'Customer Tax',
|
||||
help="This account will be used as the receivable account for partners in this position",
|
||||
),
|
||||
'account_supplier_tax': fields.many2one(
|
||||
'account.tax', 'Supplier Tax',
|
||||
help="This account will be used as the payable account for partners in this position",
|
||||
),
|
||||
'account_ids': fields.one2many('account.fiscal.position.account', 'position_id', 'Accounts Mapping')
|
||||
'account_ids': fields.one2many('account.fiscal.position.account', 'position_id', 'Accounts Mapping'),
|
||||
'tax_ids': fields.one2many('account.fiscal.position.tax', 'position_id', 'Taxes Mapping')
|
||||
}
|
||||
def map_tax(self, cr, uid, partner, taxes, context={}):
|
||||
if (not partner) or (not partner.property_account_position) :
|
||||
return taxes
|
||||
result = []
|
||||
for t in taxes:
|
||||
ok = False
|
||||
for tax in partner.property_account_position.tax_ids:
|
||||
if tax.tax_src_id.id==t.id:
|
||||
if tax.tax_dest_id:
|
||||
result.append(tax.tax_dest_id.id)
|
||||
ok=True
|
||||
if not ok:
|
||||
result.append(t.id)
|
||||
return result
|
||||
|
||||
def map_account(self, cr, uid, partner, account_id, context={}):
|
||||
if (not partner) or (not partner.property_account_position) :
|
||||
return account_id
|
||||
|
@ -58,6 +66,18 @@ class account_fiscal_position(osv.osv):
|
|||
account_fiscal_position()
|
||||
|
||||
|
||||
class account_fiscal_position_tax(osv.osv):
|
||||
_name = 'account.fiscal.position.tax'
|
||||
_description = 'Fiscal Position Taxes Mapping'
|
||||
_rec_name = 'position_id'
|
||||
_columns = {
|
||||
'position_id': fields.many2one('account.fiscal.position', 'Fiscal Position', required=True, ondelete='cascade'),
|
||||
'tax_src_id': fields.many2one('account.tax', 'Tax Source', required=True),
|
||||
'tax_dest_id': fields.many2one('account.tax', 'Replacement Tax')
|
||||
}
|
||||
account_fiscal_position_tax()
|
||||
|
||||
|
||||
class account_fiscal_position_account(osv.osv):
|
||||
_name = 'account.fiscal.position.account'
|
||||
_description = 'Fiscal Position Accounts Mapping'
|
||||
|
|
|
@ -11,8 +11,16 @@
|
|||
<field name="name" select="1"/>
|
||||
<field name="company_id"/>
|
||||
<newline/>
|
||||
<field name="account_tax" select="2"/>
|
||||
<field name="account_supplier_tax" select="2"/>
|
||||
<field name="tax_ids" colspan="4">
|
||||
<tree string="Taxes Mapping" editable="bottom">
|
||||
<field name="tax_src_id"/>
|
||||
<field name="tax_dest_id"/>
|
||||
</tree>
|
||||
<form string="Taxes Mapping">
|
||||
<field name="tax_src_id"/>
|
||||
<field name="tax_dest_id"/>
|
||||
</form>
|
||||
</field>
|
||||
<field name="account_ids" colspan="4">
|
||||
<tree string="Accounts Mapping" editable="bottom">
|
||||
<field name="account_src_id"/>
|
||||
|
@ -34,8 +42,6 @@
|
|||
<tree string="Fiscal Position">
|
||||
<field name="name"/>
|
||||
<field name="company_id"/>
|
||||
<field name="account_tax"/>
|
||||
<field name="account_supplier_tax"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
|
|
@ -74,6 +74,8 @@
|
|||
"access_account_account_product_manager","account.account product manager","model_account_account","product.group_product_manager",1,0,0,0
|
||||
"access_account_journal_product_manager","account.journal product manager","model_account_journal","product.group_product_manager",1,0,0,0
|
||||
"access_account_fiscal_position_product_manager","account.fiscal.position account.manager","model_account_fiscal_position","account.group_account_manager",1,1,1,1
|
||||
"access_account_fiscal_position_account_product_manager","account.fiscal.position account.manager","model_account_fiscal_position_account","account.group_account_manager",1,1,1,1
|
||||
"access_account_fiscal_position","account.fiscal.position all","model_account_fiscal_position","base.group_user",1,0,0,0
|
||||
"access_account_fiscal_position_tax_product_manager","account.fiscal.position.tax account.manager","model_account_fiscal_position_tax","account.group_account_manager",1,1,1,1
|
||||
"access_account_fiscal_position_tax","account.fiscal.position.tax all","model_account_fiscal_position_tax","base.group_user",1,0,0,0
|
||||
"access_account_fiscal_position_account_product_manager","account.fiscal.position account.manager","model_account_fiscal_position_account","account.group_account_manager",1,1,1,1
|
||||
"access_account_fiscal_position_account","account.fiscal.position all","model_account_fiscal_position_account","base.group_user",1,0,0,0
|
||||
|
|
|
|
@ -85,25 +85,13 @@ class stock_picking(osv.osv):
|
|||
|
||||
taxes = self.pool.get('account.tax').browse(cursor, user,
|
||||
[x.id for x in picking.carrier_id.product_id.taxes_id])
|
||||
taxep = None
|
||||
partner_id=picking.address_id.partner_id and picking.address_id.partner_id.id or False
|
||||
taxes_ids = [x.id for x in picking.carrier_id.product_id.taxes_id]
|
||||
if partner_id:
|
||||
print 'Found Partner'
|
||||
partner = picking.address_id.partner_id
|
||||
taxep = partner.property_account_position and partner.property_account_position.account_tax
|
||||
print account_id
|
||||
account_id = self.pool.get('account.fiscal.position').map_account(cr, uid, partner, account_id)
|
||||
print account_id
|
||||
|
||||
if not taxep or not taxep.id:
|
||||
taxes_ids = [x.id for x in picking.carrier_id.product_id.taxes_id]
|
||||
else:
|
||||
res5 = [taxep.id]
|
||||
for t in taxes:
|
||||
if not t.tax_group==taxep.tax_group:
|
||||
res5.append(t.id)
|
||||
taxes_ids = res5
|
||||
|
||||
taxes_ids = self.pool.get('account.fiscal.position').map_tax(cr, uid, partner, picking.carrier_id.product_id.taxes_id)
|
||||
|
||||
invoice_line_obj.create(cursor, user, {
|
||||
'name': picking.carrier_id.name,
|
||||
|
|
|
@ -1000,25 +1000,11 @@ class mrp_procurement(osv.osv):
|
|||
'notes':product.description_purchase,
|
||||
}
|
||||
|
||||
taxes = self.pool.get('account.tax').browse(cr, uid,
|
||||
[x.id for x in procurement.product_id.product_tmpl_id.supplier_taxes_id])
|
||||
taxep = None
|
||||
if partner_id:
|
||||
taxep = partner.property_account_position and partner.property_account_position.account_supplier_tax
|
||||
if not taxep or not taxep.id:
|
||||
taxes_ids = [x.id for x in procurement.product_id.product_tmpl_id.supplier_taxes_id]
|
||||
else:
|
||||
res5 = [taxep.id]
|
||||
for t in taxes:
|
||||
if not t.tax_group==taxep.tax_group:
|
||||
res5.append(t.id)
|
||||
taxes_ids = res5
|
||||
|
||||
taxes_ids = procurement.product_id.product_tmpl_id.supplier_taxes_id
|
||||
self.pool.get('account.fiscal.position').map_tax(cr, uid, partner, taxes)
|
||||
line.update({
|
||||
'taxes_id':[(6,0,taxes_ids)]
|
||||
})
|
||||
|
||||
|
||||
purchase_id = self.pool.get('purchase.order').create(cr, uid, {
|
||||
'origin': procurement.origin,
|
||||
'partner_id': partner_id,
|
||||
|
|
|
@ -437,20 +437,9 @@ class purchase_order_line(osv.osv):
|
|||
res = {'value': {'price_unit': price, 'name':prod_name, 'taxes_id':prod['supplier_taxes_id'], 'date_planned': dt,'notes':prod['description_purchase'], 'product_uom': uom}}
|
||||
domain = {}
|
||||
|
||||
|
||||
partner = partner_obj.browse(cr, uid, partner_id)
|
||||
taxes = self.pool.get('account.tax').browse(cr, uid,prod['supplier_taxes_id'])
|
||||
taxep = None
|
||||
if partner_id:
|
||||
partner = self.pool.get('res.partner').browse(cr, uid, partner_id)
|
||||
taxep = partner.property_account_position and partner.property_account_position.account_supplier_tax
|
||||
if not taxep or not taxep.id:
|
||||
res['value']['taxes_id'] = prod['supplier_taxes_id']
|
||||
else:
|
||||
res5 = [taxep.id]
|
||||
for t in taxes:
|
||||
if not t.tax_group==taxep.tax_group:
|
||||
res5.append(t.id)
|
||||
res['value']['taxes_id'] = res5
|
||||
res['value']['taxes_id'] = self.pool.get('account.fiscal.position').map_tax(cr, uid, partner, taxes)
|
||||
|
||||
res2 = self.pool.get('product.uom').read(cr, uid, [uom], ['category_id'])
|
||||
res3 = self.pool.get('product.uom').read(cr, uid, [prod_uom_po], ['category_id'])
|
||||
|
|
|
@ -837,20 +837,8 @@ class sale_order_line(osv.osv):
|
|||
|
||||
if update_tax: #The quantity only have changed
|
||||
result['delay'] = (product_obj.sale_delay or 0.0)
|
||||
taxes = self.pool.get('account.tax').browse(cr, uid,
|
||||
[x.id for x in product_obj.taxes_id])
|
||||
taxep = None
|
||||
if partner_id:
|
||||
partner = partner_obj.browse(cr, uid, partner_id)
|
||||
taxep = partner.property_account_position and partner.property_account_position.account_tax
|
||||
if not taxep or not taxep.id:
|
||||
result['tax_id'] = [x.id for x in product_obj.taxes_id]
|
||||
else:
|
||||
res5 = [taxep.id]
|
||||
for t in taxes:
|
||||
if not t.tax_group==taxep.tax_group:
|
||||
res5.append(t.id)
|
||||
result['tax_id'] = res5
|
||||
partner = partner_obj.browse(cr, uid, partner_id)
|
||||
result['tax_id'] = self.pool.get('account.fiscal.position').map_tax(cr, uid, partner, product_obj.taxes_id)
|
||||
|
||||
result['name'] = product_obj.partner_ref
|
||||
|
||||
|
|
Loading…
Reference in New Issue