Corrections
parent
6211637f67
commit
48b47e70ac
|
@ -44,10 +44,9 @@ class AccountJournal(models.Model):
|
||||||
|
|
||||||
receivable_account_id = fields.Many2one(
|
receivable_account_id = fields.Many2one(
|
||||||
comodel_name='account.account',
|
comodel_name='account.account',
|
||||||
string='Force Receivable/Payable Account',
|
string='Receivable/Payable Account',
|
||||||
help="Choose a receivable account to force the default "
|
help="Choose a receivable/payable account to use as the default "
|
||||||
"debit/credit account (eg. an intermediat bank account "
|
"debit/credit account.")
|
||||||
"instead of default debitors).")
|
|
||||||
|
|
||||||
used_for_completion = fields.Boolean(
|
used_for_completion = fields.Boolean(
|
||||||
string="Journal used for completion")
|
string="Journal used for completion")
|
||||||
|
@ -114,7 +113,13 @@ class AccountJournal(models.Model):
|
||||||
total_amount += global_commission_amount
|
total_amount += global_commission_amount
|
||||||
partner_id = self.partner_id.id
|
partner_id = self.partner_id.id
|
||||||
# Commission line
|
# Commission line
|
||||||
if global_commission_amount < 0.0:
|
if global_commission_amount > 0.0:
|
||||||
|
raise UserError(_('Commission amount should not be positive.'))
|
||||||
|
elif global_commission_amount < 0.0:
|
||||||
|
if not self.commission_account_id:
|
||||||
|
raise UserError(
|
||||||
|
_('No commission account is set on the journal.'))
|
||||||
|
else:
|
||||||
commission_account_id = self.commission_account_id.id
|
commission_account_id = self.commission_account_id.id
|
||||||
comm_values = {
|
comm_values = {
|
||||||
'name': _('Commission line'),
|
'name': _('Commission line'),
|
||||||
|
@ -129,17 +134,25 @@ class AccountJournal(models.Model):
|
||||||
move_line_obj.with_context(
|
move_line_obj.with_context(
|
||||||
check_move_validity=False
|
check_move_validity=False
|
||||||
).create(comm_values)
|
).create(comm_values)
|
||||||
|
|
||||||
# Counterpart line
|
# Counterpart line
|
||||||
if total_amount > 0.0:
|
if total_amount > 0.0:
|
||||||
receivable_account_id = self.receivable_account_id.id or False
|
account_id = self.default_debit_account_id.id
|
||||||
|
credit = 0.0
|
||||||
|
debit = total_amount
|
||||||
|
else:
|
||||||
|
account_id = self.default_credit_account_id.id
|
||||||
|
credit = -total_amount
|
||||||
|
debit = 0.0
|
||||||
counterpart_values = {
|
counterpart_values = {
|
||||||
'name': _('Counterpart line'),
|
'name': _('/'),
|
||||||
'date_maturity': parser.get_move_vals().get('date') or
|
'date_maturity': parser.get_move_vals().get('date') or
|
||||||
fields.Date.today(),
|
fields.Date.today(),
|
||||||
'debit': total_amount,
|
'credit': credit,
|
||||||
|
'debit': debit,
|
||||||
'partner_id': partner_id,
|
'partner_id': partner_id,
|
||||||
'move_id': move.id,
|
'move_id': move.id,
|
||||||
'account_id': receivable_account_id,
|
'account_id': account_id,
|
||||||
'already_completed': True,
|
'already_completed': True,
|
||||||
}
|
}
|
||||||
move_line_obj.create(counterpart_values)
|
move_line_obj.create(counterpart_values)
|
||||||
|
@ -177,10 +190,7 @@ class AccountJournal(models.Model):
|
||||||
values['company_currency_id'] = self.company_id.currency_id.id
|
values['company_currency_id'] = self.company_id.currency_id.id
|
||||||
values['journal_id'] = self.id
|
values['journal_id'] = self.id
|
||||||
values['move_id'] = move.id
|
values['move_id'] = move.id
|
||||||
if values['credit'] > 0.0:
|
values['account_id'] = self.receivable_account_id.id
|
||||||
values['account_id'] = self.default_credit_account_id.id
|
|
||||||
else:
|
|
||||||
values['account_id'] = self.default_debit_account_id.id
|
|
||||||
values = move_line_obj._add_missing_default_values(values)
|
values = move_line_obj._add_missing_default_values(values)
|
||||||
return values
|
return values
|
||||||
|
|
||||||
|
@ -263,6 +273,9 @@ class AccountJournal(models.Model):
|
||||||
move.button_auto_completion()
|
move.button_auto_completion()
|
||||||
# Write the needed log infos on profile
|
# Write the needed log infos on profile
|
||||||
self.write_logs_after_import(move, len(result_row_list))
|
self.write_logs_after_import(move, len(result_row_list))
|
||||||
|
except UserError:
|
||||||
|
# "Clean" exception, raise as such
|
||||||
|
raise
|
||||||
except Exception:
|
except Exception:
|
||||||
error_type, error_value, trbk = sys.exc_info()
|
error_type, error_value, trbk = sys.exc_info()
|
||||||
st = "Error: %s\nDescription: %s\nTraceback:" % (
|
st = "Error: %s\nDescription: %s\nTraceback:" % (
|
||||||
|
|
|
@ -99,7 +99,8 @@ class AccountMoveCompletionRule(models.Model):
|
||||||
invoice = self._find_invoice(line, inv_type)
|
invoice = self._find_invoice(line, inv_type)
|
||||||
if invoice:
|
if invoice:
|
||||||
partner_id = invoice.commercial_partner_id.id
|
partner_id = invoice.commercial_partner_id.id
|
||||||
res = {'partner_id': partner_id}
|
res = {'partner_id': partner_id,
|
||||||
|
'account_id': invoice.account_id.id}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
# Should be private but data are initialised with no update XML
|
# Should be private but data are initialised with no update XML
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
<field name="name">account.move.completion.rule.view</field>
|
<field name="name">account.move.completion.rule.view</field>
|
||||||
<field name="model">account.move.completion.rule</field>
|
<field name="model">account.move.completion.rule</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="Statement Completion Rule">
|
<tree string="Move Completion Rule">
|
||||||
<field name="sequence"/>
|
<field name="sequence"/>
|
||||||
<field name="name" select="1" />
|
<field name="name" select="1" />
|
||||||
<field name="journal_ids" />
|
<field name="journal_ids" />
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
<field name="import_type" attrs="{'required': [('used_for_import', '=', True)]}"/>
|
<field name="import_type" attrs="{'required': [('used_for_import', '=', True)]}"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<field name="commission_account_id" attrs="{'required': [('used_for_import', '=', True)]}"/>
|
<field name="commission_account_id"/>
|
||||||
<field name="receivable_account_id" attrs="{'required': [('used_for_import', '=', True)]}"/>
|
<field name="receivable_account_id" attrs="{'required': [('used_for_import', '=', True)]}"/>
|
||||||
<field name="partner_id" attrs="{'required': [('used_for_import', '=', True)]}"/>
|
<field name="partner_id"/>
|
||||||
</group>
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<button name="%(account_move_base_import.move_importer_action)d"
|
<button name="%(account_move_base_import.move_importer_action)d"
|
||||||
string="Import Bank Statement"
|
string="Import batch file"
|
||||||
type="action" icon="gtk-ok"
|
type="action" icon="gtk-ok"
|
||||||
colspan = "2"/>
|
colspan = "2"/>
|
||||||
</group>
|
</group>
|
||||||
|
|
Loading…
Reference in New Issue