@@ -1874,6 +1874,7 @@ class account_fiscal_position_template(osv.osv):
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Fiscal Position Template', size=64, translate=True, required=True),
|
||||
'chart_template_id': fields.many2one('account.chart.template', 'Chart Template', required=True),
|
||||
'account_ids': fields.one2many('account.fiscal.position.account.template', 'position_id', 'Accounts Mapping'),
|
||||
'tax_ids': fields.one2many('account.fiscal.position.tax.template', 'position_id', 'Taxes Mapping')
|
||||
}
|
||||
@@ -2153,7 +2154,7 @@ class wizard_multi_charts_accounts(osv.osv_memory):
|
||||
#create the property
|
||||
property_obj.create(cr, uid, vals)
|
||||
|
||||
fp_ids = obj_fiscal_position_template.search(cr, uid,[])
|
||||
fp_ids = obj_fiscal_position_template.search(cr, uid,[('chart_template_id', '=', obj_multi.chart_template_id.id)])
|
||||
|
||||
if fp_ids:
|
||||
for position in obj_fiscal_position_template.browse(cr, uid, fp_ids):
|
||||
|
||||
@@ -91,7 +91,6 @@ class account_move_line(osv.osv):
|
||||
def _default_get(self, cr, uid, fields, context={}):
|
||||
# Compute simple values
|
||||
data = super(account_move_line, self).default_get(cr, uid, fields, context)
|
||||
|
||||
# Starts: Manual entry from account.move form
|
||||
if context.get('lines',[]):
|
||||
|
||||
@@ -114,8 +113,11 @@ class account_move_line(osv.osv):
|
||||
account = journal_obj.default_debit_account_id
|
||||
|
||||
|
||||
if account and ((not fields) or ('debit' in fields) or ('credit' in fields)):
|
||||
data['account_id'] = account.id
|
||||
if account and ((not fields) or ('debit' in fields) or ('credit' in fields)) and 'partner_id' in data:
|
||||
part = self.pool.get('res.partner').browse(cr, uid, data['partner_id'])
|
||||
account = self.pool.get('account.fiscal.position').map_account(cr, uid, part, account.id)
|
||||
account = self.pool.get('account.account').browse(cr, uid, account)
|
||||
data['account_id'] = account.id
|
||||
|
||||
s = -total_new
|
||||
data['debit'] = s>0 and s or 0.0
|
||||
@@ -170,15 +172,15 @@ class account_move_line(osv.osv):
|
||||
total = 0
|
||||
ref_id = False
|
||||
move = self.pool.get('account.move').browse(cr, uid, move_id, context)
|
||||
|
||||
if 'name' in fields:
|
||||
data.setdefault('name', move.line_id[-1].name)
|
||||
acc1 = False
|
||||
for l in move.line_id:
|
||||
acc1 = l.account_id
|
||||
partner_id = partner_id or l.partner_id.id
|
||||
ref_id = ref_id or l.ref
|
||||
total += (l.debit or 0.0) - (l.credit or 0.0)
|
||||
if 'name' in fields:
|
||||
data.setdefault('name', l.name)
|
||||
|
||||
if 'ref' in fields:
|
||||
data['ref'] = ref_id
|
||||
if 'partner_id' in fields:
|
||||
@@ -195,11 +197,16 @@ class account_move_line(osv.osv):
|
||||
else:
|
||||
account = move.journal_id.default_debit_account_id
|
||||
|
||||
part = self.pool.get('res.partner').browse(cr, uid, partner_id)
|
||||
account = self.pool.get('account.fiscal.position').map_account(cr, uid, part, account.id)
|
||||
account = self.pool.get('account.account').browse(cr, uid, account)
|
||||
|
||||
if account and ((not fields) or ('debit' in fields) or ('credit' in fields)):
|
||||
data['account_id'] = account.id
|
||||
# Propose the price VAT excluded, the VAT will be added when confirming line
|
||||
if account.tax_ids:
|
||||
tax = account.tax_ids
|
||||
taxes = self.pool.get('account.fiscal.position').map_tax(cr, uid, part, account.tax_ids)
|
||||
tax = self.pool.get('account.tax').browse(cr, uid, taxes)
|
||||
for t in self.pool.get('account.tax').compute_inv(cr, uid, tax, total, 1):
|
||||
total -= t['amount']
|
||||
|
||||
@@ -465,19 +472,27 @@ class account_move_line(osv.osv):
|
||||
if journal:
|
||||
jt = self.pool.get('account.journal').browse(cr, uid, journal).type
|
||||
if jt=='sale':
|
||||
val['account_id'] = id2
|
||||
val['account_id'] = self.pool.get('account.fiscal.position').map_account(cr, uid, part, id2)
|
||||
|
||||
elif jt=='purchase':
|
||||
val['account_id'] = id1
|
||||
val['account_id'] = self.pool.get('account.fiscal.position').map_account(cr, uid, part, id1)
|
||||
if val.get('account_id', False):
|
||||
d = self.onchange_account_id(cr, uid, ids, val['account_id'])
|
||||
val.update(d['value'])
|
||||
|
||||
return {'value':val}
|
||||
|
||||
def onchange_account_id(self, cr, uid, ids, account_id=False):
|
||||
def onchange_account_id(self, cr, uid, ids, account_id=False, partner_id=False):
|
||||
val = {}
|
||||
if account_id:
|
||||
tax_ids = self.pool.get('account.account').browse(cr, uid, account_id).tax_ids
|
||||
val['account_tax_id'] = tax_ids and tax_ids[0].id or False
|
||||
res = self.pool.get('account.account').browse(cr, uid, account_id)
|
||||
tax_ids = res.tax_ids
|
||||
if tax_ids and partner_id:
|
||||
part = self.pool.get('res.partner').browse(cr, uid, partner_id)
|
||||
tax_id = self.pool.get('account.fiscal.position').map_tax(cr, uid, part, tax_ids)[0]
|
||||
else:
|
||||
tax_id = tax_ids and tax_ids[0].id or False
|
||||
val['account_tax_id'] = tax_id
|
||||
return {'value':val}
|
||||
|
||||
#
|
||||
@@ -684,7 +699,9 @@ class account_move_line(osv.osv):
|
||||
elif field.field=='account_tax_id':
|
||||
attrs.append('domain="[(\'parent_id\',\'=\',False)]"')
|
||||
elif field.field=='account_id' and journal.id:
|
||||
attrs.append('domain="[(\'journal_id\', \'=\', '+str(journal.id)+'),(\'type\',\'<>\',\'view\'), (\'type\',\'<>\',\'closed\')]" on_change="onchange_account_id(account_id)"')
|
||||
attrs.append('domain="[(\'journal_id\', \'=\', '+str(journal.id)+'),(\'type\',\'<>\',\'view\'), (\'type\',\'<>\',\'closed\')]" on_change="onchange_account_id(account_id, partner_id)"')
|
||||
elif field.field == 'partner_id':
|
||||
attrs.append('on_change="onchange_partner_id(move_id,partner_id,account_id,debit,credit,date,((\'journal_id\' in context) and context[\'journal_id\']) or {})"')
|
||||
if field.readonly:
|
||||
attrs.append('readonly="1"')
|
||||
if field.required:
|
||||
@@ -693,8 +710,7 @@ class account_move_line(osv.osv):
|
||||
attrs.append('required="0"')
|
||||
if field.field in ('amount_currency','currency_id'):
|
||||
attrs.append('on_change="onchange_currency(account_id,amount_currency,currency_id,date,((\'journal_id\' in context) and context[\'journal_id\']) or {})"')
|
||||
if field.field == 'partner_id':
|
||||
attrs.append('on_change="onchange_partner_id(move_id,partner_id,account_id,debit,credit,date,((\'journal_id\' in context) and context[\'journal_id\']) or {})"')
|
||||
|
||||
if field.field in widths:
|
||||
attrs.append('width="'+str(widths[field.field])+'"')
|
||||
xml += '''<field name="%s" %s/>\n''' % (field.field,' '.join(attrs))
|
||||
|
||||
@@ -5,65 +5,60 @@
|
||||
<!-- Fiscal Position Templates -->
|
||||
|
||||
<record id="fiscal_position_template_1" model="account.fiscal.position.template">
|
||||
<field name="name">Fiscal Position for Sale</field>
|
||||
<field name="name">En Belgique</field>
|
||||
<field name="chart_template_id" ref="l10nbe_chart_template"/>
|
||||
</record>
|
||||
|
||||
<record id="fiscal_position_template_2" model="account.fiscal.position.template">
|
||||
<field name="name">Fiscal Position for Purchase</field>
|
||||
<field name="name">Dans l'U.E</field>
|
||||
<field name="chart_template_id" ref="l10nbe_chart_template"/>
|
||||
</record>
|
||||
|
||||
<!-- Fiscal Position Tax Templates -->
|
||||
|
||||
<record id="fiscal_position_tax_template_1" model="account.fiscal.position.tax.template">
|
||||
<field name="position_id" ref="fiscal_position_template_1" />
|
||||
<field name="tax_src_id" ref="l10n_be.vat_6" />
|
||||
<field name="tax_dest_id" ref="l10n_be.vat_12" />
|
||||
<field name="position_id" ref="fiscal_position_template_2" />
|
||||
<field name="tax_src_id" ref="l10n_be.vat_21" />
|
||||
<field name="tax_dest_id" ref="l10n_be.vat_I0" />
|
||||
</record>
|
||||
|
||||
<record id="fiscal_position_tax_template_2" model="account.fiscal.position.tax.template">
|
||||
<field name="position_id" ref="fiscal_position_template_1" />
|
||||
<field name="tax_src_id" ref="l10n_be.vat_21" />
|
||||
<field name="tax_dest_id" ref="l10n_be.vat_21_buy" />
|
||||
<field name="position_id" ref="fiscal_position_template_2"/>
|
||||
<field name="tax_src_id" ref="l10n_be.vat_21_buy" />
|
||||
<field name="tax_dest_id" ref="l10n_be.vat_CO" />
|
||||
</record>
|
||||
|
||||
<record id="fiscal_position_tax_template_3" model="account.fiscal.position.tax.template">
|
||||
<field name="position_id" ref="fiscal_position_template_2" />
|
||||
<field name="tax_src_id" ref="l10n_be.vat_XO_1" />
|
||||
<field name="tax_dest_id" ref="l10n_be.vat_XO_2" />
|
||||
</record>
|
||||
|
||||
<record id="fiscal_position_tax_template_4" model="account.fiscal.position.tax.template">
|
||||
<field name="position_id" ref="fiscal_position_template_2" />
|
||||
<field name="tax_src_id" ref="l10n_be.vat_I0_1" />
|
||||
<field name="tax_dest_id" ref="l10n_be.vat_I0_2" />
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
<!-- Fiscal Position Account Templates -->
|
||||
|
||||
<record id="fiscal_position_account_template_1" model="account.fiscal.position.account.template">
|
||||
<field name="position_id" ref="fiscal_position_template_1" />
|
||||
<field name="account_src_id" ref="l10n_be.a408" />
|
||||
<field name="account_dest_id" ref="l10n_be.a480" />
|
||||
<field name="account_src_id" ref="l10n_be.a7000" />
|
||||
<field name="account_dest_id" ref="l10n_be.a_sale" />
|
||||
</record>
|
||||
|
||||
<record id="fiscal_position_account_template_2" model="account.fiscal.position.account.template">
|
||||
<field name="position_id" ref="fiscal_position_template_1" />
|
||||
<field name="account_src_id" ref="l10n_be.a419" />
|
||||
<field name="account_dest_id" ref="l10n_be.a4201" />
|
||||
</record>
|
||||
|
||||
|
||||
<record id="fiscal_position_account_template_3" model="account.fiscal.position.account.template">
|
||||
<field name="position_id" ref="fiscal_position_template_2" />
|
||||
<field name="account_src_id" ref="l10n_be.a4200" />
|
||||
<field name="account_dest_id" ref="l10n_be.a4168" />
|
||||
<field name="account_src_id" ref="l10n_be.a7000" />
|
||||
<field name="account_dest_id" ref="l10n_be.a7001" />
|
||||
</record>
|
||||
|
||||
<record id="fiscal_position_account_template_4" model="account.fiscal.position.account.template">
|
||||
<field name="position_id" ref="fiscal_position_template_2" />
|
||||
<field name="account_src_id" ref="l10n_be.a4210" />
|
||||
<field name="account_dest_id" ref="l10n_be.a4164" />
|
||||
<field name="account_src_id" ref="l10n_be.a_sale" />
|
||||
<field name="account_dest_id" ref="l10n_be.a7011" />
|
||||
</record>
|
||||
|
||||
<record id="fiscal_position_account_template_5" model="account.fiscal.position.account.template">
|
||||
<field name="position_id" ref="fiscal_position_template_2" />
|
||||
<field name="account_src_id" ref="l10n_be.a7020" />
|
||||
<field name="account_dest_id" ref="l10n_be.a7021" />
|
||||
</record>
|
||||
|
||||
<record id="fiscal_position_account_template_6" model="account.fiscal.position.account.template">
|
||||
<field name="position_id" ref="fiscal_position_template_2" />
|
||||
<field name="account_src_id" ref="l10n_be.a7050" />
|
||||
<field name="account_dest_id" ref="l10n_be.a7051" />
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
</openerp>
|
||||
|
||||
@@ -95,9 +95,9 @@ class wizard_default_journal(wizard.interface):
|
||||
journal_codes[obj.code] = int(obj.journal_id.id)
|
||||
|
||||
form = data['form']
|
||||
form['default_journal'] = journal_codes.get('DEFAULT')
|
||||
form['default_journal_rebate'] = journal_codes.get('REBATE')
|
||||
form['default_journal_gift'] = journal_codes.get('GIFT')
|
||||
form['default_journal'] = journal_codes.get('DEFAULT') or False
|
||||
form['default_journal_rebate'] = journal_codes.get('REBATE') or False
|
||||
form['default_journal_gift'] = journal_codes.get('GIFT') or False
|
||||
|
||||
return form
|
||||
|
||||
@@ -125,5 +125,3 @@ class wizard_default_journal(wizard.interface):
|
||||
|
||||
wizard_default_journal('pos.config.journal')
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user