mirror of
https://gitlab.com/flectra-community/bank-payment.git
synced 2024-11-24 06:32:07 +00:00
40 lines
1.5 KiB
Python
40 lines
1.5 KiB
Python
|
# Copyright 2016 Akretion (<http://www.akretion.com>).
|
||
|
# Copyright 2017 Tecnativa - Vicent Cubells.
|
||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||
|
|
||
|
from flectra import api, fields, models
|
||
|
|
||
|
|
||
|
class PurchaseOrder(models.Model):
|
||
|
_inherit = "purchase.order"
|
||
|
|
||
|
supplier_partner_bank_id = fields.Many2one(
|
||
|
comodel_name='res.partner.bank',
|
||
|
string='Supplier Bank Account',
|
||
|
domain="[('partner_id', '=', partner_id)]",
|
||
|
help="Select the bank account of your supplier on which your company "
|
||
|
"should send the payment. This field is copied from the partner "
|
||
|
"and will be copied to the supplier invoice.",
|
||
|
)
|
||
|
payment_mode_id = fields.Many2one(
|
||
|
comodel_name='account.payment.mode',
|
||
|
string='Payment Mode',
|
||
|
domain="[('payment_type', '=', 'outbound')]",
|
||
|
)
|
||
|
|
||
|
@api.model
|
||
|
def _get_default_supplier_partner_bank(self, partner):
|
||
|
"""This function is designed to be inherited"""
|
||
|
return partner.bank_ids and partner.bank_ids[0].id or False
|
||
|
|
||
|
@api.onchange('partner_id')
|
||
|
def onchange_partner_id(self):
|
||
|
super(PurchaseOrder, self).onchange_partner_id()
|
||
|
if self.partner_id:
|
||
|
self.supplier_partner_bank_id = \
|
||
|
self._get_default_supplier_partner_bank(self.partner_id)
|
||
|
self.payment_mode_id = self.partner_id.supplier_payment_mode_id
|
||
|
else:
|
||
|
self.supplier_partner_bank_id = False
|
||
|
self.payment_mode_id = False
|