You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.1 KiB

  1. # -*- coding: utf-8 -*-
  2. from openerp import models, fields, api
  3. class AccountAnalyticAccount(models.Model):
  4. _inherit = 'account.analytic.account'
  5. payment_mode_id = fields.Many2one(
  6. 'payment.mode',
  7. string='Payment Mode',
  8. domain="[('sale_ok', '=', True)]")
  9. @api.multi
  10. def on_change_partner_id(self, partner_id, name):
  11. res = super(AccountAnalyticAccount, self).on_change_partner_id(
  12. partner_id,
  13. name)
  14. partner = self.env['res.partner'].browse(partner_id)
  15. if partner and partner.customer_payment_mode:
  16. res['value']['payment_mode_id'] = partner.customer_payment_mode.id
  17. return res
  18. @api.model
  19. def _prepare_invoice_data(self, contract):
  20. invoice_vals = super(AccountAnalyticAccount, self).\
  21. _prepare_invoice_data(contract)
  22. if contract.payment_mode_id:
  23. invoice_vals['payment_mode_id'] = contract.payment_mode_id.id
  24. invoice_vals['partner_bank_id'] = \
  25. contract.payment_mode_id.bank_id.id
  26. return invoice_vals