Browse Source

[IMP] move some notions from agreement_legal to agreement

we move the is_template field definition and the agreement.type model from
the agreement_legal module to the agreement module.

The fields are not displayed by default, unless the feature is enabled through a
technical feature group, this is configurable in the agreement_sale module (because agreement
in itself has no UI, and agreement_legal enables the feature by default)
pull/397/head
Alexandre Fayolle 5 years ago
committed by Iryna Vyshnevska
parent
commit
5e2e4bc906
  1. 1
      agreement/__manifest__.py
  2. 1
      agreement/models/__init__.py
  3. 14
      agreement/models/agreement.py
  4. 12
      agreement/models/agreement_type.py
  5. 1
      agreement/readme/CONTRIBUTORS.rst
  6. 6
      agreement/readme/DESCRIPTION.rst
  7. 9
      agreement/security/agreement_security.xml
  8. 6
      agreement/views/agreement.xml
  9. 54
      agreement/views/agreement_type.xml

1
agreement/__manifest__.py

@ -16,6 +16,7 @@
'security/ir.model.access.csv',
'security/agreement_security.xml',
'views/agreement.xml',
'views/agreement_type.xml',
],
'demo': ['demo/demo.xml'],
'development_status': 'Beta',

1
agreement/models/__init__.py

@ -1 +1,2 @@
from . import agreement
from . import agreement_type

14
agreement/models/agreement.py

@ -12,11 +12,23 @@ class Agreement(models.Model):
code = fields.Char(required=True, copy=False)
name = fields.Char(required=True)
partner_id = fields.Many2one(
'res.partner', string='Partner', ondelete='restrict', required=True,
'res.partner', string='Partner', ondelete='restrict',
domain=[('parent_id', '=', False)])
company_id = fields.Many2one(
'res.company', string='Company',
default=lambda self: self.env['res.company']._company_default_get())
is_template = fields.Boolean(
string="Is a Template?",
default=False,
copy=False,
help="Set if the agreement is a template. "
"Template agreements don't require a partner."
)
agreement_type_id = fields.Many2one(
'agreement.type',
string="Agreement Type",
help="Select the type of agreement",
)
active = fields.Boolean(default=True)
signature_date = fields.Date()
start_date = fields.Date()

12
agreement/models/agreement_type.py

@ -0,0 +1,12 @@
# Copyright (C) 2018 - TODAY, Pavlov Media
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class AgreementType(models.Model):
_name = "agreement.type"
_description = "Agreement Types"
name = fields.Char(string="Name", required=True)
active = fields.Boolean(default=True)

1
agreement/readme/CONTRIBUTORS.rst

@ -1,2 +1,3 @@
* Alexis de Lattre <alexis.delattre@akretion.com>
* Yves Goldberg <yves@ygol.com>
* Alexandre Fayolle <alexandre.fayolle@camptocamp.com>

6
agreement/readme/DESCRIPTION.rst

@ -6,3 +6,9 @@ This module adds an *Agreement* object with the following properties:
* signature date.
* start date.
* end date.
Optionally, you can also enable using:
* agreement types
* a flag to set an agreement as a template agreement
(Install agreement_sale to get the configuration settings for these).

9
agreement/security/agreement_security.xml

@ -13,5 +13,14 @@
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field>
</record>
<record id="group_use_agreement_type" model="res.groups">
<field name="name">Use agreement type</field>
<field name="category_id" ref="base.module_category_hidden"/>
</record>
<record id="group_use_agreement_template" model="res.groups">
<field name="name">Use agreement template</field>
<field name="category_id" ref="base.module_category_hidden"/>
</record>
</odoo>

6
agreement/views/agreement.xml

@ -21,7 +21,11 @@
</div>
<group name="main">
<group name="left">
<field name="partner_id"/>
<field name="agreement_type_id"
groups="agreement.group_use_agreement_type"/>
<field name="is_template" groups="agreement.group_use_agreement_template"/>
<field name="partner_id"
attrs="{'required': [('is_template', '=', False)]}"/>
<field name="name"/>
<field name="signature_date"/>
</group>

54
agreement/views/agreement_type.xml

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Agreement Type List View-->
<record model="ir.ui.view" id="agreement_type_list_view">
<field name="name">Agreement Type List</field>
<field name="model">agreement.type</field>
<field name="arch" type="xml">
<tree string="Agreement Types" default_order="name">
<field name="name" string="Type Name"/>
</tree>
</field>
</record>
<!-- Agreement Type Form View -->
<record model="ir.ui.view" id="agreement_type_form_view">
<field name="name">Agreement Type Form</field>
<field name="model">agreement.type</field>
<field name="arch" type="xml">
<form string="Agreement Type">
<div class="oe_button_box" name="button_box">
<button name="toggle_active" type="object"
class="oe_stat_button" icon="fa-archive">
<field name="active" widget="boolean_button"
options='{"terminology": "archive"}'/>
</button>
</div>
<sheet>
<div class="oe_title">
<label for="name" class="oe_edit_only"/>
<h1><field name="name"/></h1>
</div>
</sheet>
</form>
</field>
</record>
<record id="agreement_type_search" model="ir.ui.view">
<field name="name">agreement.type.search</field>
<field name="model">agreement.type</field>
<field name="arch" type="xml">
<search string="Agreement Type">
<field name="name"/>
<filter name="archived" string="Archived" domain="[('active', '=', False)]"/>
</search>
</field>
</record>
<!-- Actions opening views on models -->
<record model="ir.actions.act_window" id="agreement_type_action">
<field name="name">Agreement Types</field>
<field name="res_model">agreement.type</field>
<field name="view_mode">tree,form</field>
</record>
</odoo>
Loading…
Cancel
Save