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
962 B

  1. # -*- coding: utf-8 -*-
  2. from odoo 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. if self.payment_mode_id:
  18. invoice_vals['payment_mode_id'] = self.payment_mode_id.id
  19. invoice = self.env['account.invoice'].new(invoice_vals)
  20. invoice.payment_mode_id_change()
  21. invoice_vals = invoice._convert_to_write(invoice._cache)
  22. return invoice_vals