|
|
@ -104,6 +104,10 @@ class Agreement(models.Model): |
|
|
|
track_visibility="onchange", |
|
|
|
help="ID used for internal contract tracking.", |
|
|
|
) |
|
|
|
code = fields.Char( |
|
|
|
required=True, |
|
|
|
default=lambda self: _("New"), |
|
|
|
copy=False) |
|
|
|
increase_type_id = fields.Many2one( |
|
|
|
"agreement.increasetype", |
|
|
|
string="Increase Type", |
|
|
@ -136,6 +140,7 @@ class Agreement(models.Model): |
|
|
|
partner_id = fields.Many2one( |
|
|
|
"res.partner", |
|
|
|
string="Partner", |
|
|
|
required=False, |
|
|
|
copy=True, |
|
|
|
help="The customer or vendor this agreement is related to.", |
|
|
|
) |
|
|
@ -367,11 +372,13 @@ class Agreement(models.Model): |
|
|
|
"name": "{} - OLD VERSION".format(rec.name), |
|
|
|
"active": False, |
|
|
|
"parent_agreement_id": rec.id, |
|
|
|
"code": "{} - OLD VERSION".format(rec.code), |
|
|
|
} |
|
|
|
# Make a current copy and mark it as old |
|
|
|
rec.copy(default=default_vals) |
|
|
|
# Increment the Version |
|
|
|
rec.version = rec.version + 1 |
|
|
|
rec.code = rec.code + "v" + str(rec.version) |
|
|
|
# Reset revision to 0 since it's a new version |
|
|
|
vals["revision"] = 0 |
|
|
|
return super(Agreement, self).write(vals) |
|
|
@ -379,6 +386,7 @@ class Agreement(models.Model): |
|
|
|
def create_new_agreement(self): |
|
|
|
default_vals = { |
|
|
|
"name": "NEW", |
|
|
|
"code": "NEW", |
|
|
|
"active": True, |
|
|
|
"version": 1, |
|
|
|
"revision": 0, |
|
|
@ -399,6 +407,8 @@ class Agreement(models.Model): |
|
|
|
vals["reference"] = self.env["ir.sequence"].next_by_code( |
|
|
|
"agreement" |
|
|
|
) or _("New") |
|
|
|
if vals.get("code", _("New")) == _("New"): |
|
|
|
vals["code"] = vals["reference"] |
|
|
|
return super(Agreement, self).create(vals) |
|
|
|
|
|
|
|
# Increments the revision on each save action |
|
|
|