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.

30 lines
965 B

  1. # -*- coding: utf-8 -*-
  2. from openerp import models, fields, api
  3. class AccountAnalyticAccount(models.Model):
  4. _inherit = 'account.analytic.account'
  5. @api.model
  6. def _default_journal(self):
  7. company_id = self.env.context.get(
  8. 'company_id', self.env.user.company_id.id)
  9. domain = [
  10. ('type', '=', 'sale'),
  11. ('company_id', '=', company_id)]
  12. return self.env['account.journal'].search(domain, limit=1)
  13. journal_id = fields.Many2one(
  14. 'account.journal',
  15. string='Journal',
  16. default=_default_journal,
  17. domain="[('type', '=', 'sale'),('company_id', '=', company_id)]")
  18. @api.model
  19. def _prepare_invoice_data(self, contract):
  20. invoice_vals = super(AccountAnalyticAccount, self).\
  21. _prepare_invoice_data(
  22. contract)
  23. if contract.journal_id:
  24. invoice_vals['journal_id'] = contract.journal_id.id
  25. return invoice_vals