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.

28 lines
1001 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.multi
  15. def _prepare_invoice(self):
  16. invoice_vals = super(AccountAnalyticAccount, self)._prepare_invoice()
  17. contract = self[:1]
  18. if contract.payment_mode_id:
  19. invoice_vals['payment_mode_id'] = contract.payment_mode_id.id
  20. invoice = self.env['account.invoice'].new(invoice_vals)
  21. invoice.payment_mode_id_change()
  22. invoice_vals = invoice._convert_to_write(invoice._cache)
  23. return invoice_vals