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.

25 lines
884 B

  1. from odoo import api, fields, models
  2. class AccountAnalyticAccount(models.Model):
  3. _inherit = 'account.analytic.account'
  4. payment_mode_id = fields.Many2one(
  5. comodel_name='account.payment.mode',
  6. string='Payment Mode',
  7. domain=[('payment_type', '=', 'inbound')],
  8. )
  9. @api.onchange('partner_id')
  10. def on_change_partner_id(self):
  11. self.payment_mode_id = self.partner_id.customer_payment_mode_id.id
  12. @api.multi
  13. def _prepare_invoice(self):
  14. invoice_vals = super(AccountAnalyticAccount, self)._prepare_invoice()
  15. if self.payment_mode_id:
  16. invoice_vals['payment_mode_id'] = self.payment_mode_id.id
  17. invoice = self.env['account.invoice'].new(invoice_vals)
  18. invoice._onchange_payment_mode_id()
  19. invoice_vals = invoice._convert_to_write(invoice._cache)
  20. return invoice_vals