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.

27 lines
920 B

  1. # -*- coding: utf-8 -*-
  2. from openerp import api, fields, models
  3. class AccountAnalyticAccount(models.Model):
  4. _inherit = 'account.analytic.account'
  5. payment_mode_id = fields.Many2one(
  6. comodel_name='account.payment.mode',
  7. string='Payment Mode',
  8. domain=[('payment_type', '=', 'inbound')],
  9. )
  10. @api.onchange('partner_id')
  11. def on_change_partner_id(self):
  12. if self.partner_id.customer_payment_mode_id:
  13. self.payment_mode_id = self.partner_id.customer_payment_mode_id.id
  14. @api.model
  15. def _prepare_invoice_data(self, contract):
  16. invoice_vals = super(AccountAnalyticAccount, self)._prepare_invoice()
  17. if contract.payment_mode_id:
  18. invoice_vals['payment_mode_id'] = contract.payment_mode_id.id
  19. invoice_vals['partner_bank_id'] = (
  20. contract.partner_id.bank_ids[:1].id
  21. )
  22. return invoice_vals