mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
contract_payment_mode module
This commit is contained in:
committed by
AmmarOSI
parent
e85fa6a678
commit
85f159c06f
33
contract_payment_mode/models/contract.py
Normal file
33
contract_payment_mode/models/contract.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from openerp import models, fields, api
|
||||
|
||||
|
||||
class AccountAnalyticAccount(models.Model):
|
||||
_inherit = 'account.analytic.account'
|
||||
|
||||
payment_mode_id = fields.Many2one(
|
||||
'payment.mode',
|
||||
string='Payment Mode',
|
||||
domain="[('type', '=', 'sale')]")
|
||||
|
||||
@api.multi
|
||||
def on_change_partner_id(self, partner_id, name):
|
||||
res = super(AccountAnalyticAccount, self).on_change_partner_id(
|
||||
partner_id,
|
||||
name)
|
||||
partner = self.env['res.partner'].browse(partner_id)
|
||||
if partner and partner.customer_payment_mode:
|
||||
res['value']['payment_mode_id'] = partner.customer_payment_mode.id
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def _prepare_invoice_data(self, contract):
|
||||
invoice_vals = super(AccountAnalyticAccount, self).\
|
||||
_prepare_invoice_data(
|
||||
contract)
|
||||
if contract.payment_mode_id:
|
||||
invoice_vals['payment_mode_id'] = contract.payment_mode_id.id
|
||||
invoice_vals['partner_bank_id'] = \
|
||||
contract.payment_mode_id.bank_id.id
|
||||
|
||||
return invoice_vals
|
||||
Reference in New Issue
Block a user