[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
parent 5339342d4c
commit 46830e1a51
79 changed files with 63545 additions and 15851 deletions

View File

@@ -113,7 +113,6 @@ class ContractAbstractContractLine(models.AbstractModel):
comodel_name='contract.abstract.contract',
required=True,
ondelete='cascade',
oldname='analytic_account_id',
)
@api.depends(

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,

View File

@@ -25,7 +25,6 @@ class ContractLine(models.Model):
required=True,
index=True,
ondelete='cascade',
oldname='analytic_account_id',
)
analytic_account_id = fields.Many2one(
string="Analytic account",

View File

@@ -19,5 +19,4 @@ class ContractTemplate(models.Model):
inverse_name='contract_id',
copy=True,
string='Contract template lines',
oldname='contract_line_ids',
)

View File

@@ -15,6 +15,11 @@ class ResPartner(models.Model):
string='Purchase Contracts',
compute='_compute_contract_count',
)
contract_ids = fields.One2many(
comodel_name='contract.contract',
inverse='partner_id',
string="Contracts",
)
def _compute_contract_count(self):
contract_model = self.env['contract.contract']