[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:
@@ -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'):
|
||||
|
||||
@@ -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]
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user