[IMP] account: default cash difference account

When a cash journal is used in POS, we need to have accounts to post the
difference between what it's supposed to be in the cash journal and what
we really have in the cashbox.

To help the user to configure his cash journal, we've added default
accounts for cash difference in the localisation. Those default values
are stored on the company and are use for the creation of cash journals
if no values are provided.

TASK-ID: 1934784
This commit is contained in:
Pierre Masereel
2019-07-23 07:41:20 +00:00
parent 4968eb7c83
commit d786cb13f6
5 changed files with 23 additions and 3 deletions
+9 -3
View File
@@ -583,8 +583,8 @@ class AccountJournal(models.Model):
"SEPA Credit Transfer: Pay bill from a SEPA Credit Transfer file you submit to your bank. Enable this option from the settings.")
at_least_one_inbound = fields.Boolean(compute='_methods_compute', store=True)
at_least_one_outbound = fields.Boolean(compute='_methods_compute', store=True)
profit_account_id = fields.Many2one('account.account', string='Profit Account', domain=[('deprecated', '=', False)], help="Used to register a profit when the ending balance of a cash register differs from what the system computes")
loss_account_id = fields.Many2one('account.account', string='Loss Account', domain=[('deprecated', '=', False)], help="Used to register a loss when the ending balance of a cash register differs from what the system computes")
profit_account_id = fields.Many2one('account.account', string='Profit Account', help="Used to register a profit when the ending balance of a cash register differs from what the system computes")
loss_account_id = fields.Many2one('account.account', string='Loss Account', help="Used to register a loss when the ending balance of a cash register differs from what the system computes")
belongs_to_company = fields.Boolean('Belong to the user\'s current company', compute="_belong_to_company", search="_search_company_journals",)
@@ -874,12 +874,18 @@ class AccountJournal(models.Model):
# Create a default debit/credit account if not given
default_account = vals.get('default_debit_account_id') or vals.get('default_credit_account_id')
company = self.env['res.company'].browse(company_id)
if not default_account:
company = self.env['res.company'].browse(company_id)
account_vals = self._prepare_liquidity_account(vals.get('name'), company, vals.get('currency_id'), vals.get('type'))
default_account = self.env['account.account'].create(account_vals)
vals['default_debit_account_id'] = default_account.id
vals['default_credit_account_id'] = default_account.id
if vals['type'] == 'cash':
if not vals.get('profit_account_id'):
vals['profit_account_id'] = company.default_cash_difference_income_account_id.id
if not vals.get('loss_account_id'):
vals['loss_account_id'] = company.default_cash_difference_expense_account_id.id
# We just need to create the relevant sequences according to the chosen options
if not vals.get('sequence_id'):
+8
View File
@@ -114,6 +114,8 @@ class AccountChartTemplate(models.Model):
string="Gain Exchange Rate Account", domain=[('internal_type', '=', 'other'), ('deprecated', '=', False)])
expense_currency_exchange_account_id = fields.Many2one('account.account.template',
string="Loss Exchange Rate Account", domain=[('internal_type', '=', 'other'), ('deprecated', '=', False)])
default_cash_difference_income_account_id = fields.Many2one('account.account.template', string="Cash Difference Income Account")
default_cash_difference_expense_account_id = fields.Many2one('account.account.template', string="Cash Difference Expense Account")
property_account_receivable_id = fields.Many2one('account.account.template', string='Receivable Account', oldname="property_account_receivable")
property_account_payable_id = fields.Many2one('account.account.template', string='Payable Account', oldname="property_account_payable")
property_account_expense_categ_id = fields.Many2one('account.account.template', string='Category of Expense Account', oldname="property_account_expense_categ")
@@ -242,6 +244,12 @@ class AccountChartTemplate(models.Model):
# Install all the templates objects and generate the real objects
acc_template_ref, taxes_ref = self._install_template(company, code_digits=self.code_digits)
# Set default cash difference account on company
company.write({
'default_cash_difference_income_account_id': acc_template_ref.get(self.default_cash_difference_income_account_id.id, False),
'default_cash_difference_expense_account_id': acc_template_ref.get(self.default_cash_difference_expense_account_id.id, False),
})
# Set the transfer account on the company
company.transfer_account_id = self.env['account.account'].search([('code', '=like', self.transfer_account_code_prefix + '%')])[0]
+2
View File
@@ -43,6 +43,8 @@ class ResCompany(models.Model):
chart_template_id = fields.Many2one('account.chart.template', help='The chart template for the company (if any)')
bank_account_code_prefix = fields.Char(string='Prefix of the bank accounts', oldname="bank_account_code_char")
cash_account_code_prefix = fields.Char(string='Prefix of the cash accounts')
default_cash_difference_income_account_id = fields.Many2one('account.account', string="Cash Difference Income Account")
default_cash_difference_expense_account_id = fields.Many2one('account.account', string="Cash Difference Expense Account")
transfer_account_code_prefix = fields.Char(string='Prefix of the transfer accounts')
account_sale_tax_id = fields.Many2one('account.tax', string="Default Sale Tax")
account_purchase_tax_id = fields.Many2one('account.tax', string="Default Purchase Tax")
@@ -16,8 +16,10 @@
"cas","Non-current Liabilities","1120","account.data_account_type_non_current_liabilities","l10n_generic_coa.configurable_chart_template","","False"
"conf_a_sale","Product Sales","200","account.data_account_type_revenue","l10n_generic_coa.configurable_chart_template","account.account_tag_operating","False"
"exchange_fx_income","Foreign Exchange Gain","2010","account.data_account_type_revenue","l10n_generic_coa.configurable_chart_template","account.account_tag_financing","False"
"cash_diff_income","Cash Difference Gain","2020","account.data_account_type_revenue","l10n_generic_coa.configurable_chart_template","account.account_tag_investing","False"
"conf_cog","Cost of Goods Sold","210","account.data_account_type_direct_costs","l10n_generic_coa.configurable_chart_template","account.account_tag_operating","False"
"exchange_fx_expense","Foreign Exchange Loss","2110","account.data_account_type_expenses","l10n_generic_coa.configurable_chart_template","account.account_tag_financing","False"
"cash_diff_expense","Cash Difference Loss","2120","account.data_account_type_expenses","l10n_generic_coa.configurable_chart_template","account.account_tag_investing","False"
"a_salary_expense","Salary Expenses","2121","account.data_account_type_expenses","l10n_generic_coa.configurable_chart_template","account.account_tag_operating","False"
"a_expense_invest","Purchase of Equipments","2122","account.data_account_type_expenses","l10n_generic_coa.configurable_chart_template","account.account_tag_investing","False"
"a_expense_finance","Bank Fees","2123","account.data_account_type_expenses","l10n_generic_coa.configurable_chart_template","account.account_tag_financing","False"
1 id name code user_type_id/id chart_template_id/id tag_ids/id reconcile
16 cas Non-current Liabilities 1120 account.data_account_type_non_current_liabilities l10n_generic_coa.configurable_chart_template False
17 conf_a_sale Product Sales 200 account.data_account_type_revenue l10n_generic_coa.configurable_chart_template account.account_tag_operating False
18 exchange_fx_income Foreign Exchange Gain 2010 account.data_account_type_revenue l10n_generic_coa.configurable_chart_template account.account_tag_financing False
19 cash_diff_income Cash Difference Gain 2020 account.data_account_type_revenue l10n_generic_coa.configurable_chart_template account.account_tag_investing False
20 conf_cog Cost of Goods Sold 210 account.data_account_type_direct_costs l10n_generic_coa.configurable_chart_template account.account_tag_operating False
21 exchange_fx_expense Foreign Exchange Loss 2110 account.data_account_type_expenses l10n_generic_coa.configurable_chart_template account.account_tag_financing False
22 cash_diff_expense Cash Difference Loss 2120 account.data_account_type_expenses l10n_generic_coa.configurable_chart_template account.account_tag_investing False
23 a_salary_expense Salary Expenses 2121 account.data_account_type_expenses l10n_generic_coa.configurable_chart_template account.account_tag_operating False
24 a_expense_invest Purchase of Equipments 2122 account.data_account_type_expenses l10n_generic_coa.configurable_chart_template account.account_tag_investing False
25 a_expense_finance Bank Fees 2123 account.data_account_type_expenses l10n_generic_coa.configurable_chart_template account.account_tag_financing False
@@ -12,5 +12,7 @@
<field name="property_stock_valuation_account_id" ref="conf_cas"/>
<field name="income_currency_exchange_account_id" ref="exchange_fx_income"/>
<field name="expense_currency_exchange_account_id" ref="exchange_fx_expense"/>
<field name="default_cash_difference_income_account_id" ref="cash_diff_income"/>
<field name="default_cash_difference_expense_account_id" ref="cash_diff_expense"/>
</record>
</odoo>