Browse Source

Merge pull request #304 from ygol/12.0-mig-ag_legal

[FIX] handling code field + partner_id
pull/296/head
Maxime Chambreuil 6 years ago
committed by GitHub
parent
commit
72a45cde7f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      agreement_legal/models/agreement.py
  2. 3
      agreement_legal/views/agreement.xml

9
agreement_legal/models/agreement.py

@ -96,12 +96,12 @@ class Agreement(models.Model):
string="Dynamic Special Terms",
help="Compute dynamic special terms",
)
reference = fields.Char(
code = fields.Char(
string="Reference",
copy=False,
required=True,
default=lambda self: _("New"),
track_visibility="onchange",
copy=False,
help="ID used for internal contract tracking.",
)
increase_type_id = fields.Many2one(
@ -136,6 +136,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.",
)
@ -395,8 +396,8 @@ class Agreement(models.Model):
@api.model
def create(self, vals):
if vals.get("reference", _("New")) == _("New"):
vals["reference"] = self.env["ir.sequence"].next_by_code(
if vals.get("code", _("New")) == _("New"):
vals["code"] = self.env["ir.sequence"].next_by_code(
"agreement"
) or _("New")
return super(Agreement, self).create(vals)

3
agreement_legal/views/agreement.xml

@ -40,8 +40,7 @@
</div>
<group string="General">
<group>
<field name="code"/>
<field name="reference" readonly="1"/>
<field name="code" readonly="1"/>
<field name="parent_agreement_id"
domain="[('partner_id', '=', partner_id)]"/>
<field name="is_template"/>

Loading…
Cancel
Save