[FIX+IMP+MIG] contract: Several refinements:

* Remove incorrect oldname attributes.
* Add filter on partners for running contracts (+ a support o2m field for that).
* Cover more tables in model renaming + cleaner code using a loop.
* Don't copy contract lines, but rename table + copy contract records on pre.
* Contract code is now populated to "Reference/Description" field in invoice.
* Order on new contract model has been restored to the same as old analytic accounts.
This commit is contained in:
Pedro M. Baeza
2019-09-13 11:40:47 +02:00
committed by sbejaoui
parent d93139d147
commit 09d860ba17
8 changed files with 122 additions and 268 deletions

View File

@@ -14,6 +14,7 @@ from odoo.tools.translate import _
class ContractContract(models.Model):
_name = 'contract.contract'
_description = "Contract"
_order = 'code, name asc'
_inherit = [
'mail.thread',
'mail.activity.mixin',
@@ -44,7 +45,6 @@ class ContractContract(models.Model):
comodel_name='contract.line',
inverse_name='contract_id',
copy=True,
oldnae='contract_line_ids',
)
user_id = fields.Many2one(
@@ -273,7 +273,7 @@ class ContractContract(models.Model):
if self.contract_type == 'purchase':
invoice_type = 'in_invoice'
return {
'reference': self.code,
'name': self.code,
'type': invoice_type,
'partner_id': self.invoice_partner_id.id,
'currency_id': currency.id,