Browse Source

[IMP] - Add contract tags

pull/402/head
sbejaoui 5 years ago
parent
commit
3b79dea3eb
  1. 1
      contract/__manifest__.py
  2. 1
      contract/models/__init__.py
  3. 1
      contract/models/contract.py
  4. 17
      contract/models/contract_tag.py
  5. 23
      contract/security/contract_tag.xml
  6. 1
      contract/views/contract.xml

1
contract/__manifest__.py

@ -20,6 +20,7 @@
'depends': ['base', 'account', 'product'],
"external_dependencies": {"python": ["dateutil"]},
'data': [
'security/contract_tag.xml',
'security/ir.model.access.csv',
'security/contract_security.xml',
'report/report_contract.xml',

1
contract/models/__init__.py

@ -9,3 +9,4 @@ from . import contract_line
from . import account_invoice
from . import account_invoice_line
from . import res_partner
from . import contract_tag

1
contract/models/contract.py

@ -91,6 +91,7 @@ class ContractContract(models.Model):
string='Commercial Entity',
index=True
)
tag_ids = fields.Many2many(comodel_name="contract.tag", string="Tags")
@api.multi
def _inverse_partner_id(self):

17
contract/models/contract_tag.py

@ -0,0 +1,17 @@
# Copyright 2019 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class ContractTag(models.Model):
_name = 'contract.tag'
_description = 'Contract Tag'
name = fields.Char(requirment=True)
company_id = fields.Many2one(
'res.company',
string='Company',
default=lambda self: self.env.user.company_id,
)

23
contract/security/contract_tag.xml

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2019 ACSONE SA/NV
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record model="ir.model.access" id="contract_tag_access">
<field name="name">contract.tag access</field>
<field name="model_id" ref="model_contract_tag"/>
<field name="group_id" ref="account.group_account_invoice"/>
<field name="perm_read" eval="1"/>
<field name="perm_create" eval="1"/>
<field name="perm_write" eval="1"/>
<field name="perm_unlink" eval="1"/>
</record>
<record id="contract_tag_multi_company_rule" model="ir.rule">
<field name="name">Contract tag multi-company</field>
<field name="model_id" ref="model_contract_tag"/>
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field>
</record>
</odoo>

1
contract/views/contract.xml

@ -55,6 +55,7 @@
<field name="contract_type" invisible="1"
required="1"/>
<field name="fiscal_position_id"/>
<field name="tag_ids" widget="many2many_tags"/>
</group>
</group>

Loading…
Cancel
Save