account_move.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Part of Odoo. See LICENSE file for full copyright and licensing details.
  2. from odoo import api, fields, models
  3. class AccountMove(models.Model):
  4. _inherit = 'account.move'
  5. l10n_it_origin_document_type = fields.Selection(
  6. string="Origin Document Type",
  7. selection=[('purchase_order', 'Purchase Order'), ('contract', 'Contract'), ('agreement', 'Agreement')],
  8. readonly=True, states={'draft': [('readonly', False)]}, copy=False)
  9. l10n_it_origin_document_name = fields.Char(
  10. string="Origin Document Name",
  11. readonly=True, states={'draft': [('readonly', False)]}, copy=False)
  12. l10n_it_origin_document_date = fields.Date(
  13. string="Origin Document Date",
  14. readonly=True, states={'draft': [('readonly', False)]}, copy=False)
  15. l10n_it_cig = fields.Char(
  16. string="CIG",
  17. readonly=True, states={'draft': [('readonly', False)]}, copy=False,
  18. help="Tender Unique Identifier")
  19. l10n_it_cup = fields.Char(
  20. string="CUP",
  21. readonly=True, states={'draft': [('readonly', False)]}, copy=False,
  22. help="Public Investment Unique Identifier")
  23. # Technical field for showing the above fields or not
  24. l10n_it_partner_pa = fields.Boolean(compute='_compute_l10n_it_partner_pa')
  25. @api.depends('commercial_partner_id.l10n_it_pa_index', 'company_id')
  26. def _compute_l10n_it_partner_pa(self):
  27. for move in self:
  28. move.l10n_it_partner_pa = (move.country_code == 'IT' and move.commercial_partner_id.l10n_it_pa_index and
  29. len(move.commercial_partner_id.l10n_it_pa_index) == 6)
  30. def _prepare_fatturapa_export_values(self):
  31. """Add origin document features."""
  32. template_values = super()._prepare_fatturapa_export_values()
  33. template_values.update({
  34. 'origin_document_type': self.l10n_it_origin_document_type,
  35. 'origin_document_name': self.l10n_it_origin_document_name,
  36. 'origin_document_date': self.l10n_it_origin_document_date,
  37. 'cig': self.l10n_it_cig,
  38. 'cup': self.l10n_it_cup,
  39. })
  40. return template_values