[IMP] account: add default value for partner_bank_id field
This field is referencing the bank account of the company issuing the invoice, so we default to the fist bank account for that company [REF] account Fix typo in id.
This commit is contained in:
@@ -297,7 +297,7 @@ class AccountInvoice(models.Model):
|
||||
help="It indicates that the invoice has been paid and the journal entry of the invoice has been reconciled with one or several journal entries of payment.")
|
||||
partner_bank_id = fields.Many2one('res.partner.bank', string='Bank Account',
|
||||
help='Bank Account Number to which the invoice will be paid. A Company bank account if this is a Customer Invoice or Vendor Refund, otherwise a Partner bank account number.',
|
||||
readonly=True, states={'draft': [('readonly', False)]})
|
||||
readonly=True, states={'draft': [('readonly', False)]}) #Default value computed in default_get for out_invoices
|
||||
|
||||
residual = fields.Monetary(string='Amount Due',
|
||||
compute='_compute_residual', store=True, help="Remaining amount due.")
|
||||
@@ -358,6 +358,23 @@ class AccountInvoice(models.Model):
|
||||
(not_reconciled & pre_not_reconciled).filtered(lambda invoice: invoice.state == 'paid').action_invoice_re_open()
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def default_get(self,default_fields):
|
||||
""" Compute default partner_bank_id field for 'out_invoice' type,
|
||||
using the default values computed for the other fields.
|
||||
"""
|
||||
res = super(AccountInvoice, self).default_get(default_fields)
|
||||
|
||||
if not res.get('type', False) == 'out_invoice' or not 'company_id' in res:
|
||||
return res
|
||||
|
||||
company = self.env['res.company'].browse(res['company_id'])
|
||||
if company.partner_id:
|
||||
partner_bank_result = self.env['res.partner.bank'].search([('partner_id', '=', company.partner_id.id)], limit=1)
|
||||
if partner_bank_result:
|
||||
res['partner_bank_id'] = partner_bank_result.id
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
|
||||
def get_view_id(xid, name):
|
||||
|
||||
@@ -285,7 +285,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<h2>Accounting Reports</h2>
|
||||
<div class="row mt16 o_settings_container" id="accouting_reports">
|
||||
<div class="row mt16 o_settings_container" id="accounting_reports">
|
||||
<div class="col-xs-12 col-md-6 o_setting_box" id="account_accountant" title="If you do not check this box, you will be able to do invoicing & payments, but not accounting (Journal Items, Chart of Accounts, ...).">
|
||||
<div class="o_setting_left_pane">
|
||||
<field name="module_account_accountant"/>
|
||||
|
||||
Reference in New Issue
Block a user